[Orxonox-commit 2117] r6833 - code/branches/ai/src/orxonox/controllers
gasserlu at orxonox.net
gasserlu at orxonox.net
Mon May 3 13:38:59 CEST 2010
Author: gasserlu
Date: 2010-05-03 13:38:59 +0200 (Mon, 03 May 2010)
New Revision: 6833
Added:
code/branches/ai/src/orxonox/controllers/DroneController.cc
code/branches/ai/src/orxonox/controllers/DroneController.h
Removed:
code/branches/ai/src/orxonox/controllers/DroneController.cc~
code/branches/ai/src/orxonox/controllers/DroneController.h~
Modified:
code/branches/ai/src/orxonox/controllers/ArtificialController.h
Log:
DroneController edited
Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.h 2010-05-03 11:25:58 UTC (rev 6832)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.h 2010-05-03 11:38:59 UTC (rev 6833)
@@ -50,7 +50,7 @@
{ this->team_ = team; }
inline int getTeam() const
{ return this->team_; }
- virtual void changedControllableEntity();
+ //virtual void changedControllableEntity();
protected:
Added: code/branches/ai/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.cc (rev 0)
+++ code/branches/ai/src/orxonox/controllers/DroneController.cc 2010-05-03 11:38:59 UTC (rev 6833)
@@ -0,0 +1,153 @@
+/*
+ * 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"
+
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "worldentities/ControllableEntity.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Constructor.
+ */
+ CreateFactory(DroneController);
+
+ static const float ACTION_INTERVAL = 1.0f;
+
+ DroneController::DroneController(BaseObject* creator) : ArtificialController(creator)
+ {
+ // - 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));
+
+ RegisterObject(DroneController);
+
+ this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DroneController::action, this)));
+ }
+
+ DroneController::~DroneController()
+ {
+ }
+
+ void DroneController::setPawn(Pawn* pawn){
+ pawnpointer_ = pawn;
+ }
+
+ const Pawn* DroneController::getPawn(unsigned int index) const
+ {
+ if(index == 0) return pawnpointer_;
+ return NULL;
+ }
+
+ void DroneController::action()
+ {
+ float random;
+ float maxrand = 100.0f / ACTION_INTERVAL;
+
+ // search enemy
+ random = rnd(maxrand);
+ if (random < 15 && (!this->target_))
+ this->searchNewTarget();
+
+ // forget enemy
+ random = rnd(maxrand);
+ if (random < 5 && (this->target_))
+ this->forgetTarget();
+
+ // next enemy
+ random = rnd(maxrand);
+ if (random < 10 && (this->target_))
+ this->searchNewTarget();
+
+ //fly somewhere
+ random = rnd(maxrand);
+ if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
+ this->searchRandomTargetPosition();
+
+ // stop flying
+ random = rnd(maxrand);
+ if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
+ this->bHasTargetPosition_ = false;
+
+ // fly somewhere else
+ random = rnd(maxrand);
+ if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
+ this->searchRandomTargetPosition();
+
+ /* // shoot
+ 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;
+ }
+
+
+ /**
+ @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)
+ {
+ // Place your code here:
+ // - steering commands
+
+
+ Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
+
+ if(myDrone != NULL) {
+
+ setTargetPosition(this->getControllableEntity()->getPosition());
+/*
+ myDrone->setRotationThrust(25);
+ myDrone->setAuxilaryThrust(30);
+ myDrone->rotateYaw(10*dt); */
+ }
+
+ SUPER(AIController, tick, dt);
+
+ // you can use the following commands for steering
+ // - moveFrontBack, moveRightLeft, moveUpDown
+ // - rotatePitch, rotateYaw, rotateRoll
+ // - apply the to myDrone (e.g. myDrone->rotateYaw(..) )
+
+ }
+}
Deleted: code/branches/ai/src/orxonox/controllers/DroneController.cc~
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.cc~ 2010-05-03 11:25:58 UTC (rev 6832)
+++ code/branches/ai/src/orxonox/controllers/DroneController.cc~ 2010-05-03 11:38:59 UTC (rev 6833)
@@ -1,156 +0,0 @@
-/*
- * 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"
-
-#include "core/CoreIncludes.h"
-#include "core/Executor.h"
-#include "worldentities/ControllableEntity.h"
-
-namespace orxonox
-{
- /**
- @brief
- Constructor.
- */
- CreateFactory(DroneController);
-
- static const float ACTION_INTERVAL = 1.0f;
-
- DroneController::DroneController(BaseObject* creator) : ArtificialController(creator)
- {
- /* // Place your code here:
- // - make sure to register the object in the factory
- // - do any kind of initialisation
- RegisterObject(DroneController);
-
- // 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));
- */
- RegisterObject(DroneController);
-
- this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DroneController::action, this)));
- }
-
- DroneController::~DroneController()
- {
- }
-
- void DroneController::setPawn(Pawn* pawn){
- pawnpointer_ = pawn;
- }
-
- const Pawn* DroneController::getPawn(unsigned int index) const
- {
- if(index == 0) return pawnpointer_;
- return NULL;
- }
-
- void DroneController::action()
- {
- float random;
- float maxrand = 100.0f / ACTION_INTERVAL;
-
- // search enemy
- random = rnd(maxrand);
- if (random < 15 && (!this->target_))
- this->searchNewTarget();
-
- // forget enemy
- random = rnd(maxrand);
- if (random < 5 && (this->target_))
- this->forgetTarget();
-
- // next enemy
- random = rnd(maxrand);
- if (random < 10 && (this->target_))
- this->searchNewTarget();
-
- //fly somewhere
- random = rnd(maxrand);
- if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
- this->searchRandomTargetPosition();
-
- // stop flying
- random = rnd(maxrand);
- if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
- this->bHasTargetPosition_ = false;
-
- // fly somewhere else
- random = rnd(maxrand);
- if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
- this->searchRandomTargetPosition();
-
- /* // shoot
- 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;
- }
-
-
- /**
- @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)
- {
- // Place your code here:
- // - steering commands
-
-
- Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
-
- if(myDrone != NULL) {
-
- setTargetPosition(this->getControllableEntity()->getPosition());
-/*
- myDrone->setRotationThrust(25);
- myDrone->setAuxilaryThrust(30);
- myDrone->rotateYaw(10*dt); */
- }
-
- SUPER(AIController, tick, dt);
-
- // you can use the following commands for steering
- // - moveFrontBack, moveRightLeft, moveUpDown
- // - rotatePitch, rotateYaw, rotateRoll
- // - apply the to myDrone (e.g. myDrone->rotateYaw(..) )
-
- }
-}
Added: code/branches/ai/src/orxonox/controllers/DroneController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.h (rev 0)
+++ code/branches/ai/src/orxonox/controllers/DroneController.h 2010-05-03 11:38:59 UTC (rev 6833)
@@ -0,0 +1,67 @@
+/*
+ * 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 "AIController.h"
+#include "tools/interfaces/Tickable.h"
+
+#include "tools/Timer.h"
+
+
+namespace orxonox
+{
+ /**
+ @brief
+ Controller for the Drone of the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport DroneController : public ArtificialController
+ {
+ 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.
+ void setPawn(Pawn* pawn);
+ const Pawn* getPawn(unsigned int index) const;
+
+ protected:
+ virtual void action();
+
+ private:
+ Timer actionTimer_;
+ Pawn* pawnpointer_;
+ };
+}
+
+#endif /* _DroneController_H__ */
Deleted: code/branches/ai/src/orxonox/controllers/DroneController.h~
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.h~ 2010-05-03 11:25:58 UTC (rev 6832)
+++ code/branches/ai/src/orxonox/controllers/DroneController.h~ 2010-05-03 11:38:59 UTC (rev 6833)
@@ -1,67 +0,0 @@
-/*
- * 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 "AIController.h"
-#include "tools/interfaces/Tickable.h"
-
-#include "tools/Timer.h"
-
-
-namespace orxonox
-{
- /**
- @brief
- Controller for the Drone of the PPS tutorial.
- @author
- Oli Scheuss
- */
- class _OrxonoxExport DroneController : public AIController
- {
- 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.
- void setPawn(Pawn* pawn);
- const Pawn* getPawn(unsigned int index) const;
-
- protected:
- virtual void action();
-
- private:
- Timer actionTimer_;
- Pawn* pawnpointer_;
- };
-}
-
-#endif /* _DroneController_H__ */
More information about the Orxonox-commit
mailing list