Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2956


Ignore:
Timestamp:
May 7, 2009, 4:44:12 PM (15 years ago)
Author:
Naaduun
Message:

added rotate and zoom to map. using static mapscenemanager now

Location:
code/branches/map/src/orxonox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/map/src/orxonox/objects/RadarViewable.cc

    r2942 r2956  
    5252        , MapEntity_(NULL)
    5353        , line_(NULL)
     54        , isHumanShip_(false)
    5455    {
    5556        RegisterRootObject(RadarViewable);
     
    6970    {
    7071        delete MapNode_;
     72        MapNode_=0;
    7173        delete MapEntity_;
     74        MapEntity_=0;
     75        delete line_;
     76        line_=0;
     77        delete LineNode_;
     78        LineNode_=0;
    7279    }
    7380
     
    9198
    9299            this->MapNode_->attachObject( this->MapEntity_ );
    93             this->MapNode_->attachObject( this->line_ );
     100
     101            this->LineNode_ = this->MapNode_->createChildSceneNode();
     102            this->LineNode_->attachObject( this->line_ );
    94103        }
    95104        else
     
    106115            this->MapNode_->translate( this->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 );
    107116            this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() );
    108 Vector3 v = this->getRVWorldPosition();
    109             this->line_->setPoint(1, Vector3(0,v.y,0) );
     117//Vector3 v = this->getRVWorldPosition();
     118            //this->line_->setPoint(1, Vector3(0,v.y,0) );
     119            this->line_->setPoint(1, Vector3(0, -this->getRVWorldPosition().y ,0) );
     120            this->line_->update();
     121            this->LineNode_->setDirection(Vector3::UNIT_Y,Ogre::Node::TS_WORLD,Vector3::UNIT_Y);
    110122        }
    111123    }
  • code/branches/map/src/orxonox/objects/RadarViewable.h

    r2942 r2956  
    101101        Ogre::Entity * MapEntity_;
    102102        DynamicLines* line_;
     103        Ogre::SceneNode * LineNode_;
    103104        void addMapEntity();
    104105        void updateMapPosition();
     106        bool isHumanShip_;
     107        inline std::string getUniqueId()
     108        {
     109            return this->uniqueId_;
     110        }
     111
    105112    private:
    106113        void validate(const WorldEntity* object) const
     
    113120        }
    114121
     122        //Map
     123        std::string uniqueId_;
    115124       
    116         std::string uniqueId_;
    117125
     126        //Radar
    118127        float radarObjectCamouflage_;
    119128        Shape radarObjectShape_;
  • code/branches/map/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2782 r2956  
    7575
    7676        this->registerVariables();
     77
     78        this->isHumanShip_ = this->hasLocalController();
    7779    }
    7880
     
    291293    }
    292294
     295    //Tell the Map (RadarViewable), if this is a playership
     296    void Pawn::startLocalHumanControl()
     297    {
     298//        SUPER(ControllableEntity, changedPlayer());
     299        ControllableEntity::startLocalHumanControl();
     300        this->isHumanShip_ = true;
     301    }
     302
    293303
    294304    ///////////////////
  • code/branches/map/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2662 r2956  
    108108
    109109            virtual void dropItems();
     110           
     111            virtual void startLocalHumanControl();
    110112
    111113        protected:
  • code/branches/map/src/orxonox/overlays/map/Map.cc

    r2942 r2956  
    6161    CreateFactory(Map);
    6262    SetConsoleCommand(Map, openMap, true);
    63     SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
    64     SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
     63    //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
     64    //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
     65    SetConsoleCommand(Map, Zoom, true).setAsInputCommand();
    6566
    6667    Map* Map::singletonMap_s = 0;
    67    
     68    Ogre::SceneManager* Map::mapSceneM_s = 0;
     69    //int Map::mouseLookSpeed_ = 200;
     70    //Ogre::SceneNode* Map::playerShipNode_ = 0;
     71
     72    const int PITCH=-30;
     73    const int DISTANCE=200;
     74
    6875    Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
    6976    {
    7077        RegisterObject(Map);
    7178        Map::singletonMap_s=this;
     79       
    7280        //Getting Scene Manager (Hack)
    73         ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
    74         this->sManager_ = it->getSceneManager();
    75 
    76         this->mapSceneM_ = Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" );
    77         rootNode_ = mapSceneM_->getRootSceneNode();
    78        
     81        if( !sManager_ )
     82        {
     83            ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
     84            this->sManager_ = it->getSceneManager();
     85        }
     86        if( !Map::getMapSceneManager() )
     87        {
     88            Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
     89        }
     90       
     91        this->playerShipNode_ = 0;
    7992        //this->sNode_ = new Ogre::SceneNode(sManager_);
    8093        //oManager_ = Ogre::OverlayManager::getSingletonPtr();
     
    8598        //this->isVisible_=false;
    8699        //overlay_->hide();
    87        
     100        this->mouseLookSpeed_ = 200;
    88101
    89102        //TestEntity
    90         //Ogre::Entity * ent = mapSceneM_->createEntity("ent", "drone.mesh");
    91        
    92         //rootNode_->attachObject( ent );
     103        //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh");
     104       
     105        //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent );
    93106        /*sNode_->setPosition(0,0,-50);
    94107        overlay_->add3D(sNode_);
    95108        */
    96109       
    97         this->mouseLookSpeed_ = 200;
     110       
    98111       
    99112
     
    101114        // Alter the camera aspect ratio to match the viewport
    102115        //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
    103         mReflectCam_ = mapSceneM_->createCamera("ReflectCam");
    104         mReflectCam_->setPosition(200,170, -160);
    105         mReflectCam_->lookAt(0,0,0);
    106         mReflectCam_->setAspectRatio(1);
     116        Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
     117        //Cam_->setPosition(200,170, -160);
     118        //Cam_->lookAt(0,0,0);
     119        Cam_->setAspectRatio(1);
     120        //Cam_->setRenderingDistance(0);
     121        CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
     122       
    107123
    108124        //Create overlay material
    109125        std::string camMat_id = "RttMat";
    110         Ogre::MaterialPtr material = this->createRenderCamera(mReflectCam_, camMat_id);
     126        Ogre::MaterialPtr material = this->createRenderCamera(Cam_, camMat_id);
    111127/*
    112128        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);
     
    114130        Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
    115131
    116         renderTexture->addViewport(mReflectCam_);
     132        renderTexture->addViewport(Cam_);
    117133        renderTexture->getViewport(0)->setClearEveryFrame(true);
    118134        renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
     
    154170
    155171        //Create plane in map
    156         Ogre::Entity* plane_ent = this->mapSceneM_->createEntity( "MapPlane", "plane.mesh");
    157         Ogre::SceneNode* plane_node = this->mapSceneM_->getRootSceneNode()->createChildSceneNode();
     172        Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
     173        planeNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
    158174       
    159175        //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
     
    161177        //plane_ent->setMaterialName("mapgrid");
    162178        plane_ent->setMaterialName("Map/Grid");
    163         plane_node->attachObject(plane_ent);
    164         plane_node->scale(10,1,10);
     179        planeNode_->attachObject(plane_ent);
     180        planeNode_->scale(10,1,10);
    165181        //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
    166182       
     
    178194    Map::~Map()
    179195    {
    180         singletonMap_s = 0;
     196        this->singletonMap_s = 0;
     197        /*if (this->isInitialized())
     198        {
    181199        //delete sManager_;
    182         //delete rootNode_;
     200        //delete Map::getMapSceneManager()->getRootSceneNode();
    183201        //delete oManager_;
    184         //delete mReflectCam_;
    185         //delete mapSceneM_;
     202        //delete CamNode_;
     203        //delete Cam_;
     204        //delete mapSceneM_s;
     205        //Map::getMapSceneManager()->destroyAllEntities();
     206        //Map::getMapSceneManager()->destroyAllCameras();
     207        delete Map::getMapSceneManager();
     208        }*/
    186209    }
    187210
     
    208231    {
    209232
    210 //Ogre::Entity * ent;// = mapSceneM_->createEntity("ent1", "drone.mesh");
     233//Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh");
    211234       for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
    212235            it!=ObjectList<orxonox::RadarViewable>::end();
     
    218241            if( !(it->MapNode_) )
    219242            {
    220                 it->MapNode_ = rootNode_->createChildSceneNode( it->getRVWorldPosition() );
     243                it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() );
    221244                //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD );
    222245                /*if(it->getRadarObjectShape() == RadarViewable::Dot)
     
    224247                    //if( !(it->MapEntity_) )//check wether the entity is already attached
    225248                    //{
    226                         //it->MapEntity_ = this->mapSceneM_->createEntity( getUniqueNumberString(), "drone.mesh");
     249                        //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh");
    227250                        //it->addEntity();
    228251                        //it->MapNode_->attachObject( it->MapEntity_ );
     
    234257
    235258            it->updateMapPosition();
    236 
    237 
    238 
    239259           
    240        
     260
     261
     262            if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_)
     263            {
     264                this->playerShipNode_ = it->MapNode_;
     265                this->planeNode_->getParent()->removeChild(this->planeNode_);
     266                this->playerShipNode_->addChild(this->planeNode_);
     267                this->CamNode_->getParent()->removeChild(this->CamNode_);
     268                this->playerShipNode_->addChild(this->CamNode_);
     269                this->CamNode_->attachObject(this->Cam_);
     270                //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode();
     271                //this->CamNodeHelper_->attachObject(this->Cam_);
     272                this->Cam_->setPosition(0, 0, DISTANCE);
     273                this->Cam_->pitch( (Degree)PITCH );
     274                //this->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
     275                this->Cam_->setAutoTracking(true, this->playerShipNode_);
     276            }
    241277           
    242         }
    243     }
    244 
     278           
     279        }
     280    }
     281   
     282
     283   
    245284    void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
    246285    {
     
    254293        {
    255294            //COUT(0) << "foo";
    256             this->getOwner()->getReverseCamera()->attachCamera(this->mReflectCam_);
     295            this->getOwner()->getReverseCamera()->attachCamera(this->Cam_);
    257296        }
    258297    }
     
    297336        if( this->isVisible_ )
    298337            updatePositions();
    299         //mReflectCam_->roll(Degree(1));
     338        //Cam_->roll(Degree(1));
    300339       
    301340    }
     
    303342    void Map::rotateYaw(const Vector2& value)
    304343    {
    305         //if (this->bMouseLook_)
    306             //this->mReflectCam_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
    307         if(Map::singletonMap_s)
    308             singletonMap_s->mReflectCam_->setOrientation(singletonMap_s->mReflectCam_->getOrientation() * Quaternion( (Degree)(value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_Y));
     344        if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
     345            return;
     346
     347/*
     348        singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
     349
     350        Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
     351        Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
     352*/
     353        singletonMap_s->CamNode_->yaw( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
    309354    }
    310355
    311356    void Map::rotatePitch(const Vector2& value)
    312357    {
    313         //if (this->bMouseLook_)
    314             //this->mReflectCam_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
    315         if(Map::singletonMap_s)
    316             singletonMap_s->mReflectCam_->setOrientation(singletonMap_s->mReflectCam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
    317     }
    318    
     358        if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
     359            return;
     360            //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
     361/*        singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
     362
     363        Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
     364        Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
     365*/
     366        singletonMap_s->CamNode_->pitch( (Degree)(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
     367       
     368    }
     369   
     370    void Map::Zoom(const Vector2& value)
     371    {
     372        if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
     373            return;
     374        //COUT(0) << value.y << std::endl;
     375        Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ );
     376    }
    319377 }
  • code/branches/map/src/orxonox/overlays/map/Map.h

    r2942 r2956  
    6464        static void openMap();
    6565
     66//Not yet implemented
    6667        static const int maxRange_s=1000;
    6768
    6869        static void rotateYaw(const Vector2& value);
    6970        static void rotatePitch(const Vector2& value);
    70 
     71        static void Zoom(const Vector2& value);
    7172        // variables
    7273
     
    7778        static inline Ogre::SceneManager* getMapSceneManagerPtr()
    7879        {
    79             return Map::singletonMap_s->mapSceneM_;
     80            return Map::singletonMap_s->mapSceneM_s;
    8081        }
    8182        static inline Map* getSingletonPtr()
     
    8485        }
    8586
     87        static inline Ogre::SceneManager* getMapSceneManager()
     88        {
     89            return Map::mapSceneM_s;
     90        }
    8691
    8792
     
    9196        void toggleVisibility();
    9297        void updatePositions();
    93        
     98//        void changedPlayerNode();
     99        static inline void setMapSceneManager( Ogre::SceneManager * sm)
     100        {
     101            Map::mapSceneM_s = sm;
     102        }
    94103
    95104    private: // variables
     
    97106
    98107        Ogre::SceneManager* sManager_;
    99         Ogre::SceneManager* mapSceneM_;
    100         Ogre::SceneNode* rootNode_;
    101108        Ogre::OverlayManager * oManager_;
    102         Ogre::Camera* mReflectCam_;
    103         //Ogre::SceneNode* playerShipNode_;
     109
     110        static Ogre::SceneManager* mapSceneM_s;
     111        Ogre::SceneNode* CamNode_;
     112        Ogre::Camera* Cam_;
     113        //Ogre::SceneNode* CamNodeHelper_;
     114        Ogre::SceneNode* playerShipNode_;
     115        Ogre::SceneNode* planeNode_;
     116       
    104117        int mouseLookSpeed_;
    105118        bool isVisible_;
Note: See TracChangeset for help on using the changeset viewer.