1 | |
---|
2 | |
---|
3 | /* |
---|
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 |
---|
15 | co-programmer: |
---|
16 | */ |
---|
17 | |
---|
18 | |
---|
19 | #include "test_bullet.h" |
---|
20 | |
---|
21 | #include "model.h" |
---|
22 | #include "vector.h" |
---|
23 | #include "object_manager.h" |
---|
24 | |
---|
25 | using namespace std; |
---|
26 | |
---|
27 | CREATE_FAST_FACTORY(TestBullet, CL_TEST_BULLET); |
---|
28 | |
---|
29 | /** |
---|
30 | * standard constructor |
---|
31 | */ |
---|
32 | TestBullet::TestBullet () : Projectile() |
---|
33 | { |
---|
34 | this->setClassID(CL_TEST_BULLET, "TestBullet"); |
---|
35 | |
---|
36 | float modelSize = .5; |
---|
37 | this->model = (Model*)ResourceManager::getInstance()->load("models/orx-rocket.obj", OBJ, RP_LEVEL, (void*) &modelSize); |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | /** |
---|
42 | * standard deconstructor |
---|
43 | */ |
---|
44 | TestBullet::~TestBullet () |
---|
45 | { |
---|
46 | /* |
---|
47 | do not delete the test projectModel, since it is pnode |
---|
48 | and will be cleaned out by world |
---|
49 | */ |
---|
50 | //delete this->projectileModel; |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | /** |
---|
56 | * signal tick, time dependent things will be handled here |
---|
57 | * @param time since last tick |
---|
58 | */ |
---|
59 | void TestBullet::tick (float time) |
---|
60 | { |
---|
61 | //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); |
---|
62 | Vector v = this->velocity * (time); |
---|
63 | this->shiftCoor(v); |
---|
64 | |
---|
65 | this->lifeCycle += time/this->lifeSpan; |
---|
66 | if( this->lifeCycle >= 1) |
---|
67 | { |
---|
68 | PRINTF(5)("FINALIZE==========================\n"); |
---|
69 | PRINTF(5)("current life cycle is: %f\n", this->lifeCycle); |
---|
70 | PRINTF(5)("FINALIZE===========================\n"); |
---|
71 | this->finalize(); |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * the function gets called, when the projectile is destroyed |
---|
77 | */ |
---|
78 | void TestBullet::destroy () |
---|
79 | {} |
---|
80 | |
---|
81 | |
---|
82 | void TestBullet::draw () |
---|
83 | { |
---|
84 | glMatrixMode(GL_MODELVIEW); |
---|
85 | glPushMatrix(); |
---|
86 | |
---|
87 | float matrix[4][4]; |
---|
88 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); |
---|
89 | this->getAbsDir().matrix (matrix); |
---|
90 | glMultMatrixf((float*)matrix); |
---|
91 | glScalef(2.0, 2.0, 2.0); |
---|
92 | this->model->draw(); |
---|
93 | |
---|
94 | glPopMatrix(); |
---|
95 | } |
---|
96 | |
---|