Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11243 for code/branches


Ignore:
Timestamp:
Oct 24, 2016, 4:01:11 PM (8 years ago)
Author:
ooguz
Message:

Waypointarrow und Waypoint Klassen

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

Legend:

Unmodified
Added
Removed
  • code/branches/QuestGuide_HS16/src/orxonox/worldentities/CMakeLists.txt

    r11230 r11243  
    1313  ExplosionPart.cc
    1414  Actionpoint.cc
     15  Waypointarrow.cc
    1516  Waypoint.cc
    1617)
  • code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc

    r11237 r11243  
    1313    {
    1414        RegisterObject(Waypoint);
    15 
    16         this->setPriority(Priority::VeryLow);
    17 
    18         this->registerVariables();
     15        model = new Model(this->getContext());
     16        model->setMeshSource("cube.mesh");  // Name of the arrow file for now bottle
     17        model->setScale(3);
     18        //model->setOrientation(Vector3(0,0,-1));
     19        model->setPosition(this->getPosition());        // this is wrong, it has to be triggered
    1920    }
    2021
     
    2425
    2526
     27     WorldEntity::setDirection
     28     WorldEntity::getPosition()
     29     setOrientation()
     30
     31
    2632    void Waypoint::XMLPort(Element& xmlelement, XMLPort::Mode mode){
    2733        SUPER(Waypoint, XMLPort, xmlelement, mode); // From the SpaceShip.cc file
    28 
    29 
    3034        //XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); // TRY ADDING THE WAYPOINT ARROW LIKE AN ENGINE
    3135 
     
    3438
    3539
    36 
    37     void Waypoint::registerVariables()
    38     {
    39         // Ugly const casts, but are valid because position and orientation are not actually const
    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));
    44     }
    45 
    46 
    47 
    48     void Waypoint::setOrientation(const Quaternion& orientation)
    49     {
    50         if (this->addedToPhysicalWorld())
    51         {
    52             orxout(internal_warning) << "Attempting to change the orientation of a StaticEntity at physics run time. Ignoring change." << endl;
    53             return;
    54         }
    55         if (this->isStatic())
    56         {
    57             btTransform transf = this->physicalBody_->getWorldTransform();
    58             transf.setRotation(btQuaternion(orientation.x, orientation.y, orientation.z, orientation.w));
    59             this->physicalBody_->setWorldTransform(transf);
    60         }
    61 
    62         this->node_->setOrientation(orientation);
    63  
    64     }
    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 
    75 /*
    76     bool StaticEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
    77     {
    78         if (type == WorldEntity::CollisionType::Kinematic || type == WorldEntity::CollisionType::Dynamic)
    79         {
    80             orxout(internal_warning) << "Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << endl;
    81             assert(false); // Only in debug mode
    82             return false;
    83         }
    84         else
    85             return true;
    86     }
    87 */
    88     void Waypoint::setWorldTransform(const btTransform& worldTrans)
    89     {
    90         OrxAssert(false, "Setting world transform of a StaticEntity, which is CF_STATIC!");
    91     }
    92 
    93     void Waypoint::getWorldTransform(btTransform& worldTrans) const
    94     {
    95         worldTrans.setOrigin(btVector3(node_->getPosition().x, node_->getPosition().y, node_->getPosition().z));
    96         worldTrans.setRotation(btQuaternion(node_->getOrientation().x, node_->getOrientation().y, node_->getOrientation().z, node_->getOrientation().w));
    97     }
    9840}
    99 
    100 
    101 const Pawn* pawnPtr = orxonox_cast<const Pawn*>(it->first->getWorldEntity());
    102 
    103 if (pawnPtr) {
    104    float position = pawnPtr->getPosition();
  • code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.h

    r11237 r11243  
    66#include "OrxonoxPrereqs.h"
    77#include "StaticEntity.h"
    8 #include "overlays/OverlaysPrereqs.h"
     8#include "graphics/Model.h"
    99
    1010#include <map>
     
    1313#include "util/OgreForwardRefs.h"
    1414#include "tools/interfaces/Tickable.h"
    15 #include "interfaces/RadarListener.h"
    16 #include "overlays/OrxonoxOverlay.h"
    1715
    1816namespace orxonox
     
    3028    */
    3129
    32     class _OrxonoxExport Waypoint : public StaticEntity, public RadarListener
    33     {
     30    class _OrxonoxExport Waypoint : public StaticEntity {
     31       
    3432        public:
     33
    3534            Waypoint(Context* context);
    3635            virtual ~Waypoint();
    3736
    38             virtual void addObject(RadarViewable* object) override;
    39             virtual void removeObject(RadarViewable* viewable) override;
    40             virtual void objectChanged(RadarViewable* viewable) override;
    4137
    42             using StaticEntity::setPosition;
    43             using StaticEntity::setOrientation;
    44 
    45             virtual void setPosition(const Vector3& position) override;
    46             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();
     38            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5939
    6040
    6141
    6242        private:
    63             void registerVariables();
     43   
    6444            //virtual bool isCollisionTypeLegal(CollisionType type) const override;
    65 
     45            Model* model;
     46           
    6647            // network callbacks
    67             inline void positionChanged()
    68                 { this->setPosition(this->getPosition()); }
    69             inline void orientationChanged()
    70                 { this->setOrientation(this->getOrientation()); }
    71 
    72             // Bullet btMotionState related
    73             virtual void setWorldTransform(const btTransform& worldTrans) override;
    74             virtual void getWorldTransform(btTransform& worldTrans) const override;
    7548    };
    7649}
    7750
    78 #endif /* _StaticEntity_H__ */
     51#endif /* _Waypoint_H__ */
Note: See TracChangeset for help on using the changeset viewer.