- Timestamp:
- Oct 27, 2008, 4:08:51 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/objects/worldentities
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
r2006 r2019 43 43 CreateFactory(ControllableEntity); 44 44 45 ControllableEntity::ControllableEntity( )45 ControllableEntity::ControllableEntity(BaseObject* creator) : WorldEntity(creator) 46 46 { 47 47 RegisterObject(ControllableEntity); … … 71 71 ControllableEntity::~ControllableEntity() 72 72 { 73 if (this->isInitialized() && this->bControlled_) 74 this->stopLocalControl(); 73 if (this->isInitialized()) 74 { 75 if (this->bControlled_) 76 this->stopLocalControl(); 77 78 if (this->hud_) 79 delete this->hud_; 80 81 if (this->camera_) 82 delete this->camera_; 83 } 75 84 } 76 85 … … 92 101 this->player_ = player; 93 102 this->playerID_ = player->getObjectID(); 94 this->bControlled_ = player->isLocalPlayer();103 this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer()); 95 104 96 105 if (this->bControlled_) 97 106 { 98 107 this->startLocalControl(); 99 this->setObjectMode(network::direction::bidirectional); 108 109 if (!Core::isMaster()) 110 this->setObjectMode(network::direction::bidirectional); 100 111 } 101 112 } … … 115 126 } 116 127 117 void ControllableEntity::updatePlayer() 118 { 128 void ControllableEntity::networkcallback_changedplayerID() 129 { 130 // just do this in case the entity wasn't yet synchronized when the corresponding PlayerInfo got our objectID 119 131 if (this->playerID_ != network::OBJECTID_UNKNOWN) 120 132 { 121 133 this->player_ = dynamic_cast<PlayerInfo*>(network::Synchronisable::getSynchronisable(this->playerID_)); 122 if (this->player_ && (this->player_->get Pawn() != this))134 if (this->player_ && (this->player_->getControllableEntity() != this)) 123 135 this->player_->startControl(this); 124 136 } … … 128 140 { 129 141 std::cout << this->getObjectID() << " ###### start local control" << std::endl; 130 this->camera_ = new Camera( );142 this->camera_ = new Camera(this); 131 143 this->camera_->requestFocus(); 132 144 this->attach(this->camera_); … … 134 146 if (this->hudtemplate_ != "") 135 147 { 136 this->hud_ = new OverlayGroup( );148 this->hud_ = new OverlayGroup(this); 137 149 this->hud_->addTemplate(this->hudtemplate_); 138 150 } … … 184 196 REGISTERDATA(this->client_overwrite_, network::direction::toserver); 185 197 186 REGISTERDATA(this->playerID_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity:: updatePlayer));198 REGISTERDATA(this->playerID_, network::direction::toclient, new network::NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 187 199 } 188 200 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.h
r2006 r2019 40 40 { 41 41 public: 42 ControllableEntity( );42 ControllableEntity(BaseObject* creator); 43 43 virtual ~ControllableEntity(); 44 44 … … 56 56 inline bool getDestroyWhenPlayerLeft() const 57 57 { return this->bDestroyWhenPlayerLeft_; } 58 59 virtual void startLocalControl();60 virtual void stopLocalControl();61 58 62 59 virtual void moveFrontBack(float value) {} … … 82 79 { return this->hudtemplate_; } 83 80 84 protected:85 81 using WorldEntity::setPosition; 86 82 using WorldEntity::translate; … … 112 108 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; } 113 109 110 protected: 111 virtual void startLocalControl(); 112 virtual void stopLocalControl(); 113 114 114 inline void setHudTemplate(const std::string& name) 115 115 { this->hudtemplate_ = name; } … … 130 130 void processClientOrientation(); 131 131 132 void updatePlayer();132 void networkcallback_changedplayerID(); 133 133 134 134 unsigned int server_overwrite_; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Model.cc
r2006 r2019 32 32 #include "core/CoreIncludes.h" 33 33 #include "core/XMLPort.h" 34 #include "objects/Scene.h" 34 35 35 36 namespace orxonox … … 37 38 CreateFactory(Model); 38 39 39 Model::Model( )40 Model::Model(BaseObject* creator) : PositionableEntity(creator) 40 41 { 41 42 RegisterObject(Model); … … 69 70 this->getNode()->detachObject(this->mesh_.getEntity()); 70 71 71 this->mesh_.setMeshSource(this-> meshSrc_);72 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 72 73 73 74 if (this->mesh_.getEntity()) -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Model.h
r2006 r2019 39 39 { 40 40 public: 41 Model( );41 Model(BaseObject* creator); 42 42 virtual ~Model(); 43 43 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/MovableEntity.cc
r1994 r2019 41 41 CreateFactory(MovableEntity); 42 42 43 MovableEntity::MovableEntity( )43 MovableEntity::MovableEntity(BaseObject* creator) : WorldEntity(creator) 44 44 { 45 45 RegisterObject(MovableEntity); -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/MovableEntity.h
r1993 r2019 41 41 { 42 42 public: 43 MovableEntity( );43 MovableEntity(BaseObject* creator); 44 44 virtual ~MovableEntity(); 45 45 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.cc
r2006 r2019 35 35 CreateFactory(PositionableEntity); 36 36 37 PositionableEntity::PositionableEntity( )37 PositionableEntity::PositionableEntity(BaseObject* creator) : WorldEntity(creator) 38 38 { 39 39 RegisterObject(PositionableEntity); -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/PositionableEntity.h
r2006 r2019 38 38 { 39 39 public: 40 PositionableEntity( );40 PositionableEntity(BaseObject* creator); 41 41 virtual ~PositionableEntity(); 42 42 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
r2006 r2019 30 30 #include "WorldEntity.h" 31 31 32 #include <cassert> 32 33 #include <OgreSceneManager.h> 33 34 … … 37 38 38 39 #include "GraphicsEngine.h" 40 #include "objects/Scene.h" 39 41 40 42 namespace orxonox … … 47 49 const Vector3 WorldEntity::UP = Vector3::UNIT_Y; 48 50 49 WorldEntity::WorldEntity( )51 WorldEntity::WorldEntity(BaseObject* creator) : BaseObject(creator) 50 52 { 51 53 RegisterObject(WorldEntity); 52 54 53 this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(); 55 assert(this->getScene()); 56 assert(this->getScene()->getRootSceneNode()); 57 58 this->node_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 59 54 60 this->parent_ = 0; 55 61 this->parentID_ = (unsigned int)-1; … … 66 72 { 67 73 this->node_->detachAllObjects(); 68 GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->node_->getName()); 74 if (this->getScene()->getSceneManager()) 75 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName()); 69 76 } 70 77 } 71 72 78 73 79 void WorldEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 131 137 object->parentID_ = (unsigned int)-1; 132 138 133 GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->addChild(object->node_);139 this->getScene()->getRootSceneNode()->addChild(object->node_); 134 140 } 135 141 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.h
r1989 r2019 45 45 { 46 46 public: 47 WorldEntity( );47 WorldEntity(BaseObject* creator); 48 48 virtual ~WorldEntity(); 49 49 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2006 r2019 33 33 #include "core/Core.h" 34 34 #include "objects/worldentities/Model.h" 35 #include "objects/Scene.h" 36 #include "objects/infos/PlayerInfo.h" 35 37 #include "tools/BillboardSet.h" 36 38 … … 39 41 CreateFactory(Spectator); 40 42 41 Spectator::Spectator( )43 Spectator::Spectator(BaseObject* creator) : ControllableEntity(creator) 42 44 { 43 45 RegisterObject(Spectator); … … 54 56 55 57 // test test test 58 if (this->getScene()->getSceneManager()) 56 59 { 57 60 this->testmesh_ = new Mesh(); 58 61 this->testnode_ = this->getNode()->createChildSceneNode(); 59 this->testmesh_->setMeshSource( "assff.mesh");62 this->testmesh_->setMeshSource(this->getScene()->getSceneManager(), "assff.mesh"); 60 63 if (this->testmesh_->getEntity()) 61 64 this->testnode_->attachObject(this->testmesh_->getEntity()); … … 64 67 this->testnode_->scale(10, 10, 10); 65 68 } 69 else 70 { 71 this->testmesh_ = 0; 72 this->testnode_ = 0; 73 } 66 74 // test test test 67 75 68 76 this->greetingFlare_ = new BillboardSet(); 69 this->greetingFlare_->setBillboardSet( "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);77 this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); 70 78 this->getNode()->attachObject(this->greetingFlare_->getBillboardSet()); 71 79 this->greetingFlare_->setVisible(false); … … 80 88 if (this->isInitialized()) 81 89 { 82 delete this->greetingFlare_; 90 if (this->greetingFlare_) 91 { 92 this->getNode()->detachObject(this->greetingFlare_->getBillboardSet()); 93 delete this->greetingFlare_; 94 } 83 95 84 96 // test test test 85 97 { 86 delete this->testmesh_; 87 delete this->testnode_; 98 if (this->testmesh_ && this->testnode_) 99 this->testnode_->detachObject(this->testmesh_->getEntity()); 100 101 if (this->testmesh_) 102 delete this->testmesh_; 103 104 if (this->testnode_) 105 this->getNode()->removeAndDestroyChild(this->testnode_->getName()); 88 106 } 89 107 // test test test … … 177 195 void Spectator::fire() 178 196 { 197 if (this->getPlayer()) 198 this->getPlayer()->setReadyToSpawn(true); 179 199 } 180 200 -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.h
r2006 r2019 39 39 { 40 40 public: 41 Spectator( );41 Spectator(BaseObject* creator); 42 42 virtual ~Spectator(); 43 43
Note: See TracChangeset
for help on using the changeset viewer.