Changeset 4855
- Timestamp:
- Jun 4, 2007, 12:57:01 AM (17 years ago)
- Location:
- data/contentcreation/pps/FabianLandau/mover/environments
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
data/contentcreation/pps/FabianLandau/mover/environments/mover.cc
r4844 r4855 56 56 57 57 this->originCoor = Vector(0, 0, 0); 58 this->originDir = Quaternion(0, Vector(0, 0, 0));58 this->originDir = Vector(0, 0, 0); 59 59 60 60 this->soundSource_starting.setSourceNode(this); … … 69 69 70 70 this->originCoor = this->getAbsCoor(); 71 this->originDir = this->getAbsDir() ;71 this->originDir = this->getAbsDir().getRotation(); 72 72 73 73 PRINTF(0)("1_3\n"); … … 291 291 if (this->stations) 292 292 { 293 this->s hiftCoor(this->stations->getVelocity(this->station) * dt);294 this->setAbsDir( this->originDir * (this->stations->getRotation(this->station) * this->time));293 this->setAbsCoor(this->originCoor + this->stations->getVelocity(this->station) * this->time); 294 this->setAbsDir(VtoQ(this->originDir + this->stations->getRotation(this->station) * this->time)); 295 295 } 296 296 … … 304 304 this->time = this->stations->getMovingTime(this->station) - this->time; 305 305 this->originCoor = this->originCoor - this->stations->getRelTargetCoor(this->station); 306 this->originDir = this->originDir /this->stations->getRelTargetDir(this->station);306 this->originDir = this->originDir - this->stations->getRelTargetDir(this->station); 307 307 } 308 308 } 309 309 310 if (/*this->reachedStationsTarget(dt) || */(this->stations && (this->time >= 1. 1* this->stations->getMovingTime(this->station))))310 if (/*this->reachedStationsTarget(dt) || */(this->stations && (this->time >= 1.0 * this->stations->getMovingTime(this->station)))) 311 311 // if (this->stations && (this->time >= this->stations->getMovingTime(this->station))) 312 312 { 313 313 this->setAbsCoor(this->originCoor + this->stations->getRelTargetCoor(this->station)); 314 this->setAbsDir( this->originDir * this->stations->getRelTargetDir(this->station));314 this->setAbsDir(VtoQ(this->originDir + this->stations->getRelTargetDir(this->station))); 315 315 316 316 if (this->stations->getEndingSound(this->station).loaded()) … … 319 319 320 320 this->originCoor = this->originCoor + this->stations->getRelTargetCoor(this->station); 321 this->originDir = this->originDir *this->stations->getRelTargetDir(this->station);321 this->originDir = this->originDir + this->stations->getRelTargetDir(this->station); 322 322 323 323 return STAY; … … 345 345 if (this->stations) 346 346 if ((this->getAbsCoor() - (this->originCoor + this->stations->getRelTargetCoor(this->station))).len() <= 1.2 * (this->stations->getVelocity(this->station) * dt).len()) 347 if ( fabs((this->getAbsDir() / (this->originDir * this->stations->getRelTargetDir(this->station))).w) <= 1.2 * fabs(this->stations->getRotation(this->station).w * dt))347 if ((this->getAbsDir().getRotation() - (this->originDir + this->stations->getRelTargetDir(this->station))).len() <= 1.2 * (this->stations->getRotation(this->station) * dt).len()) 348 348 return true; 349 349 -
data/contentcreation/pps/FabianLandau/mover/environments/mover.h
r4844 r4855 46 46 int stay(); 47 47 bool reachedStationsTarget(float dt); 48 Quaternion VtoQ(Vector v) { return Quaternion(v.x, v.y, v.z); } 49 Vector QtoV(Quaternion Q) { return Vector(); } 48 50 49 51 bool bLoop; … … 64 66 int repeatsToGo; 65 67 Vector originCoor; 66 QuaternionoriginDir;68 Vector originDir; 67 69 68 70 OrxSound::SoundSource soundSource_starting; -
data/contentcreation/pps/FabianLandau/mover/environments/mover_station.cc
r4844 r4855 28 28 this->rank = 0; 29 29 this->relTargetCoor = Vector(0, 0, 0); 30 this->relTargetDir = Quaternion(0, Vector(0, 0, 0));30 this->relTargetDir = Vector(0, 0, 0); 31 31 this->delay = 0; 32 32 this->movingTime = 0; … … 60 60 .defaultValues(0, 0, 0); 61 61 LoadParam(root, "rel-target-dir", this, MoverStation, setRelTargetDir) 62 .describe("The relative direction of the stations target .")63 .defaultValues(0, 0, 0 , 0);62 .describe("The relative direction of the stations target in all axes (roll/pitch/yaw).") 63 .defaultValues(0, 0, 0); 64 64 LoadParam(root, "delay", this, MoverStation, setDelay) 65 65 .describe("The amount of time the mover waits, before he starts moving.") … … 99 99 { 100 100 this->relTargetCoor = Vector(0, 0, 0); 101 this->relTargetDir = Quaternion(0, Vector(0, 0, 0));101 this->relTargetDir = Vector(0, 0, 0); 102 102 } 103 103 } -
data/contentcreation/pps/FabianLandau/mover/environments/mover_station.h
r4844 r4855 25 25 26 26 void setRank(int id) { this->rank = id; } 27 void setRelTargetCoor(float x , float y, float z) { this->relTargetCoor = Vector(x, y, z); }28 void setRelTargetDir(float w , float x, float y, float z) { this->relTargetDir = Quaternion(w, Vector(x, y, z)); }27 void setRelTargetCoor(float x = 0, float y = 0, float z = 0) { this->relTargetCoor = Vector(x, y, z); } 28 void setRelTargetDir(float wx = 0, float wy = 0, float wz = 0) { this->relTargetDir = Vector(wx, wy, wz); } 29 29 void setDelay(float t) { this->delay = t; } 30 30 void setMovingTime(float t) { this->movingTime = t; } … … 45 45 int rank; 46 46 Vector relTargetCoor; 47 QuaternionrelTargetDir;47 Vector relTargetDir; 48 48 float delay; 49 49 float movingTime; -
data/contentcreation/pps/FabianLandau/mover/environments/mover_station_list.cc
r4844 r4855 236 236 } 237 237 238 QuaternionMoverStationList::getTotalRelDir(MoverStation *station)238 Vector MoverStationList::getTotalRelDir(MoverStation *station) 239 239 { 240 240 MoverStationListElement *temp = this->first; 241 Quaternion totalRelDir = Quaternion(0, Vector(0, 0, 0));241 Vector totalRelDir = Vector(0, 0, 0); 242 242 243 243 if (station) … … 247 247 while (temp != 0) 248 248 { 249 totalRelDir *= temp->station->relTargetDir;249 totalRelDir += temp->station->relTargetDir; 250 250 if (temp->station == station) 251 251 break; … … 260 260 while (temp->next != 0) 261 261 { 262 totalRelDir *= temp->next->station->relTargetDir;262 totalRelDir += temp->next->station->relTargetDir; 263 263 if (temp->next->station == station) 264 264 break; … … 336 336 } 337 337 338 QuaternionMoverStationList::getRelTargetDir(MoverStation *station)338 Vector MoverStationList::getRelTargetDir(MoverStation *station) 339 339 { 340 340 if (station) … … 345 345 return station->relTargetDir; 346 346 else 347 return station->relTargetDir .inverse();347 return station->relTargetDir * -1; 348 348 } 349 349 else … … 354 354 { 355 355 if (this->goForward) 356 return (station->relTargetDir / this->getTotalRelDir(moveToStation)).inverse();356 return (station->relTargetDir - this->getTotalRelDir(moveToStation)) * -1; 357 357 else 358 return (station->relTargetDir / this->getTotalRelDir(moveToStation));359 } 360 } 361 } 362 363 return Quaternion(0, Vector(0, 0, 0));358 return station->relTargetDir - this->getTotalRelDir(moveToStation); 359 } 360 } 361 } 362 363 return Vector(0, 0, 0); 364 364 } 365 365 366 366 Vector MoverStationList::getVelocity(MoverStation *station) 367 367 { 368 Vector velocity = Vector(0, 0, 0);369 370 368 if (station) 371 369 if (station->movingTime != 0) 372 velocity = this->getRelTargetCoor(station) / station->movingTime; 373 374 return velocity; 375 } 376 377 Quaternion MoverStationList::getRotation(MoverStation *station) 378 { 379 Quaternion rotation = Quaternion(0, Vector(0, 0, 0)); 380 370 return this->getRelTargetCoor(station) / station->movingTime; 371 372 return Vector(0, 0, 0); 373 } 374 375 Vector MoverStationList::getRotation(MoverStation *station) 376 { 381 377 if (station) 382 378 if (station->movingTime != 0) 383 r otation = Quaternion(this->getRelTargetDir(station).w / station->movingTime, this->getRelTargetDir(station).v);384 385 return rotation;379 return this->getRelTargetDir(station) / station->movingTime; 380 381 return Vector(0, 0, 0); 386 382 } 387 383 -
data/contentcreation/pps/FabianLandau/mover/environments/mover_station_list.h
r4844 r4855 32 32 MoverStation *getNextStation(MoverStation *station); 33 33 Vector getTotalRelCoor(MoverStation *station); 34 QuaterniongetTotalRelDir(MoverStation *station);34 Vector getTotalRelDir(MoverStation *station); 35 35 bool isOpen(MoverStation *station); 36 36 bool isClosed(MoverStation *station); … … 38 38 39 39 Vector getRelTargetCoor(MoverStation *station); 40 QuaterniongetRelTargetDir(MoverStation *station);40 Vector getRelTargetDir(MoverStation *station); 41 41 float getDelay(MoverStation *station) { return station->delay; } 42 42 float getStayOpenTime(MoverStation *station) { return station->stayOpenTime; } 43 43 float getMovingTime(MoverStation *station) { return station->movingTime; } 44 44 Vector getVelocity(MoverStation *station); 45 QuaterniongetRotation(MoverStation *station);45 Vector getRotation(MoverStation *station); 46 46 OrxSound::SoundBuffer getStartingSound(MoverStation *station); 47 47 OrxSound::SoundBuffer getMovingSound(MoverStation *station);
Note: See TracChangeset
for help on using the changeset viewer.