Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 28, 2009, 2:41:15 AM (15 years ago)
Author:
landauf
Message:

merged revision 3090 from map branch back to trunk

Location:
code/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/overlays/map/Map.cc

    r3089 r3101  
    6969    Map* Map::singletonMap_s = 0;
    7070    Ogre::SceneManager* Map::mapSceneM_s = 0;
     71    Ogre::Camera* Map::Cam_ = 0;
     72    Ogre::SceneNode* Map::CamNode_ = 0;
     73    Ogre::MaterialPtr Map::OverlayMaterial_;// = init();
     74    Ogre::Overlay* Map::overlay_ = 0;
     75/*
     76Ogre::MaterialPtr Map::init()
     77{
     78    Ogre::MaterialPtr tmp;
     79    tmp.setNull();
     80    return tmp;
     81}
     82*/
     83
    7184    //int Map::mouseLookSpeed_ = 200;
    7285    //Ogre::SceneNode* Map::playerShipNode_ = 0;
     
    116129        // Alter the camera aspect ratio to match the viewport
    117130        //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
    118         Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
     131        if(!Map::Cam_)
     132            Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
    119133        //Cam_->setPosition(200,170, -160);
    120134        //Cam_->lookAt(0,0,0);
    121135        Cam_->setAspectRatio(1);
    122136        //Cam_->setRenderingDistance(0);
    123         CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
     137        if(!Map::CamNode_)
     138            CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
    124139
    125140
    126141        //Create overlay material
    127         std::string camMat_id = "RttMat";
    128         Ogre::MaterialPtr material = this->createRenderCamera(Cam_, camMat_id);
     142        if(Map::OverlayMaterial_.isNull())
     143            Map::OverlayMaterial_ = this->createRenderCamera(Cam_, "RttMat");
    129144/*
    130145        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);
     
    159174        pOverlay->show();
    160175*/
    161         this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay");
    162         Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
    163         m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
    164         m_pOverlayPanel->setPosition(10, 10);
    165         m_pOverlayPanel->setDimensions(600, 400);
    166         // Give overlay a texture
    167         m_pOverlayPanel->setMaterialName(camMat_id);
    168         overlay_->add2D(m_pOverlayPanel);
    169 
    170         //Add Borders
    171 //        Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
    172 /*
    173 //TODO border size
    174         oBorder->setBorderSize( 0.003, 16 * 0.003 );
    175         oBorder->setBorderMaterialName("StatsBorder");
    176         oBorder->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
    177         oBorder->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
    178         oBorder->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
    179         oBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
    180         oBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
    181         oBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
    182         oBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
    183         oBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
    184         overlay_->add2D(oBorder);
    185 */
     176        if(!this->overlay_)
     177        {
     178            this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay");
     179            Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
     180            //m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
     181            //m_pOverlayPanel->setPosition(10, 10);
     182            //m_pOverlayPanel->setDimensions(600, 400);
     183            m_pOverlayPanel->setPosition(0.01, 0.003);
     184            m_pOverlayPanel->setDimensions(0.5, 0.4);
     185            // Give overlay a texture
     186            m_pOverlayPanel->setMaterialName("RttMat");
     187            overlay_->add2D(m_pOverlayPanel);
     188
     189            //Add Borders
     190            Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
     191            oBorder->setBorderSize( 0.003, 0.003 );
     192            oBorder->setDimensions(0.5, 0.4);
     193            oBorder->setBorderMaterialName("StatsBorder");
     194            oBorder->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
     195            oBorder->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
     196            oBorder->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
     197            oBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
     198            oBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
     199            oBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
     200            oBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
     201            oBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
     202            //overlay_->add2D(oBorder);
     203            m_pOverlayPanel->addChild(oBorder);
     204        }
     205
    186206
    187207        //Not Showing the map as default
     
    189209        overlay_->hide();
    190210
    191         //Create plane to show grid
    192         Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
    193         planeNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
     211        //Create plane to show gridTypeError: blimport() takes no keyword arguments
     212/*        Ogre::Entity* plane_ent;
     213        if(Map::getMapSceneManager()->hasEntity("MapPlane"))
     214            plane_ent = Map::getMapSceneManager()->getEntity("MapPlane");
     215        else
     216            plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
     217*/
     218        this->movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 );
     219        this->movablePlane_->normalise();
     220
     221        if(!Map::getMapSceneManager()->hasEntity("MapPlane"))
     222        {
     223            Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
     224            planeNode_ = Map::getMapSceneManager()->createSceneNode();
    194225        //Create plane for calculations
    195         movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 );
    196         movablePlane_->normalise();
     226
    197227
    198228        //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
    199229        //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga");
    200230        //plane_ent->setMaterialName("mapgrid");
    201         plane_ent->setMaterialName("Map/Grid");
    202         planeNode_->attachObject(plane_ent);
    203 
    204         planeNode_->scale(10,1,10);
     231            plane_ent->setMaterialName("Map/Grid");
     232            planeNode_->attachObject(plane_ent);
     233
     234            planeNode_->scale(160,1,160);
    205235//        planeNode_->attachObject(movablePlane_);
    206236        //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
     
    208238
    209239        //ToDo create material script
    210         Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
    211         myManualObjectMaterial->setReceiveShadows(false);
    212         myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
    213         myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
    214         myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
    215         myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
    216 
     240            Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
     241            myManualObjectMaterial->setReceiveShadows(false);
     242            myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
     243            myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
     244            myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
     245            myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
     246        }
    217247    }
    218248
     
    220250    {
    221251        this->singletonMap_s = 0;
     252        //delete this->overlay_;
    222253        /*if (this->isInitialized())
    223254        {
     
    286317                {
    287318                    this->playerShipNode_ = it->MapNode_;
    288                     this->planeNode_->getParent()->removeChild(this->planeNode_);
     319                    if(planeNode_ && this->planeNode_->getParent())
     320                        this->planeNode_->getParent()->removeChild(this->planeNode_);
    289321                    this->playerShipNode_->addChild(this->planeNode_);
    290322                //Movable Plane needs to be attached direcly for calculations
     
    293325                //this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
    294326                //it->MapNode_->attachObject(this->movablePlane_);
    295 
    296                     this->CamNode_->getParent()->removeChild(this->CamNode_);
     327                    if(planeNode_ && this->CamNode_->getParent())
     328                        this->CamNode_->getParent()->removeChild(this->CamNode_);
    297329                    this->playerShipNode_->addChild(this->CamNode_);
    298330                    this->CamNode_->attachObject(this->Cam_);
  • code/trunk/src/orxonox/overlays/map/Map.h

    r3089 r3101  
    102102            Map::mapSceneM_s = sm;
    103103        }
     104        //static Ogre::MaterialPtr init();
    104105
    105106    private: // variables
     
    110111
    111112        static Ogre::SceneManager* mapSceneM_s;
    112         Ogre::SceneNode* CamNode_;
    113         Ogre::Camera* Cam_;
     113        static Ogre::SceneNode* CamNode_;
     114        static Ogre::Camera* Cam_;
     115        static Ogre::MaterialPtr OverlayMaterial_;
     116        static Ogre::Overlay* overlay_;
    114117        //Ogre::SceneNode* CamNodeHelper_;
    115118        Ogre::SceneNode* playerShipNode_;
Note: See TracChangeset for help on using the changeset viewer.