Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

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