Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2008, 7:40:47 PM (16 years ago)
Author:
scheusso
Message:

merged network branch back to trunk

Location:
code/trunk/src/orxonox/objects
Files:
9 edited

Legend:

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

    r1755 r1907  
    5353        this->traillength_ = 1;
    5454
    55         this->getNode()->setInheritScale(false);
     55        this->configure(maxspeed, brakingtime, scale);
     56    }
     57   
     58    bool Backlight::create(){
     59      if(!WorldEntity::create())
     60        return false;
     61     
     62      this->getNode()->setInheritScale(false);
    5663
    57         this->billboard_.setBillboardSet("Flares/backlightflare");
    58         this->attachObject(this->billboard_.getBillboardSet());
     64      this->billboard_.setBillboardSet("Flares/backlightflare");
     65      this->attachObject(this->billboard_.getBillboardSet());
    5966
    60         this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
    61         this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
    62         this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
    63         this->ribbonTrail_->addNode(this->getNode());
     67      this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
     68      this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
     69      this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
     70      this->ribbonTrail_->addNode(this->getNode());
    6471
    65         this->configure(maxspeed, brakingtime, scale);
    6672
    67         this->ribbonTrail_->setTrailLength(this->maxTraillength_);
    68         this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
     73      this->ribbonTrail_->setTrailLength(this->maxTraillength_);
     74      this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
    6975
    7076        //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
    71         this->setTimeFactor(1.0f);
     77      this->setTimeFactor(1.0f);
     78     
     79      this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
     80      this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
     81      this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());
     82      this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);
     83      return true;
    7284    }
    7385
     
    100112    {
    101113        this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
     114    }
     115   
     116   
     117    void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){
     118      SUPER(Backlight, XMLPort, xmlelement, mode);
     119     
     120      Backlight::create();
    102121    }
    103122
     
    136155        this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
    137156        this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
    138         this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
    139         this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
    140157
    141158        this->brakefactor_ = this->maxLifeTime_ / brakingtime;
    142159
    143160        this->scale(scale);
    144         this->ribbonTrail_->setInitialWidth(0, this->width_ * scale);
    145         this->ribbonTrail_->setWidthChange(0, this->width_ * scale / this->maxLifeTime_ * Backlight::timeFactor_s);
    146161    }
    147162
  • code/trunk/src/orxonox/objects/Backlight.h

    r1608 r1907  
    4545
    4646            void setConfigValues();
     47            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4748            virtual void tick(float dt);
    4849            virtual void changedVisibility();
     50            virtual bool create();
    4951
    5052            void setColour(const ColourValue& colour);
  • code/trunk/src/orxonox/objects/BillboardProjectile.cc

    r1747 r1907  
    4242        RegisterObject(BillboardProjectile);
    4343
    44         if (this->owner_)
    45         {
    46             this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
    47             this->attachObject(this->billboard_.getBillboardSet());
    48             this->scale(0.5);
    49         }
     44        this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
     45        this->attachObject(this->billboard_.getBillboardSet());
     46        this->scale(0.5);
    5047    }
    5148
  • code/trunk/src/orxonox/objects/Model.cc

    r1789 r1907  
    4646
    4747    /**
    48      *
     48     * @brief Constructor
    4949     */
    5050    Model::Model()
     
    5454    }
    5555
     56    /**
     57     * @brief Destructor
     58     */
    5659    Model::~Model()
    5760    {
     
    8689      }
    8790      if(this->isExactlyA(Class(Model)))
    88         setObjectFrequency(300); //sync all 10 seconds (this only applies to asteroids and other isExactlyA(Model)
     91        setObjectFrequency(300); //sync all 10 seconds (this only applies to asteroids and other isExactlyA(Model)'s
    8992      return true;
    9093    }
  • code/trunk/src/orxonox/objects/ParticleProjectile.cc

    r1747 r1907  
    4242        RegisterObject(ParticleProjectile);
    4343
     44        this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
     45        this->particles_->addToSceneNode(this->getNode());
     46        this->particles_->setKeepParticlesInLocalSpace(true);
    4447        if (this->owner_)
    4548        {
    46             this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
    47             this->particles_->addToSceneNode(this->getNode());
    48             this->particles_->getAllEmitters()->setDirection(-this->owner_->getInitialDir());
    49             this->particles_->setKeepParticlesInLocalSpace(true);
    5049        }
    51         else
    52         {
    53             this->particles_ = 0;
    54         }
     50//        else
     51//        {
     52//            this->particles_ = 0;
     53//        }
    5554
    5655        this->setConfigValues();
     
    7372        this->particles_->setEnabled(this->isVisible());
    7473    }
     74   
     75    bool ParticleProjectile::create(){
     76      if(!Projectile::create())
     77        return false;
     78      this->particles_->getAllEmitters()->setDirection(-this->getOrientation()*Vector3(1,0,0));
     79      return true;
     80    }
    7581}
  • code/trunk/src/orxonox/objects/ParticleProjectile.h

    r1747 r1907  
    4545            virtual void changedVisibility();
    4646            void setConfigValues();
     47           
     48            virtual bool create();
    4749
    4850        private:
  • code/trunk/src/orxonox/objects/Projectile.cc

    r1824 r1907  
    4141#include "ParticleSpawner.h"
    4242#include "Model.h"
     43#include "Settings.h"
    4344
    4445namespace orxonox
     
    5657        this->setStatic(false);
    5758        this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
    58 
     59       
    5960        if (this->owner_)
    6061        {
     62            this->setOrientation(this->owner_->getOrientation());
    6163            this->setPosition(this->owner_->getPosition());
    62             this->setOrientation(this->owner_->getOrientation());
    6364            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    6465        }
    6566
    66         this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
     67        if(!orxonox::Settings::isClient()) //only if not on client
     68          this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
    6769    }
    6870
     
    122124        delete this;
    123125    }
     126   
     127    bool Projectile::create(){
     128      return WorldEntity::create();
     129    }
    124130}
  • code/trunk/src/orxonox/objects/Projectile.h

    r1747 r1907  
    4545            void destroyObject();
    4646            virtual void tick(float dt);
     47           
     48            virtual bool create();
    4749
    4850            static float getSpeed()
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1789 r1907  
    7878      for(it = ObjectList<SpaceShip>::begin(); it; ++it){
    7979        assert(it->isA(Class(SpaceShip)));
    80         if( (it)->myShip_ || (network::Host::running() && network::Host::getShipID()==(it)->objectID) ){
     80        if( (it)->myShip_ || (network::Host::running() && network::Host::getShipID()==(it)->getObjectID()) ){
    8181//        COUT(1) << "^^^^^^^^^^ myShip_:" << *it << " classname: " << (*it)->getIdentifier()->getName() << " objectid: " << (*it)->objectID << std::endl;
    8282          return *it;
     
    173173        if (!myShip_)
    174174        {
    175             if (network::Host::running())
    176                 //COUT(3) << "this id: " << this->objectID << " myShipID: " << network::Host::getShipID() << std::endl;
    177                 if (network::Host::running() && objectID == network::Host::getShipID())
    178                 {
    179                     if (!network::Host::isServer())
    180                         setObjectMode(0x3);
    181                     myShip_ = true;
    182                 }
    183         }
    184         else
    185             this->setRadarObjectColour(this->getProjectileColour());
    186         assert(Model::create());
    187         this->init();
    188         return true;
     175            if (network::Host::running() && getObjectID() == network::Host::getShipID())
     176            {
     177                if (!network::Host::isServer())
     178                    setObjectMode(0x3);
     179                myShip_ = true;
     180            }
     181            else
     182                this->setRadarObjectColour(this->getProjectileColour());
     183      }
     184      Model::create();
     185      this->init();
     186      return true;
    189187    }
    190188
     
    258256
    259257            // START CREATING ADDITIONAL EFFECTS
    260             /*this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
    261             this->attachObject(this->backlight_);
    262             this->backlight_->setPosition(-2.35, 0, 0.2);
    263             this->backlight_->setColour(this->getProjectileColour());
    264 
    265             this->smoke_ = new ParticleSpawner();
    266             this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
    267             this->attachObject(this->smoke_);
    268 
    269             this->fire_ = new ParticleSpawner();
    270             this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
    271             this->attachObject(this->fire_);
    272             */
     258            if(!network::Host::running()){
     259              this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
     260              this->backlight_->create();
     261              this->attachObject(this->backlight_);
     262              this->backlight_->setPosition(-2.35, 0, 0.2);
     263              this->backlight_->setColour(this->getProjectileColour());
     264 
     265              this->smoke_ = new ParticleSpawner();
     266              this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
     267              this->attachObject(this->smoke_);
     268 
     269              this->fire_ = new ParticleSpawner();
     270              this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
     271              this->attachObject(this->fire_);
     272            }
     273           
    273274            // END CREATING ADDITIONAL EFFECTS
    274275
     
    374375      //if(!network::Host::running() || network::Host::getShipID()==objectID){ //TODO: check this
    375376      if(myShip_){
    376         COUT(4) << "requesting focus for camera" << std::endl;
     377        COUT(5) << "requesting focus for camera" << std::endl;
    377378        //CameraHandler::getInstance()->requestFocus(cam_);
    378379        if(this->isExactlyA(Class(SpaceShip))){
    379380          getFocus();
    380           COUT(4) << "getting focus for obj id: " << objectID << std::endl;
     381          COUT(4) << "getting focus for obj id: " << getObjectID() << std::endl;
    381382        }else
    382           COUT(4) << "not getting focus (not exactly spaceship) for obj id: " << objectID << std::endl;
     383          COUT(5) << "not getting focus (not exactly spaceship) for obj id: " << getObjectID() << std::endl;
    383384      }else
    384         COUT(4) << "not getting focus (not my ship) for obj id: " << objectID << std::endl;
     385        COUT(5) << "not getting focus (not my ship) for obj id: " << getObjectID() << std::endl;
    385386    }
    386387
     
    478479            projectile->setColour(this->getProjectileColour());
    479480            projectile->create();
    480             if (projectile->classID == 0)
     481            if (projectile->getClassID() == 0)
    481482            {
    482483              COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
     
    573574        }
    574575
    575         COUT(5) << "steering our ship: " << objectID << std::endl;
     576        COUT(5) << "steering our ship: " << getObjectID() << std::endl;
    576577        this->acceleration_.x = 0;
    577578        this->acceleration_.y = 0;
Note: See TracChangeset for help on using the changeset viewer.