[Orxonox-commit 6918] r11539 - in code/branches/Waypoints_HS17: data/levels src/modules/questsystem src/orxonox/controllers src/orxonox/worldentities
jostoffe at orxonox.net
jostoffe at orxonox.net
Mon Nov 6 16:01:33 CET 2017
Author: jostoffe
Date: 2017-11-06 16:01:33 +0100 (Mon, 06 Nov 2017)
New Revision: 11539
Added:
code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.cc
code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.h
Modified:
code/branches/Waypoints_HS17/data/levels/emptyLevel.oxw
code/branches/Waypoints_HS17/src/modules/questsystem/Quest.cc
code/branches/Waypoints_HS17/src/orxonox/controllers/CMakeLists.txt
code/branches/Waypoints_HS17/src/orxonox/worldentities/CMakeLists.txt
Log:
Arrow- und ArrowControllerfiles hinzugefuegt. Position vom Schiff wird an ArrowController uerbergeben aber noch nichts damit gemacht
Modified: code/branches/Waypoints_HS17/data/levels/emptyLevel.oxw
===================================================================
--- code/branches/Waypoints_HS17/data/levels/emptyLevel.oxw 2017-11-06 14:43:57 UTC (rev 11538)
+++ code/branches/Waypoints_HS17/data/levels/emptyLevel.oxw 2017-11-06 15:01:33 UTC (rev 11539)
@@ -40,48 +40,33 @@
displaySize="0.6, 0, 0, 0"
/>
- <Scene
- ambientlight = "0.8, 0.8, 0.8"
- skybox = "Orxonox/Starbox"
+ <Scene
+ ambientlight = "0.5, 0.5, 0.5"
+ skybox = "Orxonox/Starbox"
>
- <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"/>
- <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
- <ModularSpaceShip velocity= "20,0,0" position="0,0,200" lookat= "0,0,0" health="1000" maxhealth="1000" initialhealth="1000">
- <templates>
- <Template link=endurance />
- </templates>
- </ModularSpaceShip>
- <AutonomousDroneController>
- </AutonomousDroneController>
+ <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" />
-<SpaceShip position="0,2000,200" lookat="0,0,0">
- <templates>
- <Template link=spaceshipassff />
- </templates>
- <controller>
- <WaypointController alertnessradius=1000 team=10>
- <waypoints>
- <Model mesh="cube.mesh" scale=8 position=" 0,2000,-200" />
- <Model mesh="cube.mesh" scale=8 position=" 0,2000,-700" />
- <Model mesh="cube.mesh" scale=8 position="500,2000,-700" />
- <Model mesh="cube.mesh" scale=8 position="500,2000,-200" />
- </waypoints>
- </WaypointController>
- </controller>
- </SpaceShip>
- <DistanceTrigger name="flying1" position="0,0,0" distance=100 stayActive="true" delay=6/>
- <SimpleNotification message="Let's fly to the blinking light.">
- <events>
- <trigger>
- <EventListener event="flying1" />
- </trigger>
- </events>
- </SimpleNotification>
+
+ <SpawnPoint position="50,0,0" lookat="1,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+
+ <Arrow position = "0,50,5">
+ <attached>
+ <Model scale="10" mesh="arrow.mesh"/>
+ </attached>
+ <controllers>
+ <ArrowController>
+ </ArrowController>
+ </controllers>
+ </Arrow>
+
+
+
</Scene>
</Level>
Modified: code/branches/Waypoints_HS17/src/modules/questsystem/Quest.cc
===================================================================
--- code/branches/Waypoints_HS17/src/modules/questsystem/Quest.cc 2017-11-06 14:43:57 UTC (rev 11538)
+++ code/branches/Waypoints_HS17/src/modules/questsystem/Quest.cc 2017-11-06 15:01:33 UTC (rev 11539)
@@ -79,10 +79,21 @@
XMLPortObject(Quest, QuestHint, "hints", addHint, getHint, xmlelement, mode);
XMLPortObject(Quest, QuestEffect, "fail-effects", addFailEffect, getFailEffect, xmlelement, mode);
XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffect, xmlelement, mode);
+ XMLPortObject(Quest, Worldentity, "arrowtarget", addArrowTarget, getArrowTarget, xmlelement, mode);
QuestManager::getInstance().registerQuest(this); // Registers the Quest with the QuestManager.
}
+
+ bool Quest::addArrowTarget(Quest* quest){
+
+ assert(quest);
+
+
+ }
+
+
+
/**
@brief
Sets the parent-quest of the Quest.
Modified: code/branches/Waypoints_HS17/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/Waypoints_HS17/src/orxonox/controllers/CMakeLists.txt 2017-11-06 14:43:57 UTC (rev 11538)
+++ code/branches/Waypoints_HS17/src/orxonox/controllers/CMakeLists.txt 2017-11-06 15:01:33 UTC (rev 11539)
@@ -19,4 +19,5 @@
FightingController.cc
MasterController.cc
AutonomousDroneController.cc
+ ArrowController.cc
)
Added: code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.cc
===================================================================
--- code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.cc (rev 0)
+++ code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.cc 2017-11-06 15:01:33 UTC (rev 11539)
@@ -0,0 +1,186 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ *
+ */
+
+#include "Arrow.h"
+
+#include "core/CoreIncludes.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+ //TODO: Put your code in here:
+ // Create the factory for the drone.
+ RegisterClass(Arrow);
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ @param creator
+ The creator of this object.
+ */
+ Arrow::Arrow(Context* context) : ControllableEntity(context)
+ {
+ //TODO: Put your code in here:
+ // Register the drone class to the core.
+ RegisterObject(Arrow);
+
+ this->myController_ = NULL;
+
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ this->primaryThrust_ = 100;
+ this->auxiliaryThrust_ = 100;
+ this->rotationThrust_ = 10;
+
+ this->setCollisionType(CollisionType::Dynamic);
+
+ //this->myController_ = new ArrowController(this); // Creates a new controller and passes our this pointer to it as creator.
+ }
+
+ /**
+ @brief
+ Destructor. Destroys controller, if present.
+ */
+ Arrow::~Arrow()
+ {
+ // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
+ if( this->isInitialized() && this->myController_ != NULL )
+ delete this->myController_;
+ }
+
+ /**
+ @brief
+ Method for creating a Arrow through XML.
+ */
+ void Arrow::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ // This calls the XMLPort function of the parent class
+ SUPER(Arrow, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Arrow, "primaryThrust", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
+ //TODO: Put your code in here:
+ XMLPortParam(Arrow, "auxiliaryThrust", setAuxiliaryThrust, getAuxiliaryThrust, xmlelement, mode);
+ XMLPortParam(Arrow, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode);
+ // Make sure you add the variables auxiliaryThrust_ and rotationThrust_ to XMLPort.
+ // Variables can be added by the following command
+ // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunctionName, getFunctionName, xmlelement, mode);
+ // Also make sure that you also create the get- and set-functions in Arrow.h. As you can see, the get- and set-functions for the variable primaryThrust_ has already been specified there, so you can get your inspiration from there.
+
+
+ }
+
+ /**
+ @brief
+ Defines which actions the Arrow has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
+ void Arrow::tick(float dt)
+ {
+ SUPER(Arrow, tick, dt);
+
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxiliaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxiliaryThrust_);
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxiliaryThrust_);
+ 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 Arrow 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 Arrow::moveFrontBack(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
+ }
+
+ /**
+ @brief
+ Moves the Arrow 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 Arrow::moveRightLeft(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Moves the Arrow 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 Arrow::moveUpDown(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Arrow 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 Arrow::rotateYaw(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Arrow 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 Arrow::rotatePitch(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Arrow 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 Arrow::rotateRoll(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
+ }
+
+}
Added: code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.h
===================================================================
--- code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.h (rev 0)
+++ code/branches/Waypoints_HS17/src/orxonox/worldentities/Arrow.h 2017-11-06 15:01:33 UTC (rev 11539)
@@ -0,0 +1,146 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ *
+ */
+
+#ifndef _Arrow_H__
+#define _Arrow_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/XMLPort.h"
+#include "controllers/ArrowController.h"
+
+#include "ControllableEntity.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 Arrow : public ControllableEntity
+ {
+ public:
+ Arrow(Context* context);
+ virtual ~Arrow();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating an Arrow through XML.
+ virtual void tick(float dt); //!< Defines which actions the Arrow 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; }
+ //TODO: Place your set-functions here.
+
+ inline void setAuxiliaryThrust ( float thrust )
+ { this -> auxiliaryThrust_ = thrust; }
+
+ inline void setRotationThrust (float thrust)
+ { this -> rotationThrust_ = thrust;}
+ // Hint: auxiliary thrust, rotation thrust.
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @return The amount of thrust.
+ */
+ inline float getPrimaryThrust()
+ { return this->primaryThrust_; }
+
+ inline float getAuxiliaryThrust()
+ { return this->auxiliaryThrust_;}
+
+ inline float getRotationThrust()
+ { return this->rotationThrust_;}
+
+ //TODO: Place your get-functions here.
+
+ private:
+ ArrowController *myController_; //!< The controller of the Arrow.
+
+ btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the Arrow the next tick.
+ btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the Arrow the next tick.
+ float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward.
+ float auxiliaryThrust_; //!< The amount of auxiliary thrust. Used for all other movements (except for rotations).
+ float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.s
+
+ };
+
+}
+
+#endif // _Arrow_H__
Modified: code/branches/Waypoints_HS17/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/branches/Waypoints_HS17/src/orxonox/worldentities/CMakeLists.txt 2017-11-06 14:43:57 UTC (rev 11538)
+++ code/branches/Waypoints_HS17/src/orxonox/worldentities/CMakeLists.txt 2017-11-06 15:01:33 UTC (rev 11539)
@@ -13,6 +13,7 @@
ExplosionPart.cc
Actionpoint.cc
AutonomousDrone.cc
+ Arrow.cc
)
ADD_SUBDIRECTORY(pawns)
More information about the Orxonox-commit
mailing list