[Orxonox-commit 2235] r6951 - in code/branches/presentation3: . data/levels data/levels/includes data/particle src/modules/weapons src/modules/weapons/projectiles src/modules/weapons/weaponmodes src/orxonox/controllers src/orxonox/gametypes src/orxonox/worldentities
scheusso at orxonox.net
scheusso at orxonox.net
Fri May 21 10:25:28 CEST 2010
Author: scheusso
Date: 2010-05-21 10:25:27 +0200 (Fri, 21 May 2010)
New Revision: 6951
Added:
code/branches/presentation3/data/particle/rocketfire2.particle
code/branches/presentation3/src/modules/weapons/RocketController.cc
code/branches/presentation3/src/modules/weapons/RocketController.h
code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc
code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h
code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.cc
code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.h
code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.h
code/branches/presentation3/src/orxonox/controllers/DroneController.cc
code/branches/presentation3/src/orxonox/controllers/DroneController.h
code/branches/presentation3/src/orxonox/gametypes/Testgame.cc
code/branches/presentation3/src/orxonox/gametypes/Testgame.h
code/branches/presentation3/src/orxonox/worldentities/Drone.cc
code/branches/presentation3/src/orxonox/worldentities/Drone.h
code/branches/presentation3/src/orxonox/worldentities/RocketDrone.cc
code/branches/presentation3/src/orxonox/worldentities/RocketDrone.h
Modified:
code/branches/presentation3/
code/branches/presentation3/data/levels/includes/weaponsettings3.oxi
code/branches/presentation3/data/levels/tutorial.oxw
code/branches/presentation3/src/modules/weapons/CMakeLists.txt
code/branches/presentation3/src/modules/weapons/projectiles/CMakeLists.txt
code/branches/presentation3/src/modules/weapons/weaponmodes/CMakeLists.txt
code/branches/presentation3/src/orxonox/controllers/AIController.cc
code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt
code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc
code/branches/presentation3/src/orxonox/controllers/NewHumanController.h
code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt
Log:
merged rocket branch into presentation3 and cleaned up some things (mostly debug output and intendation)
Property changes on: code/branches/presentation3
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
+ /code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
Modified: code/branches/presentation3/data/levels/includes/weaponsettings3.oxi
===================================================================
--- code/branches/presentation3/data/levels/includes/weaponsettings3.oxi 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/data/levels/includes/weaponsettings3.oxi 2010-05-21 08:25:27 UTC (rev 6951)
@@ -38,7 +38,7 @@
<LightningGun mode=1 muzzleoffset="0,0,0" />
</Weapon>
<Weapon>
- <RocketFire mode=2 muzzleoffset="0,0,0" />
+ <SimpleRocketFire mode=2 muzzleoffset="0,0,0" />
</Weapon>
</WeaponPack>
<WeaponPack>
Modified: code/branches/presentation3/data/levels/tutorial.oxw
===================================================================
--- code/branches/presentation3/data/levels/tutorial.oxw 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/data/levels/tutorial.oxw 2010-05-21 08:25:27 UTC (rev 6951)
@@ -15,13 +15,21 @@
<Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
<attached>
- <Model scale="10" mesh="drone.mesh"/>
+ <Model scale="1" mesh="drone.mesh"/>
</attached>
<collisionShapes>
<BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
</collisionShapes>
</Drone>
+<Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
+ <attached>
+ <Model scale="1" mesh="rocket.mesh"/>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
+ </collisionShapes>
+</Drone>
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
Copied: code/branches/presentation3/data/particle/rocketfire2.particle (from rev 6950, code/branches/rocket/data/particle/rocketfire2.particle)
===================================================================
--- code/branches/presentation3/data/particle/rocketfire2.particle (rev 0)
+++ code/branches/presentation3/data/particle/rocketfire2.particle 2010-05-21 08:25:27 UTC (rev 6951)
@@ -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/presentation3/src/modules/weapons/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/modules/weapons/CMakeLists.txt 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/modules/weapons/CMakeLists.txt 2010-05-21 08:25:27 UTC (rev 6951)
@@ -1,5 +1,6 @@
SET_SOURCE_FILES(WEAPONS_SRC_FILES
MuzzleFlash.cc
+ RocketController.cc
)
ADD_SUBDIRECTORY(munitions)
Copied: code/branches/presentation3/src/modules/weapons/RocketController.cc (from rev 6950, code/branches/rocket/src/modules/weapons/RocketController.cc)
===================================================================
--- code/branches/presentation3/src/modules/weapons/RocketController.cc (rev 0)
+++ code/branches/presentation3/src/modules/weapons/RocketController.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,140 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Gabriel Nadler, Originalfile: Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "RocketController.h"
+#include "projectiles/SimpleRocket.h"
+#include "util/Math.h"
+#include "weapons/projectiles/SimpleRocket.h"
+#include "util/Debug.h"
+#include "weapons/weaponmodes/SimpleRocketFire.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Constructor.
+ */
+ RocketController::RocketController(BaseObject* creator) : Controller(creator)
+ {
+ RegisterObject(RocketController);
+ COUT(5)<< "RocketController constructed\n";
+
+
+ this->rocket = new SimpleRocket(this);
+ this->rocket->setController(this);
+ this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
+ this->haha=0;
+ }
+
+
+ /**
+ @brief
+ The controlling happens here. This method defines what the controller has to do each tick.
+ @param dt
+ The duration of the tick.
+ */
+ void RocketController::tick(float dt)
+ {
+ haha++;
+
+ //if (haha<30)this->rocket->setVelocity(rocket->getVelocity()*1.03);
+ if (this->target_) {
+ this->setTargetPosition();
+ this->moveToTargetPosition();
+ }
+ if (haha>500) rocket->setDestroy();;
+
+ }
+
+
+ RocketController::~RocketController()
+ {
+ COUT(5)<< "RocketController destroyed\n";
+ }
+
+ void RocketController::setTargetPosition()
+ {
+ //this->targetPosition_=this->target_->getWorldPosition();
+ this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getWorldPosition(), this->target_->getVelocity());
+ }
+ void RocketController::moveToTargetPosition()
+ {
+ this->moveToPosition(this->targetPosition_);
+ }
+
+
+
+ void RocketController::setTarget(WorldEntity* target)
+ {
+ this->target_ = target;
+ COUT(0)<<"got target\n";
+ }
+
+ void RocketController::moveToPosition(const Vector3& target)
+ {
+ if (!this->getControllableEntity())
+ return;
+ float dx = target.x-this->getControllableEntity()->getPosition().x;
+ float dy = target.y-this->getControllableEntity()->getPosition().y;
+ COUT(4)<<"\n diff: ";
+ COUT(4)<<target-this->getControllableEntity()->getPosition() << endl;
+ //COUT(0)<<"\n 2D view: ";
+ /* COUT(0)<<this->getControllableEntity()->getPosition().x;
+ COUT(0)<<" ";
+ COUT(0)<<this->getControllableEntity()->getPosition().y;
+ COUT(0)<<" ";
+ COUT(0)<<this->getControllableEntity()->getPosition().z;
+ COUT(0)<<"\n";*/
+ Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
+ float distance = (target - this->getControllableEntity()->getPosition()).length();
+ //Vector3D diff =target-this->rocket->getPosition();
+ COUT(4) << "viewdirection: "<< coord << endl;
+ //COUT(0)<<" ";
+ //COUT(0)<<coord.y;
+ this->getControllableEntity()->rotateYaw(-0.8f*sgn(coord.x)*coord.x*coord.x);
+ this->getControllableEntity()->rotatePitch(0.8f*sgn(coord.y)*coord.y*coord.y);
+// this->getControllableEntity()->rotateYaw(10);
+// this->getControllableEntity()->rotatePitch(0);
+ //this->getControllableEntity()->rotatePitch(rotation.getPitch().valueRadians());
+ //this->getControllableEntity()->rotateYaw(rotation.getYaw().valueRadians());
+ //this->getControllableEntity()->moveUpDown(coord.y);
+ //this->getControllableEntity()->moveRightLeft(coord.x);
+ //this->getControllableEntity()->rotatePitch(coord);
+ // if (this->target_ || distance > 10)
+ // {
+ // // Multiply with 0.8 to make them a bit slower
+ //this->getControllableEntity()->rotateYaw(coord.x );
+ // this->getControllableEntity()->rotatePitch(coord.y);
+ // }
+ }
+
+
+
+
+}
Copied: code/branches/presentation3/src/modules/weapons/RocketController.h (from rev 6950, code/branches/rocket/src/modules/weapons/RocketController.h)
===================================================================
--- code/branches/presentation3/src/modules/weapons/RocketController.h (rev 0)
+++ code/branches/presentation3/src/modules/weapons/RocketController.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,72 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Gabriel Nadler, Originalfile: Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _RocketController_H__
+#define _RocketController_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "controllers/Controller.h"
+#include "tools/interfaces/Tickable.h"
+#include "weapons/projectiles/SimpleRocket.h"
+#include "weapons/weaponmodes/SimpleRocketFire.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Controller for the Drone of the PPS tutorial.
+ @author
+ Gabriel Nadler, Originalfile: Oli Scheuss
+ */
+ class _WeaponsExport RocketController : public Controller, public Tickable
+ {
+ public:
+ RocketController(BaseObject* creator);
+ virtual ~RocketController();
+
+ virtual void tick(float dt);
+ SimpleRocket* getRocket(){return this->rocket;};
+ void setTarget(WorldEntity* target);
+ protected:
+ void moveToPosition(const Vector3& target);
+ void setTargetPosition();
+ void moveToTargetPosition();
+
+ private:
+ SimpleRocket* rocket;
+ Vector3 targetPosition_;
+ WeakPtr<PlayerInfo> player_;
+ int haha;
+ WeakPtr<WorldEntity> target_;
+
+
+ };
+}
+
+#endif /* _RocketController_H__ */
Modified: code/branches/presentation3/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/CMakeLists.txt 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/modules/weapons/projectiles/CMakeLists.txt 2010-05-21 08:25:27 UTC (rev 6951)
@@ -4,4 +4,5 @@
Projectile.cc
LightningGunProjectile.cc
Rocket.cc
+ SimpleRocket.cc
)
Copied: code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc (from rev 6950, code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc)
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc (rev 0)
+++ code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,260 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "SimpleRocket.h"
+
+#include <BulletDynamics/Dynamics/btRigidBody.h>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "worldentities/pawns/Pawn.h"
+#include "graphics/ParticleSpawner.h"
+#include "graphics/Model.h"
+#include "objects/collisionshapes/ConeCollisionShape.h"
+#include "infos/PlayerInfo.h"
+#include "controllers/Controller.h"
+#include "weapons/RocketController.h"
+#include "sound/WorldSound.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+ CreateFactory(SimpleRocket);
+ // create the factory for the SimpleRocket
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ */
+ SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator)
+ {
+ RegisterObject(SimpleRocket);// - register the SimpleRocket class to the core
+
+ this->localAngularVelocity_ = 0;
+ this->bDestroy_ = false;
+ this->lifetime_ = 100;
+ COUT(4) << "simplerocket constructed\n";
+
+
+ if (GameMode::isMaster())
+ {
+ this->setCollisionType(WorldEntity::Kinematic);
+ this->setVelocity(0,0,100);
+
+ Model* model = new Model(this);
+ model->setMeshSource("rocket.mesh");
+ model->scale(0.7f);
+ this->attach(model);
+
+ ParticleEmitter* fire = new ParticleEmitter(this);
+ this->attach(fire);
+ fire->setOrientation(this->getOrientation());
+ fire->setSource("Orxonox/rocketfire2");
+
+ this->enableCollisionCallback();
+ this->setCollisionResponse(false);
+ this->setCollisionType(Kinematic);
+
+ // TODO: fix the orientation and size of this collision shape to match the rocket
+ ConeCollisionShape* collisionShape = new ConeCollisionShape(this);
+ collisionShape->setRadius(3);
+ collisionShape->setHeight(5);
+ this->attachCollisionShape(collisionShape);
+
+ this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this)));
+ }
+
+ }
+
+ void SimpleRocket::tick(float dt)
+ {
+ SUPER(SimpleRocket, tick, dt);
+
+ this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
+ this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
+ this->localAngularVelocity_ = 0;
+
+ if( this->bDestroy_ )
+ this->destroy();
+
+ }
+
+ /**s
+ @brief
+ Destructor. Destroys controller, if present and kills sounds, if playing.
+ */
+ SimpleRocket::~SimpleRocket()
+ {
+ if (this->isInitialized())
+ {
+ this->getController()->destroy();
+ COUT(4)<< "simplerocket destroyed\n";
+ }
+ }
+
+ /**
+ @brief
+ Method for creating a SimpleRocket through XML.
+ */
+ void SimpleRocket::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // this calls the XMLPort function of the parent class
+ SUPER(SimpleRocket, XMLPort, xmlelement, mode);
+ }
+
+ void SimpleRocket::setOwner(Pawn* owner)
+ {
+ this->owner_ = owner;
+ //this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
+ this->player_ = this->owner_->getPlayer();
+ }
+
+
+ bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ if (!this->bDestroy_ && GameMode::isMaster())
+ {
+ if (otherObject == this->owner_)
+ return false;
+
+ this->bDestroy_ = true;
+
+ if (this->owner_)
+ {
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/explosion4");
+ effect->setLifetime(2.0f);
+ }
+
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/smoke4");
+ effect->setLifetime(3.0f);
+ }
+ }
+
+ float dmg = this->damage_;
+// if (this->owner_)
+// dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
+
+ Pawn* victim = orxonox_cast<Pawn*>(otherObject);
+ if (victim)
+ victim->hit(this->owner_, contactPoint, dmg);
+ }
+ return false;
+ }
+
+ void SimpleRocket::destroyObject()
+ {
+ if (GameMode::isMaster())
+ {
+ this->destroy();
+ }
+ }
+
+ void SimpleRocket::setDestroy()
+ {
+ this->bDestroy_=true;
+ CCOUT(4)<<"trying to destroy";
+ }
+
+ void SimpleRocket::fired(unsigned int firemode)
+ {
+ if (this->owner_)
+ {
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/explosion4");
+ effect->setLifetime(2.0f);
+ }
+
+ {
+ ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
+ effect->setPosition(this->getPosition());
+ effect->setOrientation(this->getOrientation());
+ effect->setDestroyAfterLife(true);
+ effect->setSource("Orxonox/smoke4");
+ effect->setLifetime(3.0f);
+ }
+ this->destroy();
+ }
+ }
+
+ /**
+ @brief
+ Rotates the SimpleRocket around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void SimpleRocket::rotateYaw(const Vector2& value)
+ {
+ ControllableEntity::rotateYaw(value);
+
+ if( !this->isInMouseLook() )
+ this->localAngularVelocity_.y += value.x;
+ }
+
+ /**
+ @brief
+ Rotates the SimpleRocket around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void SimpleRocket::rotatePitch(const Vector2& value)
+ {
+ ControllableEntity::rotatePitch(value);
+
+ if( !this->isInMouseLook() )
+ this->localAngularVelocity_.x += value.x;
+ }
+
+ /**
+ @brief
+ Rotates the SimpleRocket around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void SimpleRocket::rotateRoll(const Vector2& value)
+ {
+ ControllableEntity::rotateRoll(value);
+
+ if( !this->isInMouseLook() )
+ this->localAngularVelocity_.z += value.x;
+ }
+
+}
Copied: code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h (from rev 6950, code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h)
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h (rev 0)
+++ code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,135 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _SimpleRocket_H__
+#define _SimpleRocket_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+#include "worldentities/ControllableEntity.h"
+
+namespace orxonox
+{
+ class ConeCollisionShape;
+
+ /**
+ @brief
+ SimpleRocket, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _WeaponsExport SimpleRocket : public ControllableEntity
+ {
+ public:
+ SimpleRocket(BaseObject* creator);
+ virtual ~SimpleRocket();
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a SimpleRocket through XML.
+
+ virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+ void destroyObject();
+
+ virtual void moveFrontBack(const Vector2& value){}
+ virtual void moveRightLeft(const Vector2& value){}
+ virtual void moveUpDown(const Vector2& value){}
+
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotatePitch(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+ void setDestroy();
+
+ /**
+ @brief Moves the SimpleRocket in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the SimpleRocket is to be moved.
+ */
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the SimpleRocket in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the SimpleRocket is to be moved.
+ */
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the SimpleRocket in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the SimpleRocket is to be moved.
+ */
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ /**
+ @brief Rotates the SimpleRocket around the y-axis by the specifed amount.
+ @param value The amount by which the SimpleRocket is to be rotated.
+ */
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the SimpleRocket around the x-axis by the specifed amount.
+ @param value The amount by which the SimpleRocket is to be rotated.
+ */
+ inline void rotatePitch(float value)
+ { COUT(0)<<"rotated rocket yaw";
+ this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the SimpleRocket around the z-axis by the specifed amount.
+ @param value The amount by which the SimpleRocket is to be rotated.
+ */
+ inline void rotateRoll(float value)
+ {
+ COUT(0)<<"rotated rocket roll";
+ this->rotateRoll(Vector2(value, 0)); }
+
+ void setOwner(Pawn* owner);
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+
+ inline void setDamage(float damage)
+ { this->damage_ = damage; }
+ inline float getDamage() const
+ { return this->damage_; }
+ virtual void fired(unsigned int firemode);
+
+
+ private:
+ WeakPtr<Pawn> owner_;
+ Vector3 localAngularVelocity_;
+ float damage_;
+ bool bDestroy_;
+
+
+ WeakPtr<PlayerInfo> player_;
+ Timer destroyTimer_;
+ float lifetime_;
+
+ };
+
+}
+
+#endif /* _SimpleRocket_H__ */
Modified: code/branches/presentation3/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/modules/weapons/weaponmodes/CMakeLists.txt 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/modules/weapons/weaponmodes/CMakeLists.txt 2010-05-21 08:25:27 UTC (rev 6951)
@@ -5,4 +5,5 @@
HsW01.cc
LightningGun.cc
RocketFire.cc
+ SimpleRocketFire.cc
)
Copied: code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.cc (from rev 6950, code/branches/rocket/src/modules/weapons/weaponmodes/DroneFire.cc)
===================================================================
--- code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.cc (rev 0)
+++ code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,74 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "DroneFire.h"
+
+#include "util/Math.h"
+#include "core/CoreIncludes.h"
+#include "worldentities/RocketDrone.h"
+
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ CreateFactory(DroneFire);
+
+ DroneFire::DroneFire(BaseObject* creator) : WeaponMode(creator)
+ {
+ RegisterObject(DroneFire);
+
+ // this->reloadTime_ = 2f;
+ //this->bParallelReload_ = false;
+ //this->damage_ = 100;
+ //this->speed_ = 100;
+
+ this->setMunitionName("LaserMunition");
+ // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
+ }
+
+ DroneFire::~DroneFire()
+ {
+ }
+
+ void DroneFire::fire()
+ {
+ RocketDrone* rocket = new RocketDrone(this);
+
+ //this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ //rocket->setOrientation(this->getMuzzleOrientation());
+ //rocket->setPosition(this->getMuzzlePosition());
+ //rocket->setVelocity(this->getMuzzleDirection() * this->speed_);
+ //rocket->scale(2);
+
+ //rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ //rocket->setDamage(this->getDamage());
+ }
+}
Copied: code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.h (from rev 6950, code/branches/rocket/src/modules/weapons/weaponmodes/DroneFire.h)
===================================================================
--- code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.h (rev 0)
+++ code/branches/presentation3/src/modules/weapons/weaponmodes/DroneFire.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,50 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _DroneFire_H__
+#define _DroneFire_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+ class _WeaponsExport DroneFire : public WeaponMode
+ {
+ public:
+ DroneFire(BaseObject* creator);
+ virtual ~DroneFire();
+
+ virtual void fire();
+
+ private:
+ float speed_;
+ };
+}
+
+#endif /* _DroneFire_H__ */
Copied: code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc (from rev 6950, code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc)
===================================================================
--- code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc (rev 0)
+++ code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,80 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "SimpleRocketFire.h"
+
+#include "util/Math.h"
+#include "core/CoreIncludes.h"
+#include "weapons/RocketController.h"
+
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ CreateFactory(SimpleRocketFire);
+
+ SimpleRocketFire::SimpleRocketFire(BaseObject* creator) : WeaponMode(creator)
+ {
+ RegisterObject(SimpleRocketFire);
+
+ this->reloadTime_ = 0.20f;
+ this->bParallelReload_ = false;
+ this->damage_ = 100;
+ this->speed_ = 100;
+
+ this->setMunitionName("LaserMunition");
+ // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
+ }
+
+ SimpleRocketFire::~SimpleRocketFire()
+ {
+ }
+
+ void SimpleRocketFire::fire()
+ {
+ RocketController* con = new RocketController(this);
+ SimpleRocket* rocket = con->getRocket();
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+// rocket->setOrientation(this->getMuzzleOrientation());
+ rocket->setOrientation(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getWorldOrientation());
+ Vector3 pos = this->getMuzzlePosition();
+ rocket->setPosition(pos);
+// rocket->setAcceleration(20*rocket->getOrientation() * WorldEntity::FRONT);
+ rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
+ rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ rocket->setDamage(this->damage_);
+ WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
+ if (pawnn)
+ {
+ con->setTarget(pawnn);
+ }
+ }
+}
Copied: code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.h (from rev 6950, code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.h)
===================================================================
--- code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.h (rev 0)
+++ code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,50 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oliver Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _SimpleRocketFire_H__
+#define _SimpleRocketFire_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+ class _WeaponsExport SimpleRocketFire : public WeaponMode
+ {
+ public:
+ SimpleRocketFire(BaseObject* creator);
+ virtual ~SimpleRocketFire();
+
+ virtual void fire();
+
+ private:
+ float speed_;
+ };
+}
+
+#endif /* _SimpleRocketFire_H__ */
Modified: code/branches/presentation3/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/AIController.cc 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/orxonox/controllers/AIController.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -56,19 +56,19 @@
float maxrand = 100.0f / ACTION_INTERVAL;
// search enemy
- random = rnd(maxrand);
+ /* random = rnd(maxrand);
if (random < 15 && (!this->target_))
- this->searchNewTarget();
+ this->searchNewTarget();*/
// forget enemy
- random = rnd(maxrand);
- if (random < 5 && (this->target_))
- this->forgetTarget();
+ //random = rnd(maxrand);
+ //if (random < 5 && (this->target_))
+ // this->forgetTarget();
// next enemy
- random = rnd(maxrand);
+ /* random = rnd(maxrand);
if (random < 10 && (this->target_))
- this->searchNewTarget();
+ this->searchNewTarget();*/
// fly somewhere
random = rnd(maxrand);
@@ -86,14 +86,14 @@
this->searchRandomTargetPosition();
// shoot
- random = rnd(maxrand);
- if (random < 75 && (this->target_ && !this->bShooting_))
- this->bShooting_ = true;
+ //random = rnd(maxrand);
+ //if (random < 75 && (this->target_ && !this->bShooting_))
+ // this->bShooting_ = true;
- // stop shooting
- random = rnd(maxrand);
- if (random < 25 && (this->bShooting_))
- this->bShooting_ = false;
+ //// stop shooting
+ //random = rnd(maxrand);
+ //if (random < 25 && (this->bShooting_))
+ // this->bShooting_ = false;
}
void AIController::tick(float dt)
Modified: code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt 2010-05-21 08:25:27 UTC (rev 6951)
@@ -7,4 +7,5 @@
ScriptController.cc
WaypointController.cc
WaypointPatrolController.cc
+ DroneController.cc
)
Copied: code/branches/presentation3/src/orxonox/controllers/DroneController.cc (from rev 6950, code/branches/rocket/src/orxonox/controllers/DroneController.cc)
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/DroneController.cc (rev 0)
+++ code/branches/presentation3/src/orxonox/controllers/DroneController.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,78 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "DroneController.h"
+#include "worldentities/Drone.h"
+#include "util/Math.h"
+
+
+namespace orxonox
+{
+ /**
+ @brief
+ Constructor.
+ */
+ DroneController::DroneController(BaseObject* creator) : Controller(creator)
+ {
+ RegisterObject(DroneController);
+ // Place your code here:
+ // - make sure to register the object in the factory
+ // - do any kind of initialisation
+
+ // this checks that our creator really is a drone
+ // and saves the pointer to the drone for the controlling commands
+ assert(dynamic_cast<Drone*>(creator)!=0);
+ this->setControllableEntity(dynamic_cast<Drone*>(creator));
+ this->counter=0;
+ }
+
+ DroneController::~DroneController()
+ {
+ }
+
+ /**
+ @brief
+ The controlling happens here. This method defines what the controller has to do each tick.
+ @param dt
+ The duration of the tick.
+ */
+ void DroneController::tick(float dt)
+ {
+ this->counter++;
+ // Place your code here:
+ // - steering commands
+ Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
+ // you can use the following commands for steering
+ // - moveFrontBack, moveRightLeft, moveUpDown
+ // - rotatePitch, rotateYaw, rotateRoll
+ // - apply the to myDrone (e.g. myDrone->rotateYaw(..) )
+ myDrone->rotatePitch(0.08);
+ myDrone->moveFrontBack(1);
+
+ }
+}
Copied: code/branches/presentation3/src/orxonox/controllers/DroneController.h (from rev 6950, code/branches/rocket/src/orxonox/controllers/DroneController.h)
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/DroneController.h (rev 0)
+++ code/branches/presentation3/src/orxonox/controllers/DroneController.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,60 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _DroneController_H__
+#define _DroneController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Controller.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Controller for the Drone of the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport DroneController : public Controller, public Tickable
+ {
+ public:
+ DroneController(BaseObject* creator);
+ virtual ~DroneController();
+
+ virtual void tick(float dt); //!< The controlling happens here. This method defines what the controller has to do each tick.
+
+ protected:
+
+ private:
+ int counter;
+ };
+}
+
+#endif /* _DroneController_H__ */
Modified: code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/orxonox/controllers/NewHumanController.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -363,14 +363,21 @@
Ogre::RaySceneQueryResult& result = rsq->execute();
Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
+ WorldEntity* myWe = static_cast<WorldEntity*>(this->getControllableEntity());
Ogre::RaySceneQueryResult::iterator itr;
for (itr = result.begin(); itr != result.end(); ++itr)
{
- if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)
+// CCOUT(0) << "testing object as target" << endl;
+ if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" /*&& itr->distance > 500*/)
{
// Try to cast the user pointer
WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
+
+ // make sure we don't shoot ourselves
+ if( wePtr==myWe )
+ continue;
+
if (wePtr)
{
// go through all parents of object and look whether they are sightable or not
@@ -378,7 +385,7 @@
WorldEntity* parent = wePtr->getParent();
while (parent)
{
- if (this->targetMask_.isExcluded(parent->getIdentifier()))
+ if (this->targetMask_.isExcluded(parent->getIdentifier()) || parent==myWe)
{
parent = parent->getParent();
continue;
@@ -578,4 +585,9 @@
this->arrowsOverlay4_->hide();
}
}
+
+
+
+
+
}
Modified: code/branches/presentation3/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/NewHumanController.h 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/orxonox/controllers/NewHumanController.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -66,6 +66,7 @@
virtual void doPauseControl();
virtual void doResumeControl();
+
protected:
void updateTarget();
void alignArrows();
Copied: code/branches/presentation3/src/orxonox/gametypes/Testgame.cc (from rev 6950, code/branches/rocket/src/orxonox/gametypes/Testgame.cc)
===================================================================
--- code/branches/presentation3/src/orxonox/gametypes/Testgame.cc (rev 0)
+++ code/branches/presentation3/src/orxonox/gametypes/Testgame.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,87 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "Asteroids.h"
+
+#include "core/CoreIncludes.h"
+#include "network/Host.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ CreateUnloadableFactory(Asteroids);
+
+ Asteroids::Asteroids(BaseObject* creator) : Gametype(creator)
+ {
+ RegisterObject(Asteroids);
+ this->firstCheckpointReached_ = false;
+ }
+
+ void Asteroids::tick(float dt)
+ {
+ SUPER(Asteroids, tick, dt);
+
+ if (firstCheckpointReached_ && !this->timerIsActive_)
+ {
+ this->startTimer();
+ }
+
+ if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_)
+ {
+ this->gtinfo_->sendAnnounceMessage("Time's up - you have lost the match!");
+ this->end();
+ }
+ }
+
+ void Asteroids::pawnKilled(Pawn* victim, Pawn* killer)
+ {
+ if (victim && victim->getPlayer())
+ {
+ this->gtinfo_->sendAnnounceMessage("You're dead - you have lost the match!");
+ this->end();
+ }
+ }
+
+ void Asteroids::start()
+ {
+ Gametype::start();
+
+ std::string message("The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...");
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+
+ void Asteroids::end()
+ {
+ Gametype::end();
+
+ std::string message("The match has ended.");
+ COUT(0) << message << std::endl;
+ Host::Broadcast(message);
+ }
+}
Copied: code/branches/presentation3/src/orxonox/gametypes/Testgame.h (from rev 6950, code/branches/rocket/src/orxonox/gametypes/Testgame.h)
===================================================================
--- code/branches/presentation3/src/orxonox/gametypes/Testgame.h (rev 0)
+++ code/branches/presentation3/src/orxonox/gametypes/Testgame.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,60 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Aurelian Jaggi
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Asteroids_H__
+#define _Asteroids_H__
+
+#include "OrxonoxPrereqs.h"
+#include "Gametype.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport Asteroids : public Gametype
+ {
+ public:
+ Asteroids(BaseObject* creator);
+ virtual ~Asteroids() {}
+
+ virtual void tick(float dt);
+
+ virtual void start();
+ virtual void end();
+
+ inline void firstCheckpointReached(bool reached)
+ { this->firstCheckpointReached_ = reached; }
+
+ protected:
+ virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
+
+ private:
+ bool firstCheckpointReached_;
+ bool gameEnded_;
+ };
+}
+
+#endif /* _Asteroids_H__ */
Modified: code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt 2010-05-21 07:40:14 UTC (rev 6950)
+++ code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt 2010-05-21 08:25:27 UTC (rev 6951)
@@ -11,6 +11,7 @@
CameraPosition.cc
SpawnPoint.cc
TeamSpawnPoint.cc
+ Drone.cc
)
ADD_SUBDIRECTORY(pawns)
Copied: code/branches/presentation3/src/orxonox/worldentities/Drone.cc (from rev 6950, code/branches/rocket/src/orxonox/worldentities/Drone.cc)
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/Drone.cc (rev 0)
+++ code/branches/presentation3/src/orxonox/worldentities/Drone.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,185 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "Drone.h"
+
+#include "core/XMLPort.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+ CreateFactory(Drone);
+ // put your code in here:
+ // create the factory for the drone
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ */
+ Drone::Drone(BaseObject* creator) : ControllableEntity(creator)
+ {
+ RegisterObject(Drone);
+ // put your code in here:
+ // - register the drone class to the core
+ this->myController_ = 0;
+
+ this->localLinearAcceleration_.setValue(1, 1, 1);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ this->primaryThrust_ = 100;
+ this->auxilaryThrust_ = 100;
+ this->rotationThrust_ = 10;
+
+ this->setCollisionType(WorldEntity::Dynamic);
+
+ myController_ = new DroneController(static_cast<BaseObject*>(this)); //!< Creates a new controller and passes our this pointer to it as creator.
+ }
+
+ /**
+ @brief
+ Destructor. Destroys controller, if present.
+ */
+ Drone::~Drone()
+ {
+ if( this->isInitialized() && this->myController_ )
+ delete this->myController_;
+ }
+
+ /**
+ @brief
+ Method for creating a Drone through XML.
+ */
+ void Drone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // this calls the XMLPort function of the parent class
+ SUPER(Drone, XMLPort, xmlelement, mode);
+
+ // put your code in here:
+ // make sure you add the variables primaryThrust_, auxilaryThrust_ and rotationThrust_ to xmlport
+ // make sure that the set- and get-functions exist.
+ // variables can be added by the following command
+ // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode)
+ XMLPortParam(Drone, "primaryThrust_", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
+ XMLPortParam(Drone, "auxilaryThrust_", setAuxilaryThrust, getAuxilaryThrust, xmlelement, mode);
+ XMLPortParam(Drone, "rotationThrust_", setRotationThrust, getRotationThrust, xmlelement, mode);
+
+ }
+
+ /**
+ @brief
+ Defines which actions the Drone has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
+ void Drone::tick(float dt)
+ {
+ SUPER(Drone, tick, dt);
+
+ //if (this->hasLocalController())
+ //{
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
+ else
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
+ this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+
+ this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
+ this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ //}
+ }
+
+ /**
+ @brief
+ Moves the Drone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void Drone::moveFrontBack(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
+ }
+
+ /**
+ @brief
+ Moves the Drone in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void Drone::moveRightLeft(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Moves the Drone in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void Drone::moveUpDown(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Drone::rotateYaw(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Drone::rotatePitch(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Drone::rotateRoll(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
+ }
+
+}
Copied: code/branches/presentation3/src/orxonox/worldentities/Drone.h (from rev 6950, code/branches/rocket/src/orxonox/worldentities/Drone.h)
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/Drone.h (rev 0)
+++ code/branches/presentation3/src/orxonox/worldentities/Drone.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,137 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Drone_H__
+#define _Drone_H__
+
+#include "OrxonoxPrereqs.h"
+#include "worldentities/ControllableEntity.h"
+#include "controllers/DroneController.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Drone, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport Drone : public ControllableEntity
+ {
+ public:
+ Drone(BaseObject* creator);
+ virtual ~Drone();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Drone through XML.
+ virtual void tick(float dt); //!< Defines which actions the Drone has to take in each tick.
+
+
+ virtual void moveFrontBack(const Vector2& value);
+ virtual void moveRightLeft(const Vector2& value);
+ virtual void moveUpDown(const Vector2& value);
+
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotatePitch(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+
+ /**
+ @brief Moves the Drone in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ /**
+ @brief Rotates the Drone around the y-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the x-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotatePitch(float value)
+ { this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the z-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateRoll(float value)
+ { this->rotateRoll(Vector2(value, 0)); }
+
+ /**
+ @brief Sets the primary thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setPrimaryThrust( float thrust )
+ { this->primaryThrust_=thrust; }
+ // place your set-functions here.
+ // - hint: auxiliary thrust, rotation thrust.
+ inline void setAuxilaryThrust( float thrust )
+ { this->primaryThrust_=thrust; }
+ inline void setRotationThrust( float thrust )
+ { this->rotationThrust_=thrust; }
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @preturn The amount of thrust.
+ */
+ inline float getPrimaryThrust()
+ { return this->primaryThrust_; }
+ // place your get-functions here.
+ inline float getAuxilaryThrust()
+ { return this->auxilaryThrust_; }
+ inline float getRotationThrust()
+ { return this->rotationThrust_; }
+ private:
+ DroneController *myController_; //!< The controller of the Drone.
+
+ btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the Drone the next tick.
+ btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the Drone the next tick.
+ float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward.
+ float auxilaryThrust_; //!< The amount of auxilary thrust. Used for all other movements (except for rotations).
+ float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.
+ };
+
+}
+
+#endif /* _Drone_H__ */
Copied: code/branches/presentation3/src/orxonox/worldentities/RocketDrone.cc (from rev 6950, code/branches/rocket/src/orxonox/worldentities/RocketDrone.cc)
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/RocketDrone.cc (rev 0)
+++ code/branches/presentation3/src/orxonox/worldentities/RocketDrone.cc 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,192 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "RocketDrone.h"
+
+#include "core/XMLPort.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+#include "graphics/Model.h"
+
+namespace orxonox
+{
+ CreateFactory(RocketDrone);
+ // put your code in here:
+ // create the factory for the drone
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ */
+ RocketDrone::RocketDrone(BaseObject* creator) : ControllableEntity(creator)
+ {
+ RegisterObject(RocketDrone);
+ // put your code in here:
+ // - register the drone class to the core
+ this->myController_ = 0;
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ this->primaryThrust_ = 100;
+ this->auxilaryThrust_ = 100;
+ this->rotationThrust_ = 10;
+ Model *model = new Model(this);
+ model->setMeshSource("rocket.mesh");
+ model->scale(0.7f);
+ this->setCollisionType(WorldEntity::Dynamic);
+
+ myController_ = new RocketController(static_cast<BaseObject*>(this)); //!< Creates a new controller and passes our this pointer to it as creator.
+ }
+
+ /**
+ @brief
+ Destructor. Destroys controller, if present.
+ */
+ RocketDrone::~RocketDrone()
+ {
+ if( this->isInitialized() && this->myController_ )
+ delete this->myController_;
+ }
+
+ /**
+ @brief
+ Method for creating a Drone through XML.
+ */
+ void RocketDrone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // this calls the XMLPort function of the parent class
+ SUPER(RocketDrone, XMLPort, xmlelement, mode);
+
+ // put your code in here:
+ // make sure you add the variables primaryThrust_, auxilaryThrust_ and rotationThrust_ to xmlport
+ // make sure that the set- and get-functions exist.
+ // variables can be added by the following command
+ // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode)
+ XMLPortParam(RocketDrone, "primaryThrust_", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
+ XMLPortParam(RocketDrone, "auxilaryThrust_", setAuxilaryThrust, getAuxilaryThrust, xmlelement, mode);
+ XMLPortParam(RocketDrone, "rotationThrust_", setRotationThrust, getRotationThrust, xmlelement, mode);
+
+ }
+
+ /**
+ @brief
+ Defines which actions the Drone has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
+ void RocketDrone::tick(float dt)
+ {
+ SUPER(RocketDrone, tick, dt);
+
+ //if (this->hasLocalController())
+ //{
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
+ else
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
+ this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+
+ this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
+ this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ //}
+ }
+
+ /**
+ @brief
+ Moves the Drone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void RocketDrone::moveFrontBack(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
+ }
+
+ /**
+ @brief
+ Moves the Drone in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void RocketDrone::moveRightLeft(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Moves the Drone in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void RocketDrone::moveUpDown(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void RocketDrone::rotateYaw(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void RocketDrone::rotatePitch(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void RocketDrone::rotateRoll(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
+ }
+
+ //void RocketDrone::setOwner(Pawn* owner)
+ //{
+ // this->owner_ = owner;
+ //}
+
+}
Copied: code/branches/presentation3/src/orxonox/worldentities/RocketDrone.h (from rev 6950, code/branches/rocket/src/orxonox/worldentities/RocketDrone.h)
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/RocketDrone.h (rev 0)
+++ code/branches/presentation3/src/orxonox/worldentities/RocketDrone.h 2010-05-21 08:25:27 UTC (rev 6951)
@@ -0,0 +1,139 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _RocketDrone_H__
+#define _RocketDrone_H__
+
+#include "OrxonoxPrereqs.h"
+#include "worldentities/ControllableEntity.h"
+#include "controllers/RocketController.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Drone, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport RocketDrone : public ControllableEntity
+ {
+ public:
+ RocketDrone(BaseObject* creator);
+ virtual ~RocketDrone();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Drone through XML.
+ virtual void tick(float dt); //!< Defines which actions the Drone has to take in each tick.
+
+
+ virtual void moveFrontBack(const Vector2& value);
+ virtual void moveRightLeft(const Vector2& value);
+ virtual void moveUpDown(const Vector2& value);
+
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotatePitch(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+
+ /**
+ @brief Moves the Drone in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ /**
+ @brief Rotates the Drone around the y-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the x-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotatePitch(float value)
+ { this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the z-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateRoll(float value)
+ { this->rotateRoll(Vector2(value, 0)); }
+
+ /**
+ @brief Sets the primary thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setPrimaryThrust( float thrust )
+ { this->primaryThrust_=thrust; }
+ // place your set-functions here.
+ // - hint: auxiliary thrust, rotation thrust.
+ inline void setAuxilaryThrust( float thrust )
+ { this->primaryThrust_=thrust; }
+ inline void setRotationThrust( float thrust )
+ { this->rotationThrust_=thrust; }
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @preturn The amount of thrust.
+ */
+ inline float getPrimaryThrust()
+ { return this->primaryThrust_; }
+ // place your get-functions here.
+ inline float getAuxilaryThrust()
+ { return this->auxilaryThrust_; }
+ inline float getRotationThrust()
+ { return this->rotationThrust_; }
+
+ //void setOwner(Pawn* owner);
+ private:
+ RocketController *myController_; //!< The controller of the Drone.
+
+ btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the Drone the next tick.
+ btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the Drone the next tick.
+ float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward.
+ float auxilaryThrust_; //!< The amount of auxilary thrust. Used for all other movements (except for rotations).
+ float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.
+ };
+
+}
+
+#endif /* _RocketDrone_H__ */
More information about the Orxonox-commit
mailing list