- Timestamp:
- Oct 24, 2008, 2:48:43 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2001 r2006 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "core/Core.h" 33 34 #include "objects/worldentities/Model.h" 35 #include "tools/BillboardSet.h" 34 36 35 37 namespace orxonox … … 51 53 this->setDestroyWhenPlayerLeft(true); 52 54 53 Model* temp = new Model; 54 temp->setMeshSource("assff.mesh"); 55 this->attach(temp); 55 // test test test 56 { 57 this->testmesh_ = new Mesh(); 58 this->testnode_ = this->getNode()->createChildSceneNode(); 59 this->testmesh_->setMeshSource("assff.mesh"); 60 if (this->testmesh_->getEntity()) 61 this->testnode_->attachObject(this->testmesh_->getEntity()); 62 this->testnode_->pitch(Degree(-90)); 63 this->testnode_->roll(Degree(+90)); 64 this->testnode_->scale(10, 10, 10); 65 } 66 // test test test 67 68 this->greetingFlare_ = new BillboardSet(); 69 this->greetingFlare_->setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); 70 this->getNode()->attachObject(this->greetingFlare_->getBillboardSet()); 71 this->greetingFlare_->setVisible(false); 72 this->bGreetingFlareVisible_ = false; 73 this->bGreeting_ = false; 74 75 this->registerVariables(); 56 76 } 57 77 58 78 Spectator::~Spectator() 59 79 { 80 if (this->isInitialized()) 81 { 82 delete this->greetingFlare_; 83 84 // test test test 85 { 86 delete this->testmesh_; 87 delete this->testnode_; 88 } 89 // test test test 90 } 91 } 92 93 void Spectator::registerVariables() 94 { 95 REGISTERDATA(this->bGreetingFlareVisible_, network::direction::toclient, new network::NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 96 REGISTERDATA(this->bGreeting_, network::direction::toserver, new network::NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 97 } 98 99 void Spectator::changedGreeting() 100 { 101 this->bGreetingFlareVisible_ = this->bGreeting_; 102 this->changedFlareVisibility(); 103 } 104 105 void Spectator::changedFlareVisibility() 106 { 107 this->greetingFlare_->setVisible(this->bGreetingFlareVisible_); 60 108 } 61 109 62 110 void Spectator::tick(float dt) 63 111 { 64 Vector3 velocity = this->getVelocity(); 65 velocity.normalise(); 66 this->setVelocity(velocity * this->speed_); 112 if (this->isLocallyControlled()) 113 { 114 Vector3 velocity = this->getVelocity(); 115 velocity.normalise(); 116 this->setVelocity(velocity * this->speed_); 67 117 68 // TODO: Check why I have removed *dt (1337) 69 this->yaw(Radian(this->yaw_ * this->rotationSpeed_)); 70 this->pitch(Radian(this->pitch_ * this->rotationSpeed_)); 71 this->roll(Radian(this->roll_ * this->rotationSpeed_)); 118 this->yaw(Radian(this->yaw_ * this->rotationSpeed_)); 119 this->pitch(Radian(this->pitch_ * this->rotationSpeed_)); 120 this->roll(Radian(this->roll_ * this->rotationSpeed_)); 72 121 73 this->yaw_ = this->pitch_ = this->roll_ = 0; 122 this->yaw_ = this->pitch_ = this->roll_ = 0; 123 } 74 124 75 125 SUPER(Spectator, tick, dt); 76 126 77 this->setVelocity(Vector3::ZERO); 127 if (this->isLocallyControlled()) 128 { 129 this->setVelocity(Vector3::ZERO); 130 } 78 131 } 79 132 … … 82 135 ControllableEntity::setPlayer(player); 83 136 84 this->setObjectMode(network::direction::toclient); 137 // this->setObjectMode(network::direction::toclient); 138 } 139 140 void Spectator::startLocalControl() 141 { 142 ControllableEntity::startLocalControl(); 143 if (this->isLocallyControlled()) 144 this->testmesh_->setVisible(false); 85 145 } 86 146 … … 118 178 { 119 179 } 180 181 void Spectator::greet() 182 { 183 this->bGreeting_ = !this->bGreeting_; 184 185 if (Core::isMaster()) 186 { 187 this->bGreetingFlareVisible_ = this->bGreeting_; 188 this->changedFlareVisibility(); 189 } 190 } 120 191 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.h
r1993 r2006 42 42 virtual ~Spectator(); 43 43 44 void registerVariables(); 44 45 virtual void tick(float dt); 45 46 46 47 virtual void setPlayer(PlayerInfo* player); 48 virtual void startLocalControl(); 47 49 48 50 virtual void moveFrontBack(float value); … … 55 57 56 58 virtual void fire(); 59 virtual void greet(); 57 60 58 61 private: 62 void changedGreeting(); 63 void changedFlareVisibility(); 64 65 BillboardSet* greetingFlare_; 66 bool bGreetingFlareVisible_; 67 bool bGreeting_; 68 59 69 float speed_; 60 70 float rotationSpeed_; … … 63 73 float pitch_; 64 74 float roll_; 75 76 // test test test 77 Mesh* testmesh_; 78 Ogre::SceneNode* testnode_; 79 // test test test 65 80 }; 66 81 }
Note: See TracChangeset
for help on using the changeset viewer.