Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/weapons/test_bullet.cc @ 5055

Last change on this file since 5055 was 5055, checked in by bensch, 19 years ago

orxonox/trunk: testBullet now loads it model as it should

File size: 2.1 KB
RevLine 
[3708]1
2
[4593]3/*
[3708]4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific
14   main-programmer: Patrick Boenzli
[4593]15   co-programmer:
[3708]16*/
17
18
[3709]19#include "test_bullet.h"
[3708]20
21#include "model.h"
22#include "vector.h"
[4941]23#include "garbage_collector.h"
[4947]24#include "fast_factory.h"
[3708]25
[5054]26#include "obb_tree.h"
27
[3708]28using namespace std;
29
[4947]30CREATE_FAST_FACTORY(TestBullet, CL_TEST_BULLET);
[3708]31
32/**
[4836]33 *  standard constructor
[3708]34*/
[4932]35TestBullet::TestBullet () : Projectile()
[3755]36{
[4322]37  this->setClassID(CL_TEST_BULLET, "TestBullet");
[4597]38
[4948]39  float modelSize = .3;
[5055]40  this->loadModel("models/projectiles/orx-rocket.obj");
[4948]41
42  this->energyMin = 1;
43  this->energyMax = 10;
[4969]44  this->remove();
[3755]45}
[3708]46
47
48/**
[4836]49 *  standard deconstructor
[3708]50*/
[4593]51TestBullet::~TestBullet ()
[3708]52{
[4593]53  /*
54     do not delete the test projectModel, since it is pnode
55     and will be cleaned out by world
[3708]56  */
57  //delete this->projectileModel;
58}
59
60
61
62/**
[4836]63 *  signal tick, time dependent things will be handled here
64 * @param time since last tick
[3708]65*/
[4593]66void TestBullet::tick (float time)
[3708]67{
[4464]68  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
69  Vector v = this->velocity * (time);
[3708]70  this->shiftCoor(v);
71
[4890]72  this->lifeCycle += time/this->lifeSpan;
73  if( this->lifeCycle >= 1)
[3708]74    {
75      PRINTF(5)("FINALIZE==========================\n");
[4890]76      PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
[3708]77      PRINTF(5)("FINALIZE===========================\n");
[4941]78//      this->finalize();
79      GarbageCollector::getInstance()->collect(this);
[4942]80      this->lifeCycle = 0.0;
[4941]81
[3708]82    }
83}
84
85/**
[4836]86 *  the function gets called, when the projectile is destroyed
[3708]87*/
[4593]88void TestBullet::destroy ()
[3708]89{}
90
91
[4593]92void TestBullet::draw ()
[3708]93{
94  glMatrixMode(GL_MODELVIEW);
95  glPushMatrix();
96
[4593]97  float matrix[4][4];
[3708]98  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
99  this->getAbsDir().matrix (matrix);
[4593]100  glMultMatrixf((float*)matrix);
[3755]101  glScalef(2.0, 2.0, 2.0);
[3708]102  this->model->draw();
103
104  glPopMatrix();
105}
106
Note: See TracBrowser for help on using the repository browser.