[Orxonox-commit 6597] r11237 - code/branches/QuestGuide_HS16/src/orxonox/worldentities

ooguz at orxonox.net ooguz at orxonox.net
Mon Oct 17 16:03:06 CEST 2016


Author: ooguz
Date: 2016-10-17 16:03:06 +0200 (Mon, 17 Oct 2016)
New Revision: 11237

Modified:
   code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc
   code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.h
Log:
WayPoint class changes

Modified: code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc
===================================================================
--- code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc	2016-10-17 14:00:06 UTC (rev 11236)
+++ code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc	2016-10-17 14:03:06 UTC (rev 11237)
@@ -1,32 +1,3 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *      Reto Grieder (physics)
- *   Co-authors:
- *      ...
- *
- */
-
 #include "Waypoint.h"
 
 #include <OgreSceneNode.h>
@@ -51,31 +22,29 @@
     {
     }
 
+
+    void Waypoint::XMLPort(Element& xmlelement, XMLPort::Mode mode){
+        SUPER(Waypoint, XMLPort, xmlelement, mode); // From the SpaceShip.cc file
+
+
+        //XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); // TRY ADDING THE WAYPOINT ARROW LIKE AN ENGINE
+ 
+
+    }
+
+
+
     void Waypoint::registerVariables()
     {
         // Ugly const casts, but are valid because position and orientation are not actually const
-        registerVariable(const_cast<Vector3&>(this->getPosition()),    VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
-        registerVariable(const_cast<Quaternion&>(this->getOrientation()), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
+        registerVariable(const_cast<Vector3&>(this->getPosition()), \
+            VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
+        registerVariable(const_cast<Quaternion&>(this->getOrientation()),
+            VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
     }
 
 
-    void Waypoint::setPosition(const Vector3& position)
-    {
-        if (this->addedToPhysicalWorld())
-        {
-            orxout(internal_warning) << "Attempting to change the position of a StaticEntity at physics run time. Ignoring change." << endl;
-            return;
-        }
-        if (this->isStatic())
-        {
-            btTransform transf = this->physicalBody_->getWorldTransform();
-            transf.setOrigin(btVector3(position.x, position.y, position.z));
-            this->physicalBody_->setWorldTransform(transf);
-        }
 
-        this->node_->setPosition(position);
-    }
-
     void Waypoint::setOrientation(const Quaternion& orientation)
     {
         if (this->addedToPhysicalWorld())
@@ -91,7 +60,18 @@
         }
 
         this->node_->setOrientation(orientation);
+  
     }
+
+    Vector3 Waypoint::toAimPosition(RadarViewable* target) const
+    {
+        Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition();
+        Vector3 targetPosition = target->getRVWorldPosition();
+        Vector3 targetSpeed = target->getRVVelocity();
+
+        return getPredictedPosition(wePosition, this->currentMunitionSpeed_, targetPosition, targetSpeed);
+    }
+
 /*
     bool StaticEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
     {
@@ -116,3 +96,9 @@
         worldTrans.setRotation(btQuaternion(node_->getOrientation().x, node_->getOrientation().y, node_->getOrientation().z, node_->getOrientation().w));
     }
 }
+
+
+const Pawn* pawnPtr = orxonox_cast<const Pawn*>(it->first->getWorldEntity());
+
+if (pawnPtr) {
+   float position = pawnPtr->getPosition();

Modified: code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.h
===================================================================
--- code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.h	2016-10-17 14:00:06 UTC (rev 11236)
+++ code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.h	2016-10-17 14:03:06 UTC (rev 11237)
@@ -1,38 +1,20 @@
-/*
- *   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:
- *      Fabian 'x3n' Landau
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
 
+
 #ifndef _Waypoint_H__
 #define _Waypoint_H__
 
 #include "OrxonoxPrereqs.h"
 #include "StaticEntity.h"
+#include "overlays/OverlaysPrereqs.h"
 
+#include <map>
+#include <string>
+
+#include "util/OgreForwardRefs.h"
+#include "tools/interfaces/Tickable.h"
+#include "interfaces/RadarListener.h"
+#include "overlays/OrxonoxOverlay.h"
+
 namespace orxonox
 {
     /**
@@ -47,18 +29,36 @@
         A StaticEntity can only have the collisition type WorldEntity::None or WorldEntity::Static. The collsion types WorldEntity::Dynamic and WorldEntity::Kinematic are illegal.
     */
 
-    class _OrxonoxExport Waypoint : public StaticEntity
+    class _OrxonoxExport Waypoint : public StaticEntity, public RadarListener
     {
         public:
             Waypoint(Context* context);
             virtual ~Waypoint();
 
+            virtual void addObject(RadarViewable* object) override;
+            virtual void removeObject(RadarViewable* viewable) override;
+            virtual void objectChanged(RadarViewable* viewable) override;
+
             using StaticEntity::setPosition;
             using StaticEntity::setOrientation;
 
             virtual void setPosition(const Vector3& position) override;
             virtual void setOrientation(const Quaternion& orientation) override;
 
+            virtual void positionChanged() override { }
+            virtual void radarTick(float dt) override {}
+
+            virtual inline float getRadarSensitivity() const override
+                { return 1.0f; }
+
+            inline unsigned int getMarkerLimit() const
+                { return this->markerLimit_; }
+
+            static void selectClosestTarget();
+            static void selectNextTarget();
+
+
+
         private:
             void registerVariables();
             //virtual bool isCollisionTypeLegal(CollisionType type) const override;




More information about the Orxonox-commit mailing list