[Orxonox-commit 181] r2856 - branches/map/src/orxonox/overlays/map
Naaduun at orxonox.net
Naaduun at orxonox.net
Thu Mar 26 17:06:25 CET 2009
Author: Naaduun
Date: 2009-03-26 16:06:25 +0000 (Thu, 26 Mar 2009)
New Revision: 2856
Modified:
branches/map/src/orxonox/overlays/map/Map.cc
branches/map/src/orxonox/overlays/map/Map.h
Log:
implemented Map::openMap()
Modified: branches/map/src/orxonox/overlays/map/Map.cc
===================================================================
--- branches/map/src/orxonox/overlays/map/Map.cc 2009-03-26 15:39:31 UTC (rev 2855)
+++ branches/map/src/orxonox/overlays/map/Map.cc 2009-03-26 16:06:25 UTC (rev 2856)
@@ -27,6 +27,9 @@
#include "Map.h"
#include <string>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
#include <OgreOverlay.h>
#include <OgreOverlayElement.h>
#include <OgreOverlayManager.h>
@@ -45,25 +48,62 @@
{
RegisterObject(Map);
- //COUT(0) << "Map loaded\n" << this->getScene();
- Ogre::SceneManager* sm = this->getScene()->getSceneManager();
- Ogre::SceneNode* sn = new Ogre::SceneNode(sm);
- COUT(0) << "Map loaded\n" << sm << " / " << sn << std::endl;
+ //Getting Scene Manager (Hack)
+ ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
+ this->sManager_ = it->getSceneManager();
+
+ this->sNode_ = new Ogre::SceneNode(sManager_);
+ oManager_ = Ogre::OverlayManager::getSingletonPtr();
+ overlay_ = oManager_->create("Map");
+ //overlay_ is member of OrxonoxOverlay
+
+ //Not Showing the map as default
+ this->isVisible_=false;
+ overlay_->hide();
+
+ //TestEntity
+ Ogre::Entity * ent = sManager_->createEntity("ent", "drone.mesh");
+ sNode_->attachObject( ent );
+ sNode_->setPosition(0,0,-50);
+ overlay_->add3D(sNode_);
}
void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
{
SUPER(Map, XMLPort, xmlElement, mode);
}
+
+ void Map::toggleVisibility()
+ {
+ if (!(this->isVisible_))
+ {
+ this->overlay_->show();
+ this->isVisible_=1;
+ }
+ else
+ {
+ this->overlay_->hide();
+ this->isVisible_=0;
+ }
+ }
- void Map::changedVisibility()
+ //Static function to toggle visibility of the map
+ void Map::openMap()
{
- SUPER(Map, changedVisibility);
-
+ for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
+ it!=ObjectList<orxonox::Map>::end();
+ it++)
+ {
+ //Map * m = it->getMap();
+ COUT(0) << it->isVisible_ << std::endl;
+ it->toggleVisibility();
+ }
}
void Map::tick(float dt)
{
+ sNode_->lookAt(Vector3::NEGATIVE_UNIT_Z, Ogre::Node::TS_WORLD, Vector3::NEGATIVE_UNIT_Z);
+
}
}
Modified: branches/map/src/orxonox/overlays/map/Map.h
===================================================================
--- branches/map/src/orxonox/overlays/map/Map.h 2009-03-26 15:39:31 UTC (rev 2855)
+++ branches/map/src/orxonox/overlays/map/Map.h 2009-03-26 16:06:25 UTC (rev 2856)
@@ -30,6 +30,13 @@
#include "OrxonoxPrereqs.h"
#include <OgrePrerequisites.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
#include <OgreBorderPanelOverlayElement.h>
#include <OgreTextAreaOverlayElement.h>
@@ -50,19 +57,20 @@
virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
virtual void tick(float dt);
- virtual void changedVisibility();
- inline static void openMap()
- {
- COUT(0) << "Opening Map";
- }
+ static void openMap();
+
private: // functions
+ void toggleVisibility();
private: // variables
-
-
+ Ogre::SceneManager* sManager_;
+ Ogre::SceneNode* sNode_;
+ Ogre::OverlayManager * oManager_;
+
+ bool isVisible_;
};
}
More information about the Orxonox-commit
mailing list