Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2942


Ignore:
Timestamp:
Apr 30, 2009, 2:12:57 PM (15 years ago)
Author:
Naaduun
Message:

=added dynamic libs to orxonox/tools. changed humancontroller to use mouseview

Location:
code/branches/map/src
Files:
4 added
8 edited

Legend:

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

    r2913 r2942  
    3535#include "objects/worldentities/WorldEntity.h"
    3636#include "objects/Radar.h"
     37#include "util/String.h"
     38#include <OgreManualObject.h>
     39#include "overlays/map/Map.h"
     40#include "orxonox/tools/DynamicLines.h"
    3741
    3842namespace orxonox
     
    4751        , MapNode_(NULL)
    4852        , MapEntity_(NULL)
     53        , line_(NULL)
    4954    {
    5055        RegisterRootObject(RadarViewable);
     56
     57        this->uniqueId_=getUniqueNumberString();
     58/*
     59        if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr())
     60        {
     61            this->addEntity();
     62        }
     63
     64        */
     65    }
     66
     67
     68    RadarViewable::~RadarViewable()
     69    {
     70        delete MapNode_;
     71        delete MapEntity_;
     72    }
     73
     74    void RadarViewable::addMapEntity()
     75    { //TODO Check shape and add accordantly
     76        if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() )
     77        {
     78            COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n";
     79            this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh");
     80            /*this->line_ =  Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l");
     81            this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP);
     82            //line_->position(0, -it->getRVWorldPosition().y, 0);
     83            //this->line_->position(0, -20, 0);
     84            this->line_->position(0, 0, -10); //Front Arrow
     85            this->line_->position(0, 0, 0);
     86
     87            this->line_->end(); */
     88            this->line_ = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
     89            this->line_->addPoint( Vector3(0,0,0) );
     90            this->line_->addPoint( Vector3(0,0,0) );
     91
     92            this->MapNode_->attachObject( this->MapEntity_ );
     93            this->MapNode_->attachObject( this->line_ );
     94        }
     95        else
     96        {
     97            COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n";
     98        }
     99    }
     100
     101    void RadarViewable::updateMapPosition()
     102    {
     103        if( this->MapNode_ )
     104        {
     105            this->MapNode_->setPosition( this->getRVWorldPosition() );
     106            this->MapNode_->translate( this->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 );
     107            this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() );
     108Vector3 v = this->getRVWorldPosition();
     109            this->line_->setPoint(1, Vector3(0,v.y,0) );
     110        }
    51111    }
    52112
  • code/branches/map/src/orxonox/objects/RadarViewable.h

    r2913 r2942  
    3737#include "core/OrxonoxClass.h"
    3838
     39#include <string>
    3940#include <OgreSceneNode.h>
    4041#include <OgreEntity.h>
     42#include <OgreManualObject.h>
     43#include "orxonox/tools/DynamicLines.h"
    4144
    4245namespace orxonox
     
    5558        };
    5659
     60
    5761    public:
    5862        RadarViewable();
    59         virtual ~RadarViewable() { }
     63        virtual ~RadarViewable();
    6064
    6165        inline void setRadarObjectCamouflage(float camouflage)
     
    96100        Ogre::SceneNode * MapNode_;
    97101        Ogre::Entity * MapEntity_;
    98 
     102        DynamicLines* line_;
     103        void addMapEntity();
     104        void updateMapPosition();
    99105    private:
    100106        void validate(const WorldEntity* object) const
     
    107113        }
    108114
     115       
     116        std::string uniqueId_;
     117
    109118        float radarObjectCamouflage_;
    110119        Shape radarObjectShape_;
  • code/branches/map/src/orxonox/objects/controllers/HumanController.cc

    r2662 r2942  
    3535#include "objects/worldentities/pawns/Pawn.h"
    3636#include "objects/gametypes/Gametype.h"
     37#include "overlays/map/Map.h"
    3738
    3839namespace orxonox
     
    9293    void HumanController::rotateYaw(const Vector2& value)
    9394    {
     95        //Hack to enable mouselook in map
     96        if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
     97        {
     98            Map::getSingletonPtr()->rotateYaw(value);
     99            return;
     100        }
    94101        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    95102            HumanController::localController_s->controllableEntity_->rotateYaw(value);
     
    98105    void HumanController::rotatePitch(const Vector2& value)
    99106    {
     107        //Hack to enable mouselook in map
     108        if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
     109        {
     110            Map::getSingletonPtr()->rotatePitch(value);
     111            return;
     112        }
    100113        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    101114            HumanController::localController_s->controllableEntity_->rotatePitch(value);
  • code/branches/map/src/orxonox/objects/controllers/HumanController.h

    r2662 r2942  
    6666            static void killBots(unsigned int amount = 0);
    6767
     68            //friend class, for mouselook
     69            friend class Map;
     70
    6871        private:
    6972            static HumanController* localController_s;
  • code/branches/map/src/orxonox/overlays/map/Map.cc

    r2913 r2942  
    2828 
    2929#include <string>
     30#include "util/String.h"
    3031#include <OgreSceneManager.h>
    3132#include <OgreSceneNode.h>
     
    3334#include <OgreNode.h>
    3435
     36
    3537#include <OgreRenderWindow.h>
    3638#include <OgreRenderTexture.h>
    3739#include <OgreTexture.h>
    3840#include <OgreViewport.h>
    39 #include <OgreMaterial.h>
     41
    4042#include <OgreMaterialManager.h>
    4143#include <OgreRoot.h>
     
    5355#include "objects/Scene.h"
    5456#include "objects/RadarViewable.h"
     57#include "objects/controllers/HumanController.h"
    5558 
    5659 namespace orxonox
    5760 {
    5861    CreateFactory(Map);
    59      SetConsoleCommand(Map, openMap, true);
     62    SetConsoleCommand(Map, openMap, true);
     63    SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
     64    SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
     65
     66    Map* Map::singletonMap_s = 0;
    6067   
    6168    Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
    6269    {
    6370        RegisterObject(Map);
    64        
     71        Map::singletonMap_s=this;
    6572        //Getting Scene Manager (Hack)
    6673        ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
     
    8895        */
    8996       
    90        
     97        this->mouseLookSpeed_ = 200;
    9198       
    9299
     
    99106        mReflectCam_->setAspectRatio(1);
    100107
     108        //Create overlay material
    101109        std::string camMat_id = "RttMat";
    102110        Ogre::MaterialPtr material = this->createRenderCamera(mReflectCam_, camMat_id);
     
    145153        overlay_->hide();
    146154
    147     }
    148    
     155        //Create plane in map
     156        Ogre::Entity* plane_ent = this->mapSceneM_->createEntity( "MapPlane", "plane.mesh");
     157        Ogre::SceneNode* plane_node = this->mapSceneM_->getRootSceneNode()->createChildSceneNode();
     158       
     159        //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
     160        //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga");
     161        //plane_ent->setMaterialName("mapgrid");
     162        plane_ent->setMaterialName("Map/Grid");
     163        plane_node->attachObject(plane_ent);
     164        plane_node->scale(10,1,10);
     165        //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
     166       
     167
     168        //ToDo create material script
     169        Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
     170        myManualObjectMaterial->setReceiveShadows(false);
     171        myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
     172        myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
     173        myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
     174        myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
     175
     176    }
     177
     178    Map::~Map()
     179    {
     180        singletonMap_s = 0;
     181        //delete sManager_;
     182        //delete rootNode_;
     183        //delete oManager_;
     184        //delete mReflectCam_;
     185        //delete mapSceneM_;
     186    }
     187
    149188    Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, std::string matName)
    150189    {
     
    168207    void Map::updatePositions()
    169208    {
     209
    170210//Ogre::Entity * ent;// = mapSceneM_->createEntity("ent1", "drone.mesh");
    171        int i=0;
    172211       for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
    173212            it!=ObjectList<orxonox::RadarViewable>::end();
    174213            it++)
    175214        {
    176             i++;
    177215            //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
    178216            //Ogre::SceneNode node = it->getMapNode();
     
    182220                it->MapNode_ = rootNode_->createChildSceneNode( it->getRVWorldPosition() );
    183221                //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD );
     222                /*if(it->getRadarObjectShape() == RadarViewable::Dot)
     223                {
     224                    //if( !(it->MapEntity_) )//check wether the entity is already attached
     225                    //{
     226                        //it->MapEntity_ = this->mapSceneM_->createEntity( getUniqueNumberString(), "drone.mesh");
     227                        //it->addEntity();
     228                        //it->MapNode_->attachObject( it->MapEntity_ );
     229                        //it->MapNode_->attachObject( it->line_ );
     230                   // }
     231                }*/
     232                it->addMapEntity();
    184233            }
    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             }
     234
     235            it->updateMapPosition();
     236
     237
     238
    192239           
    193240       
     
    218265            this->overlay_->show();
    219266            this->isVisible_=1;
    220             //updatePositions();
     267            //set mouselook when showing map
     268            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook())
     269            HumanController::localController_s->controllableEntity_->mouseLook();
    221270        }
    222271        else
     
    224273            this->overlay_->hide();
    225274            this->isVisible_=0;
     275            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook())
     276            HumanController::localController_s->controllableEntity_->mouseLook();
    226277        }
    227278    }
     
    235286        {
    236287        //Map * m = it->getMap();
    237         COUT(0) << it->isVisible_ << std::endl;
     288        //COUT(0) << it->isVisible_ << std::endl;
    238289        it->toggleVisibility();
    239290        //it->updatePositions();
     
    244295    {
    245296        //sNode_->lookAt(Vector3::NEGATIVE_UNIT_Z, Ogre::Node::TS_WORLD, Vector3::NEGATIVE_UNIT_Z);
    246         updatePositions();
    247        
     297        if( this->isVisible_ )
     298            updatePositions();
     299        //mReflectCam_->roll(Degree(1));
     300       
     301    }
     302
     303    void Map::rotateYaw(const Vector2& value)
     304    {
     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));
     309    }
     310
     311    void Map::rotatePitch(const Vector2& value)
     312    {
     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));
    248317    }
    249318   
  • code/branches/map/src/orxonox/overlays/map/Map.h

    r2913 r2942  
    5454    public: // functions
    5555        Map(BaseObject* creator);
    56         virtual ~Map() {}
     56        ~Map();
    5757
    5858        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     
    6565
    6666        static const int maxRange_s=1000;
     67
     68        static void rotateYaw(const Vector2& value);
     69        static void rotatePitch(const Vector2& value);
     70
     71        // variables
     72
     73
     74        bool inline getVisibility()
     75            { return this->isVisible_; };
     76
     77        static inline Ogre::SceneManager* getMapSceneManagerPtr()
     78        {
     79            return Map::singletonMap_s->mapSceneM_;
     80        }
     81        static inline Map* getSingletonPtr()
     82        {
     83            return Map::singletonMap_s;
     84        }
     85
     86
     87
    6788       
    6889    private: // functions
     90
    6991        void toggleVisibility();
    7092        void updatePositions();
    71 
     93       
    7294
    7395    private: // variables
     96        static Map* singletonMap_s;
     97
    7498        Ogre::SceneManager* sManager_;
    7599        Ogre::SceneManager* mapSceneM_;
     
    77101        Ogre::OverlayManager * oManager_;
    78102        Ogre::Camera* mReflectCam_;
    79 
    80        
    81        
     103        //Ogre::SceneNode* playerShipNode_;
     104        int mouseLookSpeed_;
    82105        bool isVisible_;
    83106    };
  • code/branches/map/src/orxonox/tools/CMakeLists.txt

    r2710 r2942  
    77  Timer.cc
    88  WindowEventListener.cc
     9  DynamicLines.cpp
     10  DynamicRenderable.cpp
    911)
  • code/branches/map/src/util/CMakeLists.txt

    r2773 r2942  
    3737  UtilPrereqs.h
    3838  mbool.h
    39 
     39 
    4040  Clipboard.cc
    4141  CRC32.cc
Note: See TracChangeset for help on using the changeset viewer.