- Timestamp:
- Oct 22, 2008, 5:25:01 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/objects/worldentities
- Files:
-
- 5 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
r1989 r1993 53 53 this->hud_ = 0; 54 54 this->camera_ = 0; 55 55 this->bDestroyWhenPlayerLeft_ = false; 56 56 57 57 this->velocity_ = Vector3::ZERO; … … 94 94 95 95 if (this->bControlled_) 96 { 96 97 this->startLocalControl(); 98 this->setObjectMode(network::direction::bidirectional); 99 } 97 100 } 98 101 … … 105 108 this->playerID_ = network::OBJECTID_UNKNOWN; 106 109 this->bControlled_ = false; 110 this->setObjectMode(network::direction::toclient); 111 112 if (this->bDestroyWhenPlayerLeft_) 113 delete this; 107 114 } 108 115 109 116 void ControllableEntity::updatePlayer() 110 117 { 111 this->player_ = dynamic_cast<PlayerInfo*>(network::Synchronisable::getSynchronisable(this->playerID_)); 112 if (this->player_ && (this->player_->getPawn() != this)) 113 this->player_->startControl(this); 118 if (this->playerID_ != network::OBJECTID_UNKNOWN) 119 { 120 this->player_ = dynamic_cast<PlayerInfo*>(network::Synchronisable::getSynchronisable(this->playerID_)); 121 if (this->player_ && (this->player_->getPawn() != this)) 122 this->player_->startControl(this); 123 } 114 124 } 115 125 116 126 void ControllableEntity::startLocalControl() 117 127 { 128 std::cout << "###### start local control" << std::endl; 118 129 this->camera_ = new Camera(); 119 130 this->camera_->requestFocus(); 120 121 this->hud_ = new OverlayGroup(); 122 this->hud_->addTemplate(this->hudtemplate_); 131 this->attach(this->camera_); 132 133 if (this->hudtemplate_ != "") 134 { 135 this->hud_ = new OverlayGroup(); 136 this->hud_->addTemplate(this->hudtemplate_); 137 } 123 138 } 124 139 125 140 void ControllableEntity::stopLocalControl() 126 141 { 142 std::cout << "###### stop local control" << std::endl; 143 this->detach(this->camera_); 127 144 delete this->camera_; 128 145 this->camera_ = 0; … … 137 154 { 138 155 this->velocity_ += (dt * this->acceleration_); 139 this->node_->translate(dt * this->velocity_ );156 this->node_->translate(dt * this->velocity_, Ogre::Node::TS_PARENT); 140 157 141 158 if (Core::isMaster()) … … 150 167 } 151 168 } 152 153 // std::cout << this->getPosition() << std::endl;154 169 } 155 170 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.h
r1989 r1993 52 52 { return this->player_; } 53 53 54 inline void setDestroyWhenPlayerLeft(bool bDestroy) 55 { this->bDestroyWhenPlayerLeft_ = bDestroy; } 56 inline bool getDestroyWhenPlayerLeft() const 57 { return this->bDestroyWhenPlayerLeft_; } 58 54 59 virtual void startLocalControl(); 55 60 virtual void stopLocalControl(); … … 70 75 virtual void switchCamera() {} 71 76 77 inline const Vector3& getVelocity() const 78 { return this->velocity_; } 79 inline const Vector3& getAcceleration() const 80 { return this->acceleration_; } 81 inline const std::string& getHudTemplate() const 82 { return this->hudtemplate_; } 83 72 84 protected: 73 85 using WorldEntity::setPosition; … … 75 87 using WorldEntity::setOrientation; 76 88 using WorldEntity::rotate; 89 using WorldEntity::yaw; 90 using WorldEntity::pitch; 91 using WorldEntity::roll; 77 92 using WorldEntity::lookAt; 78 93 using WorldEntity::setDirection; … … 91 106 inline void setVelocity(float x, float y, float z) 92 107 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; } 93 inline const Vector3& getVelocity() const94 { return this->velocity_; }95 108 96 109 inline void setAcceleration(const Vector3& acceleration) … … 98 111 inline void setAcceleration(float x, float y, float z) 99 112 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; } 100 inline const Vector3& getAcceleration() const 101 { return this->acceleration_; } 113 114 inline void setHudTemplate(const std::string& name) 115 { this->hudtemplate_ = name; } 102 116 103 117 private: 104 inline void setHudTemplate(const std::string& name)105 { this->hudtemplate_ = name; }106 inline const std::string& getHudTemplate() const107 { return this->hudtemplate_; }108 109 118 void overwrite(); 110 119 void processOverwrite(); … … 139 148 OverlayGroup* hud_; 140 149 Camera* camera_; 150 bool bDestroyWhenPlayerLeft_; 141 151 }; 142 152 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/MovableEntity.cc
r1989 r1993 79 79 this->node_->rotate(this->rotationAxis_, this->rotationRate_ * dt); 80 80 } 81 82 std::cout << this->getPosition() << std::endl;83 81 } 84 82 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/MovableEntity.h
r1989 r1993 52 52 using WorldEntity::setOrientation; 53 53 using WorldEntity::rotate; 54 using WorldEntity::yaw; 55 using WorldEntity::pitch; 56 using WorldEntity::roll; 54 57 using WorldEntity::lookAt; 55 58 using WorldEntity::setDirection; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.cc
r1960 r1993 57 57 REGISTERDATA(this->getOrientation().z, network::direction::toclient); 58 58 } 59 60 void PositionableEntity::tick(float dt) 61 { 62 // I don't know why but this has to be done to update the position if attached to another Entity 63 this->node_->translate(Vector3::ZERO); 64 std::cout << this->getWorldPosition() << std::endl; 65 } 59 66 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.h
r1989 r1993 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "WorldEntity.h" 34 #include "objects/Tickable.h" 34 35 35 36 namespace orxonox 36 37 { 37 class _OrxonoxExport PositionableEntity : public WorldEntity 38 class _OrxonoxExport PositionableEntity : public WorldEntity, public Tickable 38 39 { 39 40 public: … … 42 43 43 44 void registerVariables(); 45 virtual void tick(float dt); 44 46 45 47 using WorldEntity::setPosition; … … 47 49 using WorldEntity::setOrientation; 48 50 using WorldEntity::rotate; 51 using WorldEntity::yaw; 52 using WorldEntity::pitch; 53 using WorldEntity::roll; 49 54 using WorldEntity::lookAt; 50 55 using WorldEntity::setDirection; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
r1989 r1993 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/XMLPort.h" 36 #include "util/Convert.h" 36 37 37 38 #include "GraphicsEngine.h" … … 110 111 if (object->getParent()) 111 112 object->detachFromParent(); 113 else 114 { 115 Ogre::Node* parent = object->node_->getParent(); 116 if (parent) 117 parent->removeChild(object->node_); 118 } 112 119 113 120 this->node_->addChild(object->node_); … … 123 130 object->parent_ = 0; 124 131 object->parentID_ = (unsigned int)-1; 132 133 GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->addChild(object->node_); 125 134 } 126 135
Note: See TracChangeset
for help on using the changeset viewer.