Changeset 3953 in orxonox.OLD for orxonox/branches/physics/src/world_entities/test_gun.cc
- Timestamp:
- Apr 25, 2005, 9:29:41 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/world_entities/test_gun.cc
r3855 r3953 40 40 creates a new weapon 41 41 */ 42 TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion*direction, int leftRight)42 TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight) 43 43 : Weapon (parent, coordinate, direction) 44 44 { … … 47 47 this->leftRight = leftRight; 48 48 49 if( this->leftRight == 0) 50 this->projOffset = new Vector(1.0, 0.0, -0.35); 51 else if( this->leftRight == 1) 52 this->projOffset = new Vector(1.0, 0.0, 0.5); 49 this->objectComponent1 = new PNode(); 50 this->animation1 = new Animation3D(this->objectComponent1); 51 parent->addChild(this->objectComponent1, PNODE_ALL); 53 52 53 this->animation1->setInfinity(ANIM_INF_CONSTANT); 54 // ANIM_LINEAR was ANIM_NEG_EXP 55 if( this->leftRight == W_LEFT) 56 { 57 this->projectileOffset = Vector(1.0, 0.0, -0.35); 54 58 55 this->dummy1 = new WorldEntity(); // a world entity that is not drawed: use this for the weapon 56 this->animation = new Animation3D(dummy1); 59 this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR); 60 this->animation1->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.5, ANIM_LINEAR); 61 this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR); 62 } 63 else if( this->leftRight == W_RIGHT) 64 { 65 this->projectileOffset = Vector(1.0, 0.0, 0.5); 57 66 58 parent->addChild(this->dummy1, PNODE_ALL); 59 60 this->animation->setInfinity(ANIM_INF_CONSTANT); 61 // ANIM_LINEAR was ANIM_NEG_EXP 62 if( this->leftRight == 0) 63 { 64 this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR); 65 this->animation->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.5, ANIM_LINEAR); 66 this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR); 67 this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR); 68 this->animation1->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.5, ANIM_LINEAR); 69 this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR); 67 70 } 68 else if( this->leftRight == 1)69 {70 this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);71 this->animation->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.5, ANIM_LINEAR);72 this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR);73 }74 /*75 if( this->leftRight == 0)76 {77 this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.0, ANIM_NEG_EXP);78 this->animation->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.1, ANIM_NEG_EXP);79 this->animation->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.5, ANIM_NEG_EXP);80 }81 else if( this->leftRight == 1)82 {83 this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.0, ANIM_NEG_EXP);84 this->animation->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.1, ANIM_NEG_EXP);85 this->animation->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.5, ANIM_NEG_EXP);86 }87 */88 71 } 89 72 … … 127 110 void TestGun::fire() 128 111 { 129 if( this->localTime < this->idleTime)112 if( !this->hasWeaponIdleTimeElapsed()) 130 113 { 131 114 this->weaponIdle(); 132 115 return; 133 116 } 117 134 118 Projectile* pj = new TestBullet(this); 135 136 pj->setAbsCoor(this->getAbsCoor() + *this->projOffset); 119 pj->setAbsCoor(this->getAbsCoor() + this->projectileOffset); 137 120 pj->setAbsDir(this->getAbsDir()); 138 139 121 pj->setFlightDirection(this->getAbsDir()); 140 122 pj->setSpeed(this->getSpeed()); 141 142 123 this->worldEntities->add(pj); 143 124 this->localTime = 0; 144 125 145 this->animation ->replay();126 this->animation1->replay(); 146 127 } 147 128 … … 190 171 void TestGun::draw () 191 172 { 192 193 /* draw gun body 1 */ 173 /* draw gun body */ 194 174 glMatrixMode(GL_MODELVIEW); 195 175 glPushMatrix(); 196 176 float matrix[4][4]; 197 198 if( this->leftRight == 0) 199 { 200 glTranslatef (this->getAbsCoor ().x, 201 this->getAbsCoor ().y, 202 this->getAbsCoor ().z); 203 204 this->getAbsDir ().matrix (matrix); 205 glMultMatrixf((float*)matrix); 206 this->model->draw(1); 207 } 208 else if( this->leftRight == 1) 209 { 210 glTranslatef (this->getAbsCoor ().x, 211 this->getAbsCoor ().y, 212 this->getAbsCoor ().z); 213 214 this->getAbsDir ().matrix (matrix); 215 glMultMatrixf((float*)matrix); 216 glScalef(1.0, 1.0, -1.0); 217 this->model->draw(1); 218 } 219 177 glTranslatef (this->getAbsCoor ().x, 178 this->getAbsCoor ().y, 179 this->getAbsCoor ().z); 180 this->getAbsDir ().matrix (matrix); 181 glMultMatrixf((float*)matrix); 182 if( this->leftRight == W_RIGHT) 183 glScalef(1.0, 1.0, -1.0); 184 this->model->draw(1); 220 185 glPopMatrix(); 221 186 222 223 /* draw gun coil 1 */ 187 /* draw objectComponent1: gun coil - animated stuff */ 224 188 glMatrixMode(GL_MODELVIEW); 225 189 glPushMatrix(); 226 227 glTranslatef (this->dummy1->getAbsCoor ().x, 228 this->dummy1->getAbsCoor ().y, 229 this->dummy1->getAbsCoor ().z); 230 231 this->dummy1->getAbsDir ().matrix (matrix); 190 glTranslatef (this->objectComponent1->getAbsCoor ().x, 191 this->objectComponent1->getAbsCoor ().y, 192 this->objectComponent1->getAbsCoor ().z); 193 this->objectComponent1->getAbsDir ().matrix (matrix); 232 194 glMultMatrixf((float*)matrix); 233 195 this->model->draw(0);
Note: See TracChangeset
for help on using the changeset viewer.