- Timestamp:
- Dec 17, 2008, 5:41:29 AM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2493 r2497 32 32 #include <OgreBillboardSet.h> 33 33 34 #include "core/Core.h" 34 35 #include "core/CoreIncludes.h" 35 36 #include "objects/Scene.h" … … 43 44 RegisterObject(BillboardProjectile); 44 45 45 assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity 46 if (Core::showsGraphics()) 47 { 48 assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity 49 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1); 50 this->attachOgreObject(this->billboard_.getBillboardSet()); 51 } 46 52 47 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1); 48 this->attachOgreObject(this->billboard_.getBillboardSet()); 49 this->scale(0.2); 53 this->setScale(0.2); 50 54 } 51 55 52 56 BillboardProjectile::~BillboardProjectile() 53 57 { 54 //if (this->isInitialized() && this->owner_)55 //this->detachObject(this->billboard_.getBillboardSet());58 if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet()) 59 this->detachOgreObject(this->billboard_.getBillboardSet()); 56 60 } 57 61 … … 64 68 { 65 69 SUPER(BillboardProjectile, changedVisibility); 70 66 71 this->billboard_.setVisible(this->isVisible()); 67 72 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2493 r2497 33 33 #include <OgreParticleEmitter.h> 34 34 35 #include " ../../worldentities/pawns/SpaceShip.h"35 #include "core/Core.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" … … 46 46 RegisterObject(ParticleProjectile); 47 47 48 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal); 49 this->attachOgreObject(this->particles_->getParticleSystem()); 50 this->particles_->setKeepParticlesInLocalSpace(0); 48 if (Core::showsGraphics()) 49 { 50 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal); 51 this->attachOgreObject(this->particles_->getParticleSystem()); 52 this->particles_->setKeepParticlesInLocalSpace(0); 51 53 52 this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT); 53 /* 54 if (this->owner_) 55 { 54 this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT); 56 55 } 57 // else 58 // { 59 // this->particles_ = 0; 60 // } 61 */ 62 63 this->setConfigValues(); 56 else 57 this->particles_ = 0; 64 58 } 65 59 … … 73 67 } 74 68 75 void ParticleProjectile::setConfigValues()76 {77 //SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged);78 }79 80 69 void ParticleProjectile::changedVisibility() 81 70 { 82 71 SUPER(ParticleProjectile, changedVisibility); 83 this->particles_->setEnabled(this->isVisible()); 72 73 if (this->particles_) 74 this->particles_->setEnabled(this->isVisible()); 84 75 } 85 76 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h
r2493 r2497 44 44 virtual ~ParticleProjectile(); 45 45 virtual void changedVisibility(); 46 void setConfigValues();47 46 48 47 private: -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2494 r2497 40 40 #include "objects/worldentities/Model.h" 41 41 #include "objects/worldentities/ParticleSpawner.h" 42 #include "objects/worldentities/pawns/Pawn.h"43 42 #include "objects/collisionshapes/SphereCollisionShape.h" 44 43 #include "core/Core.h" … … 63 62 this->attachCollisionShape(shape); 64 63 65 if( !Core::isClient()) //only if not on client64 if(Core::isMaster()) 66 65 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject))); 67 66 } … … 91 90 void Projectile::destroyObject() 92 91 { 93 delete this; 92 if (Core::isMaster()) 93 delete this; 94 94 } 95 95 96 96 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 97 97 { 98 if (!this->bDestroy_ )98 if (!this->bDestroy_ && Core::isMaster()) 99 99 { 100 100 this->bDestroy_ = true; 101 Pawn* victim = dynamic_cast<Pawn*>(otherObject);102 if (victim)103 victim->damage(this->damage_, this->owner_);104 105 101 106 102 if (this->owner_) … … 123 119 } 124 120 } 121 122 Pawn* victim = dynamic_cast<Pawn*>(otherObject); 123 if (victim) 124 victim->damage(this->damage_, this->owner_); 125 125 } 126 126 return false; 127 127 } 128 129 void Projectile::destroyedPawn(Pawn* pawn) 130 { 131 if (this->owner_ == pawn) 132 this->owner_ = 0; 133 } 128 134 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
r2494 r2497 33 33 34 34 #include "objects/worldentities/MovableEntity.h" 35 #include "objects/worldentities/pawns/Pawn.h" 35 36 #include "tools/Timer.h" 36 37 37 38 namespace orxonox 38 39 { 39 class _OrxonoxExport Projectile : public MovableEntity 40 class _OrxonoxExport Projectile : public MovableEntity, public PawnListener 40 41 { 41 42 public: … … 48 49 virtual void tick(float dt); 49 50 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 51 virtual void destroyedPawn(Pawn* pawn); 50 52 51 53 inline void setOwner(Pawn* owner)
Note: See TracChangeset
for help on using the changeset viewer.