Changeset 11243 for code/branches/QuestGuide_HS16/src/orxonox
- Timestamp:
- Oct 24, 2016, 4:01:11 PM (8 years ago)
- 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 13 13 ExplosionPart.cc 14 14 Actionpoint.cc 15 Waypointarrow.cc 15 16 Waypoint.cc 16 17 ) -
code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc
r11237 r11243 13 13 { 14 14 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 19 20 } 20 21 … … 24 25 25 26 27 WorldEntity::setDirection 28 WorldEntity::getPosition() 29 setOrientation() 30 31 26 32 void Waypoint::XMLPort(Element& xmlelement, XMLPort::Mode mode){ 27 33 SUPER(Waypoint, XMLPort, xmlelement, mode); // From the SpaceShip.cc file 28 29 30 34 //XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); // TRY ADDING THE WAYPOINT ARROW LIKE AN ENGINE 31 35 … … 34 38 35 39 36 37 void Waypoint::registerVariables()38 {39 // Ugly const casts, but are valid because position and orientation are not actually const40 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) const67 {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) const77 {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 mode82 return false;83 }84 else85 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) const94 {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 }98 40 } 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 6 6 #include "OrxonoxPrereqs.h" 7 7 #include "StaticEntity.h" 8 #include " overlays/OverlaysPrereqs.h"8 #include "graphics/Model.h" 9 9 10 10 #include <map> … … 13 13 #include "util/OgreForwardRefs.h" 14 14 #include "tools/interfaces/Tickable.h" 15 #include "interfaces/RadarListener.h"16 #include "overlays/OrxonoxOverlay.h"17 15 18 16 namespace orxonox … … 30 28 */ 31 29 32 class _OrxonoxExport Waypoint : public StaticEntity , public RadarListener33 {30 class _OrxonoxExport Waypoint : public StaticEntity { 31 34 32 public: 33 35 34 Waypoint(Context* context); 36 35 virtual ~Waypoint(); 37 36 38 virtual void addObject(RadarViewable* object) override;39 virtual void removeObject(RadarViewable* viewable) override;40 virtual void objectChanged(RadarViewable* viewable) override;41 37 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; 59 39 60 40 61 41 62 42 private: 63 void registerVariables();43 64 44 //virtual bool isCollisionTypeLegal(CollisionType type) const override; 65 45 Model* model; 46 66 47 // network callbacks 67 inline void positionChanged()68 { this->setPosition(this->getPosition()); }69 inline void orientationChanged()70 { this->setOrientation(this->getOrientation()); }71 72 // Bullet btMotionState related73 virtual void setWorldTransform(const btTransform& worldTrans) override;74 virtual void getWorldTransform(btTransform& worldTrans) const override;75 48 }; 76 49 } 77 50 78 #endif /* _ StaticEntity_H__ */51 #endif /* _Waypoint_H__ */
Note: See TracChangeset
for help on using the changeset viewer.