Changeset 3755 in orxonox.OLD for orxonox/trunk/src/world_entities/test_gun.cc
- Timestamp:
- Apr 8, 2005, 12:46:33 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/test_gun.cc
r3752 r3755 40 40 creates a new weapon 41 41 */ 42 TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction )42 TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction, int leftRight) 43 43 : Weapon (parent, coordinate, direction) 44 44 { 45 45 this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN); 46 46 this->idleTime = 0.2f; 47 this->leftRight = leftRight; 47 48 48 49 this->animator = SimpleAnimation::getInstance(); 49 this->dummy = new WorldEntity(); /* a world entity that is not drawed: use this for the weapon */50 parent->addChild(this->dummy , PNODE_ALL);51 //this->dummy->setRelCoor(new Vector(-2.6, 0.1, 3.0)); 50 this->dummy1 = new WorldEntity(); /* a world entity that is not drawed: use this for the weapon */ 51 parent->addChild(this->dummy1, PNODE_ALL); 52 52 53 53 54 this->animator->animatorBegin(); 54 this->animator->selectObject(this->dummy );55 this->animator->selectObject(this->dummy1); 55 56 this->animator->setAnimationMode(SINGLE); 56 this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.0, NEG_EXP); 57 this->animator->addKeyFrame(new Vector(-3.0, 0.1, 3.0), new Quaternion(), 0.1, NEG_EXP); 58 this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.5, NEG_EXP); 57 if( this->leftRight == 0) 58 { 59 this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.0, NEG_EXP); 60 this->animator->addKeyFrame(new Vector(-3.0, 0.1, 3.0), new Quaternion(), 0.1, NEG_EXP); 61 this->animator->addKeyFrame(new Vector(-2.6, 0.1, 3.0), new Quaternion(), 0.5, NEG_EXP); 62 } 63 else if( this->leftRight == 1) 64 { 65 this->animator->addKeyFrame(new Vector(-2.6, 0.1, -2.5), new Quaternion(), 0.0, NEG_EXP); 66 this->animator->addKeyFrame(new Vector(-3.0, 0.1, -2.5), new Quaternion(), 0.1, NEG_EXP); 67 this->animator->addKeyFrame(new Vector(-2.6, 0.1, -2.5), new Quaternion(), 0.5, NEG_EXP); 68 } 59 69 this->animator->animatorEnd(); 60 70 … … 117 127 118 128 this->animator->animatorBegin(); 119 this->animator->selectObject(this->dummy );129 this->animator->selectObject(this->dummy1); 120 130 this->animator->start(); 121 131 this->animator->animatorEnd(); … … 167 177 { 168 178 179 /* draw gun body 1 */ 169 180 glMatrixMode(GL_MODELVIEW); 170 181 glPushMatrix(); 171 182 float matrix[4][4]; 172 183 173 174 glTranslatef (this->getAbsCoor ().x, 175 this->getAbsCoor ().y, 176 this->getAbsCoor ().z); 177 178 this->getAbsDir ().matrix (matrix); 179 glMultMatrixf((float*)matrix); 180 this->model->draw(1); 184 if( this->leftRight == 0) 185 { 186 glTranslatef (this->getAbsCoor ().x, 187 this->getAbsCoor ().y, 188 this->getAbsCoor ().z); 189 190 this->getAbsDir ().matrix (matrix); 191 glMultMatrixf((float*)matrix); 192 this->model->draw(1); 193 } 194 else if( this->leftRight == 1) 195 { 196 glTranslatef (this->getAbsCoor ().x, 197 this->getAbsCoor ().y, 198 this->getAbsCoor ().z); 199 200 this->getAbsDir ().matrix (matrix); 201 glMultMatrixf((float*)matrix); 202 glScalef(1.0, 1.0, -1.0); 203 this->model->draw(1); 204 } 205 181 206 glPopMatrix(); 182 183 207 208 209 /* draw gun coil 1 */ 184 210 glMatrixMode(GL_MODELVIEW); 185 211 glPushMatrix(); 186 212 187 glTranslatef (this->dummy ->getAbsCoor ().x,188 this->dummy ->getAbsCoor ().y,189 this->dummy ->getAbsCoor ().z);190 191 this->dummy ->getAbsDir ().matrix (matrix);213 glTranslatef (this->dummy1->getAbsCoor ().x, 214 this->dummy1->getAbsCoor ().y, 215 this->dummy1->getAbsCoor ().z); 216 217 this->dummy1->getAbsDir ().matrix (matrix); 192 218 glMultMatrixf((float*)matrix); 193 219 this->model->draw(0); 194 220 glPopMatrix(); 195 196 } 197 221 } 222
Note: See TracChangeset
for help on using the changeset viewer.