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:
2 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
Note: See TracChangeset for help on using the changeset viewer.