[Orxonox-commit 1449] r6167 - code/branches/presentation2/src/modules/weapons/projectiles
landauf at orxonox.net
landauf at orxonox.net
Thu Nov 26 19:41:49 CET 2009
Author: landauf
Date: 2009-11-26 19:41:49 +0100 (Thu, 26 Nov 2009)
New Revision: 6167
Modified:
code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc
code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h
Log:
- you don't have to set the syncMode of the CameraPosition to 0x0, this is already done in it's constructor
- you also don't have to attach or destroy the CameraPosition once it was added to a CE (it's automatically done)
- the same also holds for attached WorldEntities (like the model) - they get destroyed automatically unless they call setDeleteWithParent(false)
- ... and also for collision shapes
- you probably don't want a ParticleSpawner for the fire trail. ParticleEmitter is more suitable (for continuous particle effects)
</teaching>
Modified: code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc 2009-11-26 17:49:35 UTC (rev 6166)
+++ code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc 2009-11-26 18:41:49 UTC (rev 6167)
@@ -60,10 +60,10 @@
this->lifetime_ = 100;
this->bDestroy_ = false;
- this->model_ = new Model(this);
- this->model_->setMeshSource("rocket.mesh");
- this->attach(this->model_);
- ParticleSpawner* fire = new ParticleSpawner(this);
+ Model* model = new Model(this);
+ model->setMeshSource("rocket.mesh");
+ this->attach(model);
+ ParticleEmitter* fire = new ParticleEmitter(this);
this->attach(fire);
fire->setOrientation(this->getOrientation());
fire->setSource("Orxonox/rocketfire");
@@ -72,20 +72,18 @@
this->setCollisionResponse(false);
this->setCollisionType(Kinematic);
- this->collisionShape_ = new ConeCollisionShape(this);
- this->collisionShape_->setRadius(3);
- this->collisionShape_->setHeight(500);
- this->attachCollisionShape(this->collisionShape_);
+ ConeCollisionShape* collisionShape = new ConeCollisionShape(this);
+ collisionShape->setRadius(3);
+ collisionShape->setHeight(500);
+ this->attachCollisionShape(collisionShape);
this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Rocket::destroyObject, this)));
}
- this->camPosition_ = new CameraPosition(this);
- this->camPosition_->setPosition(0,10,40);
- this->camPosition_->setSyncMode(0x0);
- this->camPosition_->setAllowMouseLook(true);
- this->attach( this->camPosition_ );
- this->addCameraPosition( this->camPosition_ );
+ CameraPosition* camPosition = new CameraPosition(this);
+ camPosition->setPosition(0,10,40);
+ camPosition->setAllowMouseLook(true);
+ this->addCameraPosition(camPosition);
}
/**
@@ -96,13 +94,8 @@
{
if(this->isInitialized())
{
- if (GameMode::isMaster() && this->player_.get())
- {
- this->model_->destroy();
- this->collisionShape_->destroy();
+ if (GameMode::isMaster() && this->player_)
this->player_->stopTemporaryControl();
- }
- this->camPosition_->destroy();
}
}
Modified: code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h
===================================================================
--- code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h 2009-11-26 17:49:35 UTC (rev 6166)
+++ code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h 2009-11-26 18:41:49 UTC (rev 6167)
@@ -118,9 +118,6 @@
bool bDestroy_;
ControllableEntity* originalControllableEntity_;
- Model* model_;
- CameraPosition* camPosition_;
- ConeCollisionShape* collisionShape_;
WeakPtr<PlayerInfo> player_;
Timer destroyTimer_;
float lifetime_;
More information about the Orxonox-commit
mailing list