Changeset 10655 in orxonox.OLD
- Timestamp:
- May 13, 2007, 1:27:37 PM (18 years ago)
- Location:
- branches/vs-enhencements/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/vs-enhencements/src/ai/swarm_gorel.cc
r10618 r10655 23 23 24 24 //calculate movement parameters.. 25 float averageRadius ;25 float averageRadius = 0; 26 26 for (it=members.begin(); it!= members.end(); it++ ){ 27 27 averageRadius+=it->second->getNPCRadius(); -
branches/vs-enhencements/src/lib/math/quaternion.h
r10640 r10655 115 115 116 116 117 inlinevoid slerpTo(const Quaternion& toQuat, float t);117 void slerpTo(const Quaternion& toQuat, float t); 118 118 static Quaternion quatSlerp(const Quaternion& from, const Quaternion& to, float t); 119 119 -
branches/vs-enhencements/src/lib/math/vector.h
r10376 r10655 64 64 /** @param v The vector to substract @returns the substraction between two vectors (this - v) */ 65 65 inline Vector operator- (const sVec3D& v) const { return Vector(x - v[0], y - v[1], z - v[2]); } 66 /** @returns the substraction between (0, 0, 0) and this (null-this) */ 67 inline Vector operator- () const { return Vector(-x, -y, -z); } 66 68 /** @param v The vector to substract @returns the substraction between two vectors (this -= v) */ 67 69 inline const Vector& operator-= (const Vector& v) { this->x -= v.x; this->y -= v.y; this->z -= v.z; return *this; }; -
branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.cc
r10651 r10655 83 83 { 84 84 Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor(); 85 Vector targetDir = targetPos - this->getAbsCoor(); 85 86 86 Vector fw = this->getAbsDir().apply( Vector( 0, 0, -1 ) );87 fw.normalize();88 87 89 Vector dv = targetPos - this->getAbsCoor();90 dv.normalize();88 Quaternion cur = this->getAbsDir(); 89 Quaternion rx( 5*dt, Vector( 0, 0, 1 ) ); 91 90 92 Vector up = fw.cross( dv )*-1; 91 Quaternion tmp1 = cur * rx; 92 Quaternion tmp2 = cur * rx.inverse(); 93 93 94 Quaternion rot(up, 10.0*dt); 95 rot.normalize(); 96 Quaternion cur = this->getAbsDir(); 97 Quaternion ne = rot * cur; 98 this->setAbsDir( ne ); 94 if ( tmp1.apply( Vector(1, 0, 0) ).dot(targetDir) > tmp2.apply( Vector(1, 0, 0)).dot(targetDir) ) 95 cur = tmp1; 96 else 97 cur = tmp2; 99 98 100 // 1, 0, 0 101 // 0, 1, 0 102 return; 103 Vector k = ne.apply( Vector( 1, 0, 0 ) ); 104 k.normalize(); 99 Quaternion ry( 5*dt, cur.inverse().apply( Vector( 0, 1, 0 ) ) ); 105 100 106 Vector vr = k.cross( Vector( 0, 1, 0) ); 101 tmp1 = cur * ry; 102 tmp2 = cur * ry.inverse(); 107 103 108 rot = Quaternion(vr, 10.0*dt); 109 rot.normalize(); 110 cur = ne; 111 ne = rot * cur; 112 ne.normalize(); 113 114 this->setAbsDir( ne ); 104 if ( tmp1.apply( Vector(1, 0, 0) ).dot(targetDir) > tmp2.apply( Vector(1, 0, 0)).dot(targetDir) ) 105 cur = tmp1; 106 else 107 cur = tmp2; 108 109 this->setAbsDir( cur ); 115 110 } 116 111 … … 130 125 dv += mp; 131 126 132 Vector up = fw.cross( dv )*-1; 127 Vector spUp = this->getAbsDir().inverse().apply( this->getAbsDir().apply( Vector( 0, 1, 0 ) ) ); 128 spUp.normalize(); 129 spUp *= 100; 130 spUp += mp; 131 132 Vector up = fw.cross( dv ); 133 133 up += mp; 134 134 … … 154 154 glEnd(); 155 155 156 glColor3f(0.0, 1.0, 0.0 ); 156 157 glBegin(GL_LINE_STRIP); 157 158 glVertex3f(mp.x, mp.y, mp.z); … … 159 160 glEnd(); 160 161 162 glColor3f(0.0, 0.0, 1.0 ); 161 163 glBegin(GL_LINE_STRIP); 162 164 glVertex3f(mp.x, mp.y, mp.z); 163 165 glVertex3f(up.x, up.y, up.z); 166 glEnd(); 167 168 glColor3f(1.0, 1.0, 1.0 ); 169 glBegin(GL_LINE_STRIP); 170 glVertex3f(mp.x, mp.y, mp.z); 171 glVertex3f(spUp.x, spUp.y, spUp.z); 164 172 glEnd(); 165 173
Note: See TracChangeset
for help on using the changeset viewer.