Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1264


Ignore:
Timestamp:
May 13, 2008, 5:01:10 PM (16 years ago)
Author:
scheusso
Message:

merge network3 and camera branch into merge branch

Location:
code/branches/merge
Files:
18 edited
38 copied

Legend:

Unmodified
Added
Removed
  • code/branches/merge/CMakeLists.txt

    r1219 r1264  
    4242
    4343# global compiler/linker flags. force -O2!
    44 SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O2 -Wall -g -ggdb")
    45 SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O2 -Wall -g -ggdb")
     44SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O0 -Wall -g -ggdb")
     45SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
    4646SET(CMAKE_LD_FLAGS "$ENV{LDFLAGS}")
    4747SET(CMAKE_EXE_LINKER_FLAGS " --no-undefined")
  • code/branches/merge/bin/levels/sample.oxw

    r1102 r1264  
    99  </audio-->
    1010
    11 <Ambient colourvalue="1,1,1" />
     11<!--Ambient colourvalue="1,1,1" /-->
    1212<Skybox src="Orxonox/StarSkyBox" />
    13 
    1413<SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
    1514
     
    3130</Model-->
    3231
    33 <Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
     32<!--Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
    3433<Model position="-200,1000,500" scale="10" mesh="hoover_gear0.mesh" yawpitchroll="-90,-90,0" />
    3534<Model position="-200,1000,500" scale="10" mesh="hoover_gear1.mesh" yawpitchroll="-90,-90,0" />
    3635<Model position="-200,1000,500" scale="10" mesh="hoover_gear2.mesh" yawpitchroll="-90,-90,0" />
    37 <Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" />
     36<Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" /-->
    3837
    3938
  • code/branches/merge/cmake/FindBoost.cmake

    r790 r1264  
    101101# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
    102102SET(SUFFIX_FOR_PATH
     103 boost
    103104 boost-1_34_1
    104105 boost-1_34_0
  • code/branches/merge/src/orxonox/CMakeLists.txt

    r1224 r1264  
    1616  objects/Ambient.cc
    1717  objects/Camera.cc
     18  objects/CameraHandler.cc
    1819  objects/Explosion.cc
    1920  objects/Model.cc
  • code/branches/merge/src/orxonox/Orxonox.cc

    r1263 r1264  
    189189    GraphicsEngine::getSingleton().destroy();
    190190
    191     if (client_g)
    192       delete client_g;
     191    if (network::Client::getSingleton())
     192      network::Client::destroySingleton();
    193193    if (server_g)
    194194      delete server_g;
    195195  }
     196
    196197
    197198  /**
     
    395396
    396397    if (serverIp_.compare("") == 0)
    397       client_g = new network::Client();
     398      client_g = network::Client::createSingleton();
    398399    else
    399       client_g = new network::Client(serverIp_, NETWORK_PORT);
     400      client_g = network::Client::createSingleton(serverIp_, NETWORK_PORT);
    400401
    401402    client_g->establishConnection();
     
    511512          }
    512513
     514    if(mode_==CLIENT)
     515      network::Client::getSingleton()->closeConnection();
     516    else if(mode_==SERVER)
     517      server_g->close();
    513518    return true;
    514519  }
  • code/branches/merge/src/orxonox/objects/Ambient.cc

    r1209 r1264  
    5757        RegisterObject(Ambient);
    5858        Ambient::instance_s = this;
     59        registerAllVariables();
    5960    }
    6061
     
    6364    }
    6465
     66    bool Ambient::create(){
     67      GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
     68      return true;
     69    }
     70   
     71    void Ambient::registerAllVariables(){
     72      registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
     73     
     74    }
     75   
    6576    void Ambient::loadParams(TiXmlElement* xmlElem)
    6677    {
     
    8394   {
    8495        GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
     96      ambientLight_=colour;     
    8597   }
    8698
     
    96108
    97109        XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);
     110        create();
    98111    }
    99112}
  • code/branches/merge/src/orxonox/objects/Ambient.h

    r1056 r1264  
    3434#include "util/Math.h"
    3535#include "core/BaseObject.h"
     36#include "network/Synchronisable.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport Ambient : public BaseObject
     40    class _OrxonoxExport Ambient : public BaseObject, network::Synchronisable
    4041    {
    4142        public:
     
    4647            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4748            void setAmbientLight(const ColourValue& colour);
     49            bool create();
     50            void registerAllVariables();
    4851
    4952            static void setAmbientLightTest(const ColourValue& colour)
     
    5255        private:
    5356            static Ambient* instance_s;
     57            ColourValue ambientLight_;
    5458
    5559    };
  • code/branches/merge/src/orxonox/objects/Camera.cc

    r1209 r1264  
    4747namespace orxonox
    4848{
    49     CreateFactory(Camera);
     49  //CreateFactory(Camera);
    5050
    51     Camera::Camera()
     51  Camera::Camera(Ogre::SceneNode* node)
     52  {
     53    //RegisterObject(Camera);
     54    this->bHasFocus_ = false;
     55    if( node != NULL )
     56      this->setCameraNode(node);
     57
     58  }
     59
     60  Camera::~Camera()
     61  {
     62  }
     63
     64  /*void Camera::loadParams(TiXmlElement* xmlElem)
     65  {
     66    Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
     67
     68    if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
    5269    {
    53         RegisterObject(Camera);
     70      //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
     71
     72      std::string name = xmlElem->Attribute("name");
     73      std::string pos = xmlElem->Attribute("pos");
     74      std::string lookat = xmlElem->Attribute("lookat");
     75
     76      this->cam_ = mgr->createCamera(name);
     77
     78      float x, y, z;
     79      SubString posVec(xmlElem->Attribute("pos"), ',');
     80      convertValue<std::string, float>(&x, posVec[0]);
     81      convertValue<std::string, float>(&y, posVec[1]);
     82      convertValue<std::string, float>(&z, posVec[2]);
     83
     84      setPosition(Vector3(x,y,z));
     85
     86      //std::string target = xmlElem->Attribute("lookat");
     87      posVec.split(xmlElem->Attribute("lookat"), ',');
     88      convertValue<std::string, float>(&x, posVec[0]);
     89      convertValue<std::string, float>(&y, posVec[1]);
     90      convertValue<std::string, float>(&z, posVec[2]);
     91
     92      cam_->lookAt(Vector3(x,y,z));
     93
     94      /*std::string node = xmlElem->Attribute("node");
     95
     96      Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
     97      sceneNode->attachObject((Ogre::MovableObject*)cam_);
     98      */
     99
     100      // FIXME: unused var
     101      //Ogre::Viewport* vp =
     102      //GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam_);
     103    /*
     104
     105      COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
    54106    }
     107  }*/
    55108
    56     Camera::~Camera()
    57     {
    58     }
     109  void Camera::setCameraNode(Ogre::SceneNode* node)
     110  {
     111    this->positionNode_ = node;
     112    // set camera to node values according to camera mode
     113  }
    59114
    60     void Camera::loadParams(TiXmlElement* xmlElem)
    61     {
    62       Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
     115  void Camera::setTargetNode(Ogre::SceneNode* obj)
     116  {
     117    this->targetNode_ = obj;
     118  }
    63119
    64       if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
    65       {
    66         //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
     120  /**
     121    don't move anything before here! here the Ogre camera is set to values of this camera
     122    always call update after changes
     123  */
     124  void Camera::update()
     125  {
     126    COUT(0) << "p " << this->positionNode_->getPosition() << std::endl;
     127    COUT(0) << "t " << this->targetNode_->getPosition() << std::endl;
     128    if(this->positionNode_ != NULL)
     129      this->cam_->setPosition(this->positionNode_->getPosition());
     130    if(this->targetNode_ != NULL)
     131      this->cam_->lookAt(this->targetNode_->getPosition());
     132  }
    67133
    68         std::string name = xmlElem->Attribute("name");
    69         std::string pos = xmlElem->Attribute("pos");
    70         std::string lookat = xmlElem->Attribute("lookat");
     134  /**
     135    what to do when camera loses focus (do not request focus in this function!!)
     136    this is called by the CameraHandler singleton class to notify the camera
     137  */
     138  void Camera::removeFocus()
     139  {
     140    this->bHasFocus_ = false;
     141    this->positionNode_->detachObject(cam_);
     142  }
    71143
    72         Ogre::Camera *cam = mgr->createCamera(name);
    73 
    74         float x, y, z;
    75         SubString posVec(xmlElem->Attribute("pos"), ',');
    76         convertValue<std::string, float>(&x, posVec[0]);
    77         convertValue<std::string, float>(&y, posVec[1]);
    78         convertValue<std::string, float>(&z, posVec[2]);
    79 
    80         cam->setPosition(Vector3(x,y,z));
    81 
    82         posVec = SubString(xmlElem->Attribute("lookat"), ',');
    83         convertValue<std::string, float>(&x, posVec[0]);
    84         convertValue<std::string, float>(&y, posVec[1]);
    85         convertValue<std::string, float>(&z, posVec[2]);
    86 
    87         cam->lookAt(Vector3(x,y,z));
    88 
    89         std::string node = xmlElem->Attribute("node");
    90 
    91         Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
    92         sceneNode->attachObject((Ogre::MovableObject*)cam);
    93 
    94         // FIXME: unused var
    95         //Ogre::Viewport* vp =
    96         GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
    97 
    98 
    99         COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
    100       }
    101    }
     144  void Camera::setFocus(Ogre::Camera* ogreCam)
     145  {
     146    this->bHasFocus_ = true;
     147    this->cam_ = ogreCam;
     148    this->positionNode_->attachObject(cam_);
     149  }
    102150}
  • code/branches/merge/src/orxonox/objects/Camera.h

    r1056 r1264  
    3030#define _Camera_H__
    3131
     32#include <OgrePrerequisites.h>
     33#include <OgreSceneNode.h>
     34#include <OgreCamera.h>
     35
    3236#include "OrxonoxPrereqs.h"
    33 
    34 #include "core/BaseObject.h"
    3537
    3638namespace orxonox
    3739{
    38     class _OrxonoxExport Camera : public BaseObject
     40    class _OrxonoxExport Camera
    3941    {
    40         public:
    41             Camera();
    42             virtual ~Camera();
     42      friend class CameraHandler;
     43      public:
     44        Camera(Ogre::SceneNode* node = NULL);
     45        virtual ~Camera();
     46
     47        //inline void setPosition(Ogre::Vector3 pos) { position_->setPosition(pos); cam_->setPosition(pos); }
     48        void setCameraNode(Ogre::SceneNode* node);
     49        inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; }
     50        // maybe also BaseObject
     51        void setTargetNode(Ogre::SceneNode* obj);
    4352
    4453
    45             void loadParams(TiXmlElement* xmlElem);
     54        void update();
     55        inline bool hasFocus() { return this->bHasFocus_; }
    4656
    47         private:
     57      private:
     58        void removeFocus();
     59        void setFocus(Ogre::Camera* ogreCam);
    4860
    49 
     61      private:
     62        Ogre::SceneNode* targetNode_;
     63        Ogre::SceneNode* positionNode_;
     64        Ogre::Camera* cam_;
     65        bool bHasFocus_;
    5066    };
    5167}
  • code/branches/merge/src/orxonox/objects/Model.cc

    r1263 r1264  
    6262        XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
    6363
    64         create();
     64        Model::create();
    6565    }
    6666
     
    7171
    7272    bool Model::create(){
    73       WorldEntity::create();
     73      if(!WorldEntity::create())
     74        return false;
    7475      if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
    7576      {
    7677        this->mesh_.setMesh(meshSrc_);
    7778        this->attachObject(this->mesh_.getEntity());
    78         COUT(4) << "Loader: Created model" << std::endl;
     79        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
    7980      }
    8081      return true;
     
    8283
    8384    void Model::registerAllVariables(){
    84       WorldEntity::registerAllVariables();
     85//       WorldEntity::registerAllVariables();
     86      COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl;
    8587      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
    8688    }
  • code/branches/merge/src/orxonox/objects/NPC.cc

    r1263 r1264  
    4040  {
    4141    RegisterObject(NPC);
     42    registerAllVariables();
    4243  }
    4344
     
    5960    this->translate(location);
    6061    movable_ = movable;
     62  }
     63 
     64  void NPC::registerAllVariables(){
     65    Model::registerAllVariables();
     66    registerVar(&movable_, sizeof(movable_), network::DATA);
     67  }
     68 
     69  bool NPC::create(){
     70    Model::create();
     71    return true;
    6172  }
    6273
  • code/branches/merge/src/orxonox/objects/NPC.h

    r1056 r1264  
    5252      void update();
    5353      void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable);
     54      void registerAllVariables();
     55      bool create();
    5456
    5557    private:
  • code/branches/merge/src/orxonox/objects/Skybox.cc

    r1209 r1264  
    4747    {
    4848        RegisterObject(Skybox);
     49        registerAllVariables();
    4950    }
    5051
     
    5758        if (xmlElem->Attribute("src"))
    5859        {
    59                 std::string skyboxSrc = xmlElem->Attribute("src");
    60                 this->setSkybox(skyboxSrc);
     60                skyboxSrc_ = xmlElem->Attribute("src");
     61        this->create();
    6162
    62                 COUT(4) << "Loader: Set skybox: "<< skyboxSrc << std::endl << std::endl;
     63                COUT(4) << "Loader: Set skybox: "<< skyboxSrc_ << std::endl << std::endl;
    6364        }
    6465   }
     
    6970   }
    7071
     72   void Skybox::setSkyboxSrc(const std::string& src){
     73     skyboxSrc_ = src;
     74   }
     75   
    7176    /**
    7277        @brief XML loading and saving.
     
    7984        BaseObject::XMLPort(xmlelement, mode);
    8085
    81         XMLPortParamLoadOnly(Skybox, "src", setSkybox, xmlelement, mode);
     86        XMLPortParamLoadOnly(Skybox, "src", setSkyboxSrc, xmlelement, mode);
     87        create();
    8288    }
     89   
     90    bool Skybox::create(){
     91      this->setSkybox(skyboxSrc_);
     92      return true;
     93    }
     94   
     95    void Skybox::registerAllVariables(){
     96      registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
     97    }
     98   
    8399}
  • code/branches/merge/src/orxonox/objects/Skybox.h

    r1056 r1264  
    3333
    3434#include "core/BaseObject.h"
     35#include "network/Synchronisable.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport Skybox : public BaseObject
     39    class _OrxonoxExport Skybox : public BaseObject, public network::Synchronisable
    3940    {
    4041        public:
     
    4546            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4647            void setSkybox(const std::string& skyboxname);
     48           
     49            bool create();
     50            void registerAllVariables();
     51            void setSkyboxSrc(const std::string &src);
    4752
    4853        private:
     54            std::string skyboxSrc_;
    4955
    5056
  • code/branches/merge/src/orxonox/objects/SpaceShip.cc

    r1263 r1264  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    3737#include <OgreSceneNode.h>
    3838
     39#include "CameraHandler.h"
    3940#include "tinyxml/tinyxml.h"
    4041#include "ois/OIS.h"
     
    5051#include "core/XMLPort.h"
    5152#include "core/ConsoleCommand.h"
     53#include "network/Client.h"
    5254
    5355namespace orxonox
     
    6466    SpaceShip::SpaceShip()
    6567    {
     68        RegisterObject(SpaceShip);
     69        this->registerAllVariables();
     70
    6671        SpaceShip::instance_s = this;
     72
     73        this->setConfigValues();
    6774
    6875        this->setMouseEventCallback_ = false;
     
    7380
    7481        this->camNode_ = 0;
     82        this->camName_ = "camNode";
    7583
    7684        this->tt_ = 0;
     
    96104        this->setRotationAxis(1, 0, 0);
    97105        this->setStatic(false);
    98 /*
    99         this->moveForward_ = 0;
    100         this->rotateUp_ = 0;
    101         this->rotateDown_ = 0;
    102         this->rotateRight_ = 0;
    103         this->rotateLeft_ = 0;
    104         this->loopRight_ = 0;
    105         this->loopLeft_ = 0;
    106         this->brakeForward_ = 0;
    107         this->brakeRotate_ = 0;
    108         this->brakeLoop_ = 0;
    109         this->speedForward_ = 0;
    110         this->speedRotateUpDown_ = 0;
    111         this->speedRotateRightLeft_ = 0;
    112         this->speedLoopRightLeft_ = 0;
    113         this->maxSpeedForward_ = 0;
    114         this->maxSpeedRotateUpDown_ = 0;
    115         this->maxSpeedRotateRightLeft_ = 0;
    116         this->maxSpeedLoopRightLeft_ = 0;
    117         this->accelerationForward_ = 0;
    118         this->accelerationRotateUpDown_ = 0;
    119         this->accelerationRotateRightLeft_ = 0;
    120         this->accelerationLoopRightLeft_ = 0;
    121 
    122         this->speed = 250;
    123         this->loop = 100;
    124         this->rotate = 10;
    125         this->mouseX = 0;
    126         this->mouseY = 0;
    127         this->maxMouseX = 0;
    128         this->minMouseX = 0;
    129         this->moved = false;
    130 
    131         this->brakeRotate(rotate*10);
    132         this->brakeLoop(loop);
    133 */
    134 //         this->create();
    135 
    136         RegisterObject(SpaceShip);
    137         this->registerAllVariables();
    138         this->setConfigValues();
     106
     107        server_=false;
     108
    139109
    140110        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
     
    156126
    157127    void SpaceShip::registerAllVariables(){
    158       Model::registerAllVariables();
    159 
    160 
     128      registerVar( &camName_, camName_.length()+1, network::STRING, 0x1);
     129      registerVar( &maxSpeed_, sizeof(maxSpeed_), network::DATA, 0x1);
     130      registerVar( &maxSideAndBackSpeed_, sizeof(maxSideAndBackSpeed_), network::DATA, 0x1);
     131      registerVar( &maxRotation_, sizeof(maxRotation_), network::DATA, 0x1);
     132      registerVar( &translationAcceleration_, sizeof(translationAcceleration_), network::DATA, 0x1);
     133      registerVar( &rotationAcceleration_, sizeof(rotationAcceleration_), network::DATA, 0x1);
     134      registerVar( &rotationAccelerationRadian_, sizeof(rotationAccelerationRadian_), network::DATA, 0x1);
     135      registerVar( &translationDamping_, sizeof(translationDamping_), network::DATA, 0x1);
     136      registerVar( &rotationDamping_, sizeof(rotationDamping_), network::DATA, 0x1);
     137      registerVar( &rotationDampingRadian_, sizeof(rotationDampingRadian_), network::DATA, 0x1);
    161138
    162139    }
     
    164141    void SpaceShip::init()
    165142    {
    166         if (!setMouseEventCallback_)
    167         {
    168           InputManager::addMouseHandler(this, "SpaceShip");
    169           setMouseEventCallback_ = true;
    170         }
     143                if ((!network::Client::getSingleton() || network::Client::getSingleton()->getShipID()==objectID ))
     144                {
     145                if (!setMouseEventCallback_)
     146                {
     147                        InputManager::addMouseHandler(this, "SpaceShip");
     148                        setMouseEventCallback_ = true;
     149                }
     150                }
    171151
    172152        // START CREATING THRUSTER
     
    222202        this->chFarNode_->setScale(0.4, 0.4, 0.4);
    223203
     204        createCamera();
    224205        // END of testing crosshair
    225206    }
     
    236217        Model::loadParams(xmlElem);
    237218        this->create();
     219        this->getFocus();
    238220/*
    239221        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
     
    286268    void SpaceShip::setCamera(const std::string& camera)
    287269    {
    288         Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam");
    289         this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
     270      camName_=camera;
     271      // change camera attributes here, if you want to ;)
     272    }
     273   
     274    void SpaceShip::getFocus(){
     275      COUT(4) << "requesting focus" << std::endl;
     276      if(network::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID)
     277        CameraHandler::getInstance()->requestFocus(cam_);
     278     
     279    }
     280   
     281    void SpaceShip::createCamera(){
     282//       COUT(4) << "begin camera creation" << std::endl;
     283      this->camNode_ = this->getNode()->createChildSceneNode(camName_);
     284      COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl;
     285      this->camNode_->setPosition(/*this->getNode()->getPosition() +*/ Vector3(-50,0,10));
     286      COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl;
    290287/*
    291288//        node->setInheritOrientation(false);
     
    293290        cam->lookAt(Vector3(0,20,0));
    294291        cam->roll(Degree(0));
    295 */
    296 
    297         cam->setPosition(Vector3(-200,0,35));
     292      *//*COUT(4) << "creating new camera" << std::endl;*/
     293      cam_ = new Camera(this->camNode_);
     294
     295      cam_->setTargetNode(this->getNode());
    298296//        cam->setPosition(Vector3(0,-350,0));
    299         cam->lookAt(Vector3(0,0,35));
    300         cam->roll(Degree(-90));
    301 
    302         this->camNode_->attachObject(cam);
    303         GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
     297      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
     298        this->setBacksync(true);
     299        CameraHandler::getInstance()->requestFocus(cam_);
     300      }
     301
    304302    }
    305303
     
    337335        XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
    338336        XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
     337        server_=true; // TODO: this is only a hack
     338        SpaceShip::create();
     339        getFocus();
    339340    }
    340341
     
    448449        if (this->bLMousePressed_ && this->timeToReload_ <= 0)
    449450        {
    450             new Projectile(this);
     451            Projectile *p = new Projectile(this);
     452            p->setBacksync(true);
    451453            this->timeToReload_ = this->reloadTime_;
    452454        }
     
    520522        }
    521523
    522         if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
     524        if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ ){
     525          COUT(4) << "steering our ship: " << objectID << " mkeyboard: " << mKeyboard << std::endl;
     526          if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    523527            this->acceleration_.x = this->translationAcceleration_;
    524         else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
     528          else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
    525529            this->acceleration_.x = -this->translationAcceleration_;
    526         else
     530          else
    527531            this->acceleration_.x = 0;
    528532
    529         if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
     533          if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
    530534            this->acceleration_.y = -this->translationAcceleration_;
    531         else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
     535          else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    532536            this->acceleration_.y = this->translationAcceleration_;
    533         else
     537          else
    534538            this->acceleration_.y = 0;
    535539
    536         if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
     540          if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
    537541            this->momentum_ = Radian(-this->rotationAccelerationRadian_);
    538         else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
     542          else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
    539543            this->momentum_ = Radian(this->rotationAccelerationRadian_);
    540         else
     544          else
    541545            this->momentum_ = 0;
     546        }/*else
     547          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
    542548
    543549        WorldEntity::tick(dt);
  • code/branches/merge/src/orxonox/objects/SpaceShip.h

    r1219 r1264  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    3535
    3636#include "core/InputHandler.h"
     37#include "Camera.h"
    3738#include "Model.h"
    3839#include "../tools/BillboardSet.h"
     
    6263            void setRotDamp(float value);
    6364
     65            void getFocus();
     66
    6467            static void setMaxSpeedTest(float value)
    6568                { SpaceShip::instance_s->setMaxSpeed(value); }
     
    7275
    7376        private:
     77            void createCamera();
    7478            static SpaceShip* instance_s;
    7579
     
    8185
    8286            Ogre::SceneNode* camNode_;
     87            Camera* cam_; 
     88            std::string camName_;
     89
    8390
    8491            ParticleInterface* tt_;
     
    117124
    118125            float emitterRate_;
     126            bool server_;
    119127    };
    120128}
  • code/branches/merge/src/orxonox/objects/WorldEntity.cc

    r1263 r1264  
    6666        }
    6767    }
     68   
    6869
    6970    WorldEntity::~WorldEntity()
    7071    {
     72      // just to make sure we clean out all scene nodes
     73      if(this->getNode())
     74        this->getNode()->removeAndDestroyAllChildren();
    7175    }
    7276
     
    7579        if (!this->bStatic_)
    7680        {
     81//             COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl;
    7782            this->velocity_ += (dt * this->acceleration_);
    7883            this->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
     
    8994        create();
    9095    }
     96   
    9197
    9298    void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
     
    115121
    116122        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
     123       
     124        WorldEntity::create();
    117125    }
    118126
     
    121129    {
    122130      // register coordinates
    123       registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
    124       registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
    125       registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA);
     131      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
     132      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3);
     133      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3);
    126134      // register orientation
    127       registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA);
    128       registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA);
    129       registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA);
    130       registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);
    131       // not needed at the moment, because we don't have prediction yet
     135      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3);
     136      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3);
     137      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3);
     138      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
    132139      // register velocity_
    133       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
    134       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
    135       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA);
    136       // register rotationAxis/rate
    137       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA);
    138       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA);
    139       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA);
    140       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);
     140//       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
     141//       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
     142//       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
     143//       // register rotationAxis/rate
     144//       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
     145//       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
     146//       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
     147//       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
     148      // register scale of node
     149      registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
     150      registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
     151      registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3);
     152      //register staticity
     153      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
     154      //register acceleration
     155      // register velocity_
     156//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
     157//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
     158//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
    141159    }
    142160
  • code/branches/merge/src/orxonox/particle/ParticleInterface.cc

    r1039 r1264  
    6363  ParticleInterface::~ParticleInterface(void)
    6464  {
     65    while(particleSystem_->getNumEmitters()>0)
     66      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
    6567    sceneManager_->destroyParticleSystem(particleSystem_);
    6668  }
Note: See TracChangeset for help on using the changeset viewer.