Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 17, 2016, 4:03:06 PM (8 years ago)
Author:
ooguz
Message:

WayPoint class changes

Location:
code/branches/QuestGuide_HS16/src/orxonox/worldentities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc

    r11230 r11237  
    1 /*
    2  *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
    5  *
    6  *   License notice:
    7  *
    8  *   This program is free software; you can redistribute it and/or
    9  *   modify it under the terms of the GNU General Public License
    10  *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    21  *
    22  *   Author:
    23  *      Fabian 'x3n' Landau
    24  *      Reto Grieder (physics)
    25  *   Co-authors:
    26  *      ...
    27  *
    28  */
    29 
    301#include "Waypoint.h"
    312
     
    5223    }
    5324
     25
     26    void Waypoint::XMLPort(Element& xmlelement, XMLPort::Mode mode){
     27        SUPER(Waypoint, XMLPort, xmlelement, mode); // From the SpaceShip.cc file
     28
     29
     30        //XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); // TRY ADDING THE WAYPOINT ARROW LIKE AN ENGINE
     31 
     32
     33    }
     34
     35
     36
    5437    void Waypoint::registerVariables()
    5538    {
    5639        // Ugly const casts, but are valid because position and orientation are not actually const
    57         registerVariable(const_cast<Vector3&>(this->getPosition()),    VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
    58         registerVariable(const_cast<Quaternion&>(this->getOrientation()), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
     40        registerVariable(const_cast<Vector3&>(this->getPosition()), \
     41            VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
     42        registerVariable(const_cast<Quaternion&>(this->getOrientation()),
     43            VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
    5944    }
    6045
    6146
    62     void Waypoint::setPosition(const Vector3& position)
    63     {
    64         if (this->addedToPhysicalWorld())
    65         {
    66             orxout(internal_warning) << "Attempting to change the position of a StaticEntity at physics run time. Ignoring change." << endl;
    67             return;
    68         }
    69         if (this->isStatic())
    70         {
    71             btTransform transf = this->physicalBody_->getWorldTransform();
    72             transf.setOrigin(btVector3(position.x, position.y, position.z));
    73             this->physicalBody_->setWorldTransform(transf);
    74         }
    75 
    76         this->node_->setPosition(position);
    77     }
    7847
    7948    void Waypoint::setOrientation(const Quaternion& orientation)
     
    9261
    9362        this->node_->setOrientation(orientation);
     63 
    9464    }
     65
     66    Vector3 Waypoint::toAimPosition(RadarViewable* target) const
     67    {
     68        Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition();
     69        Vector3 targetPosition = target->getRVWorldPosition();
     70        Vector3 targetSpeed = target->getRVVelocity();
     71
     72        return getPredictedPosition(wePosition, this->currentMunitionSpeed_, targetPosition, targetSpeed);
     73    }
     74
    9575/*
    9676    bool StaticEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
     
    11797    }
    11898}
     99
     100
     101const Pawn* pawnPtr = orxonox_cast<const Pawn*>(it->first->getWorldEntity());
     102
     103if (pawnPtr) {
     104   float position = pawnPtr->getPosition();
  • code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.h

    r11230 r11237  
    1 /*
    2  *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *                    > www.orxonox.net <
    4  *
    5  *
    6  *   License notice:
    7  *
    8  *   This program is free software; you can redistribute it and/or
    9  *   modify it under the terms of the GNU General Public License
    10  *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    21  *
    22  *   Author:
    23  *      Fabian 'x3n' Landau
    24  *      Reto Grieder
    25  *   Co-authors:
    26  *      ...
    27  *
    28  */
     1
    292
    303#ifndef _Waypoint_H__
     
    336#include "OrxonoxPrereqs.h"
    347#include "StaticEntity.h"
     8#include "overlays/OverlaysPrereqs.h"
     9
     10#include <map>
     11#include <string>
     12
     13#include "util/OgreForwardRefs.h"
     14#include "tools/interfaces/Tickable.h"
     15#include "interfaces/RadarListener.h"
     16#include "overlays/OrxonoxOverlay.h"
    3517
    3618namespace orxonox
     
    4830    */
    4931
    50     class _OrxonoxExport Waypoint : public StaticEntity
     32    class _OrxonoxExport Waypoint : public StaticEntity, public RadarListener
    5133    {
    5234        public:
    5335            Waypoint(Context* context);
    5436            virtual ~Waypoint();
     37
     38            virtual void addObject(RadarViewable* object) override;
     39            virtual void removeObject(RadarViewable* viewable) override;
     40            virtual void objectChanged(RadarViewable* viewable) override;
    5541
    5642            using StaticEntity::setPosition;
     
    5945            virtual void setPosition(const Vector3& position) override;
    6046            virtual void setOrientation(const Quaternion& orientation) override;
     47
     48            virtual void positionChanged() override { }
     49            virtual void radarTick(float dt) override {}
     50
     51            virtual inline float getRadarSensitivity() const override
     52                { return 1.0f; }
     53
     54            inline unsigned int getMarkerLimit() const
     55                { return this->markerLimit_; }
     56
     57            static void selectClosestTarget();
     58            static void selectNextTarget();
     59
     60
    6161
    6262        private:
Note: See TracChangeset for help on using the changeset viewer.