Changeset 2913
- Timestamp:
- Apr 9, 2009, 4:52:36 PM (16 years ago)
- Location:
- code/branches/map/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/map/src/orxonox/objects/RadarViewable.cc
r2662 r2913 45 45 , radarObjectShape_(Dot) 46 46 , radarObjectDescription_("staticObject") 47 , MapNode_(NULL) 48 , MapEntity_(NULL) 47 49 { 48 50 RegisterRootObject(RadarViewable); -
code/branches/map/src/orxonox/objects/RadarViewable.h
r2662 r2913 36 36 #include "util/Debug.h" 37 37 #include "core/OrxonoxClass.h" 38 39 #include <OgreSceneNode.h> 40 #include <OgreEntity.h> 38 41 39 42 namespace orxonox … … 80 83 { return this->radarObjectShape_; } 81 84 85 /* 86 inline void setMapNode(Ogre::SceneNode * node) 87 { this->MapNode_ = node; } 88 inline Ogre::SceneNode * getMapNode() const 89 { return this->MapNode_; } 90 inline void setMapEntity(Ogre::Entity * ent) 91 { this->MapEntity_ = ent; } 92 inline Ogre::Entity * getMapEntity() const 93 { return this->MapEntity_; } 94 */ 95 //Used for Map 96 Ogre::SceneNode * MapNode_; 97 Ogre::Entity * MapEntity_; 98 82 99 private: 83 100 void validate(const WorldEntity* object) const … … 94 111 std::string radarObjectDescription_; 95 112 ColourValue radarObjectColour_; 113 96 114 }; 97 115 } -
code/branches/map/src/orxonox/objects/worldentities/CameraPosition.cc
r2662 r2913 30 30 #include "CameraPosition.h" 31 31 32 #include <OgreCamera.h> 33 32 34 #include "core/CoreIncludes.h" 33 35 #include "core/XMLPort.h" … … 44 46 this->bDrag_ = false; 45 47 this->bAllowMouseLook_ = false; 48 this->bRenderCamera_ = false; 46 49 47 50 this->setObjectMode(0x0); … … 58 61 XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false); 59 62 XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false); 63 XMLPortParam(CameraPosition, "rendercamera", setRenderCamera, getRenderCamera, xmlelement, mode).defaultValues(false); 60 64 } 61 65 … … 70 74 camera->setDrag(true); 71 75 } 76 77 void CameraPosition::attachCamera(Ogre::Camera* camera) 78 { 79 this->attachOgreObject(camera); 80 } 72 81 } -
code/branches/map/src/orxonox/objects/worldentities/CameraPosition.h
r2662 r2913 54 54 { return this->bAllowMouseLook_; } 55 55 56 inline void setRenderCamera(bool bRenderCamera) 57 { this->bRenderCamera_ = bRenderCamera; } 58 inline bool getRenderCamera() const 59 { return this->bRenderCamera_; } 60 56 61 void attachCamera(Camera* camera); 62 void attachCamera(Ogre::Camera* camera); 57 63 58 64 private: 59 65 bool bDrag_; 60 66 bool bAllowMouseLook_; 67 bool bRenderCamera_; 61 68 }; 62 69 } -
code/branches/map/src/orxonox/objects/worldentities/ControllableEntity.cc
r2662 r2913 62 62 this->hud_ = 0; 63 63 this->camera_ = 0; 64 this->reverseCamera_ = 0; 64 65 this->bDestroyWhenPlayerLeft_ = false; 65 66 this->cameraPositionRootNode_ = this->node_->createChildSceneNode(); … … 148 149 else 149 150 this->attach(position); 150 this->cameraPositions_.push_back(position); 151 152 if (!position->getRenderCamera()) 153 this->cameraPositions_.push_back(position); 154 else 155 this->setReverseCamera(position); 151 156 } 152 157 -
code/branches/map/src/orxonox/objects/worldentities/ControllableEntity.h
r2662 r2913 109 109 inline const std::string& getCameraPositionTemkplate() const 110 110 { return this->cameraPositionTemplate_; } 111 112 inline void setReverseCamera(CameraPosition* camera) 113 { this->reverseCamera_ = camera; } 114 inline CameraPosition* getReverseCamera() const 115 { return this->reverseCamera_; } 111 116 112 117 using WorldEntity::setPosition; … … 188 193 std::list<CameraPosition*> cameraPositions_; 189 194 std::string cameraPositionTemplate_; 195 CameraPosition* reverseCamera_; 190 196 191 197 const GametypeInfo* gtinfo_; -
code/branches/map/src/orxonox/overlays/map/Map.cc
r2856 r2913 31 31 #include <OgreSceneNode.h> 32 32 #include <OgreEntity.h> 33 #include <OgreNode.h> 34 35 #include <OgreRenderWindow.h> 36 #include <OgreRenderTexture.h> 37 #include <OgreTexture.h> 38 #include <OgreViewport.h> 39 #include <OgreMaterial.h> 40 #include <OgreMaterialManager.h> 41 #include <OgreRoot.h> 42 #include <OgreHardwarePixelBuffer.h> 43 #include "objects/worldentities/ControllableEntity.h" 44 #include "objects/worldentities/CameraPosition.h" 45 33 46 #include <OgreOverlay.h> 34 47 #include <OgreOverlayElement.h> … … 39 52 #include "core/ConsoleCommand.h" 40 53 #include "objects/Scene.h" 54 #include "objects/RadarViewable.h" 41 55 42 56 namespace orxonox … … 52 66 ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); 53 67 this->sManager_ = it->getSceneManager(); 54 55 this->sNode_ = new Ogre::SceneNode(sManager_); 56 oManager_ = Ogre::OverlayManager::getSingletonPtr(); 57 overlay_ = oManager_->create("Map"); 68 69 this->mapSceneM_ = Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ); 70 rootNode_ = mapSceneM_->getRootSceneNode(); 71 72 //this->sNode_ = new Ogre::SceneNode(sManager_); 73 //oManager_ = Ogre::OverlayManager::getSingletonPtr(); 74 //overlay_ = oManager_->create("Map"); 58 75 //overlay_ is member of OrxonoxOverlay 59 76 77 //Not Showing the map as default 78 //this->isVisible_=false; 79 //overlay_->hide(); 80 81 82 //TestEntity 83 //Ogre::Entity * ent = mapSceneM_->createEntity("ent", "drone.mesh"); 84 85 //rootNode_->attachObject( ent ); 86 /*sNode_->setPosition(0,0,-50); 87 overlay_->add3D(sNode_); 88 */ 89 90 91 92 93 94 // Alter the camera aspect ratio to match the viewport 95 //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight())); 96 mReflectCam_ = mapSceneM_->createCamera("ReflectCam"); 97 mReflectCam_->setPosition(200,170, -160); 98 mReflectCam_->lookAt(0,0,0); 99 mReflectCam_->setAspectRatio(1); 100 101 std::string camMat_id = "RttMat"; 102 Ogre::MaterialPtr material = this->createRenderCamera(mReflectCam_, camMat_id); 103 /* 104 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); 105 106 Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget(); 107 108 renderTexture->addViewport(mReflectCam_); 109 renderTexture->getViewport(0)->setClearEveryFrame(true); 110 renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black); 111 renderTexture->getViewport(0)->setOverlaysEnabled(false); 112 113 Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 114 Ogre::Technique *technique = material->createTechnique(); 115 technique->createPass(); 116 material->getTechnique(0)->getPass(0)->setLightingEnabled(false); 117 material->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex"); 118 */ 119 120 121 // create overlay 122 /* 123 Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1"); 124 125 // Create a panel with RenderToTexture texture 126 Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d")); 127 m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS); 128 m_pOverlayPanel->setPosition(10, 10); 129 m_pOverlayPanel->setDimensions(500, 300); 130 // Give overlay a texture 131 m_pOverlayPanel->setMaterialName(camMat_id); 132 pOverlay->add2D(m_pOverlayPanel); 133 pOverlay->show(); 134 */ 135 overlay_ = Ogre::OverlayManager::getSingleton().create("MapOverlay"); 136 Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d")); 137 m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS); 138 m_pOverlayPanel->setPosition(10, 10); 139 m_pOverlayPanel->setDimensions(500, 300); 140 // Give overlay a texture 141 m_pOverlayPanel->setMaterialName(camMat_id); 142 overlay_->add2D(m_pOverlayPanel); 60 143 //Not Showing the map as default 61 144 this->isVisible_=false; 62 145 overlay_->hide(); 63 64 //TestEntity 65 Ogre::Entity * ent = sManager_->createEntity("ent", "drone.mesh"); 66 sNode_->attachObject( ent ); 67 sNode_->setPosition(0,0,-50); 68 overlay_->add3D(sNode_); 69 } 70 146 147 } 148 149 Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, std::string matName) 150 { 151 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); 152 153 Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget(); 154 155 renderTexture->addViewport(cam); 156 renderTexture->getViewport(0)->setClearEveryFrame(true); 157 renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black); 158 renderTexture->getViewport(0)->setOverlaysEnabled(false); 159 160 Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 161 Ogre::Technique *technique = material->createTechnique(); 162 technique->createPass(); 163 material->getTechnique(0)->getPass(0)->setLightingEnabled(false); 164 material->getTechnique(0)->getPass(0)->createTextureUnitState(matName+"_tex"); 165 return material; 166 } 167 168 void Map::updatePositions() 169 { 170 //Ogre::Entity * ent;// = mapSceneM_->createEntity("ent1", "drone.mesh"); 171 int i=0; 172 for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin(); 173 it!=ObjectList<orxonox::RadarViewable>::end(); 174 it++) 175 { 176 i++; 177 //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl; 178 //Ogre::SceneNode node = it->getMapNode(); 179 //Ogre::Entity ent = it->getMapEntity(); 180 if( !(it->MapNode_) ) 181 { 182 it->MapNode_ = rootNode_->createChildSceneNode( it->getRVWorldPosition() ); 183 //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD ); 184 } 185 it->MapNode_->setPosition( it->getRVWorldPosition() ); 186 it->MapNode_->translate( it->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 ); 187 if( !(it->MapEntity_) ) 188 { 189 it->MapEntity_ = mapSceneM_->createEntity( "MapEnt"+i, "drone.mesh"); 190 it->MapNode_->attachObject( it->MapEntity_ ); 191 } 192 193 194 195 } 196 } 197 71 198 void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode) 72 199 { 73 200 SUPER(Map, XMLPort, xmlElement, mode); 74 } 201 } 202 203 void Map::changedOwner() 204 { 205 //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl; 206 if(this->getOwner()->getReverseCamera()) 207 { 208 //COUT(0) << "foo"; 209 this->getOwner()->getReverseCamera()->attachCamera(this->mReflectCam_); 210 } 211 } 212 75 213 76 214 void Map::toggleVisibility() … … 80 218 this->overlay_->show(); 81 219 this->isVisible_=1; 220 //updatePositions(); 82 221 } 83 222 else … … 98 237 COUT(0) << it->isVisible_ << std::endl; 99 238 it->toggleVisibility(); 239 //it->updatePositions(); 100 240 } 101 241 } … … 103 243 void Map::tick(float dt) 104 244 { 105 sNode_->lookAt(Vector3::NEGATIVE_UNIT_Z, Ogre::Node::TS_WORLD, Vector3::NEGATIVE_UNIT_Z); 245 //sNode_->lookAt(Vector3::NEGATIVE_UNIT_Z, Ogre::Node::TS_WORLD, Vector3::NEGATIVE_UNIT_Z); 246 updatePositions(); 106 247 107 248 } -
code/branches/map/src/orxonox/overlays/map/Map.h
r2856 r2913 28 28 #define _MAP_H__ 29 29 30 30 #include <string> 31 31 #include "OrxonoxPrereqs.h" 32 32 #include <OgrePrerequisites.h> … … 46 46 47 47 48 48 49 namespace orxonox 49 50 { … … 57 58 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 58 59 virtual void tick(float dt); 60 virtual void changedOwner(); 59 61 60 62 static Ogre::MaterialPtr createRenderCamera(Ogre::Camera * cam, std::string matName); 61 63 62 64 static void openMap(); 65 66 static const int maxRange_s=1000; 63 67 64 68 private: // functions 65 69 void toggleVisibility(); 70 void updatePositions(); 66 71 67 72 68 73 private: // variables 69 74 Ogre::SceneManager* sManager_; 70 Ogre::SceneNode* sNode_; 75 Ogre::SceneManager* mapSceneM_; 76 Ogre::SceneNode* rootNode_; 71 77 Ogre::OverlayManager * oManager_; 78 Ogre::Camera* mReflectCam_; 79 80 72 81 73 82 bool isVisible_;
Note: See TracChangeset
for help on using the changeset viewer.