Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 5, 2008, 1:19:22 AM (17 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)

File:
1 edited

Legend:

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