Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 1, 2008, 3:54:20 PM (16 years ago)
Author:
rgrieder
Message:
  • @everyone: Do not create a branch until I've added the svn:eol-style property correctly. Otherwise this would cost me another 4 hours or so when we want to merge back.
  • merged network branch back to trunk
  • I had to omit the changes from last evening concerning the line endings
  • might not work yet because of the line endings
  • @beni: script branch is the only branch still open. you probably will have to apply a patch because of inconsistent new lines
Location:
code/trunk/src/orxonox/objects
Files:
21 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/Ambient.cc

    r1293 r1502  
    4747namespace orxonox
    4848{
    49     ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false).setDefaultValues(ColourValue(1, 1, 1, 1));
     49    SetConsoleCommand(Ambient, setAmbientLightTest, false).setDefaultValues(ColourValue(1, 1, 1, 1)).setAccessLevel(AccessLevel::Offline);
    5050
    5151    CreateFactory(Ambient);
     
    6666    bool Ambient::create(){
    6767      GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
    68       return true;
     68      return Synchronisable::create();
    6969    }
    7070   
  • code/trunk/src/orxonox/objects/Ambient.h

    r1293 r1502  
    4747            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4848            void setAmbientLight(const ColourValue& colour);
    49             bool create();
     49            virtual bool create();
    5050            void registerAllVariables();
    5151
  • code/trunk/src/orxonox/objects/Camera.cc

    r1293 r1502  
    6060  {
    6161    CameraHandler::getInstance()->releaseFocus(this);
     62    GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
    6263  }
    6364
     
    7576  void Camera::tick(float dt)
    7677  {
    77     if(this->positionNode_ != NULL) {
     78    if (this->positionNode_ != NULL)
     79    {
    7880      // this stuff here may need some adjustments
    79       Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getPosition();
    80       this->cameraNode_->translate(15*dt*offset);
     81      Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getWorldPosition();
     82      float coeff = 15.0f * dt;
     83      if (coeff > 1.0f)
     84        coeff = 1.0f;
    8185
    82       this->cameraNode_->setOrientation(Quaternion::Slerp(0.7, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false));
     86      this->cameraNode_->translate(coeff * offset);
     87
     88      this->cameraNode_->setOrientation(Quaternion::Slerp(7.0f * dt, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false));
    8389    }
    8490  }
  • code/trunk/src/orxonox/objects/Camera.h

    r1407 r1502  
    5050        void setTargetNode(Ogre::SceneNode* obj);
    5151
     52        Ogre::Camera* cam_;
     53
    5254        void tick(float dt);
    5355        void update();
     
    6365        Ogre::SceneNode* cameraNode_;
    6466        Ogre::Vector3 oldPos;
    65         Ogre::Camera* cam_;
    6667        bool bHasFocus_;
    6768    };
  • code/trunk/src/orxonox/objects/CameraHandler.cc

    r1293 r1502  
    2626 *
    2727 */
     28#include "OrxonoxStableHeaders.h"
     29#include "CameraHandler.h"
     30
    2831#include <OgreSceneManager.h>
    2932#include <OgreRenderWindow.h>
    3033
    31 #include "OrxonoxStableHeaders.h"
    3234#include "core/ObjectList.h"
    33 #include "CameraHandler.h"
    3435#include "Camera.h"
    3536#include "GraphicsEngine.h"
  • code/trunk/src/orxonox/objects/Explosion.cc

    r1293 r1502  
    7979        }
    8080    };
     81   
     82    /*bool Explosion::create(){
     83      if(!WorldEntity::create())
     84        return false;
     85      classID=this->getIdentifier()->getNetworkID();
     86    }*/
    8187
    8288    void Explosion::destroyObject()
  • code/trunk/src/orxonox/objects/Explosion.h

    r1056 r1502  
    4343            virtual ~Explosion();
    4444            void destroyObject();
     45            virtual bool create(){return WorldEntity::create();}
    4546
    4647        private:
  • code/trunk/src/orxonox/objects/Model.cc

    r1293 r1502  
    3434#include "GraphicsEngine.h"
    3535#include "core/XMLPort.h"
     36
     37#include <OgreEntity.h>
     38#include <OgreMesh.h>
     39#include <OgreHardwareVertexBuffer.h>
     40#include <OgreMeshManager.h>
     41
    3642
    3743namespace orxonox
     
    7783        this->mesh_.setMesh(meshSrc_);
    7884        this->attachObject(this->mesh_.getEntity());
     85
     86        //HACK!!
     87        /*if ((this->meshSrc_ == "assff.mesh") || (this->meshSrc_ == "ast1.mesh") || (this->meshSrc_ == "ast2.mesh") || (this->meshSrc_ == "ast3.mesh") || (this->meshSrc_ == "ast4.mesh") ||(this->meshSrc_ == "ast5.mesh") || (this->meshSrc_ == "ast6.mesh"))
     88        {
     89          Ogre::MeshPtr pMesh = this->mesh_.getEntity()->getMesh();
     90          //set Mesh to tangentspace
     91          unsigned short src, dest;
     92          if (!pMesh->suggestTangentVectorBuildParams(Ogre::VES_TANGENT, src, dest))
     93          {
     94            pMesh->buildTangentVectors(Ogre::VES_TANGENT, src, dest);
     95          }
     96          if ((this->meshSrc_ == "assff.mesh"))
     97          {
     98            (this->mesh_.getEntity())->setMaterialName("Assff/BumpMap");
     99          }
     100          else
     101          {
     102            (this->mesh_.getEntity())->setMaterialName("Asteroid/BumpMap");
     103          }
     104
     105
     106        }*/
    79107        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
    80108      }
  • code/trunk/src/orxonox/objects/Model.h

    r1293 r1502  
    4545            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4646            void setMesh(const std::string& meshname);
    47             bool create();
     47            virtual bool create();
    4848
    4949        protected:
  • code/trunk/src/orxonox/objects/NPC.cc

    r1293 r1502  
    6767  }
    6868 
    69   bool NPC::create(){
    70     Model::create();
    71     return true;
    72   }
    7369
    7470  /**
  • code/trunk/src/orxonox/objects/NPC.h

    r1293 r1502  
    5353      void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable);
    5454      void registerAllVariables();
    55       bool create();
     55      virtual bool create(){return Model::create();}
    5656
    5757    private:
  • code/trunk/src/orxonox/objects/Projectile.cc

    r1360 r1502  
    3030#include "Projectile.h"
    3131
     32#include <OgreBillboard.h>
     33
    3234#include "core/CoreIncludes.h"
    3335#include "core/Executor.h"
     
    4143{
    4244    CreateFactory(Projectile);
     45
     46    float Projectile::speed_ = 0;
    4347
    4448    Projectile::Projectile(SpaceShip* owner) :
     
    6367
    6468        this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
    65         this->classID = this->getIdentifier()->getNetworkID(); // TODO: remove this hack
    6669//        COUT(3) << this->classID << std::endl;
    6770    }
     
    9295                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
    9396                {
    94                     new Explosion(this);
     97                    Explosion *exp = new Explosion(this);
     98                    exp->create();
    9599                    delete this;
    96100                    return;
     
    104108        delete this;
    105109    }
     110
     111    void Projectile::setColour(const ColourValue& colour)
     112    {
     113        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
     114    }
    106115}
  • code/trunk/src/orxonox/objects/Projectile.h

    r1056 r1502  
    3535#include "../tools/BillboardSet.h"
    3636#include "../tools/Timer.h"
     37#include "util/Math.h"
    3738
    3839namespace orxonox
     
    4647            void destroyObject();
    4748            virtual void tick(float dt);
     49            virtual bool create(){return WorldEntity::create();}
     50            void setColour(const ColourValue& colour);
     51
     52            static float getSpeed()
     53                { return Projectile::speed_; }
     54
     55        protected:
     56            SpaceShip* owner_;
    4857
    4958        private:
    50             SpaceShip* owner_;
    5159            BillboardSet billboard_;
    52             float speed_;
     60            static float speed_;
    5361            float lifetime_;
    5462            Timer<Projectile> destroyTimer_;
  • code/trunk/src/orxonox/objects/Skybox.cc

    r1293 r1502  
    9090    bool Skybox::create(){
    9191      this->setSkybox(skyboxSrc_);
    92       return true;
     92      return Synchronisable::create();
    9393    }
    9494   
  • code/trunk/src/orxonox/objects/Skybox.h

    r1293 r1502  
    4747            void setSkybox(const std::string& skyboxname);
    4848           
    49             bool create();
     49            virtual bool create();
    5050            void registerAllVariables();
    5151            void setSkyboxSrc(const std::string &src);
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1407 r1502  
    4545#include "particle/ParticleInterface.h"
    4646#include "Projectile.h"
     47#include "RotatingProjectile.h"
    4748#include "core/XMLPort.h"
    4849#include "core/ConsoleCommand.h"
    4950#include "network/Client.h"
     51#include "hud/HUD.h"
    5052
    5153namespace orxonox
    5254{
    53     ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false);
    54     ConsoleCommand(SpaceShip, whereAmI, AccessLevel::User, true);
    55     ConsoleCommandGeneric(test1, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed", AccessLevel::Debug), false);
    56     ConsoleCommandGeneric(test2, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber", AccessLevel::Debug), false);
    57     ConsoleCommandGeneric(test3, SpaceShip, createExecutor(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl", AccessLevel::Debug), false);
     55    SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).setAccessLevel(AccessLevel::Debug);
     56    SetConsoleCommand(SpaceShip, whereAmI, true).setAccessLevel(AccessLevel::User);
     57    SetConsoleCommand(SpaceShip, moveLongitudinal, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
     58    SetConsoleCommand(SpaceShip, moveLateral, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
     59    SetConsoleCommand(SpaceShip, moveYaw, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
     60    SetConsoleCommand(SpaceShip, movePitch, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
     61    SetConsoleCommand(SpaceShip, moveRoll, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
     62    SetConsoleCommand(SpaceShip, fire, true).setAccessLevel(AccessLevel::User).setKeybindMode(KeybindMode::OnHold);
     63    SetConsoleCommandGeneric(test1, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed"), false).setAccessLevel(AccessLevel::Debug);
     64    SetConsoleCommandGeneric(test2, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber"), false).setAccessLevel(AccessLevel::Debug);
     65    SetConsoleCommandGeneric(test3, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl"), false).setAccessLevel(AccessLevel::Debug);
    5866
    5967    CreateFactory(SpaceShip);
     
    6472      Iterator<SpaceShip> it;
    6573      for(it = ObjectList<SpaceShip>::start(); it; ++it){
    66         if((it)->server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==it->objectID ) )
     74        if( (it)->myShip_ )
    6775          return *it;
    6876      }
    6977      return NULL;
    7078    }
    71    
     79
    7280    SpaceShip::SpaceShip() :
    7381      //testvector_(0,0,0),
     
    103111      mouseY_(0.0f),
    104112      emitterRate_(0.0f),
    105       server_(false)
     113      myShip_(false),
     114      teamNr_(0),
     115      health_(100)
    106116    {
    107117        RegisterObject(SpaceShip);
     
    112122        this->setConfigValues();
    113123
     124        initialDir_ = Vector3(1.0, 0.0, 0.0);
     125        currentDir_ = initialDir_;
     126        initialOrth_ = Vector3(0.0, 0.0, 1.0);
     127        currentOrth_ = initialOrth_;
     128
     129        this->camName_ = this->getName() + "CamNode";
    114130
    115131        this->setRotationAxis(1, 0, 0);
     
    127143        if (this->cam_)
    128144          delete this->cam_;
     145        if (!Identifier::isCreatingHierarchy() && !myShip_ && &HUD::getSingleton()!=NULL)
     146          //remove the radar object
     147          HUD::getSingleton().removeRadarObject(this->getNode());
    129148    }
    130149
    131150    bool SpaceShip::create(){
     151      if(!myShip_){
     152        if(network::Client::getSingleton() && objectID == network::Client::getSingleton()->getShipID())
     153          myShip_=true;
     154        else
     155          HUD::getSingleton().addRadarObject(this->getNode(), 3);
     156      }
    132157      if(Model::create())
    133158        this->init();
     
    153178    void SpaceShip::init()
    154179    {
    155         if ((server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==objectID ) ))
    156         {
    157               if (!setMouseEventCallback_)
    158               {
    159                   InputManager::addMouseHandler(this, "SpaceShip");
    160                   //InputManager::enableMouseHandler("SpaceShip");
    161                   setMouseEventCallback_ = true;
    162               }
    163         }
    164 
    165180        // START CREATING THRUSTER
    166181        this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
     
    200215        // END CREATING BLINKING LIGHTS
    201216
    202         // START of testing crosshair
    203         this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    204         this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
    205 
    206         this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
    207         this->chNearNode_->setInheritScale(false);
    208         this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
    209         this->chFarNode_->setInheritScale(false);
    210 
    211         this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
    212         this->chNearNode_->setScale(0.2, 0.2, 0.2);
    213 
    214         this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
    215         this->chFarNode_->setScale(0.4, 0.4, 0.4);
     217        if (this->isExactlyA(Class(SpaceShip)))
     218        {
     219            // START of testing crosshair
     220            this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     221            this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
     222
     223            this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
     224            this->chNearNode_->setInheritScale(false);
     225            this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
     226            this->chFarNode_->setInheritScale(false);
     227
     228            this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
     229            this->chNearNode_->setScale(0.2, 0.2, 0.2);
     230
     231            this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
     232            this->chFarNode_->setScale(0.4, 0.4, 0.4);
     233        }
    216234
    217235        createCamera();
     
    237255        CameraHandler::getInstance()->requestFocus(cam_);
    238256
     257    }
     258
     259    Camera* SpaceShip::getCamera(){
     260        return cam_;
    239261    }
    240262
     
    295317        XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
    296318        XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
    297         server_=true; // TODO: this is only a hack
     319        myShip_=true; // TODO: this is only a hack
     320
    298321        SpaceShip::create();
    299         getFocus();
     322        if (this->isExactlyA(Class(SpaceShip)))
     323            getFocus();
    300324    }
    301325
     
    308332    }
    309333
    310     void SpaceShip::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
    311     {
    312 /*
    313         this->mouseX += e.state.X.rel;
    314         if (this->bInvertMouse_)
    315             this->mouseY += e.state.Y.rel;
    316         else
    317             this->mouseY -= e.state.Y.rel;
    318 
    319 //        if(mouseX>maxMouseX) maxMouseX = mouseX;
    320 //        if(mouseX<minMouseX) minMouseX = mouseX;
    321 //        cout << "mouseX: " << mouseX << "\tmouseY: " << mouseY << endl;
    322 
    323         this->moved = true;
    324 */
    325         if (this->bRMousePressed_)
    326         {
    327             this->camNode_->roll(Degree(-rel.x * 0.10));
    328             this->camNode_->yaw(Degree(rel.y * 0.10));
    329         }
    330         else
    331         {
    332             float minDimension = clippingSize.y;
    333             if (clippingSize.x < minDimension)
    334                 minDimension = clippingSize.x;
    335 
    336             this->mouseX_ += rel.x;
    337             if (this->mouseX_ < -minDimension)
    338                 this->mouseX_ = -minDimension;
    339             if (this->mouseX_ > minDimension)
    340                 this->mouseX_ = minDimension;
    341 
    342             this->mouseY_ += rel.y;
    343             if (this->mouseY_ < -minDimension)
    344                 this->mouseY_ = -minDimension;
    345             if (this->mouseY_ > minDimension)
    346                 this->mouseY_ = minDimension;
    347 
    348             float xRotation = this->mouseX_ / minDimension;
    349             xRotation = xRotation*xRotation * sgn(xRotation);
    350             xRotation *= -this->rotationAcceleration_;
    351             if (xRotation > this->maxRotation_)
    352                 xRotation = this->maxRotation_;
    353             if (xRotation < -this->maxRotation_)
    354                 xRotation = -this->maxRotation_;
    355             this->mouseXRotation_ = Radian(xRotation);
    356 
    357             float yRotation = this->mouseY_ / minDimension;
    358             yRotation = yRotation*yRotation * sgn(yRotation);
    359             yRotation *= this->rotationAcceleration_;
    360             if (yRotation > this->maxRotation_)
    361                 yRotation = this->maxRotation_;
    362             if (yRotation < -this->maxRotation_)
    363                 yRotation = -this->maxRotation_;
    364             this->mouseYRotation_ = Radian(yRotation);
    365         }
    366     }
    367 
    368     void SpaceShip::mouseButtonPressed(MouseButton::Enum id)
    369     {
    370         if (id == MouseButton::Left)
    371             this->bLMousePressed_ = true;
    372         else if (id == MouseButton::Right)
    373             this->bRMousePressed_ = true;
    374     }
    375 
    376     void SpaceShip::mouseButtonReleased(MouseButton::Enum id)
    377     {
    378         if (id == MouseButton::Left)
    379             this->bLMousePressed_ = false;
    380         else if (id == MouseButton::Right)
    381         {
    382             this->bRMousePressed_ = false;
    383             this->camNode_->resetOrientation();
    384         }
    385     }
    386 
    387334    std::string SpaceShip::whereAmI() {
    388335        return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x)
     
    391338    }
    392339
    393     Vector3 SpaceShip::getSPosition() {
    394         return SpaceShip::getLocalShip()->getPosition();
    395     }
    396 
    397     Quaternion SpaceShip::getSOrientation() {
    398         return SpaceShip::getLocalShip()->getOrientation();
     340    Vector3 SpaceShip::getDir() {
     341        return currentDir_;
     342    }
     343
     344    Vector3 SpaceShip::getOrth(){
     345        return currentOrth_;
    399346    }
    400347
     
    403350    void SpaceShip::tick(float dt)
    404351    {
     352        currentDir_ = getOrientation()*initialDir_;
     353                currentOrth_ = getOrientation()*initialOrth_;
     354
    405355        if (this->cam_)
    406356            this->cam_->tick(dt);
     
    422372        if (this->bLMousePressed_ && this->timeToReload_ <= 0)
    423373        {
    424          
    425             Projectile *p = new Projectile(this);
    426            
     374
     375            Projectile *p;
     376            if (this->isExactlyA(Class(SpaceShip)))
     377                p = new RotatingProjectile(this);
     378            else
     379                p = new Projectile(this);
     380            p->setColour(this->getProjectileColour());
     381            p->create();
     382            if(p->classID==0)
     383              COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
     384
    427385            p->setBacksync(true);
    428386            this->timeToReload_ = this->reloadTime_;
     
    495453        }
    496454
    497         if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ )
    498         {
    499           COUT(4) << "steering our ship: " << objectID << std::endl;
    500           if (InputManager::isKeyDown(KeyCode::Up) || InputManager::isKeyDown(KeyCode::W))
    501             this->acceleration_.x = this->translationAcceleration_;
    502           else if(InputManager::isKeyDown(KeyCode::Down) || InputManager::isKeyDown(KeyCode::S))
    503             this->acceleration_.x = -this->translationAcceleration_;
    504           else
    505             this->acceleration_.x = 0;
    506 
    507           if (InputManager::isKeyDown(KeyCode::Right) || InputManager::isKeyDown(KeyCode::D))
    508             this->acceleration_.y = -this->translationAcceleration_;
    509           else if (InputManager::isKeyDown(KeyCode::Left) || InputManager::isKeyDown(KeyCode::A))
    510             this->acceleration_.y = this->translationAcceleration_;
    511           else
    512             this->acceleration_.y = 0;
    513 
    514           if (InputManager::isKeyDown(KeyCode::Delete) || InputManager::isKeyDown(KeyCode::Q))
    515             this->momentum_ = Radian(-this->rotationAccelerationRadian_);
    516           else if (InputManager::isKeyDown(KeyCode::PageDown) || InputManager::isKeyDown(KeyCode::E))
    517             this->momentum_ = Radian(this->rotationAccelerationRadian_);
    518           else
    519             this->momentum_ = 0;
    520         }/*else
    521           COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
    522455
    523456        WorldEntity::tick(dt);
     
    533466        else
    534467            this->tt_->setRate(0);
    535     }
    536 
     468
     469        if( myShip_ )
     470        {
     471          COUT(4) << "steering our ship: " << objectID << std::endl;
     472          this->acceleration_.x = 0;
     473          this->acceleration_.y = 0;
     474          this->momentum_ = 0;
     475          this->mouseXRotation_ = Radian(0);
     476          this->mouseYRotation_ = Radian(0);
     477          this->bLMousePressed_ = false;
     478        }/*else
     479          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
     480    }
     481
     482    void SpaceShip::movePitch(float val)
     483    {   getLocalShip()->setMovePitch(val);   }
     484    void SpaceShip::moveYaw(float val)
     485    {   getLocalShip()->setMoveYaw(val);   }
     486    void SpaceShip::moveRoll(float val)
     487    {   getLocalShip()->setMoveRoll(val);   }
     488    void SpaceShip::moveLongitudinal(float val)
     489    {   getLocalShip()->setMoveLongitudinal(val);   }
     490    void SpaceShip::moveLateral(float val)
     491    {   getLocalShip()->setMoveLateral(val);   }
     492    void SpaceShip::fire()
     493    {   getLocalShip()->doFire();   }
     494
     495    void SpaceShip::setMovePitch(float val)
     496    {
     497        val = -val * val * sgn(val) * this->rotationAcceleration_;
     498        if (val > this->maxRotation_)
     499            val = this->maxRotation_;
     500        if (val < -this->maxRotation_)
     501            val = -this->maxRotation_;
     502        this->mouseYRotation_ = Radian(val);
     503    }
     504
     505    void SpaceShip::setMoveYaw(float val)
     506    {
     507        val = -val * val * sgn(val) * this->rotationAcceleration_;
     508        if (val > this->maxRotation_)
     509            val = this->maxRotation_;
     510        if (val < -this->maxRotation_)
     511            val = -this->maxRotation_;
     512        this->mouseXRotation_ = Radian(val);
     513    }
     514
     515    void SpaceShip::setMoveRoll(float val)
     516    {
     517        this->momentum_ = Radian(-this->rotationAccelerationRadian_ * val);
     518        //COUT(3) << "rotating val: " << val << " acceleration: " << this->rotationAccelerationRadian_.valueDegrees() << std::endl;
     519    }
     520
     521    void SpaceShip::setMoveLongitudinal(float val)
     522    {
     523        this->acceleration_.x = this->translationAcceleration_ * val;
     524    }
     525
     526    void SpaceShip::setMoveLateral(float val)
     527    {
     528        this->acceleration_.y = -this->translationAcceleration_ * val;
     529    }
     530
     531    void SpaceShip::doFire()
     532    {
     533        this->bLMousePressed_ = true;
     534    }
    537535}
  • code/trunk/src/orxonox/objects/SpaceShip.h

    r1407 r1502  
    4141namespace orxonox
    4242{
    43     class _OrxonoxExport SpaceShip : public Model, public MouseHandler
     43    class _OrxonoxExport SpaceShip : public Model
    4444    {
    4545        public:
    46          
     46
    4747            static SpaceShip *getLocalShip();
    48            
     48
    4949            SpaceShip();
    5050            ~SpaceShip();
    51             bool create();
     51            virtual bool create();
    5252            void registerAllVariables();
    5353            void init();
     
    6464            void setTransDamp(float value);
    6565            void setRotDamp(float value);
     66            void getFocus();
    6667
    67             void getFocus();
    68             static SpaceShip* instance_s;
    69             static Vector3 getSPosition();
    70             static Quaternion getSOrientation();
    7168            static std::string whereAmI();
    7269            static void setMaxSpeedTest(float value)
    7370                { SpaceShip::instance_s->setMaxSpeed(value); }
    7471
    75             void mouseButtonPressed (MouseButton::Enum id);
    76             void mouseButtonReleased(MouseButton::Enum id);
    77             void mouseButtonHeld    (MouseButton::Enum id) { }
    78             void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
    79             void mouseScrolled      (int abs, int rel) { }
     72            static void movePitch(float value);
     73            static void moveYaw(float value);
     74            static void moveRoll(float value);
     75            static void moveLongitudinal(float value);
     76            static void moveLateral(float value);
     77            static void fire();
     78            void setMovePitch(float value);
     79            void setMoveYaw(float value);
     80            void setMoveRoll(float value);
     81            void setMoveLongitudinal(float value);
     82            void setMoveLateral(float value);
     83            void doFire();
    8084
    8185            float getMaxSpeed();
     86            Vector3 getDir();
     87            Vector3 getOrth();
     88            Camera* getCamera();
     89
     90            int getTeamNr() const
     91                { return this->teamNr_; }
     92            int getHealth() const
     93                { return this->health_; }
     94
     95            bool getMyShip(){return myShip_;}
     96
     97        protected:
     98            void setTeamNr(int teamNr)
     99                { this->teamNr_ = teamNr; }
    82100
    83101        private:
    84102            void createCamera();
     103            virtual ColourValue getProjectileColour() const
     104                { return ColourValue(1.0, 1.0, 0.5); }
    85105
    86106            Vector3 testvector_;
     107            Vector3 initialDir_;
     108            Vector3 currentDir_;
     109            Vector3 initialOrth_;
     110            Vector3 currentOrth_;
    87111            bool bInvertYAxis_;
    88112            bool setMouseEventCallback_;
     
    130154
    131155            float emitterRate_;
    132             bool server_;
     156
     157        protected:
     158            bool myShip_;
     159
     160            int teamNr_;
     161            int health_;
     162
     163            static SpaceShip* instance_s;
    133164    };
    134165}
  • code/trunk/src/orxonox/objects/WorldEntity.cc

    r1360 r1502  
    8585            this->rotationRate_ += (dt * this->momentum_);
    8686            this->rotate(this->rotationAxis_, dt * this->rotationRate_);
     87            //COUT(3) << "rotationrate: " << this->rotationRate_.valueDegrees() << " momentum: " << this->momentum_.valueDegrees() << std::endl;
    8788        }
    8889    }
     
    153154      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
    154155      //register acceleration & momentum
    155       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
    156       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
    157       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
    158       registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA);
     156//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x2);
     157//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x2);
     158//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x2);
     159//       registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA, 0x2); // only backsync
    159160    }
    160161
  • code/trunk/src/orxonox/objects/WorldEntity.h

    r1227 r1502  
    5353            virtual void loadParams(TiXmlElement* xmlElem);
    5454            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    55             inline bool create(){ return true; }
     55            virtual inline bool create(){ return Synchronisable::create(); }
    5656
    5757            void attachWorldEntity(WorldEntity* entity);
  • code/trunk/src/orxonox/objects/weapon/AmmunitionDump.h

    r1056 r1502  
    6060
    6161  protected:
    62     inline bool create() { return true; }
     62    inline bool create() { return Synchronisable::create(); }
    6363    void registerAllVariables();
    6464
  • code/trunk/src/orxonox/objects/weapon/BulletManager.h

    r1209 r1502  
    6060
    6161  protected:
    62     inline bool create() { return true; }
     62    inline bool create() { return Synchronisable::create(); }
    6363    void registerAllVariables();
    6464
Note: See TracChangeset for help on using the changeset viewer.