Changeset 6033 for code/branches/steering/src/orxonox
- Timestamp:
- Nov 4, 2009, 5:47:31 PM (15 years ago)
- Location:
- code/branches/steering/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/steering/src/orxonox/controllers/HumanController.cc
r5993 r6033 143 143 } 144 144 145 void HumanController:: fire(unsigned int firemode)145 void HumanController::doFire(unsigned int firemode) 146 146 { 147 147 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) -
code/branches/steering/src/orxonox/controllers/HumanController.h
r5993 r6033 56 56 virtual void pitch(const Vector2& value); 57 57 58 static void fire(unsigned int firemode); 58 static void fire(unsigned int firemode) { HumanController::localController_s->doFire(firemode); } 59 virtual void doFire(unsigned int firemode); 59 60 static void reload(); 60 61 … … 79 80 friend class Map; 80 81 81 pr ivate:82 protected: 82 83 static HumanController* localController_s; 83 84 }; -
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 -
code/branches/steering/src/orxonox/controllers/NewHumanController.h
r6001 r6033 34 34 #include "HumanController.h" 35 35 #include "overlays/OrxonoxOverlay.h" 36 #include "util/OgreForwardRefs.h" 36 37 37 38 namespace orxonox … … 48 49 virtual void pitch(const Vector2& value); 49 50 51 virtual void doFire(unsigned int firemode); 52 50 53 private: 51 54 float currentYaw_; 52 55 float currentPitch_; 53 56 OrxonoxOverlay *CrossHairOverlay; 57 float overlaySize; 54 58 }; 55 59 } -
code/branches/steering/src/orxonox/graphics/Camera.h
r5781 r6033 52 52 void releaseFocus(); 53 53 54 inline Ogre::Camera* getCamera() 55 { return this->camera_; } 56 54 57 inline bool hasFocus() 55 58 { return this->bHasFocus_; }
Note: See TracChangeset
for help on using the changeset viewer.