Changeset 10679 in orxonox.OLD for branches/adm/src
- Timestamp:
- Jun 8, 2007, 4:21:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/adm/src/world_entities/npcs/adm_turret.cc
r10677 r10679 74 74 75 75 } 76 77 //HACK this is really ugly because if you move the AdmTurret its cannons wont follow 78 if ( this->cannons ) 79 this->cannons->setParent( NullParent::getNullParent() ); 76 80 } 77 81 … … 95 99 { 96 100 this->registerObject(this, AdmTurret::_objectList); 97 98 99 // this-> loadModel ("models/guns/turret1.obj", ,1 ) 100 101 102 //Cannon Node: 2 Cannons fixed left and right of the main turret 103 104 // this->sensor.setRelCoor( , , ) 105 106 // initialise Weapons here 101 102 //this->removeNodeFlags( 7 ); 107 103 } 108 104 … … 201 197 this->cannons->loadParams( root ); 202 198 203 this->cannons->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);204 this->cannons->addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);199 //this->cannons->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 200 //this->cannons->addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); 205 201 206 202 this->cannons->toList( getOMListNumber() ); … … 213 209 this->sensor->loadParams( root ); 214 210 215 this->sensor->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);216 this->sensor->addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);211 //this->sensor->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 212 //this->sensor->addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); 217 213 this->sensor->toList( getOMListNumber() ); 218 214 } … … 220 216 void AdmTurret::moveTowards( Vector targetDir, float dt ) 221 217 { 222 223 if(false){ 218 #if 0 219 static Quaternion mrot = this->getAbsDir(); 220 Quaternion ry( dt, Vector(0, 1, 0) ); 221 mrot *= ry; 222 this->setAbsDir(mrot); 223 224 static Quaternion rot = this->cannons->getAbsDir(); 225 Quaternion rx( dt, Vector( 0, 0, 1 ) ); 226 rot *= rx; 227 this->cannons->setAbsDir(rot*mrot); 228 return; 229 #endif 230 231 224 232 225 233 226 234 Quaternion cur = this->getAbsDir(); 227 235 228 Quaternion ry( dt, cur. apply( Vector( 0, 1, 0 ) ) );236 Quaternion ry( dt, cur.inverse().apply( Vector( 0, 1, 0 ) ) ); 229 237 230 238 Quaternion tmp1 = cur * ry; 231 239 Quaternion tmp2 = cur * ry.inverse(); 232 240 241 bool usetmp1 = false; 242 Quaternion r1; 233 243 if ( tmp1.apply( Vector(1, 0, 0) ).dot(targetDir) < tmp2.apply( Vector(1, 0, 0)).dot(targetDir) ) 244 { 245 usetmp1 = true; 234 246 cur = tmp1; 247 r1 = ry; 248 } 235 249 else 250 { 236 251 cur = tmp2; 252 r1 = ry.inverse(); 253 } 237 254 238 255 this->setAbsDir( cur ); 239 } 240 241 { 242 //targetDir = this->getAbsDir().apply( targetDir ); 243 Quaternion cur = this->cannons->getAbsDir(); 244 //Quaternion rx( dt, Vector( 0, 0, 1 ) ); 245 Quaternion rx( dt, Vector( 0, 0, 1 ) ); 246 247 Quaternion tmp1 = cur * rx; 248 Quaternion tmp2 = cur * rx.inverse(); 256 257 258 Quaternion cur2 = this->cannons->getAbsDir(); 259 Quaternion rx( dt, cur.inverse().apply( Vector( 0, 0, 1 ) ) ); 260 Quaternion rr( dt, cur2.inverse().apply( Vector( 0, 1, 0 ) ) ); 261 if ( !usetmp1 ) 262 rr = rr.inverse(); 263 264 265 tmp1 = cur2 * rx; 266 tmp2 = cur2 * rx.inverse(); 249 267 250 268 Quaternion dec; 251 if ( tmp1.apply( Vector(-1, 0, 0) ).dot(targetDir) < tmp2.apply( Vector(-1, 0, 0) ).dot(targetDir) ) 269 Quaternion r2; 270 if ( tmp1.apply( Vector(-1, 0, 0) ).dot(targetDir) > tmp2.apply( Vector(-1, 0, 0) ).dot(targetDir) ) 271 { 272 r2 = rx; 252 273 dec = tmp1; 274 } 253 275 else 276 { 277 r2 = rx.inverse(); 254 278 dec = tmp2; 279 } 255 280 256 281 float dp = dec.apply( Vector(-1, 0, 0) ).dot(Vector(0, 1, 0)); 257 if ( true /*dp > -0.9 && dp < 0.9*/)258 { 259 cur = dec;260 } 261 262 this->cannons->setAbsDir( cur );263 } 264 265 266 } 282 if ( dp > -0.9 && dp < 0.9 ) 283 { 284 cur2 = dec; 285 } 286 287 this->cannons->setAbsDir( cur2 ); 288 289 290 291 }
Note: See TracChangeset
for help on using the changeset viewer.