Changeset 1907 for code/trunk/src/orxonox/objects
- Timestamp:
- Oct 12, 2008, 7:40:47 PM (16 years ago)
- Location:
- code/trunk/src/orxonox/objects
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/Backlight.cc
r1755 r1907 53 53 this->traillength_ = 1; 54 54 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); 56 63 57 58 64 this->billboard_.setBillboardSet("Flares/backlightflare"); 65 this->attachObject(this->billboard_.getBillboardSet()); 59 66 60 61 62 63 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()); 64 71 65 this->configure(maxspeed, brakingtime, scale);66 72 67 68 73 this->ribbonTrail_->setTrailLength(this->maxTraillength_); 74 this->ribbonTrail_->setMaterialName("Trail/backlighttrail"); 69 75 70 76 //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; 72 84 } 73 85 … … 100 112 { 101 113 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(); 102 121 } 103 122 … … 136 155 this->maxTraillength_ = this->maxLifeTime_ * maxspeed; 137 156 this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_); 138 this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);139 this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);140 157 141 158 this->brakefactor_ = this->maxLifeTime_ / brakingtime; 142 159 143 160 this->scale(scale); 144 this->ribbonTrail_->setInitialWidth(0, this->width_ * scale);145 this->ribbonTrail_->setWidthChange(0, this->width_ * scale / this->maxLifeTime_ * Backlight::timeFactor_s);146 161 } 147 162 -
code/trunk/src/orxonox/objects/Backlight.h
r1608 r1907 45 45 46 46 void setConfigValues(); 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 48 virtual void tick(float dt); 48 49 virtual void changedVisibility(); 50 virtual bool create(); 49 51 50 52 void setColour(const ColourValue& colour); -
code/trunk/src/orxonox/objects/BillboardProjectile.cc
r1747 r1907 42 42 RegisterObject(BillboardProjectile); 43 43 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); 50 47 } 51 48 -
code/trunk/src/orxonox/objects/Model.cc
r1789 r1907 46 46 47 47 /** 48 * 48 * @brief Constructor 49 49 */ 50 50 Model::Model() … … 54 54 } 55 55 56 /** 57 * @brief Destructor 58 */ 56 59 Model::~Model() 57 60 { … … 86 89 } 87 90 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 89 92 return true; 90 93 } -
code/trunk/src/orxonox/objects/ParticleProjectile.cc
r1747 r1907 42 42 RegisterObject(ParticleProjectile); 43 43 44 this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal); 45 this->particles_->addToSceneNode(this->getNode()); 46 this->particles_->setKeepParticlesInLocalSpace(true); 44 47 if (this->owner_) 45 48 { 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);50 49 } 51 else52 {53 this->particles_ = 0;54 }50 // else 51 // { 52 // this->particles_ = 0; 53 // } 55 54 56 55 this->setConfigValues(); … … 73 72 this->particles_->setEnabled(this->isVisible()); 74 73 } 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 } 75 81 } -
code/trunk/src/orxonox/objects/ParticleProjectile.h
r1747 r1907 45 45 virtual void changedVisibility(); 46 46 void setConfigValues(); 47 48 virtual bool create(); 47 49 48 50 private: -
code/trunk/src/orxonox/objects/Projectile.cc
r1824 r1907 41 41 #include "ParticleSpawner.h" 42 42 #include "Model.h" 43 #include "Settings.h" 43 44 44 45 namespace orxonox … … 56 57 this->setStatic(false); 57 58 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 58 59 59 60 if (this->owner_) 60 61 { 62 this->setOrientation(this->owner_->getOrientation()); 61 63 this->setPosition(this->owner_->getPosition()); 62 this->setOrientation(this->owner_->getOrientation());63 64 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 64 65 } 65 66 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))); 67 69 } 68 70 … … 122 124 delete this; 123 125 } 126 127 bool Projectile::create(){ 128 return WorldEntity::create(); 129 } 124 130 } -
code/trunk/src/orxonox/objects/Projectile.h
r1747 r1907 45 45 void destroyObject(); 46 46 virtual void tick(float dt); 47 48 virtual bool create(); 47 49 48 50 static float getSpeed() -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1789 r1907 78 78 for(it = ObjectList<SpaceShip>::begin(); it; ++it){ 79 79 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()) ){ 81 81 // COUT(1) << "^^^^^^^^^^ myShip_:" << *it << " classname: " << (*it)->getIdentifier()->getName() << " objectid: " << (*it)->objectID << std::endl; 82 82 return *it; … … 173 173 if (!myShip_) 174 174 { 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; 189 187 } 190 188 … … 258 256 259 257 // 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 273 274 // END CREATING ADDITIONAL EFFECTS 274 275 … … 374 375 //if(!network::Host::running() || network::Host::getShipID()==objectID){ //TODO: check this 375 376 if(myShip_){ 376 COUT( 4) << "requesting focus for camera" << std::endl;377 COUT(5) << "requesting focus for camera" << std::endl; 377 378 //CameraHandler::getInstance()->requestFocus(cam_); 378 379 if(this->isExactlyA(Class(SpaceShip))){ 379 380 getFocus(); 380 COUT(4) << "getting focus for obj id: " << objectID<< std::endl;381 COUT(4) << "getting focus for obj id: " << getObjectID() << std::endl; 381 382 }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; 383 384 }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; 385 386 } 386 387 … … 478 479 projectile->setColour(this->getProjectileColour()); 479 480 projectile->create(); 480 if (projectile-> classID== 0)481 if (projectile->getClassID() == 0) 481 482 { 482 483 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output … … 573 574 } 574 575 575 COUT(5) << "steering our ship: " << objectID<< std::endl;576 COUT(5) << "steering our ship: " << getObjectID() << std::endl; 576 577 this->acceleration_.x = 0; 577 578 this->acceleration_.y = 0;
Note: See TracChangeset
for help on using the changeset viewer.