Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: movement stuff in the data-filestructure adapted

File size: 2.2 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
26using namespace std;
27
[4947]28CREATE_FAST_FACTORY(TestBullet, CL_TEST_BULLET);
[3708]29
30/**
[4836]31 *  standard constructor
[3708]32*/
[4932]33TestBullet::TestBullet () : Projectile()
[3755]34{
[4322]35  this->setClassID(CL_TEST_BULLET, "TestBullet");
[4597]36
[4948]37  float modelSize = .3;
[4982]38  this->model = (Model*)ResourceManager::getInstance()->load("models/projectiles/orx-rocket.obj", OBJ, RP_LEVEL, (void*) &modelSize);
[4948]39
40  this->energyMin = 1;
41  this->energyMax = 10;
[4969]42  this->remove();
[3755]43}
[3708]44
45
46/**
[4836]47 *  standard deconstructor
[3708]48*/
[4593]49TestBullet::~TestBullet ()
[3708]50{
[4593]51  /*
52     do not delete the test projectModel, since it is pnode
53     and will be cleaned out by world
[3708]54  */
55  //delete this->projectileModel;
56}
57
58
59
60/**
[4836]61 *  signal tick, time dependent things will be handled here
62 * @param time since last tick
[3708]63*/
[4593]64void TestBullet::tick (float time)
[3708]65{
[4464]66  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
67  Vector v = this->velocity * (time);
[3708]68  this->shiftCoor(v);
69
[4890]70  this->lifeCycle += time/this->lifeSpan;
71  if( this->lifeCycle >= 1)
[3708]72    {
73      PRINTF(5)("FINALIZE==========================\n");
[4890]74      PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
[3708]75      PRINTF(5)("FINALIZE===========================\n");
[4941]76//      this->finalize();
77      GarbageCollector::getInstance()->collect(this);
[4942]78      this->lifeCycle = 0.0;
[4941]79
[3708]80    }
81}
82
83/**
[4836]84 *  the function gets called, when the projectile is destroyed
[3708]85*/
[4593]86void TestBullet::destroy ()
[3708]87{}
88
89
[4593]90void TestBullet::draw ()
[3708]91{
92  glMatrixMode(GL_MODELVIEW);
93  glPushMatrix();
94
[4593]95  float matrix[4][4];
[3708]96  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
97  this->getAbsDir().matrix (matrix);
[4593]98  glMultMatrixf((float*)matrix);
[3755]99  glScalef(2.0, 2.0, 2.0);
[3708]100  this->model->draw();
101
102  glPopMatrix();
103}
104
Note: See TracBrowser for help on using the repository browser.