[Orxonox-commit 2118] r6834 - in code/branches/rocket: data/levels/includes data/particle src/modules/weapons src/modules/weapons/projectiles src/modules/weapons/weaponmodes
gnadler at orxonox.net
gnadler at orxonox.net
Mon May 3 13:40:16 CEST 2010
Author: gnadler
Date: 2010-05-03 13:40:16 +0200 (Mon, 03 May 2010)
New Revision: 6834
Added:
code/branches/rocket/data/particle/rocketfire2.particle
Modified:
code/branches/rocket/data/levels/includes/weaponsettings3.oxi
code/branches/rocket/src/modules/weapons/RocketController.cc
code/branches/rocket/src/modules/weapons/RocketController.h
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
Log:
Success:
Now rocket spawns somewhere around the ship and the orientation is more or less correct. The controller does nothing but change some pitch/roll (to be sure it does something).
I modified the rocketfire particle to produce rocketfire2.particle which is slightly smaller and matches the smaller rocket.
Modified: code/branches/rocket/data/levels/includes/weaponsettings3.oxi
===================================================================
--- code/branches/rocket/data/levels/includes/weaponsettings3.oxi 2010-05-03 11:38:59 UTC (rev 6833)
+++ code/branches/rocket/data/levels/includes/weaponsettings3.oxi 2010-05-03 11:40:16 UTC (rev 6834)
@@ -38,7 +38,7 @@
<LightningGun mode=1 muzzleoffset="0,0,0" />
</Weapon>
<Weapon>
- <SimpleRocketFire mode=2 muzzleoffset="0,0,0" />
+ <SimpleRocketFire mode=2 muzzleoffset="10,10,10" />
</Weapon>
</WeaponPack>
<WeaponPack>
Added: code/branches/rocket/data/particle/rocketfire2.particle
===================================================================
--- code/branches/rocket/data/particle/rocketfire2.particle (rev 0)
+++ code/branches/rocket/data/particle/rocketfire2.particle 2010-05-03 11:40:16 UTC (rev 6834)
@@ -0,0 +1,50 @@
+particle_system Orxonox/rocketfire2
+{
+ quota 300
+ material PE/explosion
+ particle_width 5
+ particle_height 2
+ cull_each false
+ renderer billboard
+ sorted false
+ local_space false
+ iteration_interval 0
+ nonvisible_update_timeout 0
+ billboard_type point
+ billboard_origin center
+ billboard_rotation_type texcoord
+ common_up_vector 0 1 0
+ point_rendering false
+ accurate_facing false
+
+ emitter Ellipsoid
+ {
+ angle 2
+ colour 1 0.682759 1 1
+ colour_range_start 1 0.682759 1 1
+ colour_range_end 1 0.682759 1 1
+ direction 0 0 1
+ emission_rate 1200
+ position 0 0 3
+ velocity 10
+ velocity_min 10
+ velocity_max 48
+ time_to_live 0.1
+ time_to_live_min 0.1
+ time_to_live_max 0.2
+ duration 0
+ duration_min 0
+ duration_max 0
+ repeat_delay 0
+ repeat_delay_min 0
+ repeat_delay_max 0
+ width 0.8
+ height 0.8
+ depth 4
+ }
+
+ affector Scaler
+ {
+ rate -20
+ }
+}
Modified: code/branches/rocket/src/modules/weapons/RocketController.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.cc 2010-05-03 11:38:59 UTC (rev 6833)
+++ code/branches/rocket/src/modules/weapons/RocketController.cc 2010-05-03 11:40:16 UTC (rev 6834)
@@ -31,8 +31,8 @@
#include "util/Math.h"
#include "weapons/projectiles/SimpleRocket.h"
#include "util/Debug.h"
+#include "weapons/weaponmodes/SimpleRocketFire.h"
-
namespace orxonox
{
/**
@@ -44,10 +44,9 @@
COUT(0)<< "RocketController constructed\n";
RegisterObject(RocketController);
- SimpleRocket* rocket = new SimpleRocket(this);
- rocket->setController(this);
+ this->rocket = new SimpleRocket(this);
+ this->rocket->setController(dynamic_cast<RocketController*>(this));
this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
-
}
@@ -61,11 +60,10 @@
{
SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity());
+ double rd = rand();
+ if (rd > 0.5) rocket->rotateRoll(5);
+ else rocket->rotatePitch(5);
-
- rocket->rotateYaw(0.2);
- //rocket->moveFrontBack(2);
-
}
Modified: code/branches/rocket/src/modules/weapons/RocketController.h
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.h 2010-05-03 11:38:59 UTC (rev 6833)
+++ code/branches/rocket/src/modules/weapons/RocketController.h 2010-05-03 11:40:16 UTC (rev 6834)
@@ -34,6 +34,7 @@
#include "controllers/Controller.h"
#include "tools/interfaces/Tickable.h"
#include "weapons/projectiles/SimpleRocket.h"
+#include "weapons/weaponmodes/SimpleRocketFire.h"
namespace orxonox
{
@@ -50,10 +51,12 @@
virtual ~RocketController();
virtual void tick(float dt);
+ SimpleRocket* getRocket(){return rocket;};
protected:
private:
+ SimpleRocket* rocket;
};
}
Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc 2010-05-03 11:38:59 UTC (rev 6833)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc 2010-05-03 11:40:16 UTC (rev 6834)
@@ -59,29 +59,22 @@
this->bDestroy_ = false;
this->lifetime_ = 100;
COUT(0)<< "simplerocket constructed\n";
- //this->camera_ = null;
- //RocketController* myRController = new RocketController(this);
- //this->setController(creator);
- //myRController->setRocket(this, myRController);
-
- //this->getController()->setControllableEntity(this);
- //myController->setControllableEntity(this);
- //this->getController()->setControllableEntity(this);
- //this->controllableEntity_->setController(this->controller_);
+
//if (GameMode::isMaster())
//{
- /* this->setCollisionType(WorldEntity::Kinematic);
- this->setVelocity(0,0,-100);*/
+ this->setCollisionType(WorldEntity::Kinematic);
+ this->setVelocity(0,0,100);
Model* model = new Model(this);
model->setMeshSource("rocket.mesh");
- //model->scale(0.7f);
+ model->scale(0.7f);
this->attach(model);
- /* ParticleEmitter* fire = new ParticleEmitter(this);
+
+ ParticleEmitter* fire = new ParticleEmitter(this);
this->attach(fire);
fire->setOrientation(this->getOrientation());
- fire->setSource("Orxonox/Rocketfire");
+ fire->setSource("Orxonox/rocketfire2");
this->enableCollisionCallback();
this->setCollisionResponse(false);
@@ -90,7 +83,7 @@
ConeCollisionShape* collisionShape = new ConeCollisionShape(this);
collisionShape->setRadius(3);
collisionShape->setHeight(500);
- this->attachCollisionShape(collisionShape);*/
+ this->attachCollisionShape(collisionShape);
this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this)));
// }
@@ -126,27 +119,7 @@
this->player_ = this->owner_->getPlayer();
}
- /**
- @brief
- Defines which actions the SimpleRocket has to take in each tick.
- @param dt
- The length of the tick.
- */
- void SimpleRocket::tick(float dt)
- {
- SUPER(SimpleRocket, tick, dt);
- if( this->hasLocalController() )
- {
- this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
- this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
- this->localAngularVelocity_ = 0;
-
- if( this->bDestroy_ )
- this->destroy();
- }
- }
-
bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
{
if (!this->bDestroy_ && GameMode::isMaster())
Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h 2010-05-03 11:38:59 UTC (rev 6833)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h 2010-05-03 11:40:16 UTC (rev 6834)
@@ -52,7 +52,6 @@
virtual ~SimpleRocket();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a SimpleRocket through XML.
- virtual void tick(float dt); //!< Defines which actions the SimpleRocket has to take in each tick.
virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
void destroyObject();
Modified: code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc 2010-05-03 11:38:59 UTC (rev 6833)
+++ code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc 2010-05-03 11:40:16 UTC (rev 6834)
@@ -44,6 +44,7 @@
SimpleRocketFire::SimpleRocketFire(BaseObject* creator) : WeaponMode(creator)
{
RegisterObject(SimpleRocketFire);
+
/* this->reloadTime_ = 0.20f;
this->bParallelReload_ = false;
@@ -60,18 +61,26 @@
void SimpleRocketFire::fire()
{
- SimpleRocket* rocket = new SimpleRocket(this);
- RocketController* con = new RocketController(this);
+ //SimpleRocket* rocket = new SimpleRocket(this);
+ RocketController* con = new RocketController(this);
+ SimpleRocket* rocket = con->getRocket();
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ rocket->setOrientation(this->getMuzzleOrientation());
+ rocket->setPosition(this->getMuzzlePosition());
+ rocket->setVelocity(this->getMuzzleDirection() * rocket->getVelocity());
+ rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ //con->getRocket()->setPosition(this->getMuzzlePosition());
+ //con->setControllableEntity(dynamic_cast<ControllableEntity*>(rocket));
+ //con->getControllableEntity()->setPosition(this->getMuzzlePosition());
-
- this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ /* this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
rocket->setOrientation(this->getMuzzleOrientation());
rocket->setPosition(this->getMuzzlePosition());
- rocket->scale(10);
+ rocket->scale(10);
rocket->setVelocity(this->getMuzzleDirection() * this->speed_);
rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
- rocket->setDamage(this->getDamage());
- //rocket->scale(2);
-
+ rocket->setDamage(this->getDamage());
+ rocket->scale(2);
+ */
}
}
More information about the Orxonox-commit
mailing list