Changeset 1625
- Timestamp:
- Jun 26, 2008, 2:13:17 PM (17 years ago)
- Location:
- code/trunk
- Files:
-
- 3 deleted
- 35 edited
- 47 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/bin/levels/sample.oxw
r1608 r1625 9 9 </audio--> 10 10 11 <Ambient colourvalue=" 0.5, 0.5, 0.5" />11 <Ambient colourvalue="1.0, 1.0, 1.0" /> 12 12 <Skybox src="Orxonox/Starbox" /> 13 13 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="0,0,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" /> -
code/trunk/src/core/BaseObject.cc
r1559 r1625 66 66 67 67 /** 68 @brief load general xml paramters69 */70 void BaseObject::loadParams(TiXmlElement* xmlElem)71 {72 if (xmlElem->Attribute("name"))73 {74 this->setName(xmlElem->Attribute("name"));75 }76 }77 78 /**79 68 @brief XML loading and saving. 80 69 @param xmlelement The XML-element … … 85 74 { 86 75 XMLPortParam(BaseObject, "name", setName, getName, xmlelement, mode); 76 XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode); 77 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode); 87 78 } 88 79 -
code/trunk/src/core/BaseObject.h
r1608 r1625 52 52 BaseObject(); 53 53 virtual ~BaseObject(); 54 virtual void loadParams(TiXmlElement* xmlElem);55 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 55 -
code/trunk/src/core/Executor.cc
r1505 r1625 30 30 #include "Executor.h" 31 31 #include "util/Math.h" 32 #include "util/Convert.h" 32 33 #include "Language.h" 33 34 … … 136 137 { 137 138 std::string paramnumber; 138 if (! Convert::ToString(¶mnumber, param))139 if (!convertValue(¶mnumber, param)) 139 140 return (*this); 140 141 -
code/trunk/src/core/Iterator.h
r1543 r1625 92 92 { 93 93 this->element_ = element; 94 return *this; 94 95 } 95 96 -
code/trunk/src/core/Loader.cc
r1505 r1625 116 116 Script::run();*/ 117 117 Script* lua = Script::getInstance(); 118 lua->clearLuaOutput(); 118 119 lua->loadFile(level->getFile(), true); 119 120 lua->run(); -
code/trunk/src/core/Script.h
r1505 r1625 72 72 inline std::string getLuaOutput() { return output_; }; 73 73 //inline std::string* getFileString() { return &fileString_; }; 74 inline void clearLuaOutput() { output_ = ""; } 74 75 75 76 unsigned int getNextQuote(const std::string& text, unsigned int start); -
code/trunk/src/core/TclThreadManager.h
r1535 r1625 45 45 namespace orxonox 46 46 { 47 class boost::thread;48 49 47 struct _CoreExport TclInterpreterBundle 50 48 { -
code/trunk/src/network/GameStateClient.cc
r1534 r1625 34 34 #include "core/BaseObject.h" 35 35 #include "Synchronisable.h" 36 #include "objects/SpaceShip.h" 36 37 37 38 -
code/trunk/src/network/GameStateClient.h
r1505 r1625 44 44 // 45 45 #include "NetworkPrereqs.h" 46 #include "OrxonoxPrereqs.h" 46 47 #include "core/CorePrereqs.h" 47 48 #include "PacketTypes.h" 48 #include " objects/SpaceShip.h"49 #include "Synchronisable.h" 49 50 50 51 51 52 #define GAMESTATEID_INITIAL -1 53 52 54 53 55 namespace network -
code/trunk/src/orxonox/CMakeLists.txt
r1612 r1625 3 3 Main.cc 4 4 Orxonox.cc 5 Radar.cc 6 RadarListener.cc 7 RadarViewable.cc 5 8 Settings.cc 6 9 7 console/InGameConsole.cc 8 hud/HUD.cc 9 hud/BarOverlayElement.cc 10 hud/RadarOverlayElement.cc 11 hud/RadarObject.cc 12 hud/Navigation.cc 10 overlays/OrxonoxOverlay.cc 11 overlays/OverlayGroup.cc 12 overlays/OverlayText.cc 13 14 overlays/console/InGameConsole.cc 15 16 overlays/debug/DebugFPSText.cc 17 overlays/debug/DebugRTRText.cc 18 19 overlays/hud/HUDBar.cc 20 overlays/hud/HUDNavigation.cc 21 overlays/hud/HUDRadar.cc 22 overlays/hud/HUDSpeedBar.cc 23 13 24 tolua/tolua_bind.cc 14 25 … … 17 28 tools/Mesh.cc 18 29 tools/ParticleInterface.cc 30 tools/TextureGenerator.cc 19 31 tools/Timer.cc 32 tools/WindowEventListener.cc 20 33 21 34 objects/Ambient.cc … … 36 49 objects/RotatingProjectile.cc 37 50 objects/ParticleProjectile.cc 38 39 # objects/weapon/AmmunitionDump.cc40 # objects/weapon/BarrelGun.cc41 # objects/weapon/BaseWeapon.cc42 # objects/weapon/Bullet.cc43 # objects/weapon/BulletManager.cc44 # objects/weapon/WeaponStation.cc45 51 ) 46 52 -
code/trunk/src/orxonox/GraphicsEngine.cc
r1564 r1625 50 50 #include "core/CommandExecutor.h" 51 51 #include "core/ConsoleCommand.h" 52 #include "core/input/InputManager.h" 53 54 #include "console/InGameConsole.h" 55 #include "hud/HUD.h" 52 53 #include "overlays/console/InGameConsole.h" 54 #include "overlays/OverlayGroup.h" 56 55 #include "tools/ParticleInterface.h" 57 56 #include "Settings.h" 58 59 60 namespace orxonox { 57 #include "tools/WindowEventListener.h" 58 59 60 namespace orxonox 61 { 61 62 /** 62 63 @brief Returns the singleton instance and creates it the first time. … … 435 436 436 437 /** 437 * Window has resized.438 * Window has moved. 438 439 * @param rw The render window it occured in 439 440 */ 440 441 void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw) 441 442 { 442 // note: this doesn't change the window extents 443 for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it) 444 it->windowMoved(); 443 445 } 444 446 … … 451 453 void GraphicsEngine::windowResized(Ogre::RenderWindow *rw) 452 454 { 453 // change the mouse clipping size for absolute mouse movements 454 int w = rw->getWidth(); 455 int h = rw->getHeight(); 456 InputManager::setWindowExtents(w, h); 457 InGameConsole::getInstance().resize(); 458 HUD::getSingleton().resize(); 459 } 460 461 /** 462 * Window has resized. 455 for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it) 456 it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 457 } 458 459 /** 460 * Window has changed Focus. 463 461 * @param rw The render window it occured in 464 462 */ 465 463 void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw) 466 464 { 467 // note: this doesn't change the window extents 468 } 469 470 /** 471 * Window has resized. 465 for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it) 466 it->windowFocusChanged(); 467 } 468 469 /** 470 * Window was closed. 472 471 * @param rw The render window it occured in 473 472 */ 474 473 void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw) 475 474 { 476 // using CommandExecutor in order to avoid depending on Orxonox class.475 // using CommandExecutor in order to avoid depending on Orxonox.h. 477 476 CommandExecutor::execute("exit", false); 478 477 } -
code/trunk/src/orxonox/GraphicsEngine.h
r1563 r1625 47 47 48 48 49 namespace orxonox {50 49 namespace orxonox 50 { 51 51 /** 52 52 @brief Graphics engine manager class … … 72 72 int getWindowHeight() const; 73 73 float getWindowAspectRatio() const; 74 float getAverageFPS() const 75 { if (renderWindow_) return this->renderWindow_->getAverageFPS(); else return 0.0f; } 74 float getAverageFramesPerSecond() const { return this->avgFramesPerSecond_; } 75 float getAverageTickTime() const { return this->avgTickTime_; } 76 void setAverageTickTime(float tickTime) { this->avgTickTime_ = tickTime; } 77 void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; } 78 79 void setWindowActivity(bool activity) 80 { if (this->renderWindow_) this->renderWindow_->setActive(activity); } 76 81 77 82 void windowMoved (Ogre::RenderWindow* rw); … … 108 113 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 109 114 unsigned int detailLevelParticle_; //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high) 115 float avgTickTime_; //!< time in ms to tick() one frame 116 float avgFramesPerSecond_; //!< number of frames processed in one second 110 117 }; 111 118 } -
code/trunk/src/orxonox/Orxonox.cc
r1608 r1625 69 69 70 70 // objects and tools 71 #include " hud/HUD.h"72 #include " console/InGameConsole.h"71 #include "overlays/OverlayGroup.h" 72 #include "overlays/console/InGameConsole.h" 73 73 #include "objects/Tickable.h" 74 74 #include "objects/Backlight.h" … … 77 77 #include "GraphicsEngine.h" 78 78 #include "Settings.h" 79 #include "Radar.h" 79 80 80 81 // globals for the server or client … … 96 97 * Create a new instance of Orxonox. Avoid doing any actual work here. 97 98 */ 98 Orxonox::Orxonox() :99 ogre_(0),100 //auMan_(0),101 timer_(0),102 // turn on frame smoothing by setting a value different from 0103 frameSmoothingTime_(0.0f),104 orxonoxHUD_(0),105 bAbort_(false),106 timefactor_(1.0f),107 mode_(STANDALONE),108 serverIp_(""),109 serverPort_(NETWORK_PORT)99 Orxonox::Orxonox() 100 : ogre_(0) 101 , startLevel_(0) 102 , hud_(0) 103 , radar_(0) 104 //, auMan_(0) 105 , timer_(0) 106 , bAbort_(false) 107 , timefactor_(1.0f) 108 , mode_(STANDALONE) 109 , serverIp_("") 110 , serverPort_(NETWORK_PORT) 110 111 { 111 112 } … … 117 118 { 118 119 // keep in mind: the order of deletion is very important! 119 this->orxonoxHUD_->destroy(); 120 Loader::unload(startLevel_); 121 if (this->startLevel_) 122 delete this->startLevel_; 123 124 Loader::unload(hud_); 125 if (this->hud_) 126 delete this->hud_; 127 128 if (this->radar_) 129 delete this->radar_; 130 120 131 Loader::close(); 121 InputManager::destroy();122 132 //if (this->auMan_) 123 133 // delete this->auMan_; … … 125 135 if (this->timer_) 126 136 delete this->timer_; 137 InputManager::destroy(); 127 138 GraphicsEngine::getSingleton().destroy(); 128 139 … … 335 346 336 347 // Load the HUD 337 COUT(3) << "Orxonox: Loading HUD..." << std::endl; 338 orxonoxHUD_ = &HUD::getSingleton(); 339 orxonoxHUD_->initialise(); 348 COUT(3) << "Orxonox: Loading HUD" << std::endl; 349 hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo"); 350 Loader::load(hud_); 351 352 // Start the Radar 353 this->radar_ = new Radar(); 340 354 341 355 return true; … … 398 412 bool Orxonox::loadScene() 399 413 { 400 Level* startlevel= new Level("levels/sample.oxw");401 Loader::open(start level);414 startLevel_ = new Level("levels/sample.oxw"); 415 Loader::open(startLevel_); 402 416 403 417 return true; … … 424 438 425 439 426 // Contains the times of recently fired events427 // eventTimes[4] is the list for the times required for the fps counter428 std::deque<unsigned long> eventTimes[3];429 // Clear event times430 for (int i = 0; i < 3; ++i)431 eventTimes[i].clear();432 433 440 // use the ogre timer class to measure time. 434 441 if (!timer_) 435 442 timer_ = new Ogre::Timer(); 443 444 unsigned long frameCount = 0; 445 446 // TODO: this would very well fit into a configValue 447 const unsigned long refreshTime = 200000; 448 unsigned long refreshStartTime = 0; 449 unsigned long tickTime = 0; 450 unsigned long oldFrameCount = 0; 451 452 unsigned long timeBeforeTick = 0; 453 unsigned long timeBeforeTickOld = 0; 454 unsigned long timeAfterTick = 0; 455 456 COUT(3) << "Orxonox: Starting the main loop." << std::endl; 457 436 458 timer_->reset(); 437 438 float renderTime = 0.0f;439 float frameTime = 0.0f;440 // clock_t time = 0;441 442 //Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager();443 //Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport();444 445 //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Bloom");446 //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "MotionBlur");447 448 COUT(3) << "Orxonox: Starting the main loop." << std::endl;449 459 while (!bAbort_) 450 460 { 451 461 // get current time 452 unsigned long now = timer_->getMilliseconds(); 453 454 // create an event to pass to the frameStarted method in ogre 455 Ogre::FrameEvent evt; 456 evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]); 457 evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]); 458 frameTime += evt.timeSinceLastFrame; 459 460 // show the current time in the HUD 461 // HUD::getSingleton().setTime(now); 462 if (mode_ != DEDICATED && frameTime > 0.4f) 463 { 464 HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime); 465 frameTime = 0.0f; 466 renderTime = 0.0f; 467 } 468 469 // tick the core 470 Core::tick((float)evt.timeSinceLastFrame); 462 timeBeforeTickOld = timeBeforeTick; 463 timeBeforeTick = timer_->getMicroseconds(); 464 float dt = (timeBeforeTick - timeBeforeTickOld) / 1000000.0; 465 466 467 // tick the core (needs real time for input and tcl thread management) 468 Core::tick(dt); 469 471 470 // Call those objects that need the real time 472 471 for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it) 473 it->tick( (float)evt.timeSinceLastFrame);472 it->tick(dt); 474 473 // Call the scene objects 475 474 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 476 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 477 //AudioManager::tick(); 475 it->tick(dt * this->timefactor_); 476 477 // call server/client with normal dt 478 478 if (client_g) 479 client_g->tick( (float)evt.timeSinceLastFrame);479 client_g->tick(dt * this->timefactor_); 480 480 if (server_g) 481 server_g->tick((float)evt.timeSinceLastFrame); 481 server_g->tick(dt * this->timefactor_); 482 483 484 // get current time once again 485 timeAfterTick = timer_->getMicroseconds(); 486 487 tickTime += timeAfterTick - timeBeforeTick; 488 if (timeAfterTick > refreshStartTime + refreshTime) 489 { 490 GraphicsEngine::getSingleton().setAverageTickTime( 491 (float)tickTime * 0.001 / (frameCount - oldFrameCount)); 492 GraphicsEngine::getSingleton().setAverageFramesPerSecond( 493 (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0); 494 oldFrameCount = frameCount; 495 tickTime = 0; 496 refreshStartTime = timeAfterTick; 497 } 498 482 499 483 500 // don't forget to call _fireFrameStarted in ogre to make sure 484 501 // everything goes smoothly 502 Ogre::FrameEvent evt; 503 evt.timeSinceLastFrame = dt; 504 evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway 485 505 ogreRoot._fireFrameStarted(evt); 486 487 // get current time488 now = timer_->getMilliseconds();489 calculateEventTime(now, eventTimes[2]);490 506 491 507 if (mode_ != DEDICATED) … … 494 510 // This calls the WindowEventListener objects. 495 511 Ogre::WindowEventUtilities::messagePump(); 512 // make sure the window stays active even when not focused 513 // (probably only necessary on windows) 514 GraphicsEngine::getSingleton().setWindowActivity(true); 496 515 497 516 // render … … 499 518 } 500 519 501 // get current time502 now = timer_->getMilliseconds();503 504 // create an event to pass to the frameEnded method in ogre505 evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);506 renderTime += calculateEventTime(now, eventTimes[2]);507 508 520 // again, just to be sure ogre works fine 509 ogreRoot._fireFrameEnded(evt); 510 //msleep(500); 521 ogreRoot._fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted 522 523 ++frameCount; 511 524 } 512 525 … … 518 531 return true; 519 532 } 520 521 /**522 Method for calculating the average time between recently fired events.523 Code directly taken from OgreRoot.cc524 @param now The current time in ms.525 @param type The type of event to be considered.526 */527 float Orxonox::calculateEventTime(unsigned long now, std::deque<unsigned long> ×)528 {529 // Calculate the average time passed between events of the given type530 // during the last frameSmoothingTime_ seconds.531 532 times.push_back(now);533 534 if(times.size() == 1)535 return 0;536 537 // Times up to frameSmoothingTime_ seconds old should be kept538 unsigned long discardThreshold = (unsigned long)(frameSmoothingTime_ * 1000.0f);539 540 // Find the oldest time to keep541 std::deque<unsigned long>::iterator it = times.begin();542 // We need at least two times543 std::deque<unsigned long>::iterator end = times.end() - 2;544 545 while(it != end)546 {547 if (now - *it > discardThreshold)548 ++it;549 else550 break;551 }552 553 // Remove old times554 times.erase(times.begin(), it);555 556 return (float)(times.back() - times.front()) / ((times.size() - 1) * 1000);557 }558 533 } -
code/trunk/src/orxonox/Orxonox.h
r1563 r1625 62 62 63 63 void abortRequest(); 64 //inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };65 64 66 65 static Orxonox* getSingleton(); … … 93 92 private: 94 93 GraphicsEngine* ogre_; //!< our dearest graphics engine <3 94 Level* startLevel_; //!< current hard coded default level 95 Level* hud_; //!< 'level' object fo the HUD 96 Radar* radar_; //!< represents the Radar (not the HUD part) 95 97 //audio::AudioManager* auMan_; //!< audio manager 96 98 Ogre::Timer* timer_; //!< Main loop timer 97 // TODO: make this a config-value by creating a config class for orxonox98 float frameSmoothingTime_;99 HUD* orxonoxHUD_;100 99 bool bAbort_; //!< aborts the render loop if true 101 100 float timefactor_; //!< A factor to change the gamespeed -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r1564 r1625 62 62 namespace orxonox 63 63 { 64 namespace LODParticle 65 { 66 enum LOD 64 namespace LODParticle 67 65 { 68 off = 0, 69 low = 1, 70 normal = 2, 71 high = 3 72 }; 73 } 66 enum LOD 67 { 68 off = 0, 69 low = 1, 70 normal = 2, 71 high = 3 72 }; 73 } 74 74 75 class GraphicsEngine;76 class Orxonox;75 class GraphicsEngine; 76 class Orxonox; 77 77 78 // objects 79 class Ambient; 80 class Backlight; 81 class Camera; 82 class Fighter; 83 class Model; 84 class NPC; 85 class ParticleSpawner; 86 class Skybox; 87 class SpaceShip; 88 class SpaceShipAI; 89 class WorldEntity; 78 class RadarViewable; 79 class Radar; 80 class RadarListener; 90 81 91 class Projectile; 92 class BillboardProjectile; 93 class RotatingProjectile; 94 class ParticleProjectile; 82 // objects 83 class Ambient; 84 class Backlight; 85 class Camera; 86 class Fighter; 87 class Model; 88 class NPC; 89 class ParticleSpawner; 90 class Skybox; 91 class SpaceShip; 92 class SpaceShipAI; 93 class WorldEntity; 95 94 96 class AmmunitionDump; 97 class Bullet; 98 class BulletManager; 99 class BaseWeapon; 100 class BarrelGun; 101 class WeaponStation; 95 class Projectile; 96 class BillboardProjectile; 97 class RotatingProjectile; 98 class ParticleProjectile; 102 99 103 // tools104 class BillboardSet;105 class Light;106 class Mesh;107 template <class T>108 class Timer;109 class TimerBase;100 // tools 101 class BillboardSet; 102 class Light; 103 class Mesh; 104 class ParticleInterface; 105 template <class T> 106 class Timer; 110 107 111 // particle 112 class ParticleInterface; 113 114 // hud 115 class BarOverlayElement; 116 class BarOverlayElementFactory; 117 class HUD; 118 class Navigation; 119 class RadarObject; 120 class RadarOverlayElement; 121 class RadarOverlayElementFactory; 122 123 //console 124 class InGameConsole; 108 // overlays 109 class BarColour; 110 class DebugFPSText; 111 class DebugRTRText; 112 class HUDBar; 113 class HUDNavigation; 114 class HUDRadar; 115 class HUDSpeedBar; 116 class InGameConsole; 117 class OrxonoxOverlay; 118 class OverlayGroup; 119 class OverlayText; 125 120 } 126 121 122 namespace Ogre 123 { 124 // some got forgotten in OgrePrerequisites 125 class BorderPanelOverlayElement; 126 class PanelOverlayElement; 127 class TextAreaOverlayElement; 128 } 127 129 128 130 #endif /* _OrxonoxPrereqs_H__ */ -
code/trunk/src/orxonox/objects/Ambient.cc
r1505 r1625 73 73 74 74 } 75 76 void Ambient:: loadParams(TiXmlElement* xmlElem)75 76 void Ambient::setAmbientLight(const ColourValue& colour) 77 77 { 78 if (xmlElem->Attribute("colourvalue")) 79 { 80 SubString colourvalues(xmlElem->Attribute("colourvalue"), ','); 81 82 float r, g, b; 83 convertValue<std::string, float>(&r, colourvalues[0]); 84 convertValue<std::string, float>(&g, colourvalues[1]); 85 convertValue<std::string, float>(&b, colourvalues[2]); 86 87 this->setAmbientLight(ColourValue(r, g, b)); 88 89 COUT(4) << "Loader: Set ambient light: "<<r<<" " << g << " " << b << std::endl << std::endl; 90 } 91 } 92 93 void Ambient::setAmbientLight(const ColourValue& colour) 94 { 95 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour); 78 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour); 96 79 ambientLight_=colour; 97 }80 } 98 81 99 82 /** -
code/trunk/src/orxonox/objects/Ambient.h
r1505 r1625 44 44 virtual ~Ambient(); 45 45 46 void loadParams(TiXmlElement* xmlElem);47 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 47 void setAmbientLight(const ColourValue& colour); -
code/trunk/src/orxonox/objects/NPC.cc
r1505 r1625 45 45 NPC::~NPC() 46 46 { 47 }48 49 void NPC::loadParams(TiXmlElement* xmlElem)50 {51 Model::loadParams(xmlElem);52 47 } 53 48 -
code/trunk/src/orxonox/objects/NPC.h
r1505 r1625 48 48 NPC(); 49 49 virtual ~NPC(); 50 virtual void loadParams(TiXmlElement* xmlElem);51 50 void tick(float dt); 52 51 void update(); -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1608 r1625 43 43 #include "core/XMLPort.h" 44 44 #include "core/ConsoleCommand.h" 45 #include "core/input/InputManager.h"46 45 47 46 #include "network/Client.h" 48 47 49 #include "hud/HUD.h"50 48 #include "tools/ParticleInterface.h" 51 49 … … 118 116 this->timeToReload_ = 0; 119 117 120 this->setMouseEventCallback_ = false;121 118 this->bLMousePressed_ = false; 122 119 this->bRMousePressed_ = false; 123 120 this->mouseXRotation_ = 0; 124 121 this->mouseYRotation_ = 0; 125 this->mouseX_ = 0;126 this->mouseY_ = 0;127 122 this->myShip_ = false; 128 123 … … 142 137 this->teamNr_ = 0; 143 138 this->health_ = 100; 139 140 this->radarObject_ = static_cast<WorldEntity*>(this); 144 141 } 145 142 … … 161 158 delete this->backlight_; 162 159 163 if (this->setMouseEventCallback_)164 InputManager::removeMouseHandler("SpaceShip");165 166 160 if (this->cam_) 167 161 delete this->cam_; 168 169 if (!this->myShip_)170 HUD::getSingleton().removeRadarObject(this);171 162 } 172 163 } … … 177 168 myShip_=true; 178 169 else 179 HUD::getSingleton().addRadarObject(this,this->getProjectileColour());170 this->setRadarObjectColour(this->getProjectileColour()); 180 171 } 181 172 if(Model::create()) … … 418 409 419 410 currentDir_ = getOrientation()*initialDir_; 420 411 currentOrth_ = getOrientation()*initialOrth_; 421 412 422 413 if (this->cam_) -
code/trunk/src/orxonox/objects/SpaceShip.h
r1608 r1625 36 36 #include "Camera.h" 37 37 #include "Model.h" 38 #include "RadarViewable.h" 38 39 #include "tools/BillboardSet.h" 39 40 40 41 namespace orxonox 41 42 { 42 class _OrxonoxExport SpaceShip : public Model 43 class _OrxonoxExport SpaceShip : public Model, public RadarViewable 43 44 { 44 45 public: … … 131 132 Vector3 currentOrth_; 132 133 bool bInvertYAxis_; 133 bool setMouseEventCallback_;134 134 bool bLMousePressed_; 135 135 bool bRMousePressed_; -
code/trunk/src/orxonox/objects/WorldEntity.cc
r1602 r1625 95 95 } 96 96 97 void WorldEntity::loadParams(TiXmlElement* xmlElem)98 {99 100 BaseObject::loadParams(xmlElem);101 create();102 }103 104 97 105 98 void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll) -
code/trunk/src/orxonox/objects/WorldEntity.h
r1602 r1625 51 51 52 52 virtual void tick(float dt); 53 virtual void loadParams(TiXmlElement* xmlElem);54 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 54 virtual inline bool create(){ return Synchronisable::create(); } … … 74 73 inline const Vector3& getPosition() const 75 74 { return this->node_->getPosition(); } 75 inline const Vector3& getWorldPosition() const 76 { return this->node_->getWorldPosition(); } 76 77 77 78 inline void translate(const Vector3& d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) … … 101 102 inline const Ogre::Quaternion& getOrientation() 102 103 { return this->node_->getOrientation(); } 104 inline const Ogre::Quaternion& getWorldOrientation() 105 { return this->node_->getWorldOrientation(); } 103 106 inline void setOrientation(const Ogre::Quaternion& quat) 104 107 { this->node_->setOrientation(quat); } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r1624 r1625 76 76 77 77 //! Shows the overlay with an detour to BaseObject::visibility_ 78 void show() { this->setVisib ility(true); }78 void show() { this->setVisible(true); } 79 79 //! Hides the overlay with an detour to BaseObject::visibility_ 80 void hide() { this->setVisib ility(false); }80 void hide() { this->setVisible(false); } 81 81 82 82 /** Sets whether the aspect of the overlay is corrected. -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r1624 r1625 138 138 { 139 139 if ((*it)->getName() == name) 140 (*it)->setVisib ility(!((*it)->isVisible()));140 (*it)->setVisible(!((*it)->isVisible())); 141 141 } 142 142 } -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc
r1624 r1625 97 97 98 98 // hide at first 99 this->setVisib ility(false);99 this->setVisible(false); 100 100 } 101 101 -
code/trunk/src/tinyxml/ticpp.cc
r1505 r1625 23 23 */ 24 24 25 /* 26 Modifications by the orxonox team: 27 In function: void Document::Parse( const std::string& xml, bool throwIfParseError, TiXmlEncoding encoding ) 28 change: Added row and column number to the error description. 29 author: Reto Grieder 30 */ 31 25 32 #ifdef TIXML_USE_TICPP 26 33 … … 853 860 if( throwIfParseError && m_tiXmlPointer->Error() ) 854 861 { 855 TICPPTHROW( "Error parsing xml: " << m_tiXmlPointer->ErrorDesc() ); 862 TICPPTHROW( "Error parsing xml: " << m_tiXmlPointer->ErrorDesc() 863 << " In row " << m_tiXmlPointer->ErrorRow() << ", column " << m_tiXmlPointer->ErrorCol() << "."); 856 864 } 857 865 } -
code/trunk/src/util/Convert.h
r1505 r1625 43 43 #include "SubString.h" 44 44 #include "MultiTypeMath.h" 45 #include "String.h" 45 46 46 47 // disable annoying warning about forcing value to boolean … … 299 300 }; 300 301 302 // convert to string Shortcut 303 template <class FromType> 304 std::string convertToString(FromType value) 305 { 306 return getConvertedValue<FromType, std::string>(value); 307 } 308 301 309 // convert from string 302 310 template <class ToType> … … 313 321 } 314 322 }; 323 324 // convert from string Shortcut 325 template <class ToType> 326 ToType convertFromString(std::string str) 327 { 328 return getConvertedValue<std::string, ToType>(str); 329 } 315 330 316 331 … … 404 419 //////////////////// 405 420 421 // bool to std::string 422 template <> 423 struct ConverterSpecialized<bool, std::string, _Explicit_> 424 { 425 enum { specialized = true }; 426 static bool convert(std::string* output, const bool& input) 427 { 428 if (input) 429 *output = "true"; 430 else 431 *output = "false"; 432 return false; 433 } 434 }; 435 406 436 // Vector2 to std::string 407 437 template <> … … 494 524 //////////////////// 495 525 526 // std::string to bool 527 template <> 528 struct ConverterSpecialized<std::string, bool, _Explicit_> 529 { 530 enum { specialized = true }; 531 static bool convert(bool* output, const std::string& input) 532 { 533 std::string stripped = getLowercase(removeTrailingWhitespaces(input)); 534 if (stripped == "true" || stripped == "on" || stripped == "yes") 535 { 536 *output = true; 537 return true; 538 } 539 else if (stripped == "false" || stripped == "off" || stripped == "no") 540 { 541 *output = false; 542 return true; 543 } 544 545 std::istringstream iss(input); 546 if (iss >> (*output)) 547 return true; 548 else 549 return false; 550 } 551 }; 552 496 553 // std::string to Vector2 497 554 template <> … … 611 668 612 669 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); 613 if (tokens.size() >= 4)670 if (tokens.size() >= 3) 614 671 { 615 672 if (!ConvertValue(&(output->r), tokens[0])) … … 619 676 if (!ConvertValue(&(output->b), tokens[2])) 620 677 return false; 621 if (!ConvertValue(&(output->a), tokens[3])) 622 return false; 678 if (tokens.size() >= 4) 679 { 680 if (!ConvertValue(&(output->a), tokens[3])) 681 return false; 682 } 683 else 684 output->a = 1.0; 623 685 624 686 return true; -
code/trunk/src/util/Math.cc
r1608 r1625 30 30 31 31 #include "Math.h" 32 #include "Convert.h" 32 33 33 34 /** … … 136 137 return (targetposition + targetvelocity * time); 137 138 } 139 140 unsigned long getUniqueNumber() 141 { 142 static unsigned long aNumber = 135; 143 return aNumber++; 144 } 145 146 std::string getUniqueNumberStr() 147 { 148 return convertToString(getUniqueNumber()); 149 } -
code/trunk/src/util/Math.h
r1566 r1625 33 33 34 34 #include <ostream> 35 #include <string> 35 36 36 37 #include <OgreMath.h> … … 39 40 #include <OgreVector4.h> 40 41 #include <OgreMatrix3.h> 42 #include <OgreMatrix4.h> 41 43 #include <OgreQuaternion.h> 42 44 #include <OgreColourValue.h> … … 50 52 typedef Ogre::Vector4 Vector4; 51 53 typedef Ogre::Matrix3 Matrix3; 54 typedef Ogre::Matrix4 Matrix4; 52 55 typedef Ogre::Quaternion Quaternion; 53 56 typedef Ogre::ColourValue ColourValue; … … 161 164 } 162 165 166 _UtilExport unsigned long getUniqueNumber(); 167 _UtilExport std::string getUniqueNumberStr(); 168 163 169 class _UtilExport IntVector2 164 170 { -
code/trunk/src/util/String.cc
r1505 r1625 31 31 #include <cctype> 32 32 #include <iostream> 33 34 /** 35 @brief Blank string as variable so you can use const std::string& even 36 if you have to return "". 37 */ 38 std::string blankString = ""; 33 39 34 40 /** -
code/trunk/src/util/String.h
r1505 r1625 35 35 #include <sstream> 36 36 37 extern _UtilExport std::string blankString; 38 37 39 _UtilExport void strip(std::string* str); 38 40 _UtilExport std::string getStripped(const std::string& str); … … 70 72 _UtilExport unsigned int getNextCommentPosition(const std::string& str, unsigned int start = 0); 71 73 72 //! The Convert class has some static member functions to convert strings to values and values to strings.73 class _UtilExport Convert74 {75 public:76 /**77 @brief Converts a value of any type to a string.78 @param output The string to write the result in79 @param input The variable to convert80 @return True if the conversion succeded81 82 @example83 float f = 3.14;84 std::string output;85 bool success = Convert::ToString(&output, f);86 */87 template <typename T>88 static bool ToString(std::string* output, T input)89 {90 std::ostringstream oss;91 if (oss << input)92 {93 (*output) = oss.str();94 return true;95 }96 97 return false;98 }99 100 /**101 @brief Converts a value of any type to a string and assigns a defaultvalue if the conversion fails.102 @param output The string to write the result in103 @param input The variable to convert104 @param fallbackString The assigned string if the conversion fails.105 @return True if the conversion succeeded106 107 @example108 float f = 3.14;109 std::string output;110 bool success = Convert::ToString(&output, f, "0.000000");111 */112 template <typename T>113 static bool ToString(std::string* output, T input, const std::string& fallbackString)114 {115 if (Convert::ToString(output, input))116 return true;117 118 (*output) = fallbackString;119 return false;120 }121 122 /**123 @brief Converts a string to a value of any type.124 @param output The variable to assign the result to125 @param input The string to convert126 @return True if the conversion succeeded127 128 @example129 std::string input = "3.14";130 float f;131 bool success = string2Number(&f, input);132 */133 template <typename T>134 static bool FromString(T* output, const std::string& input)135 {136 std::istringstream iss(input);137 if (iss >> (*output))138 return true;139 140 return false;141 }142 143 /**144 @brief Converts a string to a value of any type.145 @param output The variable to assign the result to146 @param input The string to convert147 @param fallbackValue The assigned value if the conversion fails148 @return True if the conversion succeeded149 150 @example151 std::string input = "3.14";152 float f;153 bool success = string2Number(&f, input, 0.000000);154 */155 template <typename T>156 static bool FromString(T* output, const std::string& input, T fallbackValue)157 {158 if (Convert::FromString(output, input))159 return true;160 161 (*output) = fallbackValue;162 return false;163 }164 };165 166 74 #endif /* _Util_String_H__ */ -
code/trunk/src/util/UtilPrereqs.h
r1505 r1625 61 61 //----------------------------------------------------------------------- 62 62 class ArgReader; 63 class Convert;64 63 class MultiTypePrimitive; 65 64 class MultiTypeString; -
code/trunk/visual_studio/vc8/audio.vcproj
r1024 r1625 82 82 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\audio_properties.vsprops" 83 83 CharacterSet="1" 84 WholeProgramOptimization=" 1"84 WholeProgramOptimization="0" 85 85 > 86 86 <Tool -
code/trunk/visual_studio/vc8/ois.vcproj
r1567 r1625 24 24 InheritedPropertySheets="..\directory_properties.vsprops" 25 25 CharacterSet="2" 26 WholeProgramOptimization=" 1"26 WholeProgramOptimization="0" 27 27 > 28 28 <Tool -
code/trunk/visual_studio/vc8/orxonox.vcproj
r1624 r1625 185 185 </File> 186 186 <File 187 RelativePath="..\..\src\orxonox\Radar.cc" 188 > 189 </File> 190 <File 191 RelativePath="..\..\src\orxonox\RadarListener.cc" 192 > 193 </File> 194 <File 195 RelativePath="..\..\src\orxonox\RadarViewable.cc" 196 > 197 <FileConfiguration 198 Name="Debug|Win32" 199 > 200 <Tool 201 Name="VCCLCompilerTool" 202 ObjectFile="$(IntDir)\$(InputName)1.obj" 203 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 204 /> 205 </FileConfiguration> 206 <FileConfiguration 207 Name="Release|Win32" 208 > 209 <Tool 210 Name="VCCLCompilerTool" 211 ObjectFile="$(IntDir)\$(InputName)1.obj" 212 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 213 /> 214 </FileConfiguration> 215 </File> 216 <File 187 217 RelativePath="..\..\src\orxonox\Settings.cc" 188 218 > 189 219 </File> 190 <Filter191 Name="hud"192 >193 <File194 RelativePath="..\..\src\orxonox\hud\BarOverlayElement.cc"195 >196 </File>197 <File198 RelativePath="..\..\src\orxonox\hud\HUD.cc"199 >200 </File>201 <File202 RelativePath="..\..\src\orxonox\hud\Navigation.cc"203 >204 </File>205 <File206 RelativePath="..\..\src\orxonox\hud\RadarObject.cc"207 >208 </File>209 <File210 RelativePath="..\..\src\orxonox\hud\RadarOverlayElement.cc"211 >212 </File>213 </Filter>214 220 <Filter 215 221 Name="objects" … … 424 430 </File> 425 431 <File 432 RelativePath="..\..\src\orxonox\tools\TextureGenerator.cc" 433 > 434 </File> 435 <File 426 436 RelativePath="..\..\src\orxonox\tools\Timer.cc" 427 437 > 428 438 </File> 429 </Filter> 430 <Filter 431 Name="console" 432 > 433 <File 434 RelativePath="..\..\src\orxonox\console\InGameConsole.cc" 439 <File 440 RelativePath="..\..\src\orxonox\tools\WindowEventListener.cc" 435 441 > 436 442 </File> … … 460 466 </File> 461 467 </Filter> 468 <Filter 469 Name="overlays" 470 > 471 <File 472 RelativePath="..\..\src\orxonox\overlays\OrxonoxOverlay.cc" 473 > 474 </File> 475 <File 476 RelativePath="..\..\src\orxonox\overlays\OverlayGroup.cc" 477 > 478 </File> 479 <File 480 RelativePath="..\..\src\orxonox\overlays\OverlayText.cc" 481 > 482 </File> 483 <Filter 484 Name="console" 485 > 486 <File 487 RelativePath="..\..\src\orxonox\overlays\console\InGameConsole.cc" 488 > 489 </File> 490 </Filter> 491 <Filter 492 Name="hud" 493 > 494 <File 495 RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.cc" 496 > 497 </File> 498 <File 499 RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.cc" 500 > 501 </File> 502 <File 503 RelativePath="..\..\src\orxonox\overlays\hud\HUDRadar.cc" 504 > 505 </File> 506 <File 507 RelativePath="..\..\src\orxonox\overlays\hud\HUDSpeedBar.cc" 508 > 509 </File> 510 </Filter> 511 <Filter 512 Name="debug" 513 > 514 <File 515 RelativePath="..\..\src\orxonox\overlays\debug\DebugFPSText.cc" 516 > 517 </File> 518 <File 519 RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.cc" 520 > 521 </File> 522 </Filter> 523 </Filter> 462 524 </Filter> 463 525 <Filter … … 483 545 </File> 484 546 <File 547 RelativePath="..\..\src\orxonox\Radar.h" 548 > 549 </File> 550 <File 551 RelativePath="..\..\src\orxonox\RadarListener.h" 552 > 553 </File> 554 <File 555 RelativePath="..\..\src\orxonox\RadarViewable.h" 556 > 557 </File> 558 <File 485 559 RelativePath="..\..\src\orxonox\Settings.h" 486 560 > 487 561 </File> 488 <Filter489 Name="hud"490 >491 <File492 RelativePath="..\..\src\orxonox\hud\BarOverlayElement.h"493 >494 </File>495 <File496 RelativePath="..\..\src\orxonox\hud\HUD.h"497 >498 </File>499 <File500 RelativePath="..\..\src\orxonox\hud\Navigation.h"501 >502 </File>503 <File504 RelativePath="..\..\src\orxonox\hud\OverlayElementFactories.h"505 >506 </File>507 <File508 RelativePath="..\..\src\orxonox\hud\RadarObject.h"509 >510 </File>511 <File512 RelativePath="..\..\src\orxonox\hud\RadarOverlayElement.h"513 >514 </File>515 </Filter>516 562 <Filter 517 563 Name="objects" … … 630 676 </File> 631 677 <File 678 RelativePath="..\..\src\orxonox\tools\TextureGenerator.h" 679 > 680 </File> 681 <File 632 682 RelativePath="..\..\src\orxonox\tools\Timer.h" 633 683 > 634 684 </File> 635 </Filter> 636 <Filter 637 Name="console" 638 > 639 <File 640 RelativePath="..\..\src\orxonox\console\InGameConsole.h" 685 <File 686 RelativePath="..\..\src\orxonox\tools\WindowEventListener.h" 641 687 > 642 688 </File> … … 649 695 > 650 696 </File> 697 </Filter> 698 <Filter 699 Name="overlays" 700 > 701 <File 702 RelativePath="..\..\src\orxonox\overlays\OrxonoxOverlay.h" 703 > 704 </File> 705 <File 706 RelativePath="..\..\src\orxonox\overlays\OverlayGroup.h" 707 > 708 </File> 709 <File 710 RelativePath="..\..\src\orxonox\overlays\OverlayText.h" 711 > 712 </File> 713 <Filter 714 Name="hud" 715 > 716 <File 717 RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.h" 718 > 719 </File> 720 <File 721 RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.h" 722 > 723 </File> 724 <File 725 RelativePath="..\..\src\orxonox\overlays\hud\HUDRadar.h" 726 > 727 </File> 728 <File 729 RelativePath="..\..\src\orxonox\overlays\hud\HUDSpeedBar.h" 730 > 731 </File> 732 </Filter> 733 <Filter 734 Name="console" 735 > 736 <File 737 RelativePath="..\..\src\orxonox\overlays\console\InGameConsole.h" 738 > 739 </File> 740 </Filter> 741 <Filter 742 Name="debug" 743 > 744 <File 745 RelativePath="..\..\src\orxonox\overlays\debug\DebugFPSText.h" 746 > 747 </File> 748 <File 749 RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.h" 750 > 751 </File> 752 </Filter> 651 753 </Filter> 652 754 </Filter> -
code/trunk/visual_studio/vc8/util.vcproj
r1502 r1625 82 82 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\util_properties.vsprops" 83 83 CharacterSet="1" 84 WholeProgramOptimization=" 1"84 WholeProgramOptimization="0" 85 85 > 86 86 <Tool
Note: See TracChangeset
for help on using the changeset viewer.