Changeset 2256 for code/branches/objecthierarchy2/src/orxonox/objects
- Timestamp:
- Nov 25, 2008, 1:14:19 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/Radar.cc
r2087 r2256 112 112 for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement) 113 113 { 114 /* 115 if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) 114 if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) 116 115 (*itListener)->displayObject(*itElement, *itElement == this->focus_); 117 */118 116 } 119 117 } … … 128 126 this->focus_ = 0; 129 127 } 130 else 131 { 132 Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition(); 128 /* 129 else if (this->owner_) 130 { 131 Vector3 localPosition = this->owner_->getPosition(); 133 132 Vector3 targetPosition = localPosition; 134 133 if (*(this->itFocus_)) … … 143 142 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it) 144 143 { 145 /* 146 if (*it == SpaceShip::getLocalShip()) 144 if (*it == (RadarViewable*)this->owner_) 147 145 continue; 148 */ 146 149 147 float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition()); 150 148 if (targetDistance > currentDistance && targetDistance < nextDistance) … … 171 169 } 172 170 } 171 */ 173 172 } 174 173 -
code/branches/objecthierarchy2/src/orxonox/objects/RadarViewable.cc
r2087 r2256 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "RadarViewable.h" 31 31 32 #include "util/Debug.h" 33 #include "util/Exception.h" 32 34 #include "core/CoreIncludes.h" 33 //#include "objects/WorldEntity.h"34 #include " Radar.h"35 #include "objects/worldentities/WorldEntity.h" 36 #include "objects/Radar.h" 35 37 36 38 namespace orxonox … … 40 42 */ 41 43 RadarViewable::RadarViewable() 42 : radarObject_(0) 43 , radarObjectCamouflage_(0.0f) 44 , radarObjectType_(Dot) 44 : radarObjectCamouflage_(0.0f) 45 , radarObjectShape_(Dot) 45 46 , radarObjectDescription_("staticObject") 46 47 { … … 52 53 Radar* radar = Radar::getInstancePtr(); 53 54 if (radar) 54 this->radarObject Type_ = radar->addObjectDescription(str);55 this->radarObjectShape_ = radar->addObjectDescription(str); 55 56 else 56 57 { … … 62 63 const Vector3& RadarViewable::getWorldPosition() const 63 64 { 64 validate(); 65 return Vector3::ZERO;//this->radarObject_->getWorldPosition(); 65 const WorldEntity* object = this->getWorldEntity(); 66 validate(object); 67 return object->getWorldPosition(); 66 68 } 67 69 68 70 Vector3 RadarViewable::getOrientedVelocity() const 69 71 { 70 validate(); 71 return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity(); 72 const WorldEntity* object = this->getWorldEntity(); 73 validate(object); 74 return object->getWorldOrientation() * object->getVelocity(); 72 75 } 73 76 } -
code/branches/objecthierarchy2/src/orxonox/objects/RadarViewable.h
r2087 r2256 44 44 class _OrxonoxExport RadarViewable : virtual public OrxonoxClass 45 45 { 46 class WorldEntity;47 48 46 public: 49 47 enum Shape … … 58 56 virtual ~RadarViewable() { } 59 57 60 float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; } 61 void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; } 58 inline void setRadarObjectCamouflage(float camouflage) 59 { this->radarObjectCamouflage_ = camouflage; } 60 inline float getRadarObjectCamouflage() const 61 { return this->radarObjectCamouflage_; } 62 62 63 const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; } 64 void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; } 63 inline void setRadarObjectColour(const ColourValue& colour) 64 { this->radarObjectColour_ = colour; } 65 inline const ColourValue& getRadarObjectColour() const 66 { return this->radarObjectColour_; } 65 67 66 const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; }67 68 void setRadarObjectDescription(const std::string& str); 69 inline const std::string& getRadarObjectDescription() const 70 { return this->radarObjectDescription_; } 68 71 69 const WorldEntity* getWorldEntity() const { return this->radarObject_; } 72 virtual const WorldEntity* getWorldEntity() const = 0; 73 70 74 const Vector3& getWorldPosition() const; 71 75 Vector3 getOrientedVelocity() const; 72 76 73 Shape getRadarObjectType() const { return this->radarObjectType_; }74 75 protected:76 WorldEntity* radarObject_;77 inline void setRadarObjectShape(Shape shape) 78 { this->radarObjectShape_ = shape; } 79 inline Shape getRadarObjectShape() const 80 { return this->radarObjectShape_; } 77 81 78 82 private: 79 void validate() const { if (!this->radarObject_) 80 { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } } 83 void validate(const WorldEntity* object) const 84 { 85 if (!object) 86 { 87 COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; 88 assert(0); 89 } 90 } 81 91 82 92 float radarObjectCamouflage_; 83 Shape radarObject Type_;93 Shape radarObjectShape_; 84 94 std::string radarObjectDescription_; 85 95 ColourValue radarObjectColour_; -
code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.cc
r2254 r2256 64 64 Engine::~Engine() 65 65 { 66 if (this->isInitialized() && this->ship_) 67 this->ship_->setEngine(0); 66 68 } 67 69 … … 111 113 Synchronisable* object = Synchronisable::getSynchronisable(this->shipID_); 112 114 if (object) 113 this-> ship_ = dynamic_cast<SpaceShip*>(object);115 this->addToSpaceShip(dynamic_cast<SpaceShip*>(object)); 114 116 } 115 117 } … … 182 184 this->ship_ = ship; 183 185 if (ship) 186 { 184 187 this->shipID_ = ship->getObjectID(); 188 if (ship->getEngine() != this) 189 ship->setEngine(this); 190 } 185 191 } 186 192 -
code/branches/objecthierarchy2/src/orxonox/objects/items/Engine.h
r2254 r2256 72 72 { this->maxSpeedUpDown_ = speed; } 73 73 74 inline float getMaxSpeedFront() const 75 { return this->maxSpeedFront_; } 76 inline float getMaxSpeedBack() const 77 { return this->maxSpeedBack_; } 78 inline float getMaxSpeedLeftRight() const 79 { return this->maxSpeedLeftRight_; } 80 inline float getMaxSpeedUpDown() const 81 { return this->maxSpeedUpDown_; } 82 74 83 inline void setAccelerationFront(float acceleration) 75 84 { this->accelerationFront_ = acceleration; } … … 82 91 inline void setAccelerationUpDown(float acceleration) 83 92 { this->accelerationUpDown_ = acceleration; } 93 94 inline float getAccelerationFront() const 95 { return this->accelerationFront_; } 96 inline float getAccelerationBrake() const 97 { return this->accelerationBrake_; } 98 inline float getAccelerationBack() const 99 { return this->accelerationBack_; } 100 inline float getAccelerationLeftRight() const 101 { return this->accelerationLeftRight_; } 102 inline float getAccelerationUpDown() const 103 { return this->accelerationUpDown_; } 84 104 85 105 virtual const Vector3& getDirection() const; -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc
r2254 r2256 168 168 { 169 169 this->client_overwrite_ = this->server_overwrite_; 170 COUT(0) << "CE: bidirectional synchronization" << std::endl;171 170 this->setObjectMode(direction::bidirectional); 172 171 } … … 202 201 void ControllableEntity::startLocalHumanControl() 203 202 { 204 // std::cout << this->getObjectID() << " ###### start local control" << std::endl;205 203 this->camera_ = new Camera(this); 206 204 this->camera_->requestFocus(); … … 216 214 this->hud_ = new OverlayGroup(this); 217 215 this->hud_->addTemplate(this->hudtemplate_); 216 this->hud_->setOwner(this); 218 217 } 219 218 } … … 221 220 void ControllableEntity::stopLocalHumanControl() 222 221 { 223 // std::cout << "###### stop local control" << std::endl;224 222 this->camera_->detachFromParent(); 225 223 delete this->camera_; … … 244 242 else if (this->bHasLocalController_) 245 243 { 246 // COUT(2) << "setting client position" << endl;247 244 this->client_velocity_ = this->velocity_; 248 245 this->client_position_ = this->node_->getPosition(); … … 254 251 { 255 252 REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient); 253 REGISTERSTRING(this->hudtemplate_, direction::toclient); 256 254 257 255 REGISTERDATA(this->client_overwrite_, direction::toserver); … … 304 302 if (this->server_overwrite_ == this->client_overwrite_) 305 303 { 306 // COUT(2) << "callback: setting client position" << endl;307 304 this->node_->setPosition(this->client_position_); 308 305 this->server_position_ = this->client_position_; 309 306 } 310 // else311 // COUT(2) << "callback: not setting client position" << endl;312 307 } 313 308 -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/WorldEntity.h
r2212 r2256 72 72 inline void translate(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) 73 73 { this->translate(Vector3(x, y, z), relativeTo); } 74 75 virtual inline const Vector3& getVelocity() const 76 { return Vector3::ZERO; } 74 77 75 78 virtual void setOrientation(const Quaternion& orientation) = 0; -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2171 r2256 61 61 this->weaponSystem_->getWeaponSetPointer(0)->getWeaponSlotPointer(0)->setAmmoType(true); 62 62 */ 63 64 this->setRadarObjectColour(ColourValue::Red); 65 this->setRadarObjectShape(RadarViewable::Dot); 63 66 64 67 this->registerVariables(); -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2098 r2256 33 33 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/RadarViewable.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport Pawn : public ControllableEntity 39 class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable 39 40 { 40 41 public: … … 78 79 virtual void postSpawn(); 79 80 81 inline const WorldEntity* getWorldEntity() const 82 { return (WorldEntity*)this; } 83 80 84 protected: 81 85 virtual void spawn(); -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2254 r2256 229 229 } 230 230 } 231 232 void SpaceShip::setEngine(Engine* engine) 233 { 234 this->engine_ = engine; 235 if (engine && engine->getShip() != this) 236 engine->addToSpaceShip(this); 237 } 231 238 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/SpaceShip.h
r2254 r2256 58 58 virtual void boost(); 59 59 60 void setEngine(Engine* engine); 61 inline Engine* getEngine() const 62 { return this->engine_; } 63 60 64 void setMaxRotation(const Degree& value) 61 65 { this->maxRotation_ = value; }
Note: See TracChangeset
for help on using the changeset viewer.