- Timestamp:
- Oct 30, 2008, 2:44:48 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/objects/worldentities
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Billboard.cc
r2044 r2065 76 76 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); 77 77 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 78 this->billboard_.setVisible(this->isVisible()); 78 79 } 79 80 } … … 90 91 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); 91 92 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 93 this->billboard_.setVisible(this->isVisible()); 92 94 } 93 95 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/BlinkingBillboard.cc
r2063 r2065 30 30 #include "BlinkingBillboard.h" 31 31 32 #include "core/Core.h" 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/XMLPort.h" 35 #include "util/Math.h" 34 36 35 37 namespace orxonox … … 44 46 this->frequency_ = 1.0f; 45 47 this->phase_ = 0; 48 this->bQuadratic_ = false; 46 49 this->time_ = 0; 47 50 … … 60 63 XMLPortParam(BlinkingBillboard, "frequency", setFrequency, getFrequency, xmlelement, mode).defaultValues(1.0f); 61 64 XMLPortParam(BlinkingBillboard, "phase", setPhase, getPhase, xmlelement, mode).defaultValues(Degree(0)); 65 XMLPortParam(BlinkingBillboard, "quadratic", setQuadratic, isQuadratic, xmlelement, mode).defaultValues(false); 62 66 } 63 67 64 68 void BlinkingBillboard::registerVariables() 65 69 { 66 REGISTERDATA(this->amplitude_, network::direction::toclient);67 REGISTERDATA(this->frequency_, network::direction::toclient);68 REGISTERDATA(this->phase_, network::direction::toclient);70 // REGISTERDATA(this->amplitude_, network::direction::toclient); 71 // REGISTERDATA(this->frequency_, network::direction::toclient); 72 // REGISTERDATA(this->phase_, network::direction::toclient); 69 73 } 70 74 71 75 void BlinkingBillboard::tick(float dt) 72 76 { 73 this->time_ += dt; 74 this->setScale(this->amplitude_ * sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_)); 77 if (Core::isMaster()) 78 { 79 this->time_ += dt; 80 if (this->bQuadratic_) 81 this->setScale(this->amplitude_ * square(sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_))); 82 else 83 this->setScale(this->amplitude_ * sin((6.2831853 * this->time_ + this->phase_.valueRadians()) * this->frequency_)); 84 } 75 85 } 76 86 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/BlinkingBillboard.h
r2063 r2065 62 62 { return this->phase_; } 63 63 64 inline void setQuadratic(bool bQuadratic) 65 { this->bQuadratic_ = bQuadratic; } 66 inline bool isQuadratic() const 67 { return this->bQuadratic_; } 68 64 69 private: 65 70 float amplitude_; 66 71 float frequency_; 67 72 Degree phase_; 73 bool bQuadratic_; 68 74 long double time_; 69 75 }; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
r2062 r2065 95 95 XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemkplate, xmlelement, mode); 96 96 97 XMLPortObject(ControllableEntity, WorldEntity, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode);97 XMLPortObject(ControllableEntity, CameraPosition, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode); 98 98 } 99 99 … … 239 239 else if (this->bControlled_) 240 240 { 241 COUT(2) << "setting client position" << endl;241 // COUT(2) << "setting client position" << endl; 242 242 this->client_velocity_ = this->velocity_; 243 243 this->client_position_ = this->node_->getPosition(); … … 249 249 { 250 250 REGISTERSTRING(this->cameraPositionTemplate_, network::direction::toclient); 251 252 253 REGISTERDATA(this->client_overwrite_, network::direction::toserver);254 REGISTERDATA(this->server_overwrite_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));255 251 256 252 REGISTERDATA(this->server_position_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); … … 258 254 REGISTERDATA(this->server_orientation_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 259 255 256 REGISTERDATA(this->server_overwrite_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 257 REGISTERDATA(this->client_overwrite_, network::direction::toserver); 260 258 261 259 REGISTERDATA(this->client_position_, network::direction::toserver, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); … … 301 299 if (this->server_overwrite_ == this->client_overwrite_) 302 300 { 303 COUT(2) << "callback: setting client position" << endl;301 // COUT(2) << "callback: setting client position" << endl; 304 302 this->node_->setPosition(this->client_position_); 305 303 this->server_position_ = this->client_position_; 306 304 } 307 else308 COUT(2) << "callback: not setting client position" << endl;305 // else 306 // COUT(2) << "callback: not setting client position" << endl; 309 307 } 310 308 … … 458 456 else if (this->bControlled_) 459 457 { 460 //this->node_->lookAt(target, relativeTo, localDirectionVector);458 this->node_->lookAt(target, relativeTo, localDirectionVector); 461 459 this->client_orientation_ = this->node_->getOrientation(); 462 460 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Light.cc
r2044 r2065 165 165 this->light_->setType(this->type_); 166 166 } 167 168 void Light::changedVisibility() 169 { 170 SUPER(Light, changedVisibility); 171 172 this->light_->setVisible(this->isVisible()); 173 } 167 174 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Light.h
r2044 r2065 49 49 void registerVariables(); 50 50 51 virtual void changedVisibility(); 52 51 53 inline Ogre::Light* getLight() 52 54 { return this->light_; } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Model.cc
r2040 r2065 76 76 this->getNode()->attachObject(this->mesh_.getEntity()); 77 77 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 78 this->mesh_.setVisible(this->isVisible()); 78 79 } 79 80 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.cc
r2027 r2065 30 30 #include "ParticleSpawner.h" 31 31 32 #include <OgreSceneManager.h>33 32 #include "core/CoreIncludes.h" 33 #include "core/EventIncludes.h" 34 34 #include "core/Executor.h" 35 #include "core/XMLPort.h" 35 36 #include "tools/ParticleInterface.h" 36 #include "GraphicsEngine.h"37 37 38 38 namespace orxonox … … 40 40 CreateFactory(ParticleSpawner); 41 41 42 ParticleSpawner::ParticleSpawner( )42 ParticleSpawner::ParticleSpawner(BaseObject* creator) : ParticleEmitter(creator) 43 43 { 44 44 RegisterObject(ParticleSpawner); 45 this->particle_ = 0;46 }47 45 48 ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction) 49 { 50 RegisterObject(ParticleSpawner); 51 this->setParticle(templateName, detaillevel, lifetime, startdelay, destroydelay, direction); 52 } 46 this->bAutostart_ = true; 47 this->bSuppressStart_ = false; 48 this->bAutoDestroy_ = true; 49 this->bForceDestroy_ = false; 50 this->bLoop_ = false; 51 this->startdelay_ = 0; 52 this->lifetime_ = 0; 53 this->destroydelay_ = 0; 53 54 54 void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction) 55 { 56 ExecutorMember<ParticleSpawner>* executor = createExecutor(createFunctor(&ParticleSpawner::createParticleSpawner)); 57 this->destroydelay_ = destroydelay; 58 executor->setDefaultValues(lifetime); 59 this->timer_.setTimer(startdelay, false, this, executor); 60 this->particle_ = new ParticleInterface(templateName, detaillevel); 61 this->particle_->addToSceneNode(this->getNode()); 62 this->particle_->setEnabled(false); 63 if (direction != Vector3::ZERO) 64 { 65 this->particle_->getAllEmitters()->setDirection(direction); 66 } 55 this->startParticleSpawner(); 67 56 } 68 57 69 58 ParticleSpawner::~ParticleSpawner() 70 59 { 71 if (this->isInitialized() && this->particle_)72 {73 this->particle_->detachFromSceneNode();74 delete this->particle_;75 }76 };77 78 void ParticleSpawner::destroy()79 {80 this->setPosition(this->getNode()->getParent()->getPosition());81 this->getNode()->getParent()->removeChild(this->getNode());82 this->detachFromParent();83 if (this->particle_)84 this->particle_->setEnabled(false);85 if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_)86 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));87 60 } 88 61 89 void ParticleSpawner:: createParticleSpawner(float lifetime)62 void ParticleSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode) 90 63 { 91 this->particle_->setEnabled(true); 92 if (lifetime != 0) 93 this->timer_.setTimer(lifetime, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner))); 64 SUPER(ParticleSpawner, XMLPort, xmlelement, mode); 65 66 XMLPortParam(ParticleSpawner, "autostart", setAutoStart, getAutoStart, xmlelement, mode).defaultValues(true); 67 XMLPortParam(ParticleSpawner, "autodestroy", setDestroyAfterLife, getDestroyAfterLife, xmlelement, mode).defaultValues(false); 68 XMLPortParam(ParticleSpawner, "loop", setLoop, getLoop, xmlelement, mode).defaultValues(false); 69 XMLPortParam(ParticleSpawner, "lifetime", setLifetime, getLifetime, xmlelement, mode).defaultValues(0.0f); 70 XMLPortParam(ParticleSpawner, "startdelay", setStartdelay, getStartdelay, xmlelement, mode).defaultValues(0.0f); 71 XMLPortParam(ParticleSpawner, "destroydelay", setDestroydelay, getDestroydelay, xmlelement, mode).defaultValues(0.0f); 72 } 73 74 void ParticleSpawner::processEvent(Event& event) 75 { 76 SUPER(ParticleSpawner, processEvent, event); 77 78 SetEvent(ParticleSpawner, "spawn", spawn, event); 79 } 80 81 void ParticleSpawner::configure(float lifetime, float startdelay, float destroydelay, bool autodestroy) 82 { 83 this->bAutoDestroy_ = autodestroy; 84 this->startdelay_ = startdelay; 85 this->lifetime_ = lifetime; 86 this->destroydelay_ = destroydelay; 87 } 88 89 void ParticleSpawner::startParticleSpawner() 90 { 91 if (!this->particles_) 92 return; 93 94 this->particles_->setEnabled(false); 95 96 if (this->bForceDestroy_ || this->bSuppressStart_) 97 return; 98 99 this->timer_.setTimer(this->startdelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner))); 100 } 101 102 void ParticleSpawner::fireParticleSpawner() 103 { 104 this->particles_->setEnabled(true); 105 if (this->lifetime_ != 0) 106 this->timer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&ParticleSpawner::stopParticleSpawner))); 107 } 108 109 void ParticleSpawner::stopParticleSpawner() 110 { 111 this->particles_->setEnabled(false); 112 113 if (this->bAutoDestroy_ || this->bForceDestroy_) 114 { 115 this->setPosition(this->getWorldPosition()); 116 this->detachFromParent(); 117 118 if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_) 119 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner))); 120 } 121 else if (this->bLoop_) 122 { 123 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner))); 124 } 94 125 } 95 126 … … 98 129 delete this; 99 130 } 100 101 void ParticleSpawner::setVisible(bool visible)102 {103 if (this->particle_)104 this->particle_->setEnabled(visible);105 }106 131 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleSpawner.h
r2044 r2065 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "P ositionableEntity.h"34 #include "ParticleEmitter.h" 35 35 #include "tools/Timer.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport ParticleSpawner : public P ositionableEntity39 class _OrxonoxExport ParticleSpawner : public ParticleEmitter 40 40 { 41 41 public: 42 ParticleSpawner(); 43 ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO); 42 ParticleSpawner(BaseObject* creator); 44 43 virtual ~ParticleSpawner(); 45 void destroy();46 44 47 void setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO); 48 inline ParticleInterface* getParticleInterface() const 49 { return this->particle_; } 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 virtual void processEvent(Event& event); 50 47 51 void setVisible(bool visible); 48 inline void destroy() 49 { this->bForceDestroy_ = true; this->stopParticleSpawner(); } 50 inline void spawn() 51 { this->bSuppressStart_ = false; this->startParticleSpawner(); } 52 53 void configure(float lifetime = 0, float startdelay = 0, float destroydelay = 0, bool autodestroy = true); 54 55 inline void setAutoStart(bool autostart) 56 { this->bAutostart_ = autostart; this->bSuppressStart_ = !autostart; } 57 inline bool getAutoStart() const 58 { return this->bAutostart_; } 59 60 inline void setDestroyAfterLife(bool destroy) 61 { this->bAutoDestroy_ = destroy; } 62 inline bool getDestroyAfterLife() const 63 { return this->bAutoDestroy_; } 64 65 inline void setLoop(bool loop) 66 { this->bLoop_ = loop; } 67 inline bool getLoop() const 68 { return this->bLoop_; } 69 70 inline void setLifetime(float lifetime) 71 { this->lifetime_ = lifetime; this->startParticleSpawner(); } 72 inline float getLifetime() const 73 { return this->lifetime_; } 74 75 inline void setStartdelay(float startdelay) 76 { this->startdelay_ = startdelay; this->startParticleSpawner(); } 77 inline float getStartdelay() const 78 { return this->startdelay_; } 79 80 inline void setDestroydelay(float destroydelay) 81 { this->destroydelay_ = destroydelay; this->startParticleSpawner(); } 82 inline float getDestroydelay() const 83 { return this->destroydelay_; } 52 84 53 85 private: 54 void createParticleSpawner(float lifetime); 86 void startParticleSpawner(); 87 void fireParticleSpawner(); 88 void stopParticleSpawner(); 55 89 void destroyParticleSpawner(); 56 90 57 91 Timer<ParticleSpawner> timer_; 58 ParticleInterface* particle_; 92 93 bool bSuppressStart_; 94 bool bAutostart_; 95 bool bForceDestroy_; 96 bool bAutoDestroy_; 97 bool bLoop_; 98 float startdelay_; 99 float lifetime_; 59 100 float destroydelay_; 60 101 }; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/SpawnPoint.cc
r2040 r2065 78 78 { 79 79 this->getGametype()->pawnPreSpawn(entity); 80 80 81 this->spawn(entity); 82 81 83 if (this->template_) 82 84 entity->addTemplate(this->template_); 85 83 86 entity->postSpawn(); 87 84 88 this->getGametype()->pawnPostSpawn(entity); 89 90 this->fireEvent(); 85 91 } 86 92 return entity; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.h
r2040 r2065 134 134 { parent->attach(this); } 135 135 inline void detachFromParent() 136 { this->parent_->detach(this);}136 { if (this->parent_) { this->parent_->detach(this); } } 137 137 inline WorldEntity* getParent() const 138 138 { return this->parent_; } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.cc
r2031 r2065 128 128 this->bTriggered_ = (newState & 0x1); 129 129 this->bActive_ = newState & 2; 130 this->fireEvent(this->bActive_); 130 131 this->stateChanges_.pop(); 131 132 if (this->stateChanges_.size() != 0)
Note: See TracChangeset
for help on using the changeset viewer.