Changeset 2485 for code/branches/presentation/src/orxonox/objects
- Timestamp:
- Dec 16, 2008, 6:01:13 PM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 90 edited
- 24 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/src/orxonox/objects/CMakeLists.txt
r2459 r2485 3 3 EventDispatcher.cc 4 4 EventTarget.cc 5 GlobalShader.cc 5 6 Level.cc 6 7 Radar.cc … … 17 18 ADD_SOURCE_DIRECTORY(SRC_FILES gametypes) 18 19 ADD_SOURCE_DIRECTORY(SRC_FILES infos) 20 ADD_SOURCE_DIRECTORY(SRC_FILES items) 19 21 #ADD_SOURCE_DIRECTORY(SRC_FILES pickup) 20 22 ADD_SOURCE_DIRECTORY(SRC_FILES quest) -
code/branches/presentation/src/orxonox/objects/EventTarget.cc
r2087 r2485 48 48 void EventTarget::changedName() 49 49 { 50 SUPER(EventTarget, changedName); 51 50 52 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 51 53 if (it->getName() == this->getName()) -
code/branches/presentation/src/orxonox/objects/GlobalShader.cc
r2480 r2485 66 66 void GlobalShader::registerVariables() 67 67 { 68 REGISTERDATA (this->bVisible_, direction::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));69 REGISTERSTRING(const_cast<std::string&>(this->shader_.getCompositor()), direction::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));68 registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility)); 69 registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), variableDirection::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor)); 70 70 } 71 71 -
code/branches/presentation/src/orxonox/objects/GlobalShader.h
r2480 r2485 33 33 34 34 #include "core/BaseObject.h" 35 #include "network/ Synchronisable.h"35 #include "network/synchronisable/Synchronisable.h" 36 36 #include "tools/Shader.h" 37 37 -
code/branches/presentation/src/orxonox/objects/Level.cc
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/Level.cc (added) merged: 2173 /code/trunk/src/orxonox/objects/Level.cc merged: 2107-2169
r2459 r2485 141 141 void Level::playerEntered(PlayerInfo* player) 142 142 { 143 COUT(3) << "player entered level " << std::endl;143 COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl; 144 144 player->setGametype(this->getGametype()); 145 145 } … … 147 147 void Level::playerLeft(PlayerInfo* player) 148 148 { 149 COUT(3) << "player left level " << std::endl;149 COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl; 150 150 player->setGametype(0); 151 151 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/Level.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/Level.h merged: 2107-2169
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/Radar.cc
r2087 r2485 99 99 void Radar::tick(float dt) 100 100 { 101 SUPER(Radar, tick, dt); 102 101 103 if (this->focus_ != *(this->itFocus_)) 102 104 { … … 112 114 for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement) 113 115 { 114 /* 115 if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) 116 if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) 116 117 (*itListener)->displayObject(*itElement, *itElement == this->focus_); 117 */118 118 } 119 119 } … … 128 128 this->focus_ = 0; 129 129 } 130 else 131 { 132 Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition(); 130 /* 131 else if (this->owner_) 132 { 133 Vector3 localPosition = this->owner_->getPosition(); 133 134 Vector3 targetPosition = localPosition; 134 135 if (*(this->itFocus_)) 135 targetPosition = this->itFocus_->get WorldPosition();136 targetPosition = this->itFocus_->getRVWorldPosition(); 136 137 137 138 // find the closed object further away than targetPosition … … 143 144 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it) 144 145 { 145 /* 146 if (*it == SpaceShip::getLocalShip()) 146 if (*it == (RadarViewable*)this->owner_) 147 147 continue; 148 */ 149 float targetDistance = localPosition.squaredDistance((*it)->get WorldPosition());148 149 float targetDistance = localPosition.squaredDistance((*it)->getRVWorldPosition()); 150 150 if (targetDistance > currentDistance && targetDistance < nextDistance) 151 151 { … … 171 171 } 172 172 } 173 */ 173 174 } 174 175 … … 186 187 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i) 187 188 { 188 COUT(3) << i++ << ": " << (*it)->get WorldPosition() << std::endl;189 COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl; 189 190 } 190 191 } -
code/branches/presentation/src/orxonox/objects/RadarViewable.cc
r2087 r2485 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 { … … 60 61 } 61 62 62 const Vector3& RadarViewable::get WorldPosition() const63 const Vector3& RadarViewable::getRVWorldPosition() 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 Vector3 RadarViewable::get OrientedVelocity() const70 Vector3 RadarViewable::getRVOrientedVelocity() 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/presentation/src/orxonox/objects/RadarViewable.h
r2087 r2485 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_; } 70 const Vector3& getWorldPosition() const; 71 Vector3 getOrientedVelocity() const; 72 virtual const WorldEntity* getWorldEntity() const = 0; 72 73 73 Shape getRadarObjectType() const { return this->radarObjectType_; } 74 const Vector3& getRVWorldPosition() const; 75 Vector3 getRVOrientedVelocity() const; 74 76 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/presentation/src/orxonox/objects/Scene.cc
r2468 r2485 34 34 #include <OgreSceneManagerEnumerator.h> 35 35 #include <OgreSceneNode.h> 36 #include <OgreLight.h>37 36 38 37 #include "BulletCollision/BroadphaseCollision/btAxisSweep3.h" … … 56 55 57 56 this->setScene(this); 58 this->bShadows_ = false;57 this->bShadows_ = true; 59 58 60 59 if (Core::showsGraphics()) … … 90 89 this->broadphase_ = 0; 91 90 92 // test test test93 if (Core::showsGraphics() && this->sceneManager_)94 {95 Ogre::Light* light;96 light = this->sceneManager_->createLight("Light-1");97 light->setType(Ogre::Light::LT_DIRECTIONAL);98 light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0));99 light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0));100 light->setDirection(1, -0.3, 0.3);101 }102 // test test test103 104 91 this->registerVariables(); 105 92 } … … 145 132 registerVariable(this->gravity_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity)); 146 133 registerVariable(this->bHasPhysics_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics)); 134 registerVariable(this->bShadows_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows)); 147 135 } 148 136 … … 156 144 if (this->hasPhysics()) 157 145 { 158 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 146 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 159 147 << "This causes a complete physical reload which might take some time." << std::endl; 160 148 this->setPhysicalWorld(false); … … 175 163 if (this->hasPhysics()) 176 164 { 177 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 165 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 178 166 << "This causes a complete physical reload which might take some time." << std::endl; 179 167 this->setPhysicalWorld(false); -
code/branches/presentation/src/orxonox/objects/Scene.h
r2468 r2485 76 76 void networkcallback_applyAmbientLight() 77 77 { this->setAmbientLight(this->ambientLight_); } 78 void networkcallback_applyShadows() 79 { this->setShadow(this->bShadows_); } 78 80 79 81 Ogre::SceneManager* sceneManager_; -
code/branches/presentation/src/orxonox/objects/Script.cc
r2087 r2485 64 64 void Script::execute() 65 65 { 66 LuaBind *lua = LuaBind::getInstance();67 lua ->loadString(this->code_);68 lua ->run();66 LuaBind& lua = LuaBind::getInstance(); 67 lua.loadString(this->code_); 68 lua.run(); 69 69 } 70 70 } -
code/branches/presentation/src/orxonox/objects/controllers/CMakeLists.txt
r2131 r2485 2 2 Controller.cc 3 3 HumanController.cc 4 ArtificialController.cc 5 AIController.cc 6 ScriptController.cc 4 7 ) 5 8 -
code/branches/presentation/src/orxonox/objects/controllers/Controller.cc
r2087 r2485 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "overlays/OverlayGroup.h" 33 34 34 35 namespace orxonox … … 42 43 this->player_ = 0; 43 44 this->controllableEntity_ = 0; 45 this->hud_ = 0; 46 this->bUpdateHUD_ = false; 44 47 } 45 48 46 49 Controller::~Controller() 47 50 { 51 if (this->isInitialized() && this->hud_) 52 delete this->hud_; 53 } 54 55 void Controller::changedControllableEntity() 56 { 57 if (this->bUpdateHUD_) 58 { 59 this->updateHUD(); 60 this->bUpdateHUD_ = false; 61 } 62 63 if (this->hud_) 64 this->hud_->setOwner(this->getControllableEntity()); 65 } 66 67 void Controller::updateHUD() 68 { 69 if (this->hud_) 70 { 71 delete this->hud_; 72 this->hud_ = 0; 73 } 74 75 if (this->hudtemplate_ != "") 76 { 77 this->hud_ = new OverlayGroup(this); 78 this->hud_->addTemplate(this->hudtemplate_); 79 this->hud_->setOwner(this->getControllableEntity()); 80 } 48 81 } 49 82 } -
code/branches/presentation/src/orxonox/objects/controllers/Controller.h
r2087 r2485 47 47 { return this->player_; } 48 48 49 virtual inline void setControllableEntity(ControllableEntity* entity) 50 { this->controllableEntity_ = entity; } 51 virtual inline ControllableEntity* getControllableEntity() const 49 inline void setControllableEntity(ControllableEntity* entity) 50 { 51 if (entity != this->controllableEntity_) 52 { 53 this->controllableEntity_ = entity; 54 this->changedControllableEntity(); 55 } 56 } 57 inline ControllableEntity* getControllableEntity() const 52 58 { return this->controllableEntity_; } 59 virtual void changedControllableEntity(); 60 61 inline void setHUDTemplate(const std::string& name) 62 { 63 if (name != this->hudtemplate_) 64 { 65 this->hudtemplate_ = name; 66 if (this->controllableEntity_) 67 this->updateHUD(); 68 else 69 this->bUpdateHUD_ = true; 70 } 71 } 72 inline const std::string& getHUDTemplate() const 73 { return this->hudtemplate_; } 74 75 inline OverlayGroup* getHUD() const 76 { return this->hud_; } 53 77 54 78 protected: 79 void updateHUD(); 80 55 81 PlayerInfo* player_; 56 82 ControllableEntity* controllableEntity_; 83 std::string hudtemplate_; 84 OverlayGroup* hud_; 85 bool bUpdateHUD_; 57 86 }; 58 87 } -
code/branches/presentation/src/orxonox/objects/controllers/HumanController.cc
r2087 r2485 33 33 #include "core/ConsoleCommand.h" 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/worldentities/pawns/Pawn.h" 36 #include "objects/gametypes/Gametype.h" 35 37 36 38 namespace orxonox … … 44 46 SetConsoleCommand(HumanController, fire, true).keybindMode(KeybindMode::OnHold); 45 47 SetConsoleCommand(HumanController, altFire, true).keybindMode(KeybindMode::OnHold); 48 SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold); 46 49 SetConsoleCommand(HumanController, greet, true); 47 50 SetConsoleCommand(HumanController, use, true); 48 51 SetConsoleCommand(HumanController, switchCamera, true); 52 SetConsoleCommand(HumanController, mouseLook, true); 53 SetConsoleCommand(HumanController, suicide, true); 54 SetConsoleCommand(HumanController, addBots, true).defaultValues(1); 55 SetConsoleCommand(HumanController, killBots, true).defaultValues(0); 49 56 50 57 CreateUnloadableFactory(HumanController); … … 112 119 } 113 120 121 void HumanController::boost() 122 { 123 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 124 HumanController::localController_s->controllableEntity_->boost(); 125 } 126 114 127 void HumanController::greet() 115 128 { … … 129 142 HumanController::localController_s->controllableEntity_->switchCamera(); 130 143 } 144 145 void HumanController::mouseLook() 146 { 147 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 148 HumanController::localController_s->controllableEntity_->mouseLook(); 149 } 150 151 void HumanController::suicide() 152 { 153 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 154 { 155 Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_); 156 if (pawn) 157 pawn->kill(); 158 } 159 } 160 161 void HumanController::addBots(unsigned int amount) 162 { 163 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 164 HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount); 165 } 166 167 void HumanController::killBots(unsigned int amount) 168 { 169 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 170 HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount); 171 } 131 172 } -
code/branches/presentation/src/orxonox/objects/controllers/HumanController.h
r2087 r2485 54 54 static void altFire(); 55 55 56 static void boost(); 56 57 static void greet(); 57 58 static void use(); 58 59 static void switchCamera(); 60 static void mouseLook(); 61 62 static void suicide(); 63 64 static void addBots(unsigned int amount); 65 static void killBots(unsigned int amount = 0); 59 66 60 67 private: -
code/branches/presentation/src/orxonox/objects/gametypes/Gametype.cc
r2171 r2485 34 34 35 35 #include "core/CoreIncludes.h" 36 #include "core/ConfigValueIncludes.h" 36 37 #include "objects/infos/PlayerInfo.h" 38 #include "objects/infos/Bot.h" 37 39 #include "objects/worldentities/pawns/Spectator.h" 38 40 #include "objects/worldentities/SpawnPoint.h" 41 #include "objects/worldentities/Camera.h" 39 42 40 43 #include "network/Host.h" … … 44 47 CreateUnloadableFactory(Gametype); 45 48 46 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) 49 Gametype::Gametype(BaseObject* creator) : BaseObject(creator), gtinfo_(creator) 47 50 { 48 51 RegisterObject(Gametype); 49 52 53 this->setGametype(this); 54 50 55 this->defaultControllableEntity_ = Class(Spectator); 51 56 52 this->bStarted_ = false;53 this->bEnded_ = false;54 57 this->bAutoStart_ = false; 55 58 this->bForceSpawn_ = false; 59 this->numberOfBots_ = 0; 56 60 57 61 this->initialStartCountdown_ = 3; 58 this->startCountdown_ = 0; 59 this->bStartCountdownRunning_ = false; 62 63 this->setConfigValues(); 64 65 this->addBots(this->numberOfBots_); 66 } 67 68 void Gametype::setConfigValues() 69 { 70 SetConfigValue(initialStartCountdown_, 3.0f); 71 SetConfigValue(bAutoStart_, false); 72 SetConfigValue(bForceSpawn_, false); 73 SetConfigValue(numberOfBots_, 0); 60 74 } 61 75 62 76 void Gametype::tick(float dt) 63 77 { 64 if (this->bStartCountdownRunning_ && !this->bStarted_) 65 this->startCountdown_ -= dt; 66 67 if (!this->bStarted_) 78 SUPER(Gametype, tick, dt); 79 80 if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_) 81 this->gtinfo_.startCountdown_ -= dt; 82 83 if (!this->gtinfo_.bStarted_) 68 84 this->checkStart(); 69 85 else … … 76 92 { 77 93 COUT(0) << "game started" << std::endl; 78 this-> bStarted_ = true;94 this->gtinfo_.bStarted_ = true; 79 95 80 96 this->spawnPlayersIfRequested(); … … 84 100 { 85 101 COUT(0) << "game ended" << std::endl; 86 this-> bEnded_ = true;102 this->gtinfo_.bEnded_ = true; 87 103 } 88 104 … … 140 156 void Gametype::pawnKilled(Pawn* victim, Pawn* killer) 141 157 { 158 if (victim && victim->getPlayer()) 159 { 160 std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(victim->getPlayer()); 161 if (it != this->players_.end()) 162 { 163 it->second = PlayerState::Dead; 164 165 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator()); 166 if (victim->getCamera()) 167 { 168 entity->setPosition(victim->getCamera()->getWorldPosition()); 169 entity->setOrientation(victim->getCamera()->getWorldOrientation()); 170 } 171 else 172 { 173 entity->setPosition(victim->getWorldPosition()); 174 entity->setOrientation(victim->getWorldOrientation()); 175 } 176 it->first->startControl(entity); 177 } 178 else 179 COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl; 180 } 142 181 } 143 182 … … 150 189 if (this->spawnpoints_.size() > 0) 151 190 { 152 srand(time(0));153 rnd();154 155 191 unsigned int randomspawn = (unsigned int)rnd(this->spawnpoints_.size()); 156 192 unsigned int index = 0; … … 170 206 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 171 207 { 172 if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_)) 173 { 174 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 175 if (spawn) 176 { 177 // force spawn at spawnpoint with default pawn 178 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 179 spawn->spawn(entity); 180 it->first->startControl(entity); 181 it->second = PlayerState::Dead; 208 if (!it->first->getControllableEntity()) 209 { 210 it->second = PlayerState::Dead; 211 212 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_) 213 { 214 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 215 if (spawn) 216 { 217 // force spawn at spawnpoint with default pawn 218 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 219 spawn->spawn(entity); 220 it->first->startControl(entity); 221 it->second = PlayerState::Dead; 222 } 223 else 224 { 225 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 226 abort(); 227 } 228 } 229 } 230 } 231 } 232 233 void Gametype::checkStart() 234 { 235 if (!this->gtinfo_.bStarted_) 236 { 237 if (this->gtinfo_.bStartCountdownRunning_) 238 { 239 if (this->gtinfo_.startCountdown_ <= 0) 240 { 241 this->gtinfo_.bStartCountdownRunning_ = false; 242 this->gtinfo_.startCountdown_ = 0; 243 this->start(); 244 } 245 } 246 else if (this->players_.size() > 0) 247 { 248 if (this->bAutoStart_) 249 { 250 this->start(); 182 251 } 183 252 else 184 253 { 185 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;186 abort();187 }188 }189 }190 }191 192 void Gametype::checkStart()193 {194 if (!this->bStarted_)195 {196 if (this->bStartCountdownRunning_)197 {198 if (this->startCountdown_ <= 0)199 {200 this->bStartCountdownRunning_ = false;201 this->startCountdown_ = 0;202 this->start();203 }204 }205 else if (this->players_.size() > 0)206 {207 if (this->bAutoStart_)208 {209 this->start();210 }211 else212 {213 254 bool allplayersready = true; 255 bool hashumanplayers = false; 214 256 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 215 257 { 216 258 if (!it->first->isReadyToSpawn()) 217 259 allplayersready = false; 260 if (it->first->isHumanPlayer()) 261 hashumanplayers = true; 218 262 } 219 if (allplayersready )263 if (allplayersready && hashumanplayers) 220 264 { 221 this-> startCountdown_ = this->initialStartCountdown_;222 this-> bStartCountdownRunning_ = true;265 this->gtinfo_.startCountdown_ = this->initialStartCountdown_; 266 this->gtinfo_.bStartCountdownRunning_ = true; 223 267 } 224 268 } … … 256 300 } 257 301 } 302 303 void Gametype::addBots(unsigned int amount) 304 { 305 for (unsigned int i = 0; i < amount; ++i) 306 new Bot(this); 307 } 308 309 void Gametype::killBots(unsigned int amount) 310 { 311 unsigned int i = 0; 312 for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); ) 313 { 314 if (it->getGametype() == this) 315 { 316 delete (*(it++)); 317 ++i; 318 } 319 } 320 } 258 321 } -
code/branches/presentation/src/orxonox/objects/gametypes/Gametype.h
r2171 r2485 38 38 #include "objects/worldentities/ControllableEntity.h" 39 39 #include "objects/Tickable.h" 40 #include "objects/infos/GametypeInfo.h" 40 41 41 42 namespace orxonox … … 60 61 virtual ~Gametype() {} 61 62 63 void setConfigValues(); 64 62 65 virtual void tick(float dt); 63 66 67 inline const GametypeInfo* getGametypeInfo() const 68 { return &this->gtinfo_; } 69 64 70 inline bool hasStarted() const 65 { return this-> bStarted_; }71 { return this->gtinfo_.bStarted_; } 66 72 inline bool hasEnded() const 67 { return this-> bEnded_; }73 { return this->gtinfo_.bEnded_; } 68 74 69 75 virtual void start(); … … 88 94 89 95 inline bool isStartCountdownRunning() const 90 { return this-> bStartCountdownRunning_; }96 { return this->gtinfo_.bStartCountdownRunning_; } 91 97 inline float getStartCountdown() const 92 { return this->startCountdown_; } 98 { return this->gtinfo_.startCountdown_; } 99 100 void addBots(unsigned int amount); 101 void killBots(unsigned int amount = 0); 93 102 94 103 private: … … 104 113 void spawnDeadPlayersIfRequested(); 105 114 106 bool bStarted_;107 bool bEnded_; 115 GametypeInfo gtinfo_; 116 108 117 bool bAutoStart_; 109 118 bool bForceSpawn_; 110 119 111 120 float initialStartCountdown_; 112 float startCountdown_; 113 bool bStartCountdownRunning_; 121 unsigned int numberOfBots_; 114 122 115 123 std::map<PlayerInfo*, PlayerState::Enum> players_; -
code/branches/presentation/src/orxonox/objects/infos/CMakeLists.txt
r2171 r2485 1 1 SET( SRC_FILES 2 Bot.cc 2 3 Info.cc 3 4 PlayerInfo.cc 4 5 HumanPlayer.cc 6 GametypeInfo.cc 5 7 ) 6 8 -
code/branches/presentation/src/orxonox/objects/infos/GametypeInfo.cc
r2480 r2485 54 54 void GametypeInfo::registerVariables() 55 55 { 56 REGISTERDATA(this->bStarted_, direction::toclient);57 REGISTERDATA(this->bEnded_, direction::toclient);58 REGISTERDATA(this->startCountdown_, direction::toclient);59 REGISTERDATA(this->bStartCountdownRunning_, direction::toclient);56 registerVariable(this->bStarted_, variableDirection::toclient); 57 registerVariable(this->bEnded_, variableDirection::toclient); 58 registerVariable(this->startCountdown_, variableDirection::toclient); 59 registerVariable(this->bStartCountdownRunning_, variableDirection::toclient); 60 60 } 61 61 } -
code/branches/presentation/src/orxonox/objects/infos/HumanPlayer.cc
r2371 r2485 37 37 #include "objects/controllers/HumanController.h" 38 38 #include "objects/gametypes/Gametype.h" 39 #include "overlays/OverlayGroup.h" 39 40 40 41 namespace orxonox … … 63 64 { 64 65 SetConfigValue(nick_, "Player").callback(this, &HumanPlayer::configvaluecallback_changednick); 66 SetConfigValue(hudtemplate_, "defaultHUD").callback(this, &HumanPlayer::configvaluecallback_changedHUDTemplate); 65 67 } 66 68 … … 69 71 registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick)); 70 72 71 registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));73 registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged)); 72 74 registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized)); 73 75 registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized)); … … 83 85 this->setName(this->nick_); 84 86 } 87 } 88 89 void HumanPlayer::configvaluecallback_changedHUDTemplate() 90 { 91 this->changedController(); 85 92 } 86 93 … … 138 145 this->networkcallback_clientIDchanged(); 139 146 } 147 148 void HumanPlayer::changedController() 149 { 150 if (this->getController()) 151 { 152 this->getController()->setHUDTemplate(this->hudtemplate_); 153 154 if (this->getController() && this->getController()->getHUD()) 155 this->getController()->getHUD()->setOwner(this->getControllableEntity()); 156 } 157 } 140 158 } -
code/branches/presentation/src/orxonox/objects/infos/HumanPlayer.h
r2171 r2485 33 33 34 34 #include "PlayerInfo.h" 35 #include "core/Identifier.h"36 #include "objects/controllers/Controller.h"37 35 38 36 namespace orxonox … … 53 51 void setClientID(unsigned int clientID); 54 52 53 virtual void changedController(); 54 55 55 protected: 56 56 void configvaluecallback_changednick(); 57 void configvaluecallback_changedHUDTemplate(); 57 58 void networkcallback_changednick(); 58 59 void networkcallback_clientIDchanged(); … … 62 63 std::string nick_; 63 64 std::string synchronize_nick_; 65 std::string hudtemplate_; 64 66 bool server_initialized_; 65 67 bool client_initialized_; -
code/branches/presentation/src/orxonox/objects/infos/PlayerInfo.cc
r2371 r2485 46 46 this->bLocalPlayer_ = false; 47 47 this->bReadyToSpawn_ = false; 48 this->bSetUnreadyAfterSpawn_ = true; 48 49 this->controller_ = 0; 49 50 this->controllableEntity_ = 0; … … 64 65 this->controller_ = 0; 65 66 } 67 68 if (this->getGametype()) 69 this->getGametype()->playerLeft(this); 66 70 } 67 71 } … … 76 80 void PlayerInfo::changedName() 77 81 { 82 SUPER(PlayerInfo, changedName); 83 78 84 if (this->isInitialized() && this->getGametype()) 79 85 this->getGametype()->playerChangedName(this); … … 109 115 if (this->controllableEntity_) 110 116 this->controller_->setControllableEntity(this->controllableEntity_); 117 this->changedController(); 111 118 } 112 119 113 void PlayerInfo::startControl(ControllableEntity* entity )120 void PlayerInfo::startControl(ControllableEntity* entity, bool callback) 114 121 { 122 if (entity == this->controllableEntity_) 123 return; 124 115 125 if (this->controllableEntity_) 116 this->stopControl(this->controllableEntity_ );126 this->stopControl(this->controllableEntity_, callback); 117 127 118 128 this->controllableEntity_ = entity; … … 122 132 this->controllableEntityID_ = entity->getObjectID(); 123 133 entity->setPlayer(this); 124 this->bReadyToSpawn_ = false;134 this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_); 125 135 } 126 136 else -
code/branches/presentation/src/orxonox/objects/infos/PlayerInfo.h
r2171 r2485 65 65 { return this->bReadyToSpawn_; } 66 66 67 void startControl(ControllableEntity* entity );67 void startControl(ControllableEntity* entity, bool callback = true); 68 68 void stopControl(ControllableEntity* entity, bool callback = true); 69 69 … … 71 71 { return this->controllableEntity_; } 72 72 73 inline Controller* getController() const 74 { return this->controller_; } 75 virtual void changedController() {} 76 73 77 protected: 74 78 void createController(); 75 void networkcallback_changedcontrollableentityID();76 79 77 80 bool bHumanPlayer_; 78 81 bool bLocalPlayer_; 82 bool bSetUnreadyAfterSpawn_; 83 SubclassIdentifier<Controller> defaultController_; 84 unsigned int clientID_; 85 86 private: 87 void networkcallback_changedcontrollableentityID(); 88 79 89 bool bReadyToSpawn_; 80 SubclassIdentifier<Controller> defaultController_;81 90 Controller* controller_; 82 91 ControllableEntity* controllableEntity_; 83 92 unsigned int controllableEntityID_; 84 unsigned int clientID_;85 93 }; 86 94 } -
code/branches/presentation/src/orxonox/objects/items/Engine.cc
r2480 r2485 104 104 void Engine::registerVariables() 105 105 { 106 REGISTERDATA(this->shipID_, direction::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));107 108 REGISTERDATA(this->speedFactor_, direction::toclient);109 REGISTERDATA(this->boostFactor_, direction::toclient);110 111 REGISTERDATA(this->maxSpeedFront_, direction::toclient);112 REGISTERDATA(this->maxSpeedBack_, direction::toclient);113 REGISTERDATA(this->maxSpeedLeftRight_, direction::toclient);114 REGISTERDATA(this->maxSpeedUpDown_, direction::toclient);115 116 REGISTERDATA(this->accelerationFront_, direction::toclient);117 REGISTERDATA(this->accelerationBrake_, direction::toclient);118 REGISTERDATA(this->accelerationBack_, direction::toclient);119 REGISTERDATA(this->accelerationLeftRight_, direction::toclient);120 REGISTERDATA(this->accelerationUpDown_, direction::toclient);106 registerVariable(this->shipID_, variableDirection::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID)); 107 108 registerVariable(this->speedFactor_, variableDirection::toclient); 109 registerVariable(this->boostFactor_, variableDirection::toclient); 110 111 registerVariable(this->maxSpeedFront_, variableDirection::toclient); 112 registerVariable(this->maxSpeedBack_, variableDirection::toclient); 113 registerVariable(this->maxSpeedLeftRight_, variableDirection::toclient); 114 registerVariable(this->maxSpeedUpDown_, variableDirection::toclient); 115 116 registerVariable(this->accelerationFront_, variableDirection::toclient); 117 registerVariable(this->accelerationBrake_, variableDirection::toclient); 118 registerVariable(this->accelerationBack_, variableDirection::toclient); 119 registerVariable(this->accelerationLeftRight_, variableDirection::toclient); 120 registerVariable(this->accelerationUpDown_, variableDirection::toclient); 121 121 } 122 122 -
code/branches/presentation/src/orxonox/objects/items/Item.h
r2480 r2485 33 33 34 34 #include "core/BaseObject.h" 35 #include "network/ Synchronisable.h"35 #include "network/synchronisable/Synchronisable.h" 36 36 37 37 namespace orxonox -
code/branches/presentation/src/orxonox/objects/items/MultiStateEngine.cc
r2480 r2485 83 83 void MultiStateEngine::registerVariables() 84 84 { 85 REGISTERDATA(this->state_, direction::toserver);85 registerVariable(this->state_, variableDirection::toserver); 86 86 } 87 87 … … 92 92 if (this->getShip()->hasLocalController()) 93 93 { 94 this->setObjectMode( direction::bidirectional);94 this->setObjectMode(objectDirection::bidirectional); 95 95 96 96 const Vector3& direction = this->getDirection(); -
code/branches/presentation/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddReward.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddReward.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/FailQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/FailQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/LocalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/LocalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Quest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Quest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestDescription.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestDescription.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestEffect.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestEffect.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestItem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestItem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestManager.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestManager.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Rewardable.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Rewardable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/Backlight.cc
- Property svn:mergeinfo changed
r2459 r2485 30 30 #include "Backlight.h" 31 31 32 #include <OgreBillboard.h>33 32 #include <OgreRibbonTrail.h> 34 33 #include <OgreSceneManager.h> 35 34 35 #include "core/Core.h" 36 36 #include "core/CoreIncludes.h" 37 #include "core/ConfigValueIncludes.h"38 37 #include "core/Executor.h" 39 #include "util/Math.h" 40 #include "GraphicsEngine.h" 38 #include "core/XMLPort.h" 39 #include "objects/Scene.h" 40 #include "util/Exception.h" 41 41 42 42 namespace orxonox … … 44 44 CreateFactory(Backlight); 45 45 46 float Backlight::timeFactor_s = 1.0; 47 48 Backlight::Backlight(float maxspeed, float brakingtime, float scale) 46 Backlight::Backlight(BaseObject* creator) : FadingBillboard(creator) 49 47 { 50 48 RegisterObject(Backlight); 51 49 52 this->setConfigValues(); 53 this->traillength_ = 1; 54 55 this->configure(maxspeed, brakingtime, scale); 56 } 57 58 bool Backlight::create(){ 59 if(!WorldEntity::create()) 60 return false; 61 62 this->getNode()->setInheritScale(false); 63 64 this->billboard_.setBillboardSet("Flares/backlightflare"); 65 this->attachObject(this->billboard_.getBillboardSet()); 66 67 this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail"); 68 this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode"); 69 this->ribbonTrailNode_->attachObject(this->ribbonTrail_); 70 this->ribbonTrail_->addNode(this->getNode()); 71 72 73 this->ribbonTrail_->setTrailLength(this->maxTraillength_); 74 this->ribbonTrail_->setMaterialName("Trail/backlighttrail"); 75 76 //this->setTimeFactor(Orxonox::getInstance().getTimeFactor()); 77 this->setTimeFactor(1.0f); 78 79 this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_); 80 this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_); 81 this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale()); 82 this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s); 83 return true; 50 this->ribbonTrail_ = 0; 51 this->ribbonTrailNode_ = 0; 52 53 this->width_ = 0; 54 this->length_ = 1.0f; 55 this->lifetime_ = 0.001f; 56 this->maxelements_ = 1; 57 58 this->tickcount_ = 0; 59 60 if (Core::showsGraphics()) 61 { 62 if (!this->getScene()) 63 ThrowException(AbortLoading, "Can't create Backlight, no scene given."); 64 if (!this->getScene()->getSceneManager()) 65 ThrowException(AbortLoading, "Can't create Backlight, no scene manager given."); 66 if (!this->getScene()->getRootSceneNode()) 67 ThrowException(AbortLoading, "Can't create Backlight, no root scene node given."); 68 69 this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName()); 70 71 this->ribbonTrailNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 72 this->ribbonTrailNode_->attachObject(this->ribbonTrail_); 73 74 this->ribbonTrail_->setMaxChainElements(this->maxelements_); 75 this->ribbonTrail_->setTrailLength(this->length_); 76 this->ribbonTrail_->setInitialWidth(0, 0); 77 } 78 79 this->registerVariables(); 84 80 } 85 81 … … 88 84 if (this->isInitialized()) 89 85 { 90 this->detachObject(this->billboard_.getBillboardSet()); 91 GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode"); 92 GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_); 93 } 94 } 95 96 void Backlight::setConfigValues() 97 { 98 SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible"); 99 SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)"); 100 SetConfigValue(width_, 7.0).description("The width of the trail"); 101 } 102 103 void Backlight::setTimeFactor(float factor) 104 { 105 Backlight::timeFactor_s = factor; 106 float change = Backlight::timeFactor_s / this->maxLifeTime_; 107 this->ribbonTrail_->setWidthChange(0, this->width_ * change); 108 this->updateColourChange(); 109 } 110 111 void Backlight::updateColourChange() 112 { 113 this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s)); 114 } 115 116 117 void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){ 118 SUPER(Backlight, XMLPort, xmlelement, mode); 119 120 Backlight::create(); 86 if (this->ribbonTrail_) 87 { 88 if (this->ribbonTrailNode_) 89 { 90 this->ribbonTrailNode_->detachObject(this->ribbonTrail_); 91 this->getScene()->getSceneManager()->destroySceneNode(this->ribbonTrailNode_->getName()); 92 } 93 this->getScene()->getSceneManager()->destroyRibbonTrail(this->ribbonTrail_); 94 } 95 } 96 } 97 98 void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode) 99 { 100 SUPER(Backlight, XMLPort, xmlelement, mode); 101 102 XMLPortParam(Backlight, "length", setLength, getLength, xmlelement, mode).defaultValues(100.0f); 103 XMLPortParam(Backlight, "width", setWidth, getWidth, xmlelement, mode).defaultValues(1.0f); 104 XMLPortParam(Backlight, "elements", setMaxElements, getMaxElements, xmlelement, mode).defaultValues(10); 105 XMLPortParam(Backlight, "lifetime", setLifetime, getLifetime, xmlelement, mode).defaultValues(1.0f); 106 XMLPortParam(Backlight, "trailmaterial", setTrailMaterial, getTrailMaterial, xmlelement, mode); 107 } 108 109 void Backlight::registerVariables() 110 { 111 registerVariable(this->width_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width)); 112 registerVariable(this->lifetime_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime)); 113 registerVariable(this->length_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length)); 114 registerVariable(this->maxelements_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements)); 115 registerVariable(this->trailmaterial_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial)); 116 } 117 118 void Backlight::changedColour() 119 { 120 FadingBillboard::changedColour(); 121 122 if (this->ribbonTrail_ && this->tickcount_ >= 2) 123 this->ribbonTrail_->setInitialColour(0, this->getFadedColour()); 124 } 125 126 void Backlight::update_width() 127 { 128 if (this->ribbonTrail_ && this->tickcount_ >= 2) 129 this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getWorldScale()); 130 this->update_lifetime(); 131 } 132 133 void Backlight::update_lifetime() 134 { 135 if (this->ribbonTrail_ && this->tickcount_ >= 2) 136 { 137 this->ribbonTrail_->setWidthChange(0, this->width_ * this->getWorldScale() / this->lifetime_ * this->getTimeFactor()); 138 this->ribbonTrail_->setColourChange(0, 0, 0, 0, 1.0f / this->lifetime_ * this->getTimeFactor()); 139 } 140 } 141 142 void Backlight::update_length() 143 { 144 if (this->ribbonTrail_ && this->tickcount_ >= 2) 145 this->ribbonTrail_->setTrailLength(this->length_ * this->getWorldScale()); 146 } 147 148 void Backlight::update_maxelements() 149 { 150 if (this->ribbonTrail_ && this->tickcount_ >= 2) 151 this->ribbonTrail_->setMaxChainElements(this->maxelements_); 152 } 153 154 void Backlight::update_trailmaterial() 155 { 156 if (this->ribbonTrail_ && this->tickcount_ >= 2) 157 this->ribbonTrail_->setMaterialName(this->trailmaterial_); 158 } 159 160 void Backlight::changedVisibility() 161 { 162 SUPER(Backlight, changedVisibility); 163 164 if (this->ribbonTrail_) 165 this->ribbonTrail_->setVisible(this->isVisible()); 166 } 167 168 void Backlight::startturnonoff() 169 { 170 FadingBillboard::startturnonoff(); 171 172 if (this->ribbonTrail_ && this->isActive() && this->isVisible()) 173 this->ribbonTrail_->setVisible(true); 174 } 175 176 void Backlight::stopturnonoff() 177 { 178 this->postprocessingtime_ = max(0.0f, this->lifetime_ - this->turnofftime_); 179 180 FadingBillboard::stopturnonoff(); 181 182 if (this->ribbonTrail_) 183 this->ribbonTrail_->setInitialColour(0, this->getFadedColour()); 184 } 185 186 void Backlight::poststopturnonoff() 187 { 188 FadingBillboard::poststopturnonoff(); 189 190 if (this->ribbonTrail_) 191 this->ribbonTrail_->setVisible(false); 192 } 193 194 void Backlight::changedScale() 195 { 196 SUPER(Backlight, changedScale); 197 198 this->update_width(); 199 this->update_length(); 121 200 } 122 201 123 202 void Backlight::tick(float dt) 124 203 { 204 if (this->tickcount_ < 2) 205 { 206 ++this->tickcount_; 207 if (this->tickcount_ == 2) 208 { 209 this->changedColour(); 210 this->update_width(); 211 this->update_lifetime(); 212 this->update_length(); 213 this->update_maxelements(); 214 this->update_trailmaterial(); 215 if (this->ribbonTrail_) 216 this->ribbonTrail_->addNode(const_cast<Ogre::SceneNode*>(this->getNode())); 217 } 218 } 219 125 220 SUPER(Backlight, tick, dt); 126 221 127 if (this->isActive()) 128 { 129 if (this->traillength_ < this->maxTraillength_) 130 { 131 this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_); 132 this->updateColourChange(); 133 } 134 } 135 else 136 { 137 if (this->traillength_ > 1) 138 { 139 this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_); 140 this->updateColourChange(); 141 } 142 } 143 144 this->ribbonTrail_->setTrailLength(this->traillength_); 145 } 146 147 void Backlight::setColour(const ColourValue& colour) 148 { 149 this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour); 150 this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75)); 151 } 152 153 void Backlight::configure(float maxspeed, float brakingtime, float scale) 154 { 155 this->maxTraillength_ = this->maxLifeTime_ * maxspeed; 156 this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_); 157 158 this->brakefactor_ = this->maxLifeTime_ / brakingtime; 159 160 this->scale(scale); 161 } 162 163 void Backlight::changedVisibility() 164 { 165 SUPER(Backlight, changedVisibility); 166 167 this->billboard_.setVisible(this->isVisible()); 168 this->ribbonTrail_->setVisible(this->isVisible()); 222 if (this->ribbonTrail_ && this->changedirection_ != 0) 223 { 224 // we use alpha_blend, only adjust alpha 225 const ColourValue& colour = this->getColour(); 226 this->ribbonTrail_->setInitialColour(0, colour.r, colour.g, colour.b, this->getFadedColour().a); 227 } 228 } 229 230 void Backlight::changedTimeFactor(float factor_new, float factor_old) 231 { 232 this->update_lifetime(); 169 233 } 170 234 } -
code/branches/presentation/src/orxonox/objects/worldentities/Backlight.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.h (added) merged: 2182,2207,2212,2254,2406 /code/trunk/src/orxonox/objects/worldentities/Backlight.h merged: 2-1912
r2459 r2485 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include "StaticEntity.h" 35 #include "tools/BillboardSet.h" 33 #include "FadingBillboard.h" 34 #include "gamestates/GSRoot.h" 36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport Backlight : public StaticEntity38 class _OrxonoxExport Backlight : public FadingBillboard, public TimeFactorListener 40 39 { 41 40 public: 42 Backlight( float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);41 Backlight(BaseObject* creator); 43 42 virtual ~Backlight(); 44 43 45 void setConfigValues();46 44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 void registerVariables(); 46 47 47 virtual void tick(float dt); 48 48 virtual void changedVisibility(); 49 virtual bool create();50 49 51 void setColour(const ColourValue& colour); 52 void setTimeFactor(float factor); 50 inline void setWidth(float width) 51 { this->width_ = width; this->update_width(); } 52 inline float getWidth() const 53 { return this->width_; } 54 55 inline void setLifetime(float lifetime) 56 { this->lifetime_ = lifetime; this->update_lifetime(); } 57 inline float getLifetime() const 58 { return this->lifetime_; } 59 60 inline void setLength(float length) 61 { this->length_ = length; this->update_length(); } 62 inline float getLength() const 63 { return this->length_; } 64 65 inline void setMaxElements(size_t maxelements) 66 { this->maxelements_ = maxelements; this->update_maxelements(); } 67 inline size_t getMaxElements() const 68 { return this->maxelements_; } 69 70 inline void setTrailMaterial(const std::string& material) 71 { this->trailmaterial_ = material; this->update_trailmaterial(); } 72 inline const std::string& getTrailMaterial() const 73 { return this->trailmaterial_; } 74 75 virtual void changedScale(); 76 77 protected: 78 virtual void changedTimeFactor(float factor_new, float factor_old); 53 79 54 80 private: 55 void configure(float maxspeed, float brakingtime, float scale = 1); 56 void updateColourChange(); 81 virtual void startturnonoff(); 82 virtual void stopturnonoff(); 83 virtual void poststopturnonoff(); 84 virtual void changedColour(); 85 void update_width(); 86 void update_lifetime(); 87 void update_length(); 88 void update_maxelements(); 89 void update_trailmaterial(); 57 90 58 static float timeFactor_s; 59 BillboardSet billboard_; 91 Ogre::RibbonTrail* ribbonTrail_; 60 92 Ogre::SceneNode* ribbonTrailNode_; 61 Ogre::RibbonTrail* ribbonTrail_;62 63 float maxLifeTime_;64 float trailSegmentLength_;65 93 float width_; 66 67 float brakefactor_; 68 69 float maxTraillength_; 70 float traillength_; 71 72 size_t maxTrailsegments_; 94 float length_; 95 float lifetime_; 96 size_t maxelements_; 97 std::string trailmaterial_; 98 char tickcount_; 73 99 }; 74 100 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/Billboard.cc
r2459 r2485 44 44 RegisterObject(Billboard); 45 45 46 this->material_ = ""; 47 this->colour_ = ColourValue::White; 48 46 49 this->registerVariables(); 47 50 } … … 52 55 { 53 56 if (this->isInitialized() && this->billboard_.getBillboardSet()) 54 this->detachOgreObject(this->billboard_.get Name());57 this->detachOgreObject(this->billboard_.getBillboardSet()); 55 58 } 56 59 } … … 72 75 void Billboard::changedMaterial() 73 76 { 77 if (this->material_ == "") 78 return; 79 74 80 if (!this->billboard_.getBillboardSet()) 75 81 { … … 90 96 if (!this->billboard_.getBillboardSet()) 91 97 { 92 if (this->getScene() && this->getScene()->getSceneManager()) 98 /* 99 if (this->getScene() && this->getScene()->getSceneManager() && (this->material_ != "")) 93 100 { 94 101 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); … … 97 104 this->billboard_.setVisible(this->isVisible()); 98 105 } 106 */ 99 107 } 100 108 else -
code/branches/presentation/src/orxonox/objects/worldentities/Billboard.h
r2459 r2485 61 61 { return this->colour_; } 62 62 63 protected: 64 inline BillboardSet& getBillboardSet() 65 { return this->billboard_; } 66 67 virtual void changedColour(); 68 63 69 private: 64 70 void changedMaterial(); 65 void changedColour();66 71 67 72 BillboardSet billboard_; -
code/branches/presentation/src/orxonox/objects/worldentities/BlinkingBillboard.cc
r2171 r2485 68 68 void BlinkingBillboard::registerVariables() 69 69 { 70 // REGISTERDATA(this->amplitude_, direction::toclient);71 // REGISTERDATA(this->frequency_, direction::toclient);72 // REGISTERDATA(this->phase_, direction::toclient);70 // registerVariable(this->amplitude_, variableDirection::toclient); 71 // registerVariable(this->frequency_, variableDirection::toclient); 72 // registerVariable(this->phase_, variableDirection::toclient); 73 73 } 74 74 75 75 void BlinkingBillboard::tick(float dt) 76 76 { 77 SUPER(BlinkingBillboard, tick, dt); 78 77 79 if (Core::isMaster() && this->isActive()) 78 80 { -
code/branches/presentation/src/orxonox/objects/worldentities/CMakeLists.txt
r2459 r2485 5 5 MobileEntity.cc 6 6 ControllableEntity.cc 7 Model.cc 7 8 Backlight.cc 8 9 Billboard.cc 9 10 BlinkingBillboard.cc 11 ExplosionChunk.cc 12 FadingBillboard.cc 10 13 Light.cc 11 14 Camera.cc 12 15 CameraPosition.cc 13 SpawnPoint.cc16 Model.cc 14 17 ParticleEmitter.cc 15 18 ParticleSpawner.cc 16 19 Planet.cc 17 # Backlight.cc20 SpawnPoint.cc 18 21 ) 19 22 -
code/branches/presentation/src/orxonox/objects/worldentities/Camera.cc
- Property svn:mergeinfo changed
r2459 r2485 36 36 #include <OgreSceneManager.h> 37 37 #include <OgreSceneNode.h> 38 #include <OgreViewport.h>39 38 40 39 #include "util/Exception.h" … … 52 51 RegisterObject(Camera); 53 52 54 if (!this->getScene() || !this->getScene()->getSceneManager()) 55 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); 53 if (!this->getScene()) 54 ThrowException(AbortLoading, "Can't create Camera, no scene."); 55 if (!this->getScene()->getSceneManager()) 56 ThrowException(AbortLoading, "Can't create Camera, no scene-manager given."); 57 if (!this->getScene()->getRootSceneNode()) 58 ThrowException(AbortLoading, "Can't create Camera, no root-scene-node given."); 56 59 57 60 this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 58 this->attachOgreObject(this->camera_); 61 this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 62 this->attachNode(this->cameraNode_); 63 this->cameraNode_->attachObject(this->camera_); 59 64 60 65 this->bHasFocus_ = false; … … 66 71 this->setConfigValues(); 67 72 this->configvaluecallback_changedNearClipDistance(); 68 69 this->requestFocus(); // ! HACK ! REMOVE THIS !70 73 } 71 74 … … 75 78 { 76 79 this->releaseFocus(); 80 81 this->cameraNode_->detachAllObjects(); 82 this->getScene()->getSceneManager()->destroyCamera(this->camera_); 83 84 if (this->bDrag_) 85 this->detachNode(this->cameraNode_); 86 87 if (this->getScene()->getSceneManager()) 88 this->getScene()->getSceneManager()->destroySceneNode(this->cameraNode_->getName()); 77 89 } 78 90 } … … 90 102 void Camera::tick(float dt) 91 103 { 92 /* 93 // this stuff here may need some adjustments 94 float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f); 104 SUPER(Camera, tick, dt); 95 105 96 Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition(); 97 this->cameraNode_->translate(coeff * offset); 106 if (this->bDrag_) 107 { 108 // this stuff here may need some adjustments 109 float coeff = min(1.0f, 15.0f * dt); 98 110 99 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false)); 100 */ 111 Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition(); 112 this->cameraNode_->translate(coeff * offset); 113 114 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false)); 115 //this->cameraNode_->setOrientation(this->getWorldOrientation()); 116 } 101 117 } 102 118 … … 120 136 } 121 137 122 void Camera::setFocus( Ogre::Viewport* viewport)138 void Camera::setFocus() 123 139 { 124 140 this->bHasFocus_ = true; 125 viewport->setCamera(this->camera_); 141 CameraManager::getInstance().useCamera(this->camera_); 142 } 143 144 void Camera::setDrag(bool bDrag) 145 { 146 if (bDrag != this->bDrag_) 147 { 148 this->bDrag_ = bDrag; 149 150 if (!bDrag) 151 { 152 this->attachNode(this->cameraNode_); 153 this->cameraNode_->setPosition(Vector3::ZERO); 154 this->cameraNode_->setOrientation(Quaternion::IDENTITY); 155 } 156 else 157 { 158 this->detachNode(this->cameraNode_); 159 this->cameraNode_->setPosition(this->getWorldPosition()); 160 this->cameraNode_->setOrientation(this->getWorldOrientation()); 161 } 162 } 126 163 } 127 164 } -
code/branches/presentation/src/orxonox/objects/worldentities/Camera.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.h (added) merged: 2396,2478 /code/trunk/src/orxonox/objects/worldentities/Camera.h merged: 2-1912
r2459 r2485 55 55 { return this->bHasFocus_; } 56 56 57 inline void setDrag(bool bDrag) 58 { this->bDrag_ = bDrag; } 57 void setDrag(bool bDrag); 59 58 inline bool getDrag() const 60 59 { return this->bDrag_; } … … 62 61 private: 63 62 void removeFocus(); 64 void setFocus( Ogre::Viewport* viewport);63 void setFocus(); 65 64 void configvaluecallback_changedNearClipDistance(); 66 65 67 Ogre::Camera* camera_; 68 float nearClipDistance_; 69 bool bHasFocus_; 70 bool bDrag_; 66 Ogre::Camera* camera_; 67 Ogre::SceneNode* cameraNode_; 68 float nearClipDistance_; 69 bool bHasFocus_; 70 bool bDrag_; 71 71 }; 72 72 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/CameraPosition.cc
r2459 r2485 43 43 44 44 this->bDrag_ = false; 45 this->bAllowMouseLook_ = false; 45 46 46 47 this->setObjectMode(0x0); … … 56 57 57 58 XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false); 59 XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false); 58 60 } 59 61 60 62 void CameraPosition::attachCamera(Camera* camera) 61 63 { 62 camera->setDrag(this->bDrag_); 64 if (!this->bDrag_) 65 camera->setDrag(false); 66 63 67 this->attach(camera); 68 69 if (this->bDrag_) 70 camera->setDrag(true); 64 71 } 65 72 } -
code/branches/presentation/src/orxonox/objects/worldentities/CameraPosition.h
r2459 r2485 49 49 { return this->bDrag_; } 50 50 51 inline void setAllowMouseLook(bool bAllow) 52 { this->bAllowMouseLook_ = bAllow; } 53 inline bool getAllowMouseLook() const 54 { return this->bAllowMouseLook_; } 55 51 56 void attachCamera(Camera* camera); 52 57 53 58 private: 54 59 bool bDrag_; 60 bool bAllowMouseLook_; 55 61 }; 56 62 } -
code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.cc
r2474 r2485 30 30 #include "ControllableEntity.h" 31 31 32 #include <OgreSceneManager.h> 33 32 34 #include "core/CoreIncludes.h" 35 #include "core/ConfigValueIncludes.h" 33 36 #include "core/Core.h" 34 37 #include "core/XMLPort.h" 35 38 #include "core/Template.h" 36 39 40 #include "objects/Scene.h" 37 41 #include "objects/infos/PlayerInfo.h" 38 42 #include "objects/worldentities/Camera.h" 39 43 #include "objects/worldentities/CameraPosition.h" 44 #include "objects/gametypes/Gametype.h" 40 45 #include "overlays/OverlayGroup.h" 41 46 … … 48 53 RegisterObject(ControllableEntity); 49 54 50 this->bControlled_ = false; 55 this->bHasLocalController_ = false; 56 this->bHasHumanController_ = false; 57 51 58 this->server_overwrite_ = 0; 52 59 this->client_overwrite_ = 0; … … 56 63 this->camera_ = 0; 57 64 this->bDestroyWhenPlayerLeft_ = false; 65 this->cameraPositionRootNode_ = this->node_->createChildSceneNode(); 66 this->bMouseLook_ = false; 67 this->mouseLookSpeed_ = 200; 68 69 this->gtinfo_ = 0; 70 this->gtinfoID_ = OBJECTID_UNKNOWN; 71 this->changedGametype(); 58 72 59 73 this->server_position_ = Vector3::ZERO; … … 67 81 68 82 83 this->setConfigValues(); 69 84 this->setPriority( priority::very_high ); 70 85 this->registerVariables(); … … 75 90 if (this->isInitialized()) 76 91 { 77 if (this->bControlled_) 78 this->stopLocalControl(); 92 this->bDestroyWhenPlayerLeft_ = false; 93 94 if (this->bHasLocalController_ && this->bHasHumanController_) 95 this->stopLocalHumanControl(); 96 97 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 98 this->getPlayer()->stopControl(this, false); 79 99 80 100 if (this->hud_) … … 84 104 delete this->camera_; 85 105 86 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 87 this->getPlayer()->stopControl(this, false); 106 for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 107 delete (*it); 108 109 if (this->getScene()->getSceneManager()) 110 this->getScene()->getSceneManager()->destroySceneNode(this->cameraPositionRootNode_->getName()); 88 111 } 89 112 } … … 99 122 } 100 123 124 void ControllableEntity::setConfigValues() 125 { 126 SetConfigValue(mouseLookSpeed_, 3.0f); 127 } 128 129 void ControllableEntity::changedGametype() 130 { 131 //SUPER(ControllableEntity, changedGametype); 132 WorldEntity::changedGametype(); 133 134 this->gtinfo_ = 0; 135 this->gtinfoID_ = OBJECTID_UNKNOWN; 136 137 if (this->getGametype() && this->getGametype()->getGametypeInfo()) 138 { 139 this->gtinfo_ = this->getGametype()->getGametypeInfo(); 140 this->gtinfoID_ = this->gtinfo_->getObjectID(); 141 } 142 } 143 101 144 void ControllableEntity::addCameraPosition(CameraPosition* position) 102 145 { 103 this->attach(position); 146 if (position->getAllowMouseLook()) 147 position->attachToNode(this->cameraPositionRootNode_); 148 else 149 this->attach(position); 104 150 this->cameraPositions_.push_back(position); 105 151 } … … 142 188 else 143 189 { 144 this-> attach(this->camera_);190 this->camera_->attachToNode(this->cameraPositionRootNode_); 145 191 } 146 192 } 193 } 194 195 void ControllableEntity::mouseLook() 196 { 197 this->bMouseLook_ = !this->bMouseLook_; 198 199 if (!this->bMouseLook_) 200 this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY); 201 } 202 203 void ControllableEntity::rotateYaw(const Vector2& value) 204 { 205 if (this->bMouseLook_) 206 this->cameraPositionRootNode_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 207 } 208 209 void ControllableEntity::rotatePitch(const Vector2& value) 210 { 211 if (this->bMouseLook_) 212 this->cameraPositionRootNode_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 213 } 214 215 void ControllableEntity::rotateRoll(const Vector2& value) 216 { 217 if (this->bMouseLook_) 218 this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 147 219 } 148 220 … … 157 229 this->player_ = player; 158 230 this->playerID_ = player->getObjectID(); 159 this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer()); 160 if (this->bControlled_) 161 { 162 this->startLocalControl(); 231 this->bHasLocalController_ = player->isLocalPlayer(); 232 this->bHasHumanController_ = player->isHumanPlayer(); 233 234 if (this->bHasLocalController_ && this->bHasHumanController_) 235 { 236 this->startLocalHumanControl(); 163 237 164 238 if (!Core::isMaster()) 165 239 { 166 240 this->client_overwrite_ = this->server_overwrite_; 167 COUT(0) << "CE: bidirectional synchronization" << std::endl;168 241 this->setObjectMode(objectDirection::bidirectional); 169 242 } … … 173 246 void ControllableEntity::removePlayer() 174 247 { 175 if (this->b Controlled_)176 this->stopLocal Control();248 if (this->bHasLocalController_ && this->bHasHumanController_) 249 this->stopLocalHumanControl(); 177 250 178 251 this->player_ = 0; 179 252 this->playerID_ = OBJECTID_UNKNOWN; 180 this->bControlled_ = false; 253 this->bHasLocalController_ = false; 254 this->bHasHumanController_ = false; 181 255 this->setObjectMode(objectDirection::toclient); 182 256 … … 196 270 } 197 271 198 void ControllableEntity::startLocalControl() 199 { 200 // std::cout << this->getObjectID() << " ###### start local control" << std::endl; 201 this->camera_ = new Camera(this); 202 this->camera_->requestFocus(); 203 if (this->cameraPositionTemplate_ != "") 204 this->addTemplate(this->cameraPositionTemplate_); 205 if (this->cameraPositions_.size() > 0) 206 this->cameraPositions_.front()->attachCamera(this->camera_); 207 else 208 this->attach(this->camera_); 209 210 if (this->hudtemplate_ != "") 211 { 212 this->hud_ = new OverlayGroup(this); 213 this->hud_->addTemplate(this->hudtemplate_); 214 } 215 } 216 217 void ControllableEntity::stopLocalControl() 218 { 219 // std::cout << "###### stop local control" << std::endl; 220 this->camera_->detachFromParent(); 221 delete this->camera_; 222 this->camera_ = 0; 223 224 delete this->hud_; 225 this->hud_ = 0; 272 void ControllableEntity::networkcallback_changedgtinfoID() 273 { 274 if (this->gtinfoID_ != OBJECTID_UNKNOWN) 275 { 276 this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_)); 277 278 if (!this->gtinfo_) 279 this->gtinfoID_ = OBJECTID_UNKNOWN; 280 } 281 } 282 283 void ControllableEntity::startLocalHumanControl() 284 { 285 if (!this->camera_) 286 { 287 this->camera_ = new Camera(this); 288 this->camera_->requestFocus(); 289 if (this->cameraPositionTemplate_ != "") 290 this->addTemplate(this->cameraPositionTemplate_); 291 if (this->cameraPositions_.size() > 0) 292 this->cameraPositions_.front()->attachCamera(this->camera_); 293 else 294 this->camera_->attachToNode(this->cameraPositionRootNode_); 295 } 296 297 if (!this->hud_) 298 { 299 if (this->hudtemplate_ != "") 300 { 301 this->hud_ = new OverlayGroup(this); 302 this->hud_->addTemplate(this->hudtemplate_); 303 this->hud_->setOwner(this); 304 } 305 } 306 } 307 308 void ControllableEntity::stopLocalHumanControl() 309 { 310 if (this->camera_) 311 { 312 this->camera_->detachFromParent(); 313 delete this->camera_; 314 this->camera_ = 0; 315 } 316 317 if (this->hud_) 318 { 319 delete this->hud_; 320 this->hud_ = 0; 321 } 226 322 } 227 323 … … 242 338 this->server_angular_velocity_ = this->getAngularVelocity(); 243 339 } 244 else if (this->b Controlled_)340 else if (this->bHasLocalController_) 245 341 { 246 342 this->client_position_ = this->getPosition(); … … 255 351 void ControllableEntity::registerVariables() 256 352 { 257 registerVariable(this->cameraPositionTemplate_, variableDirection::toclient); 353 registerVariable(this->cameraPositionTemplate_, variableDirection::toclient); 354 registerVariable(this->hudtemplate_, variableDirection::toclient); 258 355 259 356 registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); … … 271 368 272 369 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 370 registerVariable(this->gtinfoID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID)); 273 371 } 274 372 275 373 void ControllableEntity::processServerPosition() 276 374 { 277 if (!this->b Controlled_)375 if (!this->bHasLocalController_) 278 376 MobileEntity::setPosition(this->server_position_); 279 377 } … … 281 379 void ControllableEntity::processServerLinearVelocity() 282 380 { 283 if (!this->b Controlled_)381 if (!this->bHasLocalController_) 284 382 MobileEntity::setVelocity(this->server_linear_velocity_); 285 383 } … … 287 385 void ControllableEntity::processServerOrientation() 288 386 { 289 if (!this->b Controlled_)387 if (!this->bHasLocalController_) 290 388 MobileEntity::setOrientation(this->server_orientation_); 291 389 } … … 293 391 void ControllableEntity::processServerAngularVelocity() 294 392 { 295 if (!this->b Controlled_)393 if (!this->bHasLocalController_) 296 394 MobileEntity::setAngularVelocity(this->server_angular_velocity_); 297 395 } … … 299 397 void ControllableEntity::processOverwrite() 300 398 { 301 if (this->b Controlled_)399 if (this->bHasLocalController_) 302 400 { 303 401 this->setPosition(this->server_position_); … … 354 452 ++this->server_overwrite_; 355 453 } 356 else if (this->b Controlled_)454 else if (this->bHasLocalController_) 357 455 { 358 456 MobileEntity::setPosition(position); … … 369 467 ++this->server_overwrite_; 370 468 } 371 else if (this->b Controlled_)469 else if (this->bHasLocalController_) 372 470 { 373 471 MobileEntity::setOrientation(orientation); … … 384 482 ++this->server_overwrite_; 385 483 } 386 else if (this->b Controlled_)484 else if (this->bHasLocalController_) 387 485 { 388 486 MobileEntity::setVelocity(velocity); … … 399 497 ++this->server_overwrite_; 400 498 } 401 else if (this->b Controlled_)499 else if (this->bHasLocalController_) 402 500 { 403 501 MobileEntity::setAngularVelocity(velocity); … … 416 514 this->server_angular_velocity_ = this->getAngularVelocity(); 417 515 } 418 else if (this->b Controlled_)516 else if (this->bHasLocalController_) 419 517 { 420 518 this->client_position_ = this->getPosition(); -
code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.h
r2459 r2485 45 45 virtual void tick(float dt); 46 46 void registerVariables(); 47 void setConfigValues(); 48 49 virtual void changedGametype(); 47 50 48 51 virtual void setPlayer(PlayerInfo* player); … … 60 63 virtual void moveUpDown(const Vector2& value) {} 61 64 62 virtual void rotateYaw(const Vector2& value) {} 63 virtual void rotatePitch(const Vector2& value) {} 64 virtual void rotateRoll(const Vector2& value) {} 65 virtual void rotateYaw(const Vector2& value); 66 virtual void rotatePitch(const Vector2& value); 67 virtual void rotateRoll(const Vector2& value); 68 69 inline void moveFrontBack(float value) 70 { this->moveFrontBack(Vector2(value, 0)); } 71 inline void moveRightLeft(float value) 72 { this->moveRightLeft(Vector2(value, 0)); } 73 inline void moveUpDown(float value) 74 { this->moveUpDown(Vector2(value, 0)); } 75 76 inline void rotateYaw(float value) 77 { this->rotateYaw(Vector2(value, 0)); } 78 inline void rotatePitch(float value) 79 { this->rotatePitch(Vector2(value, 0)); } 80 inline void rotateRoll(float value) 81 { this->rotateRoll(Vector2(value, 0)); } 65 82 66 83 virtual void fire() {} 67 84 virtual void altFire() {} 68 85 86 virtual void boost() {} 69 87 virtual void greet() {} 70 88 virtual void use() {} 71 89 virtual void switchCamera(); 90 virtual void mouseLook(); 72 91 73 92 inline const std::string& getHudTemplate() const … … 99 118 void setAngularVelocity(const Vector3& velocity); 100 119 120 inline bool hasLocalController() const 121 { return this->bHasLocalController_; } 122 inline bool hasHumanController() const 123 { return this->bHasHumanController_; } 124 125 inline const GametypeInfo* getGametypeInfo() const 126 { return this->gtinfo_; } 127 128 inline bool isInMouseLook() const 129 { return this->bMouseLook_; } 130 inline float getMouseLookSpeed() const 131 { return this->mouseLookSpeed_; } 132 101 133 protected: 102 virtual void startLocal Control();103 virtual void stopLocal Control();134 virtual void startLocalHumanControl(); 135 virtual void stopLocalHumanControl(); 104 136 105 137 inline void setHudTemplate(const std::string& name) 106 138 { this->hudtemplate_ = name; } 107 108 inline bool isLocallyControlled() const109 { return this->bControlled_; }110 139 111 140 private: … … 124 153 125 154 void networkcallback_changedplayerID(); 155 void networkcallback_changedgtinfoID(); 126 156 127 157 // Bullet btMotionState related … … 131 161 unsigned int client_overwrite_; 132 162 133 bool bControlled_; 163 bool bHasLocalController_; 164 bool bHasHumanController_; 165 bool bDestroyWhenPlayerLeft_; 166 134 167 Vector3 server_position_; 135 168 Vector3 client_position_; … … 143 176 PlayerInfo* player_; 144 177 unsigned int playerID_; 178 145 179 std::string hudtemplate_; 146 180 OverlayGroup* hud_; 181 147 182 Camera* camera_; 148 bool bDestroyWhenPlayerLeft_; 149 183 bool bMouseLook_; 184 float mouseLookSpeed_; 185 Ogre::SceneNode* cameraPositionRootNode_; 150 186 std::list<CameraPosition*> cameraPositions_; 151 187 std::string cameraPositionTemplate_; 188 189 const GametypeInfo* gtinfo_; 190 unsigned int gtinfoID_; 152 191 }; 153 192 } -
code/branches/presentation/src/orxonox/objects/worldentities/ExplosionChunk.cc
r2480 r2485 30 30 #include "ExplosionChunk.h" 31 31 32 #include <OgreParticleSystem.h> 33 32 34 #include "core/Core.h" 33 35 #include "core/CoreIncludes.h" … … 54 56 { 55 57 this->fire_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_); 56 this-> fire_->addToSceneNode(this->getNode());58 this->attachOgreObject(this->fire_->getParticleSystem()); 57 59 this->smoke_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_); 58 this-> smoke_->addToSceneNode(this->getNode());60 this->attachOgreObject(this->smoke_->getParticleSystem()); 59 61 } 60 62 catch (...) … … 83 85 { 84 86 if (this->fire_) 87 { 88 this->detachOgreObject(this->fire_->getParticleSystem()); 85 89 delete this->fire_; 90 } 86 91 if (this->smoke_) 92 { 93 this->detachOgreObject(this->smoke_->getParticleSystem()); 87 94 delete this->smoke_; 95 } 88 96 } 89 97 } … … 91 99 void ExplosionChunk::registerVariables() 92 100 { 93 REGISTERDATA(this->LOD_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));94 REGISTERDATA(this->bStop_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));101 registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged)); 102 registerVariable(this->bStop_, variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop)); 95 103 } 96 104 -
code/branches/presentation/src/orxonox/objects/worldentities/FadingBillboard.cc
r2480 r2485 66 66 void FadingBillboard::registerVariables() 67 67 { 68 REGISTERDATA(this->turnontime_, direction::toclient);69 REGISTERDATA(this->turnofftime_, direction::toclient);68 registerVariable(this->turnontime_, variableDirection::toclient); 69 registerVariable(this->turnofftime_, variableDirection::toclient); 70 70 } 71 71 -
code/branches/presentation/src/orxonox/objects/worldentities/Light.cc
r2459 r2485 36 36 37 37 #include "util/String.h" 38 #include "util/Convert.h" 38 #include "util/Exception.h" 39 #include "core/Core.h" 39 40 #include "core/CoreIncludes.h" 40 41 #include "core/XMLPort.h" … … 43 44 namespace orxonox 44 45 { 45 unsigned int Light::lightCounter_s = 0;46 47 46 CreateFactory(Light); 48 47 … … 51 50 RegisterObject(Light); 52 51 53 if (this->getScene() && this->getScene()->getSceneManager()) 54 this->light_ = this->getScene()->getSceneManager()->createLight("Light" + convertToString(Light::lightCounter_s++)); 55 this->attachOgreObject(this->light_); 52 this->light_ = 0; 53 this->diffuse_ = ColourValue::White; 54 this->specular_ = ColourValue::White; 55 this->type_ = Ogre::Light::LT_POINT; 56 this->attenuation_ = Vector4(100000, 1, 0, 0); 57 this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f); 58 59 if (Core::showsGraphics()) 60 { 61 if (!this->getScene()) 62 ThrowException(AbortLoading, "Can't create Light, no scene given."); 63 if (!this->getScene()->getSceneManager()) 64 ThrowException(AbortLoading, "Can't create Light, no scene manager given."); 65 66 if (this->getScene() && this->getScene()->getSceneManager()) 67 { 68 this->light_ = this->getScene()->getSceneManager()->createLight("Light" + getUniqueNumberString()); 69 this->light_->setDirection(WorldEntity::FRONT); 70 this->attachOgreObject(this->light_); 71 72 this->updateType(); 73 this->updateDiffuseColour(); 74 this->updateSpecularColour(); 75 this->updateAttenuation(); 76 this->updateSpotlightRange(); 77 } 78 } 56 79 57 80 this->registerVariables(); … … 71 94 SUPER(Light, XMLPort, xmlelement, mode); 72 95 73 XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point"); 74 XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "diffuse", setDiffuseColour, getDiffuseColour, xmlelement, mode, const ColourValue&); 75 XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "specular", setSpecularColour, getSpecularColour, xmlelement, mode, const ColourValue&); 76 XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "direction", setDirection, getDirection, xmlelement, mode, const Vector3&); 96 XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point"); 97 XMLPortParam(Light, "diffuse", setDiffuseColour, getDiffuseColour, xmlelement, mode).defaultValues(ColourValue::White); 98 XMLPortParam(Light, "specular", setSpecularColour, getSpecularColour, xmlelement, mode).defaultValues(ColourValue::White); 99 XMLPortParam(Light, "attenuation", setAttenuation, getAttenuation, xmlelement, mode).defaultValues(Vector4(100000, 1, 0, 0)); 100 XMLPortParam(Light, "spotlightrange", setSpotlightRange, getSpotlightRange, xmlelement, mode).defaultValues(Vector3(40.0f, 30.0f, 1.0f)); 77 101 } 78 102 79 103 void Light::registerVariables() 80 104 { 81 registerVariable((int &)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::changedType)); 82 registerVariable(this->light_->getDiffuseColour(), variableDirection::toclient); 83 registerVariable(this->light_->getSpecularColour(), variableDirection::toclient); 84 registerVariable(this->light_->getDirection(), variableDirection::toclient); 105 registerVariable((int&)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateType)); 106 registerVariable(this->diffuse_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour)); 107 registerVariable(this->specular_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour)); 108 registerVariable(this->attenuation_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation)); 109 registerVariable(this->spotlightRange_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange)); 85 110 } 86 111 87 const std::string& Light::getName() const112 void Light::updateDiffuseColour() 88 113 { 89 114 if (this->light_) 90 return this->light_->getName(); 91 else 92 return BLANKSTRING; 115 this->light_->setDiffuseColour(this->diffuse_); 93 116 } 94 117 95 void Light:: setDiffuseColour(const ColourValue& colour)118 void Light::updateSpecularColour() 96 119 { 97 120 if (this->light_) 98 this->light_->set DiffuseColour(colour);121 this->light_->setSpecularColour(this->specular_); 99 122 } 100 123 101 const ColourValue& Light::getDiffuseColour() const124 void Light::updateAttenuation() 102 125 { 103 if (this->light_) 104 return this->light_->getDiffuseColour(); 105 else 106 return ColourValue::White; 126 if (this->light_ && this->type_ != Ogre::Light::LT_DIRECTIONAL) 127 this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w); 107 128 } 108 129 109 void Light:: setSpecularColour(const ColourValue& colour)130 void Light::updateSpotlightRange() 110 131 { 111 if (this->light_) 112 this->light_->setSpecularColour(colour); 113 } 114 115 const ColourValue& Light::getSpecularColour() const 116 { 117 if (this->light_) 118 return this->light_->getSpecularColour(); 119 else 120 return ColourValue::White; 121 } 122 123 void Light::setDirection(const Vector3& direction) 124 { 125 if (this->light_) 126 this->light_->setDirection(direction); 127 } 128 129 const Vector3& Light::getDirection() const 130 { 131 if (this->light_) 132 return this->light_->getDirection(); 133 else 134 return Vector3::ZERO; 132 if (this->light_ && this->type_ == Ogre::Light::LT_SPOTLIGHT) 133 this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z); 135 134 } 136 135 … … 157 156 case Ogre::Light::LT_POINT: 158 157 default: 159 return "poin T";158 return "point"; 160 159 } 161 160 } 162 161 163 void Light:: changedType()162 void Light::updateType() 164 163 { 165 this->light_->setType(this->type_); 164 if (this->light_) 165 { 166 this->light_->setType(this->type_); 167 168 if (this->type_ != Ogre::Light::LT_DIRECTIONAL) 169 this->updateAttenuation(); 170 if (this->type_ == Ogre::Light::LT_SPOTLIGHT) 171 this->updateSpotlightRange(); 172 } 166 173 } 167 174 … … 170 177 SUPER(Light, changedVisibility); 171 178 172 this->light_->setVisible(this->isVisible()); 179 if (this->light_) 180 this->light_->setVisible(this->isVisible()); 173 181 } 174 182 } -
code/branches/presentation/src/orxonox/objects/worldentities/Light.h
r2459 r2485 54 54 { return this->light_; } 55 55 56 const std::string& getName() const;57 58 56 inline void setType(Ogre::Light::LightTypes type) 59 { this->type_ = type; this-> changedType(); }60 Ogre::Light::LightTypes getType() const57 { this->type_ = type; this->updateType(); } 58 inline Ogre::Light::LightTypes getType() const 61 59 { return this->type_; } 62 60 63 void setDiffuseColour(const ColourValue& colour); 64 const ColourValue& getDiffuseColour() const; 61 inline void setDiffuseColour(const ColourValue& colour) 62 { this->diffuse_ = colour; this->updateDiffuseColour(); } 63 inline const ColourValue& getDiffuseColour() const 64 { return this->diffuse_; } 65 65 66 void setSpecularColour(const ColourValue& colour); 67 const ColourValue& getSpecularColour() const; 66 inline void setSpecularColour(const ColourValue& colour) 67 { this->specular_ = colour; this->updateSpecularColour(); } 68 inline const ColourValue& getSpecularColour() const 69 { return this->specular_; } 68 70 69 void setDirection(const Vector3& direction); 70 const Vector3& getDirection() const; 71 /** 72 @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance. 73 74 @param attenuation.x range (The absolute upper range of the light in world units) 75 @param attenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation) 76 @param attenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance) 77 @param attenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula) 78 79 Quote from the Ogre API: 80 Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects. 81 Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity. 82 This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here! 83 84 Quote from the Ogre wiki: 85 "Using these numbers, the light has 100% intensity at 0 distance, and 86 trails off to near black at a distance equal to the Range. Keep in mind 87 that most of the light falls in the first 20% of the range." 88 89 Range Constant Linear Quadratic 90 3250, 1.0, 0.0014, 0.000007 91 600, 1.0, 0.007, 0.0002 92 325, 1.0, 0.014, 0.0007 93 200, 1.0, 0.022, 0.0019 94 160, 1.0, 0.027, 0.0028 95 100, 1.0, 0.045, 0.0075 96 65, 1.0, 0.07, 0.017 97 50, 1.0, 0.09, 0.032 98 32, 1.0, 0.14, 0.07 99 20, 1.0, 0.22, 0.20 100 13, 1.0, 0.35, 0.44 101 7, 1.0, 0.7, 1.8 102 */ 103 inline void setAttenuation(const Vector4& attenuation) 104 { this->attenuation_ = attenuation; this->updateAttenuation(); } 105 inline const Vector4& getAttenuation() const 106 { return this->attenuation_; } 107 108 /** 109 @brief Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them. 110 111 @param spotlightRange.x innerAngle (The angle covered by the bright inner cone) 112 @param spotlightRange.x outerAngle (The angle covered by the outer cone) 113 @param spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.) 114 */ 115 inline void setSpotlightRange(const Vector3& spotlightRange) 116 { this->spotlightRange_ = spotlightRange; this->updateSpotlightRange(); } 117 inline const Vector3& getSpotlightRange() const 118 { return this->spotlightRange_; } 71 119 72 120 private: … … 74 122 std::string getTypeString() const; 75 123 76 void changedType(); 124 void updateType(); 125 void updateDiffuseColour(); 126 void updateSpecularColour(); 127 void updateAttenuation(); 128 void updateSpotlightRange(); 77 129 78 static unsigned int lightCounter_s;79 130 Ogre::Light* light_; 80 131 Ogre::Light::LightTypes type_; 81 132 ColourValue diffuse_; 133 ColourValue specular_; 134 Vector4 attenuation_; 135 Vector3 spotlightRange_; 82 136 }; 83 137 } -
code/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.cc
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/MobileEntity.cc (added) merged: 2-2170
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/MobileEntity.h (added) merged: 2-2170
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/Model.cc
r2468 r2485 42 42 { 43 43 RegisterObject(Model); 44 45 this->bCastShadows_ = true; 44 46 45 47 this->registerVariables(); -
code/branches/presentation/src/orxonox/objects/worldentities/MovableEntity.cc
r2470 r2485 35 35 #include "core/Executor.h" 36 36 #include "core/Core.h" 37 #include "tools/Timer.h"38 37 39 38 namespace orxonox … … 81 80 void MovableEntity::clientConnected(unsigned int clientID) 82 81 { 83 new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), true);82 this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize))); 84 83 } 85 84 -
code/branches/presentation/src/orxonox/objects/worldentities/MovableEntity.h
r2459 r2485 35 35 #include "MobileEntity.h" 36 36 #include "network/ClientConnectionListener.h" 37 #include "tools/Timer.h" 37 38 38 39 namespace orxonox … … 72 73 Vector3 overwrite_position_; 73 74 Quaternion overwrite_orientation_; 75 76 Timer<MovableEntity> resynchronizeTimer_; 74 77 Timer<MovableEntity>* continuousResynchroTimer_; 75 78 }; -
code/branches/presentation/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2468 r2485 52 52 53 53 if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager())) 54 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given.");54 ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given."); 55 55 56 56 this->particles_ = 0; … … 109 109 { 110 110 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_); 111 this->attachOgreObject( particles_->getParticleSystem());111 this->attachOgreObject(this->particles_->getParticleSystem()); 112 112 this->particles_->setVisible(this->isVisible()); 113 113 this->particles_->setEnabled(this->isActive()); -
code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.cc
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.h merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc
r2481 r2485 95 95 { 96 96 this->node_->detachAllObjects(); 97 98 for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ) 99 delete (*(it++)); 100 101 if (this->parent_) 102 this->detachFromParent(); 103 104 this->node_->removeAllChildren(); 105 97 106 if (this->getScene()->getSceneManager()) 98 107 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName()); … … 140 149 void WorldEntity::registerVariables() 141 150 { 151 registerVariable(this->mainStateName_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState)); 152 142 153 registerVariable(this->bActive_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); 143 154 registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility)); … … 212 223 } 213 224 225 void WorldEntity::attachNode(Ogre::SceneNode* node) 226 { 227 Ogre::Node* parent = node->getParent(); 228 if (parent) 229 parent->removeChild(node); 230 this->node_->addChild(node); 231 } 232 233 void WorldEntity::detachNode(Ogre::SceneNode* node) 234 { 235 this->node_->removeChild(node); 236 // this->getScene()->getRootSceneNode()->addChild(node); 237 } 238 239 void WorldEntity::attachToNode(Ogre::SceneNode* node) 240 { 241 Ogre::Node* parent = this->node_->getParent(); 242 if (parent) 243 parent->removeChild(this->node_); 244 node->addChild(this->node_); 245 } 246 247 void WorldEntity::detachFromNode(Ogre::SceneNode* node) 248 { 249 node->removeChild(this->node_); 250 // this->getScene()->getRootSceneNode()->addChild(this->node_); 251 } 252 214 253 void WorldEntity::attach(WorldEntity* object) 215 254 { … … 243 282 } 244 283 284 if (object == this) 285 { 286 COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl; 287 return; 288 } 289 245 290 if (object->getParent()) 246 291 object->detachFromParent(); 247 else 248 { 249 Ogre::Node* parent = object->node_->getParent(); 250 if (parent) 251 parent->removeChild(object->node_); 252 } 253 254 this->node_->addChild(object->node_); 292 293 this->attachNode(object->node_); 294 255 295 this->children_.insert(object); 256 296 object->parent_ = this; … … 275 315 } 276 316 277 this-> node_->removeChild(object->node_);317 this->detachNode(object->node_); 278 318 this->children_.erase(object); 279 319 object->parent_ = 0; 280 320 object->parentID_ = OBJECTID_UNKNOWN; 281 // this->getScene()->getRootSceneNode()->addChild(object->node_);282 321 283 322 // Note: It is possible that the object has physics but was disabled when attaching … … 466 505 467 506 this->node_->setScale(scale); 507 508 this->changedScale(); 509 } 510 511 const Vector3& WorldEntity::getWorldScale3D() const 512 { 513 return this->node_->_getDerivedScale(); 514 } 515 516 float WorldEntity::getWorldScale() const 517 { 518 Vector3 scale = this->getWorldScale3D(); 519 return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; 468 520 } 469 521 -
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.h
r2466 r2485 74 74 inline void translate(float x, float y, float z, TransformSpace::Space relativeTo = TransformSpace::Parent) 75 75 { this->translate(Vector3(x, y, z), relativeTo); } 76 77 virtual inline const Vector3& getVelocity() const 78 { return Vector3::ZERO; } 76 79 77 80 virtual void setOrientation(const Quaternion& orientation) = 0; … … 105 108 { this->setScale3D(Vector3(x, y, z)); } 106 109 const Vector3& getScale3D(void) const; 107 108 void setScale(float scale) 110 const Vector3& getWorldScale3D() const; 111 112 inline void setScale(float scale) 109 113 { this->setScale3D(scale, scale, scale); } 110 114 inline float getScale() const 111 115 { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; } 116 float getWorldScale() const; 112 117 113 118 inline void scale3D(const Vector3& scale) … … 118 123 { this->scale3D(scale, scale, scale); } 119 124 125 virtual void changedScale() {} 126 120 127 void attach(WorldEntity* object); 121 128 void detach(WorldEntity* object); … … 134 141 inline WorldEntity* getParent() const 135 142 { return this->parent_; } 143 144 void attachNode(Ogre::SceneNode* node); 145 void detachNode(Ogre::SceneNode* node); 146 void attachToNode(Ogre::SceneNode* node); 147 void detachFromNode(Ogre::SceneNode* node); 136 148 137 149 void notifyChildPropsChanged(); … … 302 314 { return this->node_->getScale(); } 303 315 #endif 316 317 SUPER_FUNCTION(5, WorldEntity, changedScale, false); 304 318 } 305 319 -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2371 r2485 30 30 #include "Pawn.h" 31 31 32 #include "core/Core.h" 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/XMLPort.h" 34 35 #include "util/Math.h" 36 #include "PawnManager.h" 35 37 #include "objects/infos/PlayerInfo.h" 36 38 #include "objects/gametypes/Gametype.h" 37 39 #include "objects/weaponSystem/WeaponSystem.h" 40 #include "objects/worldentities/ParticleSpawner.h" 41 #include "objects/worldentities/ExplosionChunk.h" 38 42 39 43 namespace orxonox … … 45 49 RegisterObject(Pawn); 46 50 47 this->bAlive_ = false; 51 PawnManager::touch(); 52 53 this->bAlive_ = true; 48 54 49 55 this->health_ = 0; … … 53 59 this->lastHitOriginator_ = 0; 54 60 this->weaponSystem_ = 0; 61 62 this->spawnparticleduration_ = 3.0f; 55 63 56 64 /* … … 62 70 */ 63 71 72 this->setRadarObjectColour(ColourValue::Red); 73 this->setRadarObjectShape(RadarViewable::Dot); 74 64 75 this->registerVariables(); 65 76 } … … 67 78 Pawn::~Pawn() 68 79 { 80 if (this->isInitialized()) 81 { 82 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) 83 it->destroyedPawn(this); 84 } 69 85 } 70 86 … … 73 89 SUPER(Pawn, XMLPort, xmlelement, mode); 74 90 75 XMLPortParam(Pawn, "health", setHealth, getHeal ht, xmlelement, mode).defaultValues(100);91 XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 76 92 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 77 93 XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); 94 XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode); 95 XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f); 96 XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); 78 97 } 79 98 80 99 void Pawn::registerVariables() 81 100 { 82 registerVariable(this->bAlive_, variableDirection::toclient); 83 registerVariable(this->health_, variableDirection::toclient); 101 registerVariable(this->bAlive_, variableDirection::toclient); 102 registerVariable(this->health_, variableDirection::toclient); 103 registerVariable(this->initialHealth_, variableDirection::toclient); 84 104 } 85 105 … … 119 139 } 120 140 121 void Pawn::spawn ()141 void Pawn::spawneffect() 122 142 { 123 143 // play spawn effect 144 if (this->spawnparticlesource_ != "") 145 { 146 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 147 effect->setPosition(this->getPosition()); 148 effect->setOrientation(this->getOrientation()); 149 effect->setDestroyAfterLife(true); 150 effect->setSource(this->spawnparticlesource_); 151 effect->setLifetime(this->spawnparticleduration_); 152 } 124 153 } 125 154 126 155 void Pawn::death() 127 156 { 157 // Set bAlive_ to false and wait for PawnManager to do the destruction 128 158 this->bAlive_ = false; 159 160 this->setDestroyWhenPlayerLeft(false); 161 129 162 if (this->getGametype()) 130 163 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 164 131 165 if (this->getPlayer()) 132 166 this->getPlayer()->stopControl(this); 133 167 134 delete this; 135 168 if (Core::isMaster()) 169 this->deatheffect(); 170 } 171 172 void Pawn::deatheffect() 173 { 136 174 // play death effect 175 { 176 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 177 effect->setPosition(this->getPosition()); 178 effect->setOrientation(this->getOrientation()); 179 effect->setDestroyAfterLife(true); 180 effect->setSource("Orxonox/explosion2b"); 181 effect->setLifetime(4.0f); 182 } 183 { 184 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 185 effect->setPosition(this->getPosition()); 186 effect->setOrientation(this->getOrientation()); 187 effect->setDestroyAfterLife(true); 188 effect->setSource("Orxonox/smoke6"); 189 effect->setLifetime(4.0f); 190 } 191 { 192 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 193 effect->setPosition(this->getPosition()); 194 effect->setOrientation(this->getOrientation()); 195 effect->setDestroyAfterLife(true); 196 effect->setSource("Orxonox/sparks"); 197 effect->setLifetime(4.0f); 198 } 199 for (unsigned int i = 0; i < this->numexplosionchunks_; ++i) 200 { 201 ExplosionChunk* chunk = new ExplosionChunk(this->getCreator()); 202 chunk->setPosition(this->getPosition()); 203 204 } 137 205 } 138 206 … … 146 214 { 147 215 this->setHealth(this->initialHealth_); 148 this->spawn(); 216 if (Core::isMaster()) 217 this->spawneffect(); 218 } 219 220 /////////////////// 221 // Pawn Listener // 222 /////////////////// 223 PawnListener::PawnListener() 224 { 225 RegisterRootObject(PawnListener); 149 226 } 150 227 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.h
r2098 r2485 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: … … 54 55 inline void removeHealth(float health) 55 56 { this->setHealth(this->health_ - health); } 56 inline float getHeal ht() const57 inline float getHealth() const 57 58 { return this->health_; } 58 59 … … 78 79 virtual void postSpawn(); 79 80 81 inline const WorldEntity* getWorldEntity() const 82 { return (WorldEntity*)this; } 83 84 inline void setSpawnParticleSource(const std::string& source) 85 { this->spawnparticlesource_ = source; } 86 inline const std::string& getSpawnParticleSource() const 87 { return this->spawnparticlesource_; } 88 89 inline void setSpawnParticleDuration(float duration) 90 { this->spawnparticleduration_ = duration; } 91 inline float getSpawnParticleDuration() const 92 { return this->spawnparticleduration_; } 93 94 inline void setExplosionChunks(unsigned int chunks) 95 { this->numexplosionchunks_ = chunks; } 96 inline unsigned int getExplosionChunks() const 97 { return this->numexplosionchunks_; } 98 80 99 protected: 81 virtual void spawn();82 100 virtual void death(); 101 virtual void deatheffect(); 102 virtual void spawneffect(); 83 103 84 104 bool bAlive_; … … 91 111 92 112 WeaponSystem* weaponSystem_; 113 114 std::string spawnparticlesource_; 115 float spawnparticleduration_; 116 unsigned int numexplosionchunks_; 117 }; 118 119 class _OrxonoxExport PawnListener : public OrxonoxClass 120 { 121 friend class Pawn; 122 123 public: 124 PawnListener(); 125 virtual ~PawnListener() {} 126 127 protected: 128 virtual void destroyedPawn(Pawn* pawn) = 0; 93 129 }; 94 130 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2475 r2485 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" 38 #include "core/Template.h" 38 39 #include "core/XMLPort.h" 40 #include "objects/items/Engine.h" 39 41 40 42 namespace orxonox … … 53 55 this->localLinearAcceleration_.setValue(0, 0, 0); 54 56 this->localAngularAcceleration_.setValue(0, 0, 0); 57 this->bBoost_ = false; 58 this->steering_ = Vector3::ZERO; 59 this->engine_ = 0; 60 55 61 56 62 this->bInvertYAxis_ = false; … … 70 76 SpaceShip::~SpaceShip() 71 77 { 78 if (this->isInitialized() && this->engine_) 79 delete this->engine_; 72 80 } 73 81 … … 76 84 SUPER(SpaceShip, XMLPort, xmlelement, mode); 77 85 86 XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode); 78 87 XMLPortParamVariable(SpaceShip, "primaryThrust", primaryThrust_, xmlelement, mode); 79 88 XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); … … 109 118 SUPER(SpaceShip, tick, dt); 110 119 111 if (this-> isLocallyControlled())120 if (this->hasLocalController()) 112 121 { 113 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 114 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 115 if (this->localLinearAcceleration_.z() > 0) 116 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 117 else 118 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 119 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 120 this->localLinearAcceleration_.setValue(0, 0, 0); 122 if (!this->isInMouseLook()) 123 { 124 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 125 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 126 if (this->localLinearAcceleration_.z() > 0) 127 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 128 else 129 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 130 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 131 this->localLinearAcceleration_.setValue(0, 0, 0); 132 } 121 133 122 134 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; … … 129 141 { 130 142 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x); 143 this->steering_.z = -value.x; 131 144 } 132 145 … … 134 147 { 135 148 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x); 149 this->steering_.x = value.x; 136 150 } 137 151 … … 139 153 { 140 154 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x); 155 this->steering_.y = value.x; 141 156 } 142 157 … … 144 159 { 145 160 this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x); 161 162 Pawn::rotateYaw(value); 146 163 } 147 164 … … 149 166 { 150 167 this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x); 168 169 Pawn::rotatePitch(value); 151 170 } 152 171 … … 154 173 { 155 174 this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x); 175 176 Pawn::rotateRoll(value); 156 177 } 157 178 … … 159 180 { 160 181 } 182 183 void SpaceShip::boost() 184 { 185 this->bBoost_ = true; 186 } 187 188 void SpaceShip::loadEngineTemplate() 189 { 190 if (this->enginetemplate_ != "") 191 { 192 Template* temp = Template::getTemplate(this->enginetemplate_); 193 194 if (temp) 195 { 196 Identifier* identifier = temp->getBaseclassIdentifier(); 197 198 if (identifier) 199 { 200 BaseObject* object = identifier->fabricate(this); 201 this->engine_ = dynamic_cast<Engine*>(object); 202 203 if (this->engine_) 204 { 205 this->engine_->addTemplate(temp); 206 this->engine_->addToSpaceShip(this); 207 } 208 else 209 { 210 delete object; 211 } 212 } 213 } 214 } 215 } 216 217 void SpaceShip::setEngine(Engine* engine) 218 { 219 this->engine_ = engine; 220 if (engine && engine->getShip() != this) 221 engine->addToSpaceShip(this); 222 } 161 223 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.h
r2459 r2485 58 58 59 59 virtual void fire(); 60 virtual void boost(); 61 62 void setEngine(Engine* engine); 63 inline Engine* getEngine() const 64 { return this->engine_; } 65 66 inline void setSteeringDirection(const Vector3& direction) 67 { this->steering_ = direction; } 68 inline const Vector3& getSteeringDirection() const 69 { return this->steering_; } 70 71 inline void setBoost(bool bBoost) 72 { this->bBoost_ = bBoost; } 73 inline bool getBoost() const 74 { return this->bBoost_; } 75 76 inline void setEngineTemplate(const std::string& temp) 77 { this->enginetemplate_ = temp; this->loadEngineTemplate(); } 78 inline const std::string& getEngineTemplate() const 79 { return this->enginetemplate_; } 60 80 61 81 protected: 62 82 bool bInvertYAxis_; 63 83 84 bool bBoost_; 85 Vector3 steering_; 64 86 float primaryThrust_; 65 87 float auxilaryThrust_; … … 71 93 private: 72 94 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; 95 96 private: 97 void loadEngineTemplate(); 98 99 std::string enginetemplate_; 100 Engine* engine_; 73 101 }; 74 102 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2480 r2485 33 33 34 34 #include "core/CoreIncludes.h" 35 #include "core/ConfigValueIncludes.h" 35 36 #include "core/Core.h" 36 37 #include "objects/worldentities/Model.h" … … 51 52 RegisterObject(Spectator); 52 53 53 this->speed_ = 100; 54 this->rotationGain_ = 3; 54 this->speed_ = 200; 55 55 56 56 this->yaw_ = 0; … … 59 59 this->localVelocity_ = Vector3::ZERO; 60 60 this->setHudTemplate("spectatorhud"); 61 this-> hudmode_ = 0;61 this->greetingFlare_ = 0; 62 62 63 63 this->setDestroyWhenPlayerLeft(true); 64 64 65 if ( Core::showsGraphics())66 65 if (Core::showsGraphics()) 66 { 67 67 this->greetingFlare_ = new BillboardSet(); 68 68 this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); … … 71 71 this->greetingFlare_->setVisible(false); 72 72 } 73 else 74 this->greetingFlare_ = 0; 73 75 74 this->bGreetingFlareVisible_ = false; 76 75 this->bGreeting_ = false; 77 76 77 this->setConfigValues(); 78 78 this->registerVariables(); 79 79 } … … 87 87 if (this->greetingFlare_->getBillboardSet()) 88 88 this->detachOgreObject(this->greetingFlare_->getBillboardSet()); 89 89 90 delete this->greetingFlare_; 90 91 } … … 92 93 } 93 94 95 void Spectator::setConfigValues() 96 { 97 SetConfigValue(speed_, 200.0f); 98 } 99 94 100 void Spectator::registerVariables() 95 101 { 96 102 registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 97 103 registerVariable(this->bGreeting_, variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 98 registerVariable(this->hudmode_, variableDirection::toclient);99 104 } 100 105 … … 107 112 void Spectator::changedFlareVisibility() 108 113 { 109 if ( this->greetingFlare_ ) 114 if ( this->greetingFlare_ ) 110 115 this->greetingFlare_->setVisible(this->bGreetingFlareVisible_); 111 116 } … … 113 118 void Spectator::tick(float dt) 114 119 { 115 this->updateHUD(); 116 117 if (this->isLocallyControlled()) 120 if (this->hasLocalController()) 118 121 { 119 122 float localSpeedSquared = this->localVelocity_.squaredLength(); … … 132 135 this->localVelocity_.z = 0; 133 136 134 this->yaw (Radian(this->yaw_ * this->rotationGain_)); 135 this->pitch(Radian(this->pitch_ * this->rotationGain_)); 136 this->roll (Radian(this->roll_ * this->rotationGain_)); 137 if (!this->isInMouseLook()) 138 { 139 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed())); 140 this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 141 this->roll(Radian(this->roll_ * this->getMouseLookSpeed())); 142 } 137 143 138 144 this->yaw_ = this->pitch_ = this->roll_ = 0; … … 146 152 ControllableEntity::setPlayer(player); 147 153 148 // this->setObjectMode(direction::toclient); 149 } 150 151 void Spectator::startLocalControl() 152 { 153 ControllableEntity::startLocalControl(); 154 // if (this->isLocallyControlled()) 155 // this->testmesh_->setVisible(false); 154 // this->setObjectMode(objectDirection::toclient); 155 } 156 157 void Spectator::startLocalHumanControl() 158 { 159 ControllableEntity::startLocalHumanControl(); 156 160 } 157 161 … … 174 178 { 175 179 this->yaw_ += value.y; 180 181 ControllableEntity::rotateYaw(value); 176 182 } 177 183 … … 179 185 { 180 186 this->pitch_ += value.y; 187 188 ControllableEntity::rotatePitch(value); 181 189 } 182 190 … … 184 192 { 185 193 this->roll_ += value.y; 194 195 ControllableEntity::rotateRoll(value); 186 196 } 187 197 … … 202 212 } 203 213 } 204 205 void Spectator::updateHUD()206 {207 // <hack>208 if (Core::isMaster())209 {210 if (this->getPlayer() && this->getGametype())211 {212 if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())213 {214 if (!this->getPlayer()->isReadyToSpawn())215 this->hudmode_ = 0;216 else217 this->hudmode_ = 1;218 }219 else if (!this->getGametype()->hasEnded())220 {221 if (this->getGametype()->isStartCountdownRunning())222 this->hudmode_ = 2 + 10*(int)ceil(this->getGametype()->getStartCountdown());223 else224 this->hudmode_ = 3;225 }226 else227 this->hudmode_ = 4;228 }229 else230 return;231 }232 233 if (this->getHUD())234 {235 std::string text;236 int hudmode = this->hudmode_ % 10;237 238 switch (hudmode)239 {240 case 0:241 text = "Press [Fire] to start the match";242 break;243 case 1:244 text = "Waiting for other players";245 break;246 case 2:247 text = convertToString((this->hudmode_ - 2) / 10);248 break;249 case 3:250 text = "Press [Fire] to respawn";251 break;252 case 4:253 text = "Game has ended";254 break;255 default:;256 }257 258 std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();259 for (; it != this->getHUD()->getOverlays().end(); ++it)260 {261 if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")262 {263 OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);264 if (overlay)265 overlay->setCaption(text);266 break;267 }268 }269 }270 // </hack>271 }272 214 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.h
r2459 r2485 42 42 virtual ~Spectator(); 43 43 44 void setConfigValues(); 44 45 void registerVariables(); 45 46 virtual void tick(float dt); 46 47 47 48 virtual void setPlayer(PlayerInfo* player); 48 virtual void startLocal Control();49 virtual void startLocalHumanControl(); 49 50 50 51 virtual void moveFrontBack(const Vector2& value); … … 62 63 void changedGreeting(); 63 64 void changedFlareVisibility(); 64 void updateHUD();65 65 66 66 BillboardSet* greetingFlare_; … … 69 69 70 70 float speed_; 71 float rotationGain_;72 71 73 72 float yaw_; … … 76 75 77 76 Vector3 localVelocity_; 78 79 int hudmode_;80 77 }; 81 78 } -
code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.cc
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/worldentities/triggers/Trigger.cc (added) merged: 2361 /code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc merged: 2-1912
r2459 r2485 107 107 if (!this->BaseObject::isActive()) 108 108 return; 109 110 SUPER(Trigger, tick, dt); 109 111 110 112 bool newTriggered = this->isTriggered() ^ this->bInvertMode_; - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h merged: 2-1912
- Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.