Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 7, 2008, 4:39:42 PM (16 years ago)
Author:
scheusso
Message:

different enhancements in input/network handling and synchronisation

File:
1 edited

Legend:

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

    r1234 r1245  
    104104        this->setRotationAxis(1, 0, 0);
    105105        this->setStatic(false);
    106 /*
    107         this->moveForward_ = 0;
    108         this->rotateUp_ = 0;
    109         this->rotateDown_ = 0;
    110         this->rotateRight_ = 0;
    111         this->rotateLeft_ = 0;
    112         this->loopRight_ = 0;
    113         this->loopLeft_ = 0;
    114         this->brakeForward_ = 0;
    115         this->brakeRotate_ = 0;
    116         this->brakeLoop_ = 0;
    117         this->speedForward_ = 0;
    118         this->speedRotateUpDown_ = 0;
    119         this->speedRotateRightLeft_ = 0;
    120         this->speedLoopRightLeft_ = 0;
    121         this->maxSpeedForward_ = 0;
    122         this->maxSpeedRotateUpDown_ = 0;
    123         this->maxSpeedRotateRightLeft_ = 0;
    124         this->maxSpeedLoopRightLeft_ = 0;
    125         this->accelerationForward_ = 0;
    126         this->accelerationRotateUpDown_ = 0;
    127         this->accelerationRotateRightLeft_ = 0;
    128         this->accelerationLoopRightLeft_ = 0;
    129 
    130         this->speed = 250;
    131         this->loop = 100;
    132         this->rotate = 10;
    133         this->mouseX = 0;
    134         this->mouseY = 0;
    135         this->maxMouseX = 0;
    136         this->minMouseX = 0;
    137         this->moved = false;
    138 
    139         this->brakeRotate(rotate*10);
    140         this->brakeLoop(loop);
    141 */
    142 //         this->create();
    143106
    144107
     
    161124
    162125    void SpaceShip::registerAllVariables(){
    163       registerVar( &camName_, camName_.length()+1, network::STRING);
     126      registerVar( &camName_, camName_.length()+1, network::STRING, 0x1);
     127      registerVar( &maxSpeed_, sizeof(maxSpeed_), network::DATA, 0x1);
     128      registerVar( &maxSideAndBackSpeed_, sizeof(maxSideAndBackSpeed_), network::DATA, 0x1);
     129      registerVar( &maxRotation_, sizeof(maxRotation_), network::DATA, 0x1);
     130      registerVar( &translationAcceleration_, sizeof(translationAcceleration_), network::DATA, 0x1);
     131      registerVar( &rotationAcceleration_, sizeof(rotationAcceleration_), network::DATA, 0x1);
     132      registerVar( &rotationAccelerationRadian_, sizeof(rotationAccelerationRadian_), network::DATA, 0x1);
     133      registerVar( &translationDamping_, sizeof(translationDamping_), network::DATA, 0x1);
     134      registerVar( &rotationDamping_, sizeof(rotationDamping_), network::DATA, 0x1);
     135      registerVar( &rotationDampingRadian_, sizeof(rotationDampingRadian_), network::DATA, 0x1);
     136     
    164137    }
    165138
    166139    void SpaceShip::init()
    167140    {
    168         COUT(4) << "================ \t\t\t\tspaceship::init" << std::endl;
     141//         COUT(4) << "================ \t\t\t\tspaceship::init" << std::endl;
    169142        // START CREATING THRUSTER
    170143        this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
     
    197170        this->greenNode_->setInheritScale(false);
    198171
    199         COUT(4) << "attaching red billboard" << std::endl;
     172//         COUT(4) << "attaching red billboard" << std::endl;
    200173        this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
    201174        this->redNode_->setScale(0.3, 0.3, 0.3);
    202175
    203         COUT(4) << "attaching green billboard" << std::endl;
     176//         COUT(4) << "attaching green billboard" << std::endl;
    204177        this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
    205178        this->greenNode_->setScale(0.3, 0.3, 0.3);
     
    215188        this->chFarNode_->setInheritScale(false);
    216189
    217         COUT(4) << "attaching crosshair near billboard" << std::endl;
     190//         COUT(4) << "attaching crosshair near billboard" << std::endl;
    218191        this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
    219192        this->chNearNode_->setScale(0.2, 0.2, 0.2);
    220193
    221         COUT(4) << "attaching crosshair far billboard" << std::endl;
     194//         COUT(4) << "attaching crosshair far billboard" << std::endl;
    222195        this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
    223196        this->chFarNode_->setScale(0.4, 0.4, 0.4);
    224         COUT(4) << "attaching camera" << std::endl;
     197//         COUT(4) << "attaching camera" << std::endl;
    225198       
    226199        createCamera();
     
    237210    void SpaceShip::loadParams(TiXmlElement* xmlElem)
    238211    {
    239       COUT(4) << "using loadparams" << std::endl;
     212//       COUT(4) << "using loadparams" << std::endl;
    240213        Model::loadParams(xmlElem);
    241214        this->create();
     
    303276   
    304277    void SpaceShip::createCamera(){
    305       COUT(4) << "begin camera creation" << std::endl;
     278//       COUT(4) << "begin camera creation" << std::endl;
    306279      this->camNode_ = this->getNode()->createChildSceneNode(camName_);
    307280      COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl;
     
    313286      cam->lookAt(Vector3(0,20,0));
    314287      cam->roll(Degree(0));
    315       */COUT(4) << "creating new camera" << std::endl;
     288      *//*COUT(4) << "creating new camera" << std::endl;*/
    316289      cam_ = new Camera(this->camNode_);
    317       COUT(4) << "setting target node" << std::endl;
     290//       COUT(4) << "setting target node" << std::endl;
    318291      cam_->setTargetNode(this->getNode());
    319292      // this only applies to clients
    320       if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID)
     293      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
     294        this->setBacksync(true);
    321295        CameraHandler::getInstance()->requestFocus(cam_);
     296      }
    322297//        cam->setPosition(Vector3(0,-350,0));
    323298      //cam->roll(Degree(-90));
    324299
    325300      //this->camNode_->attachObject(cam);
    326       COUT(4) << "created camera" << std::endl;
     301//       COUT(4) << "created camera" << std::endl;
    327302    }
    328303
     
    460435    {
    461436        // only do this if not client TODO: remove this hack
    462       if (!network::Client::getSingleton() && InputManager::getSingleton().getMouse()->getEventCallback() != this)
     437      if ((!network::Client::getSingleton() || network::Client::getSingleton()->getShipID()==objectID ) && InputManager::getSingleton().getMouse()->getEventCallback() != this)
    463438        {
    464439            if (InputManager::getSingleton().getMouse())
     
    485460        if (this->bLMousePressed_ && this->timeToReload_ <= 0)
    486461        {
    487             new Projectile(this);
     462            Projectile *p = new Projectile(this);
     463            p->setBacksync(true);
    488464            this->timeToReload_ = this->reloadTime_;
    489465        }
     
    560536
    561537        if(!network::Client::getSingleton() || network::Client::getSingleton()->getShipID() == objectID){
     538          COUT(4) << "steering our ship: " << objectID << " mkeyboard: " << mKeyboard << std::endl;
    562539          if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    563540              this->acceleration_.x = this->translationAcceleration_;
     
    580557          else
    581558              this->momentum_ = 0;
    582         }
     559        }/*else
     560          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
    583561
    584562        WorldEntity::tick(dt);
Note: See TracChangeset for help on using the changeset viewer.