Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 5, 2008, 1:19:22 AM (16 years ago)
Author:
scheusso
Message:

a lot of changes in order to make it possible to have mulpiple clients with each one a new ship
camera changes
object changes
synchronisable: backsyncronisation should be possible now
gamestatemanager/gamestateclient: functions for backsyncronisation
some changes in order to get the input system (the old one) on the client working
TODO something with the camera position is wrong at the moment (clientside)

Location:
code/branches/network3/src/orxonox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network3/src/orxonox/Orxonox.cc

    r1184 r1232  
    326326    orxonoxHUD_->setEnergyDistr(20,20,60);
    327327    hudOverlay->show();
     328    setupInputSystem();
    328329
    329330    client_g->establishConnection();
     
    362363  }
    363364
    364   void Orxonox::createScene(void)
     365  void Orxonox::createScene()
    365366  {
    366367          // Init audio
  • code/branches/network3/src/orxonox/objects/Camera.cc

    r1212 r1232  
    127127    COUT(0) << "t " << this->targetNode_->getPosition() << std::endl;
    128128    if(this->positionNode_ != NULL)
    129       //this->cam_->setPosition(this->positionNode_->getPosition());
     129      this->cam_->setPosition(this->positionNode_->getPosition());
    130130    if(this->targetNode_ != NULL)
    131131      this->cam_->lookAt(this->targetNode_->getPosition());
     
    139139  {
    140140    this->bHasFocus_ = false;
     141    this->positionNode_->detachObject(cam_);
    141142  }
    142143
  • code/branches/network3/src/orxonox/objects/Model.cc

    r1174 r1232  
    7373        XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
    7474
    75         create();
     75        Model::create();
    7676    }
    7777
  • code/branches/network3/src/orxonox/objects/SpaceShip.cc

    r1212 r1232  
    8080
    8181        this->camNode_ = 0;
     82        this->camName_ = "camNode";
    8283
    8384        this->tt_ = 0;
     
    160161
    161162    void SpaceShip::registerAllVariables(){
    162 
    163 
    164 
     163      registerVar( &camName_, camName_.length()+1, network::STRING);
    165164    }
    166165
    167166    void SpaceShip::init()
    168167    {
    169         createCamera();
     168        COUT(4) << "================ \t\t\t\tspaceship::init" << std::endl;
    170169        // START CREATING THRUSTER
    171170        this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
     
    198197        this->greenNode_->setInheritScale(false);
    199198
     199        COUT(4) << "attaching red billboard" << std::endl;
    200200        this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
    201201        this->redNode_->setScale(0.3, 0.3, 0.3);
    202202
     203        COUT(4) << "attaching green billboard" << std::endl;
    203204        this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
    204205        this->greenNode_->setScale(0.3, 0.3, 0.3);
     
    214215        this->chFarNode_->setInheritScale(false);
    215216
     217        COUT(4) << "attaching crosshair near billboard" << std::endl;
    216218        this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
    217219        this->chNearNode_->setScale(0.2, 0.2, 0.2);
    218220
     221        COUT(4) << "attaching crosshair far billboard" << std::endl;
    219222        this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
    220223        this->chFarNode_->setScale(0.4, 0.4, 0.4);
    221 
     224        COUT(4) << "attaching camera" << std::endl;
     225       
     226        createCamera();
    222227        // END of testing crosshair
    223228    }
     
    232237    void SpaceShip::loadParams(TiXmlElement* xmlElem)
    233238    {
     239      COUT(4) << "using loadparams" << std::endl;
    234240        Model::loadParams(xmlElem);
    235241        this->create();
     242        this->getFocus();
    236243/*
    237244        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
     
    284291    void SpaceShip::setCamera(const std::string& camera)
    285292    {
     293      camName_=camera;
    286294      // change camera attributes here, if you want to ;)
     295    }
     296   
     297    void SpaceShip::getFocus(){
     298      COUT(4) << "requesting focus" << std::endl;
     299      if(network::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID)
     300        CameraHandler::getInstance()->requestFocus(cam_);
     301     
    287302    }
    288303   
    289304    void SpaceShip::createCamera(){
    290       this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
    291       camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10));
     305      COUT(4) << "begin camera creation" << std::endl;
     306      this->camNode_ = this->getNode()->createChildSceneNode(camName_);
     307      COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl;
     308      this->camNode_->setPosition(this->getNode()->getPosition() + Vector3(-50,0,10));
     309      COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl;
    292310/*
    293311//        node->setInheritOrientation(false);
     
    295313      cam->lookAt(Vector3(0,20,0));
    296314      cam->roll(Degree(0));
    297 */
     315      */COUT(4) << "creating new camera" << std::endl;
    298316      cam_ = new Camera(this->camNode_);
     317      COUT(4) << "setting target node" << std::endl;
    299318      cam_->setTargetNode(this->getNode());
    300       CameraHandler::getInstance()->requestFocus(cam_);
     319      // this only applies to clients
     320      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID)
     321        CameraHandler::getInstance()->requestFocus(cam_);
    301322//        cam->setPosition(Vector3(0,-350,0));
    302323      //cam->roll(Degree(-90));
    303324
    304325      //this->camNode_->attachObject(cam);
    305      
     326      COUT(4) << "created camera" << std::endl;
    306327    }
    307328
     
    329350    void SpaceShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    330351    {
     352      COUT(4) << "using xmlport" << std::endl;
    331353        Model::XMLPort(xmlelement, mode);
    332354
     
    339361        XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
    340362        XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
     363       
     364        SpaceShip::create();
     365        getFocus();
    341366    }
    342367
     
    534559        }
    535560
    536         if(!network::Client::getSingleton()){
     561        if(!network::Client::getSingleton() || network::Client::getSingleton()->getShipID() == objectID){
    537562          if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    538563              this->acceleration_.x = this->translationAcceleration_;
  • code/branches/network3/src/orxonox/objects/SpaceShip.h

    r1212 r1232  
    6363            void setTransDamp(float value);
    6464            void setRotDamp(float value);
     65           
     66            void getFocus();
    6567
    6668            static void setMaxSpeedTest(float value)
     
    8385
    8486            Ogre::SceneNode* camNode_;
    85             Camera* cam_;
     87            Camera* cam_; 
     88            std::string camName_;
     89
    8690
    8791            ParticleInterface* tt_;
  • code/branches/network3/src/orxonox/objects/WorldEntity.cc

    r1191 r1232  
    190190        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
    191191       
    192         //create();
     192        WorldEntity::create();
    193193    }
    194194
     
    197197    {
    198198      // register coordinates
    199       registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
    200       registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
    201       registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA);
     199      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
     200      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3);
     201      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3);
    202202      // register orientation
    203       registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA);
    204       registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA);
    205       registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA);
    206       registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);
     203      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3);
     204      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3);
     205      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3);
     206      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
    207207      // register velocity_
    208       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
    209       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
    210       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA);
     208      registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
     209      registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
     210      registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
    211211      // register rotationAxis/rate
    212       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA);
    213       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA);
    214       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA);
    215       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);
     212      registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
     213      registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
     214      registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
     215      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
    216216      // register scale of node
    217       registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA);
    218       registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA);
    219       registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA);
     217      registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
     218      registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
     219      registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3);
    220220      //register staticity
    221       registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA);
     221      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
     222      //register acceleration
     223      // register velocity_
     224      registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
     225      registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
     226      registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
    222227    }
    223228
Note: See TracChangeset for help on using the changeset viewer.