1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Si Sun |
---|
24 | * |
---|
25 | */ |
---|
26 | #include "Map.h" |
---|
27 | |
---|
28 | #include <string> |
---|
29 | #include "util/String.h" |
---|
30 | #include <OgreSceneManager.h> |
---|
31 | #include <OgreSceneNode.h> |
---|
32 | #include <OgreEntity.h> |
---|
33 | #include <OgreNode.h> |
---|
34 | |
---|
35 | |
---|
36 | #include <OgreRenderWindow.h> |
---|
37 | #include <OgreRenderTexture.h> |
---|
38 | #include <OgreTexture.h> |
---|
39 | #include <OgreViewport.h> |
---|
40 | |
---|
41 | #include <OgreMaterialManager.h> |
---|
42 | #include <OgreRoot.h> |
---|
43 | #include <OgreHardwarePixelBuffer.h> |
---|
44 | #include "objects/worldentities/ControllableEntity.h" |
---|
45 | #include "objects/worldentities/CameraPosition.h" |
---|
46 | |
---|
47 | #include <OgreOverlay.h> |
---|
48 | #include <OgreMovablePlane.h> |
---|
49 | #include <OgreOverlayElement.h> |
---|
50 | #include <OgreOverlayManager.h> |
---|
51 | #include <OgreOverlayContainer.h> |
---|
52 | #include "core/CoreIncludes.h" |
---|
53 | #include "core/ConfigValueIncludes.h" |
---|
54 | #include "core/ConsoleCommand.h" |
---|
55 | #include "objects/Scene.h" |
---|
56 | #include "objects/RadarViewable.h" |
---|
57 | #include "objects/controllers/HumanController.h" |
---|
58 | |
---|
59 | namespace orxonox |
---|
60 | { |
---|
61 | CreateFactory(Map); |
---|
62 | SetConsoleCommand(Map, openMap, true); |
---|
63 | //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand(); |
---|
64 | //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand(); |
---|
65 | SetConsoleCommand(Map, Zoom, true).setAsInputCommand(); |
---|
66 | |
---|
67 | |
---|
68 | Map* Map::singletonMap_s = 0; |
---|
69 | Ogre::SceneManager* Map::mapSceneM_s = 0; |
---|
70 | Ogre::Camera* Map::Cam_ = 0; |
---|
71 | Ogre::SceneNode* Map::CamNode_ = 0; |
---|
72 | Ogre::MaterialPtr Map::OverlayMaterial_;// = init(); |
---|
73 | Ogre::Overlay* Map::overlay_ = 0; |
---|
74 | /* |
---|
75 | Ogre::MaterialPtr Map::init() |
---|
76 | { |
---|
77 | Ogre::MaterialPtr tmp; |
---|
78 | tmp.setNull(); |
---|
79 | return tmp; |
---|
80 | } |
---|
81 | */ |
---|
82 | |
---|
83 | //int Map::mouseLookSpeed_ = 200; |
---|
84 | //Ogre::SceneNode* Map::playerShipNode_ = 0; |
---|
85 | |
---|
86 | const int PITCH=-30; |
---|
87 | const int DISTANCE=200; |
---|
88 | |
---|
89 | Map::Map(BaseObject* creator) : OrxonoxOverlay(creator) |
---|
90 | { |
---|
91 | RegisterObject(Map); |
---|
92 | Map::singletonMap_s=this; |
---|
93 | |
---|
94 | //Getting Scene Manager (Hack) |
---|
95 | if( !sManager_ ) |
---|
96 | { |
---|
97 | ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); |
---|
98 | this->sManager_ = it->getSceneManager(); |
---|
99 | } |
---|
100 | if( !Map::getMapSceneManager() ) |
---|
101 | { |
---|
102 | Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) ); |
---|
103 | } |
---|
104 | |
---|
105 | this->playerShipNode_ = 0; |
---|
106 | //this->sNode_ = new Ogre::SceneNode(sManager_); |
---|
107 | //oManager_ = Ogre::OverlayManager::getSingletonPtr(); |
---|
108 | //overlay_ = oManager_->create("Map"); |
---|
109 | //overlay_ is member of OrxonoxOverlay |
---|
110 | |
---|
111 | //Not Showing the map as default |
---|
112 | //this->isVisible_=false; |
---|
113 | //overlay_->hide(); |
---|
114 | this->mouseLookSpeed_ = 200; |
---|
115 | |
---|
116 | //TestEntity |
---|
117 | //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh"); |
---|
118 | |
---|
119 | //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent ); |
---|
120 | /*sNode_->setPosition(0,0,-50); |
---|
121 | overlay_->add3D(sNode_); |
---|
122 | */ |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | // Alter the camera aspect ratio to match the viewport |
---|
129 | //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight())); |
---|
130 | if(!Map::Cam_) |
---|
131 | Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam"); |
---|
132 | //Cam_->setPosition(200,170, -160); |
---|
133 | //Cam_->lookAt(0,0,0); |
---|
134 | Cam_->setAspectRatio(1); |
---|
135 | //Cam_->setRenderingDistance(0); |
---|
136 | if(!Map::CamNode_) |
---|
137 | CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode(); |
---|
138 | |
---|
139 | |
---|
140 | //Create overlay material |
---|
141 | if(Map::OverlayMaterial_.isNull()) |
---|
142 | Map::OverlayMaterial_ = this->createRenderCamera(Cam_, "RttMat"); |
---|
143 | /* |
---|
144 | Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET); |
---|
145 | |
---|
146 | Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget(); |
---|
147 | |
---|
148 | renderTexture->addViewport(Cam_); |
---|
149 | renderTexture->getViewport(0)->setClearEveryFrame(true); |
---|
150 | renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black); |
---|
151 | renderTexture->getViewport(0)->setOverlaysEnabled(false); |
---|
152 | |
---|
153 | Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); |
---|
154 | Ogre::Technique *technique = material->createTechnique(); |
---|
155 | technique->createPass(); |
---|
156 | material->getTechnique(0)->getPass(0)->setLightingEnabled(false); |
---|
157 | material->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex"); |
---|
158 | */ |
---|
159 | |
---|
160 | |
---|
161 | // create overlay |
---|
162 | /* |
---|
163 | Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1"); |
---|
164 | |
---|
165 | // Create a panel with RenderToTexture texture |
---|
166 | Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d")); |
---|
167 | m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS); |
---|
168 | m_pOverlayPanel->setPosition(10, 10); |
---|
169 | m_pOverlayPanel->setDimensions(500, 300); |
---|
170 | // Give overlay a texture |
---|
171 | m_pOverlayPanel->setMaterialName(camMat_id); |
---|
172 | pOverlay->add2D(m_pOverlayPanel); |
---|
173 | pOverlay->show(); |
---|
174 | */ |
---|
175 | if(!this->overlay_) |
---|
176 | { |
---|
177 | this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay"); |
---|
178 | Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d")); |
---|
179 | //m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS); |
---|
180 | //m_pOverlayPanel->setPosition(10, 10); |
---|
181 | //m_pOverlayPanel->setDimensions(600, 400); |
---|
182 | m_pOverlayPanel->setPosition(0.01, 0.003); |
---|
183 | m_pOverlayPanel->setDimensions(0.5, 0.4); |
---|
184 | // Give overlay a texture |
---|
185 | m_pOverlayPanel->setMaterialName("RttMat"); |
---|
186 | overlay_->add2D(m_pOverlayPanel); |
---|
187 | |
---|
188 | //Add Borders |
---|
189 | Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString())); |
---|
190 | oBorder->setBorderSize( 0.003, 0.003 ); |
---|
191 | oBorder->setDimensions(0.5, 0.4); |
---|
192 | oBorder->setBorderMaterialName("StatsBorder"); |
---|
193 | oBorder->setTopBorderUV(0.49, 0.0, 0.51, 0.5); |
---|
194 | oBorder->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5); |
---|
195 | oBorder->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5); |
---|
196 | oBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51); |
---|
197 | oBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5); |
---|
198 | oBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0); |
---|
199 | oBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0); |
---|
200 | oBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0); |
---|
201 | //overlay_->add2D(oBorder); |
---|
202 | m_pOverlayPanel->addChild(oBorder); |
---|
203 | } |
---|
204 | |
---|
205 | |
---|
206 | //Not Showing the map as default |
---|
207 | this->isVisible_=false; |
---|
208 | overlay_->hide(); |
---|
209 | |
---|
210 | //Create plane to show gridTypeError: blimport() takes no keyword arguments |
---|
211 | /* Ogre::Entity* plane_ent; |
---|
212 | if(Map::getMapSceneManager()->hasEntity("MapPlane")) |
---|
213 | plane_ent = Map::getMapSceneManager()->getEntity("MapPlane"); |
---|
214 | else |
---|
215 | plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh"); |
---|
216 | */ |
---|
217 | this->movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 ); |
---|
218 | this->movablePlane_->normalise(); |
---|
219 | |
---|
220 | if(!Map::getMapSceneManager()->hasEntity("MapPlane")) |
---|
221 | { |
---|
222 | Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh"); |
---|
223 | planeNode_ = Map::getMapSceneManager()->createSceneNode(); |
---|
224 | //Create plane for calculations |
---|
225 | |
---|
226 | |
---|
227 | //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General"); |
---|
228 | //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga"); |
---|
229 | //plane_ent->setMaterialName("mapgrid"); |
---|
230 | plane_ent->setMaterialName("Map/Grid"); |
---|
231 | planeNode_->attachObject(plane_ent); |
---|
232 | |
---|
233 | planeNode_->scale(160,1,160); |
---|
234 | // planeNode_->attachObject(movablePlane_); |
---|
235 | //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock"); |
---|
236 | |
---|
237 | |
---|
238 | //ToDo create material script |
---|
239 | Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General"); |
---|
240 | myManualObjectMaterial->setReceiveShadows(false); |
---|
241 | myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true); |
---|
242 | myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0); |
---|
243 | myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0); |
---|
244 | myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0); |
---|
245 | } |
---|
246 | } |
---|
247 | |
---|
248 | Map::~Map() |
---|
249 | { |
---|
250 | this->singletonMap_s = 0; |
---|
251 | //delete this->overlay_; |
---|
252 | /*if (this->isInitialized()) |
---|
253 | { |
---|
254 | //delete sManager_; |
---|
255 | //delete Map::getMapSceneManager()->getRootSceneNode(); |
---|
256 | //delete oManager_; |
---|
257 | //delete CamNode_; |
---|
258 | //delete Cam_; |
---|
259 | //delete mapSceneM_s; |
---|
260 | //Map::getMapSceneManager()->destroyAllEntities(); |
---|
261 | //Map::getMapSceneManager()->destroyAllCameras(); |
---|
262 | delete Map::getMapSceneManager(); |
---|
263 | }*/ |
---|
264 | } |
---|
265 | |
---|
266 | Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, std::string matName) |
---|
267 | { |
---|
268 | Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(matName+"_tex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET); |
---|
269 | |
---|
270 | Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget(); |
---|
271 | |
---|
272 | renderTexture->addViewport(cam); |
---|
273 | renderTexture->getViewport(0)->setClearEveryFrame(true); |
---|
274 | renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black); |
---|
275 | renderTexture->getViewport(0)->setOverlaysEnabled(false); |
---|
276 | |
---|
277 | Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); |
---|
278 | Ogre::Technique *technique = material->createTechnique(); |
---|
279 | technique->createPass(); |
---|
280 | material->getTechnique(0)->getPass(0)->setLightingEnabled(false); |
---|
281 | material->getTechnique(0)->getPass(0)->createTextureUnitState(matName+"_tex"); |
---|
282 | return material; |
---|
283 | } |
---|
284 | |
---|
285 | void Map::updatePositions() |
---|
286 | { |
---|
287 | |
---|
288 | //Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh"); |
---|
289 | for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin(); |
---|
290 | it!=ObjectList<orxonox::RadarViewable>::end(); |
---|
291 | it++) |
---|
292 | { |
---|
293 | //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl; |
---|
294 | //Ogre::SceneNode node = it->getMapNode(); |
---|
295 | //Ogre::Entity ent = it->getMapEntity(); |
---|
296 | if( !(it->MapNode_) ) |
---|
297 | { |
---|
298 | it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() ); |
---|
299 | //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD ); |
---|
300 | /*if(it->getRadarObjectShape() == RadarViewable::Dot) |
---|
301 | { |
---|
302 | //if( !(it->MapEntity_) )//check wether the entity is already attached |
---|
303 | //{ |
---|
304 | //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh"); |
---|
305 | //it->addEntity(); |
---|
306 | //it->MapNode_->attachObject( it->MapEntity_ ); |
---|
307 | //it->MapNode_->attachObject( it->line_ ); |
---|
308 | // } |
---|
309 | }*/ |
---|
310 | it->addMapEntity(); |
---|
311 | } |
---|
312 | if(it->isHumanShip_) |
---|
313 | { |
---|
314 | this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition()); |
---|
315 | if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_) |
---|
316 | { |
---|
317 | this->playerShipNode_ = it->MapNode_; |
---|
318 | if(planeNode_ && this->planeNode_->getParent()) |
---|
319 | this->planeNode_->getParent()->removeChild(this->planeNode_); |
---|
320 | this->playerShipNode_->addChild(this->planeNode_); |
---|
321 | //Movable Plane needs to be attached direcly for calculations |
---|
322 | //this->movablePlane_->detatchFromParent(); |
---|
323 | //this->movablePlane_->getParentSceneNode()->detachObject(this->movablePlane_); |
---|
324 | //this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition()); |
---|
325 | //it->MapNode_->attachObject(this->movablePlane_); |
---|
326 | if(planeNode_ && this->CamNode_->getParent()) |
---|
327 | this->CamNode_->getParent()->removeChild(this->CamNode_); |
---|
328 | this->playerShipNode_->addChild(this->CamNode_); |
---|
329 | this->CamNode_->attachObject(this->Cam_); |
---|
330 | //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode(); |
---|
331 | //this->CamNodeHelper_->attachObject(this->Cam_); |
---|
332 | this->Cam_->setPosition(0, 0, DISTANCE); |
---|
333 | this->Cam_->pitch( (Degree)PITCH ); |
---|
334 | this->Cam_->lookAt(Vector3(0,0,0)); |
---|
335 | //this->Cam_->setAutoTracking(true, this->playerShipNode_); |
---|
336 | } |
---|
337 | } |
---|
338 | it->updateMapPosition(); |
---|
339 | |
---|
340 | |
---|
341 | |
---|
342 | |
---|
343 | |
---|
344 | |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | |
---|
349 | |
---|
350 | void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode) |
---|
351 | { |
---|
352 | SUPER(Map, XMLPort, xmlElement, mode); |
---|
353 | } |
---|
354 | |
---|
355 | void Map::changedOwner() |
---|
356 | { |
---|
357 | SUPER(Map, changedOwner); |
---|
358 | //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl; |
---|
359 | |
---|
360 | ControllableEntity* entity = dynamic_cast<ControllableEntity*>(this->getOwner()); |
---|
361 | if(entity && entity->getReverseCamera()) |
---|
362 | { |
---|
363 | //COUT(0) << "foo"; |
---|
364 | entity->getReverseCamera()->attachCamera(this->Cam_); |
---|
365 | } |
---|
366 | } |
---|
367 | |
---|
368 | |
---|
369 | void Map::toggleVisibility() |
---|
370 | { |
---|
371 | if (!(this->isVisible_)) |
---|
372 | { |
---|
373 | this->overlay_->show(); |
---|
374 | this->isVisible_=1; |
---|
375 | //set mouselook when showing map |
---|
376 | if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook()) |
---|
377 | HumanController::localController_s->controllableEntity_->mouseLook(); |
---|
378 | } |
---|
379 | else |
---|
380 | { |
---|
381 | this->overlay_->hide(); |
---|
382 | this->isVisible_=0; |
---|
383 | if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook()) |
---|
384 | HumanController::localController_s->controllableEntity_->mouseLook(); |
---|
385 | } |
---|
386 | } |
---|
387 | |
---|
388 | //Static function to toggle visibility of the map |
---|
389 | void Map::openMap() |
---|
390 | { |
---|
391 | for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin(); |
---|
392 | it!=ObjectList<orxonox::Map>::end(); |
---|
393 | it++) |
---|
394 | { |
---|
395 | //Map * m = it->getMap(); |
---|
396 | //COUT(0) << it->isVisible_ << std::endl; |
---|
397 | it->toggleVisibility(); |
---|
398 | //it->updatePositions(); |
---|
399 | } |
---|
400 | } |
---|
401 | |
---|
402 | void Map::tick(float dt) |
---|
403 | { |
---|
404 | //Debug |
---|
405 | //COUT(0) << "MovablePlane Position: " << this->movablePlane_->getParentSceneNode()->getName() << this->movablePlane_->getParentSceneNode()->getPosition() << std::endl; |
---|
406 | //COUT(0) << "planeNode_ Position: " << this->planeNode_ ->getName() << this->planeNode_->getPosition() << std::endl; |
---|
407 | //COUT(0) << "planeNode_ Parrent Position" << this->planeNode_->getParent()->getName() << this->planeNode_->getParent()->getPosition() << std::endl; |
---|
408 | if( this->isVisible_ ) |
---|
409 | updatePositions(); |
---|
410 | //Cam_->roll(Degree(1)); |
---|
411 | |
---|
412 | } |
---|
413 | |
---|
414 | void Map::rotateYaw(const Vector2& value) |
---|
415 | { |
---|
416 | if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ )) |
---|
417 | return; |
---|
418 | |
---|
419 | /* |
---|
420 | singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) )); |
---|
421 | |
---|
422 | Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y); |
---|
423 | Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT); |
---|
424 | */ |
---|
425 | singletonMap_s->CamNode_->yaw( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT); |
---|
426 | } |
---|
427 | |
---|
428 | void Map::rotatePitch(const Vector2& value) |
---|
429 | { |
---|
430 | if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ )) |
---|
431 | return; |
---|
432 | //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X)); |
---|
433 | /* singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) )); |
---|
434 | |
---|
435 | Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y); |
---|
436 | Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT); |
---|
437 | */ |
---|
438 | singletonMap_s->CamNode_->pitch( (Degree)(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL); |
---|
439 | |
---|
440 | } |
---|
441 | |
---|
442 | void Map::Zoom(const Vector2& value) |
---|
443 | { |
---|
444 | if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ )) |
---|
445 | return; |
---|
446 | //COUT(0) << value.y << std::endl; |
---|
447 | Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ ); |
---|
448 | } |
---|
449 | } |
---|