Changeset 10656 in orxonox.OLD for branches/vs-enhencements/src/world_entities
- Timestamp:
- May 14, 2007, 11:27:18 AM (18 years ago)
- Location:
- branches/vs-enhencements/src/world_entities/npcs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.cc
r10655 r10656 38 38 this->isActive = true; 39 39 40 //TODO init to zero for non-debug41 40 this->pitch = 0.0f; 42 this->dPitch = PI;41 this->dPitch = 0.0; 43 42 44 43 if ( root ) … … 57 56 void ActionboxEnemy::tick( float dt ) 58 57 { 58 myDir = this->getAbsDir(); 59 myCoor = this->getAbsCoor(); 60 59 61 this->pitch += this->dPitch*dt; 62 while ( pitch > 2*PI ) 63 pitch -= 2*PI; 64 while ( pitch < 0 ) 65 pitch += 2*PI; 66 67 myDir *= qPitch.inverse(); 68 69 qPitch = Quaternion( pitch, Vector( 1, 0, 0 ) ); 60 70 61 71 moveTowardsBox( NULL, dt ); 62 return; 63 72 64 73 if ( isActive && State::getActionBox() ) 65 74 { … … 74 83 } 75 84 } 85 86 myDir *= qPitch; 87 88 this->setAbsDir( myDir ); 89 this->setAbsCoor( myCoor ); 76 90 } 77 91 … … 83 97 { 84 98 Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor(); 85 Vector targetDir = targetPos - this->getAbsCoor();99 Vector targetDir = targetPos - myCoor; 86 100 87 88 Quaternion cur = this->getAbsDir(); 101 Quaternion cur = myDir; 89 102 Quaternion rx( 5*dt, Vector( 0, 0, 1 ) ); 90 103 … … 92 105 Quaternion tmp2 = cur * rx.inverse(); 93 106 107 Quaternion dec; 94 108 if ( tmp1.apply( Vector(1, 0, 0) ).dot(targetDir) > tmp2.apply( Vector(1, 0, 0)).dot(targetDir) ) 95 cur= tmp1;109 dec = tmp1; 96 110 else 97 cur = tmp2; 111 dec = tmp2; 112 113 float dp = dec.apply( Vector(1, 0, 0) ).dot(Vector(0, 1, 0)); 114 if ( dp > -0.9 && dp < 0.9 ) 115 { 116 cur = dec; 117 } 98 118 99 119 Quaternion ry( 5*dt, cur.inverse().apply( Vector( 0, 1, 0 ) ) ); … … 107 127 cur = tmp2; 108 128 109 this->setAbsDir( cur );129 myDir = cur; 110 130 } 111 131 112 132 void ActionboxEnemy::draw( ) const 113 133 { 134 #if 0 114 135 Vector fw = this->getAbsDir().apply( Vector( 1, 0, 0 ) ); 115 136 fw.normalize(); … … 173 194 174 195 glPopMatrix(); 175 196 #enif 176 197 WorldEntity::draw(); 177 198 } -
branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.h
r10651 r10656 24 24 float pitch; // rotate angle around x-axix 25 25 float dPitch; // change pitch += dPitch*dt 26 Quaternion qPitch; 27 28 Quaternion myDir; 29 Vector myCoor; 26 30 27 31 void attackPlayer( ActionBox* box, float dt );
Note: See TracChangeset
for help on using the changeset viewer.