[Orxonox-commit 2066] r6782 - in code/branches/ai: data/levels src/modules/pickup src/modules/pickup/items src/orxonox/controllers src/orxonox/interfaces src/orxonox/worldentities
gasserlu at orxonox.net
gasserlu at orxonox.net
Mon Apr 26 15:59:43 CEST 2010
Author: gasserlu
Date: 2010-04-26 15:59:43 +0200 (Mon, 26 Apr 2010)
New Revision: 6782
Added:
code/branches/ai/src/modules/pickup/items/DronePickup.cc
code/branches/ai/src/modules/pickup/items/DronePickup.h
Modified:
code/branches/ai/data/levels/pickup.oxw
code/branches/ai/data/levels/tutorial.oxw
code/branches/ai/src/modules/pickup/PickupPrereqs.h
code/branches/ai/src/modules/pickup/items/CMakeLists.txt
code/branches/ai/src/orxonox/controllers/CMakeLists.txt
code/branches/ai/src/orxonox/interfaces/PickupCarrier.h
code/branches/ai/src/orxonox/worldentities/CMakeLists.txt
Log:
drone, dronecontroller implemented
Modified: code/branches/ai/data/levels/pickup.oxw
===================================================================
--- code/branches/ai/data/levels/pickup.oxw 2010-04-26 13:46:06 UTC (rev 6781)
+++ code/branches/ai/data/levels/pickup.oxw 2010-04-26 13:59:43 UTC (rev 6782)
@@ -21,13 +21,51 @@
<?lua
include("includes/pickups.oxi")
?>
+
+ <Template name=droneTemplate>
+ <Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
+ <attached>
+ <Model scale="10" mesh="drone.mesh"/>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
+ </collisionShapes>
+
+ <weaponslots>
+ <WeaponSlot position=" 0, 0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ </links>
+ <Weapon>
+ <attached>
+ <Model mesh="hs-w01.mesh" roll="195" position="0,1,0" scale=2 />
+ <Model mesh="hs-w01s.mesh" roll="195" position="0.1,0.5,0" scale=2 />
+ </attached>
+ <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5,-4" />
+ <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" muzzleoffset="-0.9, 1.1,-4" />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
+
+
+ </Drone>
+ </Template>
+
<PickupSpawner position="-100,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
<pickup>
- <MetaPickup metaType="drop" />
+ <DronePickup droneTemplate=droneTemplate />
</pickup>
</PickupSpawner>
-
+
+
+
<PickupSpawner position="-75,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
<pickup>
<MetaPickup metaType="use" />
Modified: code/branches/ai/data/levels/tutorial.oxw
===================================================================
--- code/branches/ai/data/levels/tutorial.oxw 2010-04-26 13:46:06 UTC (rev 6781)
+++ code/branches/ai/data/levels/tutorial.oxw 2010-04-26 13:59:43 UTC (rev 6782)
@@ -13,7 +13,9 @@
skybox = "Orxonox/skypanoramagen1"
>
-<Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
+ <PickupSpawner position="0,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <drones>
+ <Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
<attached>
<Model scale="10" mesh="drone.mesh"/>
</attached>
@@ -21,6 +23,8 @@
<BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
</collisionShapes>
</Drone>
+ </drones>
+ </PickupSpawner>
<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" />
Modified: code/branches/ai/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/ai/src/modules/pickup/PickupPrereqs.h 2010-04-26 13:46:06 UTC (rev 6781)
+++ code/branches/ai/src/modules/pickup/PickupPrereqs.h 2010-04-26 13:59:43 UTC (rev 6782)
@@ -74,6 +74,7 @@
class PickupSpawner;
//items
+ class DronePickup;
class HealthPickup;
class MetaPickup;
Modified: code/branches/ai/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/ai/src/modules/pickup/items/CMakeLists.txt 2010-04-26 13:46:06 UTC (rev 6781)
+++ code/branches/ai/src/modules/pickup/items/CMakeLists.txt 2010-04-26 13:59:43 UTC (rev 6782)
@@ -1,4 +1,5 @@
ADD_SOURCE_FILES(PICKUP_SRC_FILES
HealthPickup.cc
MetaPickup.cc
+ DronePickup.cc
)
Added: code/branches/ai/src/modules/pickup/items/DronePickup.cc
===================================================================
--- code/branches/ai/src/modules/pickup/items/DronePickup.cc (rev 0)
+++ code/branches/ai/src/modules/pickup/items/DronePickup.cc 2010-04-26 13:59:43 UTC (rev 6782)
@@ -0,0 +1,196 @@
+/*
+ * 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:
+ * Lukas Gasser
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DronePickup.cc
+ @brief Implementation of the DronePickup class.
+*/
+
+#include "DronePickup.h"
+#include "worldentities/Drone.h"
+#include "controllers/DroneController.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/StringUtils.h"
+
+#include "worldentities/pawns/Pawn.h"
+#include "pickup/PickupIdentifier.h"
+
+#include <sstream>
+
+namespace orxonox
+{
+
+ CreateFactory(DronePickup);
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes the member variables.
+ */
+ DronePickup::DronePickup(BaseObject* creator) : Pickup(creator)
+ {
+ RegisterObject(DronePickup);
+
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ DronePickup::~DronePickup()
+ {
+
+ }
+
+ /**
+ @brief
+ Initializes the member variables.
+ */
+ void DronePickup::initialize(void)
+ {
+ this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
+ this->setDurationTypeDirect(pickupDurationType::once);
+ this->droneTemplate_ = "";
+ }
+
+ /**
+ @brief
+ Initializes the PickupIdentifier of this pickup.
+ */
+ void DronePickup::initializeIdentifier(void)
+ {
+ std::string val = this->getDroneTemplate();
+ std::string type = "droneTemplate";
+ this->pickupIdentifier_->addParameter(type, val);
+ }
+
+ /**
+ @brief
+ Method for creating a DronePickup object through XML.
+ */
+ void DronePickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+ {
+ SUPER(DronePickup, XMLPort, xmlelement, mode);
+ XMLPortParam(DronePickup, "droneTemplate", setDroneTemplate, getDroneTemplate, xmlelement, mode);
+
+ this->initializeIdentifier();
+ }
+
+ void DronePickup::setDroneTemplate(std::string templatename){
+ droneTemplate_ = templatename;
+ }
+
+ const std::string& DronePickup::getDroneTemplate() const
+ {
+ return droneTemplate_;
+ }
+
+ /**
+ @brief
+ Is called when the pickup has transited from used to unused or the other way around.
+ */
+ void DronePickup::changedUsed(void)
+ {
+ SUPER(DronePickup, changedUsed);
+
+ //! If the pickup is not picked up nothing must be done.
+ if(!this->isPickedUp())
+ return;
+
+ //! If the pickup has transited to used.
+ if(this->isUsed())
+ {
+
+ Pawn* pawn = this->carrierToPawnHelper();
+ if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ this->destroy();
+
+ //Attach to pawn
+ Drone* drone = new Drone(this);
+ drone->addTemplate(this->getDroneTemplate());
+ pawn->attach(drone);
+ Controller* controller = drone->getController();
+ DroneController* droneController = dynamic_cast<DroneController*>(controller);
+ if(droneController != NULL)
+ {
+ droneController->setPawn(pawn);
+ }
+
+ //! The pickup has been used up.
+ this->setUsed(false);
+ }
+ else
+ {
+ //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
+ if(this->isOnce() || (this->isContinuous() ))
+ {
+ this->destroy();
+ }
+ }
+ }
+
+ /**
+ @brief
+ Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+ @return
+ A pointer to the Pawn, or NULL if the conversion failed.
+ */
+ Pawn* DronePickup::carrierToPawnHelper(void)
+ {
+ PickupCarrier* carrier = this->getCarrier();
+ Pawn* pawn = dynamic_cast<Pawn*>(carrier);
+
+ if(pawn == NULL)
+ {
+ COUT(1) << "Invalid PickupCarrier in DronePickup." << std::endl;
+ }
+
+ return pawn;
+ }
+
+ /**
+ @brief
+ Creates a duplicate of the input OrxonoxClass.
+ @param item
+ A pointer to the Orxonox class.
+ */
+ void DronePickup::clone(OrxonoxClass*& item)
+ {
+ if(item == NULL)
+ item = new DronePickup(this);
+
+ SUPER(DronePickup, clone, item);
+
+ DronePickup* pickup = dynamic_cast<DronePickup*>(item);
+ pickup->setDroneTemplate(this->getDroneTemplate());
+
+ pickup->initializeIdentifier();
+ }
+}
Added: code/branches/ai/src/modules/pickup/items/DronePickup.h
===================================================================
--- code/branches/ai/src/modules/pickup/items/DronePickup.h (rev 0)
+++ code/branches/ai/src/modules/pickup/items/DronePickup.h 2010-04-26 13:59:43 UTC (rev 6782)
@@ -0,0 +1,79 @@
+/*
+ * 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:
+ * Lukas Gasser
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DronePickup.h
+ @brief Declaration of the DronePickup class.
+*/
+
+#ifndef _DronePickup_H__
+#define _DronePickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+#include <worldentities/pawns/Pawn.h>
+#include <worldentities/Drone.h>
+
+#include "worldentities/StaticEntity.h"
+
+#include "pickup/Pickup.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox {
+
+
+ class _PickupExport DronePickup : public Pickup, public Tickable
+ {
+ public:
+
+ DronePickup(BaseObject* creator); //!< Constructor.
+ virtual ~DronePickup(); //!< Destructor.
+
+ virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a DronePickup object through XML.
+
+ virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
+ virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
+
+ void setDroneTemplate(std::string templatename);
+ const std::string& getDroneTemplate() const;
+
+ protected:
+ void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+
+ private:
+ void initialize(void); //!< Initializes the member variables.
+ std::string droneTemplate_;
+ Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+
+
+
+ };
+}
+
+#endif // _DronePickup_H__
Modified: code/branches/ai/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/ai/src/orxonox/controllers/CMakeLists.txt 2010-04-26 13:46:06 UTC (rev 6781)
+++ code/branches/ai/src/orxonox/controllers/CMakeLists.txt 2010-04-26 13:59:43 UTC (rev 6782)
@@ -7,4 +7,5 @@
ScriptController.cc
WaypointController.cc
WaypointPatrolController.cc
+ DroneController.cc
)
Modified: code/branches/ai/src/orxonox/interfaces/PickupCarrier.h
===================================================================
--- code/branches/ai/src/orxonox/interfaces/PickupCarrier.h 2010-04-26 13:46:06 UTC (rev 6781)
+++ code/branches/ai/src/orxonox/interfaces/PickupCarrier.h 2010-04-26 13:59:43 UTC (rev 6782)
@@ -51,6 +51,7 @@
class Pickup;
class HealthPickup;
class MetaPickup;
+ class DronePickup;
/**
@brief
@@ -66,6 +67,7 @@
friend class Pickup;
friend class HealthPickup;
friend class MetaPickup;
+ friend class DronePickup;
public:
PickupCarrier(); //!< Constructor.
Modified: code/branches/ai/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/branches/ai/src/orxonox/worldentities/CMakeLists.txt 2010-04-26 13:46:06 UTC (rev 6781)
+++ code/branches/ai/src/orxonox/worldentities/CMakeLists.txt 2010-04-26 13:59:43 UTC (rev 6782)
@@ -4,7 +4,7 @@
MovableEntity.cc
MobileEntity.cc
ControllableEntity.cc
-
+ Drone.cc
BigExplosion.cc
EffectContainer.cc
ExplosionChunk.cc
More information about the Orxonox-commit
mailing list