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