Changeset 495 for code/branches/AI/src/orxonox.cc
- Timestamp:
- Dec 12, 2007, 10:37:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI/src/orxonox.cc
r468 r495 44 44 #include "loader/LevelLoader.h" 45 45 #include "Flocking.h" 46 #include " AIClass.h"46 #include "Wander.h" 47 47 48 48 // some tests to see if enet works without includsion … … 86 86 87 87 Element arrayOfElements[9]; 88 89 // float time = 0; 88 Wander walker; 89 int counter = 0; 90 int times = 0; 91 90 92 91 93 … … 110 112 SceneManager *mgr = root_->getSceneManager("Default SceneManager"); 111 113 112 arrayOfElements[0].update(arrayOfElements, evt); 113 arrayOfElements[1].update(arrayOfElements, evt); 114 arrayOfElements[2].update(arrayOfElements, evt); 115 arrayOfElements[3].update(arrayOfElements, evt); 116 arrayOfElements[4].update(arrayOfElements, evt); 117 arrayOfElements[5].update(arrayOfElements, evt); 118 arrayOfElements[6].update(arrayOfElements, evt); 119 arrayOfElements[7].update(arrayOfElements, evt); 120 arrayOfElements[8].update(arrayOfElements, evt); 121 122 /* arrayOfElements[0].update(arrayOfElements, evt); 123 arrayOfElements[1].update(arrayOfElements, evt); 124 arrayOfElements[2].update(arrayOfElements, evt); 125 arrayOfElements[3].update(arrayOfElements, evt); 126 arrayOfElements[4].update(arrayOfElements, evt); */ 127 114 /* // RUN WANDER 115 116 walker.update(); 117 walker.speed = walker.speed + 10*walker.acceleration*evt.timeSinceLastFrame; 118 walker.location = walker.location + 10*walker.speed*evt.timeSinceLastFrame; 119 walker.acceleration = (0,0,0); 120 mgr->getSceneNode("HeadNode10")->setPosition(walker.location); 121 122 */ // END RUN WANDER 123 124 125 126 127 // RUN FLOCKING 128 129 arrayOfElements[8].location = 100*Vector3(Math::Cos(Math::DegreesToRadians(counter)/10),Math::Sin(Math::DegreesToRadians(counter)/10),Math::Cos(Math::DegreesToRadians(counter+(counter-180)/2)/10)); 130 131 arrayOfElements[0].update(arrayOfElements); 132 arrayOfElements[1].update(arrayOfElements); 133 arrayOfElements[2].update(arrayOfElements); 134 arrayOfElements[3].update(arrayOfElements); 135 arrayOfElements[4].update(arrayOfElements); 136 arrayOfElements[5].update(arrayOfElements); 137 arrayOfElements[6].update(arrayOfElements); 138 arrayOfElements[7].update(arrayOfElements); 139 arrayOfElements[8].update(arrayOfElements); 128 140 129 141 for(int i=0; i<9; i++) { 130 131 arrayOfElements[i].speed = 0.995*arrayOfElements[i].speed + arrayOfElements[i].acceleration*evt.timeSinceLastFrame; 132 133 arrayOfElements[i].location = arrayOfElements[i].location + arrayOfElements[i].speed*evt.timeSinceLastFrame; 134 135 arrayOfElements[i].acceleration = (0,0,0); 142 arrayOfElements[i].speed = 0.995*arrayOfElements[i].speed + arrayOfElements[i].acceleration*evt.timeSinceLastFrame; 143 arrayOfElements[i].location = arrayOfElements[i].location + arrayOfElements[i].speed*evt.timeSinceLastFrame; 144 arrayOfElements[i].acceleration = (0,0,0); 136 145 } 137 146 … … 146 155 mgr->getSceneNode("HeadNode9")->setPosition(arrayOfElements[8].location); 147 156 148 149 /* 150 151 mgr->getSceneNode("HeadNode9")->setPosition(Vector3(200*cos(10*time),0,0)); 152 time = time + evt.timeSinceLastFrame; 153 154 */ 155 156 157 158 // mgr->getSceneNode("HeadNode1")->yaw((Radian)10*evt.timeSinceLastFrame); 157 counter = counter + 1; 158 counter = counter%7200; 159 160 // END RUN FLOCKING 161 159 162 } 160 163 … … 272 275 cam->lookAt(Vector3(0,0,0)); 273 276 Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam); 274 example(); //my stuff 277 278 //Invoke example to test AI 279 example(); 275 280 } 276 281 … … 321 326 } 322 327 323 //declaration of the 3 Ogreheads324 //muss leider global sein.....325 //Element* arrayOfElements[2];326 327 328 void example() { 328 329 SceneManager *mgr = mRoot->getSceneManager("Default SceneManager"); 329 330 mgr->setAmbientLight(ColourValue(1.0,1.0,1.0)); 331 332 /* //TEST DATA WANDER 333 334 Entity* ent10 = mgr->createEntity("Head10", "ogrehead.mesh"); 335 SceneNode *node10 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode10", Vector3(0,0,0)); 336 node10->attachObject(ent10); 337 Vector3 temp; 338 temp = (0,0,0); 339 walker.setValues(node10->getPosition(),temp,temp,true); 340 341 */ //END TEST DATA WANDER 342 343 344 // TEST DATA FLOCKING 330 345 331 346 Entity* ent1 = mgr->createEntity("Head1", "ogrehead.mesh"); … … 347 362 SceneNode *node7 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode7", Vector3(-150,-150,0)); 348 363 SceneNode *node8 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode8", Vector3(-150,150,0)); 349 SceneNode *node9 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode9", Vector3(0,0,0)); 350 351 // follwing camera 352 353 // Camera *cam = mgr->getCamera("Camera"); 354 // node1->attachObject(cam); 355 356 357 364 SceneNode *node9 = mgr->getRootSceneNode()->createChildSceneNode("HeadNode9", Vector3(0,0,0)); 358 365 359 366 node1->attachObject(ent1); … … 376 383 ElementLocationArray[7] = node8->getPosition(); 377 384 ElementLocationArray[8] = node9->getPosition(); 378 /* 379 ElementLocationArray[5] = node6->getPosition(); 380 ElementLocationArray[6] = node7->getPosition();*/ 385 381 386 ElementSpeedArray[0] = (0,0,0); 382 387 ElementSpeedArray[1] = (0,0,0); … … 388 393 ElementSpeedArray[7] = (0,0,0); 389 394 ElementSpeedArray[8] = (0,0,0); 390 /* 391 ElementSpeedArray[5] = (0,0,0); 392 ElementSpeedArray[6] = (0,0,0); */ 395 393 396 ElementAccelerationArray[0] = (0,0,0); 394 397 ElementAccelerationArray[1] = (0,0,0); … … 400 403 ElementAccelerationArray[7] = (0,0,0); 401 404 ElementAccelerationArray[8] = (0,0,0); 402 /* 403 ElementAccelerationArray[5] = (0,0,0); 404 ElementAccelerationArray[6] = (0,0,0); */ 405 405 406 arrayOfElements[0].setValues( ElementLocationArray[0], ElementSpeedArray[0], ElementAccelerationArray[0], true); 406 407 arrayOfElements[1].setValues( ElementLocationArray[1], ElementSpeedArray[1], ElementAccelerationArray[1], true); … … 412 413 arrayOfElements[7].setValues( ElementLocationArray[7], ElementSpeedArray[7], ElementAccelerationArray[7], true); 413 414 arrayOfElements[8].setValues( ElementLocationArray[8], ElementSpeedArray[8], ElementAccelerationArray[8], false); 414 /* 415 arrayOfElements[5].setValues( ElementLocationArray[5], ElementSpeedArray[5], ElementAccelerationArray[5], false); 416 arrayOfElements[6].setValues( ElementLocationArray[6], ElementSpeedArray[6], ElementAccelerationArray[6], false);*/ 417 418 419 420 421 /* for (int i=0; i<3; i++) { 422 Element* arrayOfElements[i] = new Element( ElementLocationArray[i], ElementSpeedArray[i], ElementAccelerationArray[i] ); 423 } */ 424 /* for (int i=0; i<3; i++) { 425 arrayOfElements[i]->update(arrayOfElements); 426 } */ 427 428 //testing AIPilot -> function steer 429 // AIPilot temp; 430 // Vector3 foo = temp.steer(Vector3(0,0,1)); 415 416 // END TEST DATA FLOCKING 431 417 432 418
Note: See TracChangeset
for help on using the changeset viewer.