Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 27, 2009, 4:11:31 PM (15 years ago)
Author:
landauf
Message:

merged map branch back to trunk

Location:
code/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/RadarViewable.cc

    r3064 r3089  
    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
     
    4246    */
    4347    RadarViewable::RadarViewable()
    44         : radarObjectCamouflage_(0.0f)
     48        : MapNode_(NULL)
     49        , MapEntity_(NULL)
     50        , line_(NULL)
     51        , LineNode_(NULL)
     52        , radarObjectCamouflage_(0.0f)
    4553        , radarObjectShape_(Dot)
    4654        , radarObjectDescription_("staticObject")
     
    4957
    5058        this->bVisibility_ = true;
     59        this->isHumanShip_ = false;
     60
     61        this->uniqueId_=getUniqueNumberString();
     62/*
     63        if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr())
     64        {
     65            this->addEntity();
     66        }
     67
     68        */
     69    }
     70
     71
     72    RadarViewable::~RadarViewable()
     73    {
     74        if (MapNode_)
     75            delete MapNode_;
     76        MapNode_=0;
     77
     78        if (MapEntity_)
     79            delete MapEntity_;
     80        MapEntity_=0;
     81
     82        if (line_)
     83            delete line_;
     84        line_=0;
     85
     86        if (LineNode_)
     87            delete LineNode_;
     88        LineNode_=0;
     89    }
     90
     91    void RadarViewable::addMapEntity()
     92    { //TODO Check shape and add accordantly
     93        if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() )
     94        {
     95            COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n";
     96            this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh");
     97            /*this->line_ =  Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l");
     98            this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP);
     99            //line_->position(0, -it->getRVWorldPosition().y, 0);
     100            //this->line_->position(0, -20, 0);
     101            this->line_->position(0, 0, -10); //Front Arrow
     102            this->line_->position(0, 0, 0);
     103
     104            this->line_->end(); */
     105            this->line_ = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
     106            this->line_->addPoint( Vector3(0,0,0) );
     107            this->line_->addPoint( Vector3(0,0,0) );
     108
     109            this->MapNode_->attachObject( this->MapEntity_ );
     110
     111            this->LineNode_ = this->MapNode_->createChildSceneNode();
     112            this->LineNode_->attachObject( this->line_ );
     113        }
     114        else
     115        {
     116            COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n";
     117        }
     118    }
     119
     120    void RadarViewable::updateMapPosition()
     121    {
     122        if( this->MapNode_ )
     123        {
     124            this->MapNode_->setPosition( this->getRVWorldPosition() );
     125            this->MapNode_->translate( this->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 );
     126            this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() );
     127//Vector3 v = this->getRVWorldPosition();
     128            //this->line_->setPoint(1, Vector3(0,v.y,0) );
     129            this->line_->setPoint(1, Vector3( 0, (int) -Map::getSingletonPtr()->movablePlane_->getDistance( this->getRVWorldPosition() ) ,0 ));
     130            this->line_->update();
     131            if( Map::getSingletonPtr()->playerShipNode_ )
     132                this->LineNode_->setDirection( Map::getSingletonPtr()->playerShipNode_->getLocalAxes().GetColumn(1) ,Ogre::Node::TS_WORLD,Vector3::UNIT_Y);
     133        }
    51134    }
    52135
  • code/trunk/src/orxonox/objects/RadarViewable.h

    r3064 r3089  
    3737#include "core/OrxonoxClass.h"
    3838
     39#include <string>
     40#include <OgreSceneNode.h>
     41#include <OgreEntity.h>
     42#include <OgreManualObject.h>
     43#include "orxonox/tools/DynamicLines.h"
     44
    3945namespace orxonox
    4046{
     
    5258        };
    5359
     60
    5461    public:
    5562        RadarViewable();
    56         virtual ~RadarViewable() { }
     63        virtual ~RadarViewable();
    5764
    5865        inline void setRadarObjectCamouflage(float camouflage)
     
    8592            { return this->radarObjectShape_; }
    8693
     94/*
     95        inline void setMapNode(Ogre::SceneNode * node)
     96            { this->MapNode_ = node; }
     97        inline Ogre::SceneNode * getMapNode() const
     98            { return this->MapNode_; }
     99        inline void setMapEntity(Ogre::Entity * ent)
     100            { this->MapEntity_ = ent; }
     101        inline Ogre::Entity * getMapEntity() const
     102            { return this->MapEntity_; }
     103*/
     104        //Used for Map
     105        Ogre::SceneNode * MapNode_;
     106        Ogre::Entity * MapEntity_;
     107        DynamicLines* line_;
     108        Ogre::SceneNode * LineNode_;
     109        void addMapEntity();
     110        void updateMapPosition();
     111        bool isHumanShip_;
     112        inline std::string getUniqueId()
     113        {
     114            return this->uniqueId_;
     115        }
     116
    87117    private:
    88118        void validate(const WorldEntity* object) const
     
    94124            }
    95125        }
    96        
     126
    97127        bool bVisibility_;
     128        //Map
     129        std::string uniqueId_;
     130
     131
     132        //Radar
    98133        float radarObjectCamouflage_;
    99134        Shape radarObjectShape_;
    100135        std::string radarObjectDescription_;
    101136        ColourValue radarObjectColour_;
     137
    102138    };
    103139}
  • code/trunk/src/orxonox/objects/controllers/HumanController.cc

    r3073 r3089  
    3636#include "objects/gametypes/Gametype.h"
    3737#include "objects/infos/PlayerInfo.h"
     38#include "overlays/map/Map.h"
    3839
    3940namespace orxonox
     
    9394    void HumanController::rotateYaw(const Vector2& value)
    9495    {
     96        //Hack to enable mouselook in map
     97        if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
     98        {
     99            Map::getSingletonPtr()->rotateYaw(value);
     100            return;
     101        }
    95102        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    96103            HumanController::localController_s->controllableEntity_->rotateYaw(value);
     
    99106    void HumanController::rotatePitch(const Vector2& value)
    100107    {
     108        //Hack to enable mouselook in map
     109        if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
     110        {
     111            Map::getSingletonPtr()->rotatePitch(value);
     112            return;
     113        }
    101114        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    102115            HumanController::localController_s->controllableEntity_->rotatePitch(value);
  • code/trunk/src/orxonox/objects/controllers/HumanController.h

    r3073 r3089  
    7878            }
    7979
     80            //friend class, for mouselook
     81            friend class Map;
     82
    8083        private:
    8184            static HumanController* localController_s;
  • code/trunk/src/orxonox/objects/worldentities/CameraPosition.cc

    r2826 r3089  
    3030#include "CameraPosition.h"
    3131
     32#include <OgreCamera.h>
     33
    3234#include "core/CoreIncludes.h"
    3335#include "core/XMLPort.h"
     
    4547        this->bAllowMouseLook_ = false;
    4648        this->bAbsolute_ = false;
     49        this->bRenderCamera_ = false;
    4750
    4851        this->setObjectMode(0x0);
     
    6063        XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false);
    6164        XMLPortParam(CameraPosition, "absolute", setIsAbsolute, getIsAbsolute, xmlelement, mode).defaultValues(false);
     65        XMLPortParam(CameraPosition, "rendercamera", setRenderCamera, getRenderCamera, xmlelement, mode).defaultValues(false);
    6266    }
    6367
     
    7276            camera->setDrag(true);
    7377    }
     78
     79    void CameraPosition::attachCamera(Ogre::Camera* camera)
     80    {
     81        this->attachOgreObject(camera);
     82    }
    7483}
  • code/trunk/src/orxonox/objects/worldentities/CameraPosition.h

    r2826 r3089  
    5959                { return this->bAbsolute_; }
    6060
     61            inline void setRenderCamera(bool bRenderCamera)
     62                { this->bRenderCamera_ = bRenderCamera; }
     63            inline bool getRenderCamera() const
     64                { return this->bRenderCamera_; }
     65
    6166            void attachCamera(Camera* camera);
     67            void attachCamera(Ogre::Camera* camera);
    6268
    6369        private:
     
    6571            bool bAllowMouseLook_;
    6672            bool bAbsolute_;
     73            bool bRenderCamera_;
    6774    };
    6875}
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc

    r3084 r3089  
    6363        this->camera_ = 0;
    6464        this->xmlcontroller_ = 0;
     65        this->reverseCamera_ = 0;
    6566        this->bDestroyWhenPlayerLeft_ = false;
    6667        this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
     
    143144                parent->attach(position);
    144145        }
    145         this->cameraPositions_.push_back(position);
     146
     147        if (!position->getRenderCamera())
     148            this->cameraPositions_.push_back(position);
     149        else
     150            this->setReverseCamera(position);
    146151    }
    147152
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h

    r3073 r3089  
    107107            inline const std::string& getCameraPositionTemkplate() const
    108108                { return this->cameraPositionTemplate_; }
     109
     110            inline void setReverseCamera(CameraPosition* camera)
     111                { this->reverseCamera_ = camera; }
     112            inline CameraPosition* getReverseCamera() const
     113                { return this->reverseCamera_; }
    109114
    110115            using WorldEntity::setPosition;
     
    192197            std::string cameraPositionTemplate_;
    193198            Controller* xmlcontroller_;
     199            CameraPosition* reverseCamera_;
    194200    };
    195201}
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r3087 r3089  
    8686
    8787        this->registerVariables();
     88
     89        this->isHumanShip_ = this->hasLocalController();
    8890    }
    8991
     
    365367    }
    366368
     369    //Tell the Map (RadarViewable), if this is a playership
     370    void Pawn::startLocalHumanControl()
     371    {
     372//        SUPER(ControllableEntity, changedPlayer());
     373        ControllableEntity::startLocalHumanControl();
     374        this->isHumanShip_ = true;
     375    }
     376
    367377
    368378    ///////////////////
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h

    r3087 r3089  
    112112            virtual void useItem()
    113113                { this->pickups_.useItem(); }
     114           
     115            virtual void startLocalHumanControl();
    114116
    115117        protected:
Note: See TracChangeset for help on using the changeset viewer.