- Timestamp:
- Nov 4, 2009, 5:47:31 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/steering/src/orxonox/controllers/NewHumanController.cc
r6001 r6033 29 29 #include "NewHumanController.h" 30 30 31 #include "core/input/InputManager.h" 32 #include "core/input/InputState.h" 31 #include <OgreRay.h> 32 #include <OgreSceneQuery.h> 33 #include <OgreCamera.h> 34 #include <OgreSceneManager.h> 33 35 34 36 #include "core/CoreIncludes.h" … … 53 55 RegisterObject(NewHumanController); 54 56 57 overlaySize = 0.08; 58 55 59 CrossHairOverlay = new OrxonoxOverlay(this); 56 60 CrossHairOverlay->setBackgroundMaterial("Orxonox/Crosshair3"); 57 CrossHairOverlay->setSize(Vector2( 0.08,0.08));61 CrossHairOverlay->setSize(Vector2(overlaySize,overlaySize)); 58 62 CrossHairOverlay->show(); 59 63 } … … 67 71 68 72 void NewHumanController::tick(float dt) { 69 CrossHairOverlay->setPosition(Vector2(static_cast<float>(this->currentYaw_) , static_cast<float>(this->currentPitch_)));73 CrossHairOverlay->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize/2)); 70 74 71 75 HumanController::tick(dt); … … 88 92 }*/ 89 93 94 void NewHumanController::doFire(unsigned int firemode) 95 { 96 //if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) { 97 98 /* 99 100 // Get results, create a node/entity on the position 101 for ( itr = result.begin(); itr != result.end(); itr++ ) 102 { 103 if (itr->movable && itr->movable->getName() == "Head") 104 { 105 soundMgr->StopSound( &jaguarSoundChannel ); 106 soundMgr->PlaySound( jaguarSound, headNode, &jaguarSoundChannel ); 107 break; 108 } // if 109 } 110 */ 111 112 Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray()); 113 114 std::cout << "X: " << static_cast<float>(this->currentYaw_)/2*-1+.5 << " Y: " << static_cast<float>(this->currentPitch_)/2*-1+.5 << endl; 115 116 Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5, static_cast<float>(this->currentPitch_)/2*-1+.5); 117 118 rsq->setRay(mouseRay); 119 rsq->setSortByDistance(true); 120 121 122 Ogre::RaySceneQueryResult &result = rsq->execute(); 123 124 Ogre::RaySceneQueryResult::iterator itr; 125 for ( itr = result.begin(); itr != result.end(); itr++ ) 126 { 127 std::cout << "distance: " << itr->distance << " name: " << itr->movable->getName() << " type: " << itr->movable->getMovableType() << endl; 128 if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity") { 129 std::cout << " in scene" << endl; 130 itr->movable->getParentSceneNode()->showBoundingBox(true); 131 } 132 } 133 134 //if (result.front().movable->isInScene()) std::cout << "in scene" << endl; 135 // && result.front().movable->getParentSceneNode() != NULL) result.front().movable->getParentSceneNode()->showBoundingBox(true); 136 //result.front().movable->setVisible(false); 137 138 std::cout << endl; 139 /* 140 if (!result.empty()) { 141 Ogre::RaySceneQueryResultEntry obj = result.front(); 142 std::cout << "distance: " << obj.distance << " name: " << obj.movable->getName() << endl; 143 } 144 */ 145 146 147 HumanController::localController_s->getControllableEntity()->fire(firemode); 148 //} 149 //} 150 } 151 90 152 void NewHumanController::yaw(const Vector2& value) 91 153 { … … 94 156 95 157 this->currentYaw_ = value.x; 96 std::cout << "Y: " << static_cast<float>(this->currentPitch_) << " X: " << static_cast<float>(this->currentYaw_) << endl;158 //std::cout << "Y: " << static_cast<float>(this->currentPitch_) << " X: " << static_cast<float>(this->currentYaw_) << endl; 97 159 } 98 160 void NewHumanController::pitch(const Vector2& value) … … 102 164 103 165 this->currentPitch_ = value.x; 104 std::cout << "Y: " << static_cast<float>(this->currentPitch_) << " X: " << static_cast<float>(this->currentYaw_) << endl;166 //std::cout << "Y: " << static_cast<float>(this->currentPitch_) << " X: " << static_cast<float>(this->currentYaw_) << endl; 105 167 } 106 168
Note: See TracChangeset
for help on using the changeset viewer.