Changeset 1629
- Timestamp:
- Jun 27, 2008, 8:07:29 AM (16 years ago)
- Location:
- code/branches/input
- Files:
-
- 10 deleted
- 76 edited
- 57 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/CMakeLists.txt
r1535 r1629 63 63 #Performs the search and sets the variables 64 64 FIND_PACKAGE(OGRE) 65 #FIND_PACKAGE(OIS)66 65 # FIND_PACKAGE(CEGUI) 67 66 # FIND_PACKAGE(CEGUI_OGRE) 68 67 FIND_PACKAGE(ENet) 69 68 FIND_PACKAGE(Boost REQUIRED thread filesystem) 70 #FIND_PACKAGE(Boost REQUIRED filesystem)71 69 FIND_PACKAGE(OpenAL) 72 70 FIND_PACKAGE(ALUT) … … 80 78 LINK_DIRECTORIES( 81 79 ${OGRE_LIB_DIR} 82 # ${OIS_LIB_DIR}83 80 # ${CEGUI_LIB_DIR} ${CEGUI_OGRE_LIB_DIR} 84 81 ${ENet_LIBRARY} … … 91 88 INCLUDE_DIRECTORIES( 92 89 ${OGRE_INCLUDE_DIR} 93 # ${OIS_INCLUDE_DIR}94 90 # ${CEGUI_INCLUDE_DIR} ${CEGUI_OGRE_INCLUDE_DIR} 95 91 ${ENet_INCLUDE_DIR} -
code/branches/input/bin/levels/sample.oxw
r1505 r1629 9 9 </audio--> 10 10 11 <Ambient colourvalue=" 0.1, 0.1, 0.1" />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" /> … … 44 44 for i = 1, 226, 1 45 45 do ?> 46 <Model position="<?lua print(math.random( -19597, 18732))?>, <?lua print(math.random(-19597, 18732)) ?>, <?lua print(math.random(-19597, 18732)) ?>" scale="<?lua print(math.random( 20, 119)) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random(16, 44)) ?>" />46 <Model position="<?lua print(math.random() * 40000 - 20000)?>, <?lua print(math.random() * 40000 - 20000) ?>, <?lua print(math.random() * 40000 - 20000) ?>" scale="<?lua print(math.random() * 250 + 20) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random() * 30 + 15) ?>" /> 47 47 <?lua 48 48 end -
code/branches/input/src/CMakeLists.txt
r1505 r1629 1 1 INCLUDE_DIRECTORIES(.) 2 INCLUDE_DIRECTORIES(..) 2 3 INCLUDE_DIRECTORIES(orxonox) 3 4 INCLUDE_DIRECTORIES(tolua) 4 INCLUDE_DIRECTORIES(ois)5 5 6 6 ADD_SUBDIRECTORY(cpptcl) -
code/branches/input/src/asylum/orxonox/objects/Fighter.cc
r1505 r1629 42 42 #include "GraphicsEngine.h" 43 43 #include "core/InputManager.h" 44 #include " particle/ParticleInterface.h"44 #include "tools/ParticleInterface.h" 45 45 #include "weapon/AmmunitionDump.h" 46 46 #include "weapon/BarrelGun.h" … … 132 132 #if 0 133 133 w = new particle::ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"schuss" + this->getName(),"Orxonox/schuss"); 134 w->getParticleSystem()->setParameter("local_space","true");135 134 w->newEmitter(); 136 135 /* … … 151 150 152 151 tt = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); 153 tt->getParticleSystem()->setParameter("local_space","true");154 152 tt->newEmitter(); 155 153 /* -
code/branches/input/src/core/BaseObject.cc
r1505 r1629 45 45 @brief Constructor: Registers the object in the BaseObject-list. 46 46 */ 47 BaseObject::BaseObject() : 48 bActive_(true), 49 bVisible_(true), 50 level_(0), 51 namespace_(0) 47 BaseObject::BaseObject() : bInitialized_(false) 52 48 { 53 49 RegisterRootObject(BaseObject); 50 51 this->bInitialized_ = true; 52 53 this->bActive_ = true; 54 this->bVisible_ = true; 55 56 this->level_ = 0; 57 this->namespace_ = 0; 54 58 } 55 59 … … 59 63 BaseObject::~BaseObject() 60 64 { 61 }62 63 /**64 @brief load general xml paramters65 */66 void BaseObject::loadParams(TiXmlElement* xmlElem)67 {68 if (xmlElem->Attribute("name"))69 {70 this->setName(xmlElem->Attribute("name"));71 }72 65 } 73 66 … … 81 74 { 82 75 XMLPortParam(BaseObject, "name", setName, getName, xmlelement, mode); 76 XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode); 77 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode); 83 78 } 84 79 -
code/branches/input/src/core/BaseObject.h
r1505 r1629 47 47 class _CoreExport BaseObject : virtual public OrxonoxClass 48 48 { 49 friend class WorldEntity; 50 49 51 public: 50 52 BaseObject(); 51 53 virtual ~BaseObject(); 52 virtual void loadParams(TiXmlElement* xmlElem);53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 56 /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */ 57 inline bool isInitialized() const { return this->bInitialized_; } 54 58 55 59 /** @brief Sets the name of the object. @param name The name */ … … 61 65 62 66 /** @brief Sets the state of the objects activity. @param bActive True = active */ 63 inline void setActiv ity(bool bActive) { this->bActive_ = bActive; this->changedActivity(); }67 inline void setActive(bool bActive) { this->bActive_ = bActive; this->changedActivity(); } 64 68 /** @brief Returns the state of the objects activity. @return The state of the activity */ 65 inline constbool isActive() const { return this->bActive_; }69 inline bool isActive() const { return this->bActive_; } 66 70 /** @brief This function gets called if the activity of the object changes. */ 67 71 virtual void changedActivity() {} 68 72 69 73 /** @brief Sets the state of the objects visibility. @param bVisible True = visible */ 70 inline void setVisib ility(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }74 inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); } 71 75 /** @brief Returns the state of the objects visibility. @return The state of the visibility */ 72 inline constbool isVisible() const { return this->bVisible_; }76 inline bool isVisible() const { return this->bVisible_; } 73 77 /** @brief This function gets called if the visibility of the object changes. */ 74 78 virtual void changedVisibility() {} … … 90 94 private: 91 95 std::string name_; //!< The name of the object 96 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 92 97 bool bActive_; //!< True = the object is active 93 98 bool bVisible_; //!< True = the object is visible -
code/branches/input/src/core/CMakeLists.txt
r1543 r1629 53 53 GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION) 54 54 ADD_CUSTOM_COMMAND( 55 OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h55 OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.cc 56 56 COMMAND ${TOLUA_EXE} -n core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg 57 57 DEPENDS tolua … … 65 65 ${OGRE_LIBRARIES} 66 66 cpptcl 67 ois_orxonox 67 68 tinyxml 68 69 tolualib 69 ois70 70 util 71 71 ${Boost_thread_LIBRARIES} -
code/branches/input/src/core/CommandEvaluation.cc
r1543 r1629 78 78 if (this->bEvaluatedParams_ && this->function_) 79 79 { 80 COUT( 4) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;80 COUT(5) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl; 81 81 (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]); 82 82 return true; -
code/branches/input/src/core/ConsoleCommand.h
r1543 r1629 33 33 34 34 #include "Executor.h" 35 #include " ClassManager.h"35 #include "Identifier.h" 36 36 #include "CommandExecutor.h" 37 37 #include "ArgumentCompletionFunctions.h" -
code/branches/input/src/core/Executor.cc
r1505 r1629 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/branches/input/src/core/Iterator.h
r1543 r1629 92 92 { 93 93 this->element_ = element; 94 return *this; 94 95 } 95 96 -
code/branches/input/src/core/Loader.cc
r1505 r1629 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/branches/input/src/core/Script.cc
r1505 r1629 39 39 } 40 40 41 #include "tolua ++.h"41 #include "tolua/tolua++.h" 42 42 #include "tolua/tolua_bind.h" 43 43 -
code/branches/input/src/core/Script.h
r1505 r1629 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/branches/input/src/core/TclThreadManager.h
r1535 r1629 45 45 namespace orxonox 46 46 { 47 class boost::thread;48 49 47 struct _CoreExport TclInterpreterBundle 50 48 { -
code/branches/input/src/core/XMLPort.h
r1505 r1629 152 152 this->parseResult_ = PR_waiting_for_default_values; 153 153 } 154 else 155 this->parseResult_ = PR_waiting_for_default_values; 154 156 } 155 157 catch (ticpp::Exception& ex) -
code/branches/input/src/core/input/InputInterfaces.h
r1535 r1629 37 37 #include "core/CorePrereqs.h" 38 38 39 #include "ois/OIS.h" 39 #include "src/ois/OISKeyboard.h" 40 #include "src/ois/OISMouse.h" 41 #include "src/ois/OISJoyStick.h" 40 42 #include "util/Math.h" 41 43 … … 47 49 enum Enum 48 50 { 49 Unassigned = OIS::KC_UNASSIGNED, 50 Escape = OIS::KC_ESCAPE, 51 NumRow1 = OIS::KC_1, 52 NumRow2 = OIS::KC_2, 53 NumRow3 = OIS::KC_3, 54 NumRow4 = OIS::KC_4, 55 NumRow5 = OIS::KC_5, 56 NumRow6 = OIS::KC_6, 57 NumRow7 = OIS::KC_7, 58 NumRow8 = OIS::KC_8, 59 NumRow9 = OIS::KC_9, 60 NumRow0 = OIS::KC_0, 51 Unassigned = OIS::KC_UNASSIGNED, 52 Escape = OIS::KC_ESCAPE, 53 NumRow1 = OIS::KC_1, 54 NumRow2 = OIS::KC_2, 55 NumRow3 = OIS::KC_3, 56 NumRow4 = OIS::KC_4, 57 NumRow5 = OIS::KC_5, 58 NumRow6 = OIS::KC_6, 59 NumRow7 = OIS::KC_7, 60 NumRow8 = OIS::KC_8, 61 NumRow9 = OIS::KC_9, 62 NumRow0 = OIS::KC_0, 61 63 Minus = OIS::KC_MINUS, // - on main keyboard 62 Equals = OIS::KC_EQUALS, 64 Equals = OIS::KC_EQUALS, 63 65 Back = OIS::KC_BACK, // backspace 64 Tab = OIS::KC_TAB, 65 Q = OIS::KC_Q, 66 W = OIS::KC_W, 67 E = OIS::KC_E, 68 R = OIS::KC_R, 69 T = OIS::KC_T, 70 Y = OIS::KC_Y, 71 U = OIS::KC_U, 72 I = OIS::KC_I, 73 O = OIS::KC_O, 74 P = OIS::KC_P, 75 LeftBracket = OIS::KC_LBRACKET, 76 RightBracket = OIS::KC_RBRACKET, 66 Tab = OIS::KC_TAB, 67 Q = OIS::KC_Q, 68 W = OIS::KC_W, 69 E = OIS::KC_E, 70 R = OIS::KC_R, 71 T = OIS::KC_T, 72 Y = OIS::KC_Y, 73 U = OIS::KC_U, 74 I = OIS::KC_I, 75 O = OIS::KC_O, 76 P = OIS::KC_P, 77 LeftBracket = OIS::KC_LBRACKET, 78 RightBracket = OIS::KC_RBRACKET, 77 79 Return = OIS::KC_RETURN, // Enter on main keyboard 78 LeftControl = OIS::KC_LCONTROL, 79 A = OIS::KC_A, 80 S = OIS::KC_S, 81 D = OIS::KC_D, 82 F = OIS::KC_F, 83 G = OIS::KC_G, 84 H = OIS::KC_H, 85 J = OIS::KC_J, 86 K = OIS::KC_K, 87 L = OIS::KC_L, 88 Semicolon = OIS::KC_SEMICOLON, 89 Apostrophe = OIS::KC_APOSTROPHE, 80 LeftControl = OIS::KC_LCONTROL, 81 A = OIS::KC_A, 82 S = OIS::KC_S, 83 D = OIS::KC_D, 84 F = OIS::KC_F, 85 G = OIS::KC_G, 86 H = OIS::KC_H, 87 J = OIS::KC_J, 88 K = OIS::KC_K, 89 L = OIS::KC_L, 90 Semicolon = OIS::KC_SEMICOLON, 91 Apostrophe = OIS::KC_APOSTROPHE, 90 92 Grave = OIS::KC_GRAVE, // accent 91 LeftShift = OIS::KC_LSHIFT, 92 Backslash = OIS::KC_BACKSLASH, 93 Z = OIS::KC_Z, 94 X = OIS::KC_X, 95 C = OIS::KC_C, 96 V = OIS::KC_V, 97 B = OIS::KC_B, 98 N = OIS::KC_N, 99 M = OIS::KC_M, 100 Comma = OIS::KC_COMMA, 93 LeftShift = OIS::KC_LSHIFT, 94 Backslash = OIS::KC_BACKSLASH, 95 Z = OIS::KC_Z, 96 X = OIS::KC_X, 97 C = OIS::KC_C, 98 V = OIS::KC_V, 99 B = OIS::KC_B, 100 N = OIS::KC_N, 101 M = OIS::KC_M, 102 Comma = OIS::KC_COMMA, 101 103 Period = OIS::KC_PERIOD, // . on main keyboard 102 104 Slash = OIS::KC_SLASH, // / on main keyboard 103 RightShift = OIS::KC_RSHIFT, 105 RightShift = OIS::KC_RSHIFT, 104 106 Multiply = OIS::KC_MULTIPLY, // * on numeric keypad 105 107 LeftAlt = OIS::KC_LMENU, // left Alt 106 Space = OIS::KC_SPACE, 107 CapsLock = OIS::KC_CAPITAL, 108 F1 = OIS::KC_F1, 109 F2 = OIS::KC_F2, 110 F3 = OIS::KC_F3, 111 F4 = OIS::KC_F4, 112 F5 = OIS::KC_F5, 113 F6 = OIS::KC_F6, 114 F7 = OIS::KC_F7, 115 F8 = OIS::KC_F8, 116 F9 = OIS::KC_F9, 117 F10 = OIS::KC_F10, 118 Numlock = OIS::KC_NUMLOCK, 108 Space = OIS::KC_SPACE, 109 CapsLock = OIS::KC_CAPITAL, 110 F1 = OIS::KC_F1, 111 F2 = OIS::KC_F2, 112 F3 = OIS::KC_F3, 113 F4 = OIS::KC_F4, 114 F5 = OIS::KC_F5, 115 F6 = OIS::KC_F6, 116 F7 = OIS::KC_F7, 117 F8 = OIS::KC_F8, 118 F9 = OIS::KC_F9, 119 F10 = OIS::KC_F10, 120 Numlock = OIS::KC_NUMLOCK, 119 121 Scrolllock = OIS::KC_SCROLL, // Scroll Lock 120 Numpad7 = OIS::KC_NUMPAD7, 121 Numpad8 = OIS::KC_NUMPAD8, 122 Numpad9 = OIS::KC_NUMPAD9, 122 Numpad7 = OIS::KC_NUMPAD7, 123 Numpad8 = OIS::KC_NUMPAD8, 124 Numpad9 = OIS::KC_NUMPAD9, 123 125 NumpadSubtract= OIS::KC_SUBTRACT, // - on numeric keypad 124 Numpad4 = OIS::KC_NUMPAD4, 125 Numpad5 = OIS::KC_NUMPAD5, 126 Numpad6 = OIS::KC_NUMPAD6, 126 Numpad4 = OIS::KC_NUMPAD4, 127 Numpad5 = OIS::KC_NUMPAD5, 128 Numpad6 = OIS::KC_NUMPAD6, 127 129 NumpadAdd = OIS::KC_ADD, // + on numeric keypad 128 Numpad1 = OIS::KC_NUMPAD1, 129 Numpad2 = OIS::KC_NUMPAD2, 130 Numpad3 = OIS::KC_NUMPAD3, 131 Numpad0 = OIS::KC_NUMPAD0, 130 Numpad1 = OIS::KC_NUMPAD1, 131 Numpad2 = OIS::KC_NUMPAD2, 132 Numpad3 = OIS::KC_NUMPAD3, 133 Numpad0 = OIS::KC_NUMPAD0, 132 134 NumpadPeriod = OIS::KC_DECIMAL, // . on numeric keypad 133 135 LessThan = OIS::KC_OEM_102, // < > | on UK/Germany keyboards 134 F11 = OIS::KC_F11, 135 F12 = OIS::KC_F12, 136 F11 = OIS::KC_F11, 137 F12 = OIS::KC_F12, 136 138 F13 = OIS::KC_F13, // (NEC PC98) 137 139 F14 = OIS::KC_F14, // (NEC PC98) … … 154 156 NextTrack = OIS::KC_NEXTTRACK, // Next Track 155 157 NumpadEnter = OIS::KC_NUMPADENTER, // Enter on numeric keypad 156 RightControl = OIS::KC_RCONTROL, 158 RightControl = OIS::KC_RCONTROL, 157 159 Mute = OIS::KC_MUTE, // Mute 158 160 Calculator = OIS::KC_CALCULATOR, // Calculator … … 164 166 NumpadComma = OIS::KC_NUMPADCOMMA, // , on numeric keypad (NEC PC98) 165 167 Divide = OIS::KC_DIVIDE, // / on numeric keypad 166 SYSRQ = OIS::KC_SYSRQ, 168 SYSRQ = OIS::KC_SYSRQ, 167 169 RightAlt = OIS::KC_RMENU, // right Alt 168 170 Pause = OIS::KC_PAUSE, // Pause … … 254 256 std::vector<Vector3> mVectors; 255 257 };*/ 256 258 257 259 /** 258 260 * Helper struct to determine which handlers of an object (can implement -
code/branches/input/src/core/input/InputManager.cc
r1537 r1629 36 36 37 37 #include <limits.h> 38 38 39 #include "core/CoreIncludes.h" 39 40 #include "core/ConfigValueIncludes.h" … … 42 43 #include "core/ConsoleCommand.h" 43 44 #include "core/Shell.h" // hack! 45 44 46 #include "InputBuffer.h" 45 47 #include "KeyBinder.h" 46 48 #include "KeyDetector.h" 47 49 #include "CalibratorCallback.h" 50 51 #include "src/ois/OISException.h" 52 #include "src/ois/OISInputManager.h" 48 53 49 54 namespace orxonox … … 650 655 activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second); 651 656 } 652 657 653 658 void InputManager::_completeCalibration() 654 659 { -
code/branches/input/src/core/input/InputManager.h
r1535 r1629 41 41 #include <vector> 42 42 43 #include "ois/OIS.h"44 43 #include "util/Math.h" 45 44 #include "core/OrxonoxClass.h" -
code/branches/input/src/core/input/KeyBinder.cc
r1543 r1629 234 234 void KeyBinder::setConfigValues() 235 235 { 236 SetConfigValueGeneric(KeyBinder, analogThreshold_, 0.0 1f) .description("Threshold for analog axes until which the state is 0.");236 SetConfigValueGeneric(KeyBinder, analogThreshold_, 0.05f) .description("Threshold for analog axes until which the state is 0."); 237 237 SetConfigValueGeneric(KeyBinder, mouseSensitivity_, 1.0f) .description("Mouse sensitivity."); 238 238 SetConfigValueGeneric(KeyBinder, bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value."); 239 SetConfigValueGeneric(KeyBinder, derivePeriod_, 0. 5f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");239 SetConfigValueGeneric(KeyBinder, derivePeriod_, 0.05f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier."); 240 240 SetConfigValueGeneric(KeyBinder, mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived."); 241 241 SetConfigValueGeneric(KeyBinder, bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode."); -
code/branches/input/src/network/GameStateClient.cc
r1534 r1629 34 34 #include "core/BaseObject.h" 35 35 #include "Synchronisable.h" 36 #include "objects/SpaceShip.h" 36 37 37 38 -
code/branches/input/src/network/GameStateClient.h
r1505 r1629 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/branches/input/src/network/Server.cc
r1534 r1629 181 181 timeSinceLastUpdate_+=time; 182 182 if(timeSinceLastUpdate_>=(1./NETWORK_FREQUENCY)){ 183 timeSinceLastUpdate_-=(1./NETWORK_FREQUENCY); 183 timeSinceLastUpdate_=(float)((int)(timeSinceLastUpdate_*NETWORK_FREQUENCY))/timeSinceLastUpdate_; 184 // timeSinceLastUpdate_-=1./NETWORK_FREQUENCY; 184 185 gamestates->processGameStates(); 185 186 updateGamestate(); 186 187 } 188 /*while(timeSinceLastUpdate_>1./NETWORK_FREQUENCY) 189 timeSinceLastUpdate_-=1./NETWORK_FREQUENCY;*/ 187 190 // usleep(5000); // TODO remove 188 191 return; … … 217 220 COUT(3) << "Server: could not elaborate" << std::endl; 218 221 } 222 break; 223 default: 219 224 break; 220 225 } -
code/branches/input/src/ois/CMakeLists.txt
r1505 r1629 1 INCLUDE_DIRECTORIES(.) 2 1 3 SET( OIS_SRC_FILES 2 4 OISEffect.cpp … … 36 38 ENDIF (WIN32) 37 39 38 ADD_LIBRARY( ois SHARED ${OIS_SRC_FILES} )40 ADD_LIBRARY( ois_orxonox SHARED ${OIS_SRC_FILES} ) 39 41 40 42 IF(WIN32) 41 43 LINK_DIRECTORIES(${DirectX_LIB_DIR}) 42 TARGET_LINK_LIBRARIES( ois 44 TARGET_LINK_LIBRARIES( ois_orxonox 43 45 dxguid 44 46 dinput8 -
code/branches/input/src/orxonox/CMakeLists.txt
r1535 r1629 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 13 particle/ParticleInterface.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 14 24 tolua/tolua_bind.cc 15 25 … … 17 27 tools/Light.cc 18 28 tools/Mesh.cc 29 tools/ParticleInterface.cc 30 tools/TextureGenerator.cc 19 31 tools/Timer.cc 32 tools/WindowEventListener.cc 20 33 21 34 objects/Ambient.cc 35 objects/Backlight.cc 22 36 objects/Camera.cc 23 37 objects/CameraHandler.cc 24 objects/Explosion.cc25 38 objects/Model.cc 26 39 objects/NPC.cc 27 objects/Projectile.cc 28 objects/RotatingProjectile.cc 40 objects/ParticleSpawner.cc 29 41 objects/Skybox.cc 30 42 objects/SpaceShip.cc … … 33 45 objects/WorldEntity.cc 34 46 35 # objects/weapon/AmmunitionDump.cc 36 # objects/weapon/BarrelGun.cc 37 # objects/weapon/BaseWeapon.cc 38 # objects/weapon/Bullet.cc 39 # objects/weapon/BulletManager.cc 40 # objects/weapon/WeaponStation.cc 47 objects/Projectile.cc 48 objects/BillboardProjectile.cc 49 objects/RotatingProjectile.cc 50 objects/ParticleProjectile.cc 41 51 ) 42 52 43 53 GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION) 44 54 ADD_CUSTOM_COMMAND( 45 OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h55 OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.cc 46 56 COMMAND ${TOLUA_EXE} -n orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg 47 57 DEPENDS tolua … … 75 85 tinyxml 76 86 tolualib 77 ois 87 ois_orxonox 78 88 util 79 89 core -
code/branches/input/src/orxonox/GraphicsEngine.cc
r1538 r1629 50 50 #include "core/CommandExecutor.h" 51 51 #include "core/ConsoleCommand.h" 52 #include "core/input/InputManager.h" 53 54 #include "console/InGameConsole.h" 52 53 #include "overlays/console/InGameConsole.h" 54 #include "overlays/OverlayGroup.h" 55 #include "tools/ParticleInterface.h" 55 56 #include "Settings.h" 56 57 58 namespace orxonox { 57 #include "tools/WindowEventListener.h" 58 59 60 namespace orxonox 61 { 59 62 /** 60 63 @brief Returns the singleton instance and creates it the first time. … … 76 79 { 77 80 RegisterObject(GraphicsEngine); 81 82 this->detailLevelParticle_ = 0; 78 83 79 84 this->setConfigValues(); … … 91 96 SetConfigValue(ogreLogLevelNormal_ , 4).description("Corresponding orxonox debug level for ogre Normal"); 92 97 SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical"); 98 99 unsigned int old = this->detailLevelParticle_; 100 SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high"); 101 102 if (this->detailLevelParticle_ != old) 103 for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it) 104 it->detailLevelChanged(this->detailLevelParticle_); 93 105 } 94 106 … … 424 436 425 437 /** 426 * Window has resized.438 * Window has moved. 427 439 * @param rw The render window it occured in 428 440 */ 429 441 void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw) 430 442 { 431 // note: this doesn't change the window extents 443 for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it) 444 it->windowMoved(); 432 445 } 433 446 … … 440 453 void GraphicsEngine::windowResized(Ogre::RenderWindow *rw) 441 454 { 442 // change the mouse clipping size for absolute mouse movements 443 int w = rw->getWidth(); 444 int h = rw->getHeight(); 445 InputManager::setWindowExtents(w, h); 446 InGameConsole::getInstance().resize(); 447 } 448 449 /** 450 * 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. 451 461 * @param rw The render window it occured in 452 462 */ 453 463 void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw) 454 464 { 455 // note: this doesn't change the window extents 456 } 457 458 /** 459 * 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. 460 471 * @param rw The render window it occured in 461 472 */ 462 473 void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw) 463 474 { 464 // using CommandExecutor in order to avoid depending on Orxonox class.475 // using CommandExecutor in order to avoid depending on Orxonox.h. 465 476 CommandExecutor::execute("exit", false); 466 477 } -
code/branches/input/src/orxonox/GraphicsEngine.h
r1535 r1629 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); … … 79 84 void windowFocusChanged(Ogre::RenderWindow* rw); 80 85 void windowClosed (Ogre::RenderWindow* rw); 86 87 inline unsigned int getDetailLevelParticle() const 88 { return this->detailLevelParticle_; } 81 89 82 90 static GraphicsEngine& getSingleton(); … … 94 102 bool, const std::string&); 95 103 96 Ogre::Root* root_; //!< Ogre's root 97 Ogre::SceneManager* scene_; //!< scene manager of the game 98 Ogre::RenderWindow* renderWindow_; //!< the current render window 99 std::string resourceFile_; //!< resources file name 100 std::string ogreConfigFile_; //!< ogre config file name 101 std::string ogrePluginsFile_; //!< ogre plugins file name 102 std::string ogreLogFile_; //!< log file name for Ogre log messages 103 int ogreLogLevelTrivial_; //!< Corresponding Orxonx debug level for LL_TRIVIAL 104 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 105 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 104 Ogre::Root* root_; //!< Ogre's root 105 Ogre::SceneManager* scene_; //!< scene manager of the game 106 Ogre::RenderWindow* renderWindow_; //!< the current render window 107 std::string resourceFile_; //!< resources file name 108 std::string ogreConfigFile_; //!< ogre config file name 109 std::string ogrePluginsFile_; //!< ogre plugins file name 110 std::string ogreLogFile_; //!< log file name for Ogre log messages 111 int ogreLogLevelTrivial_; //!< Corresponding Orxonx debug level for LL_TRIVIAL 112 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 113 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 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 106 117 }; 107 118 } -
code/branches/input/src/orxonox/Orxonox.cc
r1535 r1629 69 69 70 70 // objects and tools 71 #include "hud/HUD.h" 71 #include "overlays/OverlayGroup.h" 72 #include "overlays/console/InGameConsole.h" 72 73 #include "objects/Tickable.h" 74 #include "objects/Backlight.h" 75 #include "tools/ParticleInterface.h" 73 76 74 77 #include "GraphicsEngine.h" 75 78 #include "Settings.h" 76 77 // FIXME: is this really file scope? 79 #include "Radar.h" 80 78 81 // globals for the server or client 79 network::Client *client_g = 0;80 network::Server *server_g = 0;82 static network::Client *client_g = 0; 83 static network::Server *server_g = 0; 81 84 82 85 namespace orxonox … … 94 97 * Create a new instance of Orxonox. Avoid doing any actual work here. 95 98 */ 96 Orxonox::Orxonox() :97 ogre_(0),98 //auMan_(0),99 timer_(0),100 // turn on frame smoothing by setting a value different from 0101 frameSmoothingTime_(0.0f),102 orxonoxHUD_(0),103 bAbort_(false),104 timefactor_(1.0f),105 mode_(STANDALONE),106 serverIp_(""),107 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) 108 111 { 109 112 } … … 115 118 { 116 119 // keep in mind: the order of deletion is very important! 117 // if (this->orxonoxHUD_) 118 // delete this->orxonoxHUD_; 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 119 131 Loader::close(); 120 InputManager::destroy();121 132 //if (this->auMan_) 122 133 // delete this->auMan_; 134 InGameConsole::getInstance().destroy(); 123 135 if (this->timer_) 124 136 delete this->timer_; 137 InputManager::destroy(); 125 138 GraphicsEngine::getSingleton().destroy(); 126 139 … … 159 172 delete singletonRef_s; 160 173 singletonRef_s = 0; 174 } 175 176 /** 177 @brief Changes the speed of Orxonox 178 */ 179 void Orxonox::setTimeFactor(float factor) 180 { 181 float change = factor / Orxonox::getSingleton()->getTimeFactor(); 182 Orxonox::getSingleton()->timefactor_ = factor; 183 for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it) 184 it->setSpeedFactor(it->getSpeedFactor() * change); 185 186 for (Iterator<Backlight> it = ObjectList<Backlight>::begin(); it; ++it) 187 it->setTimeFactor(Orxonox::getSingleton()->getTimeFactor()); 161 188 } 162 189 … … 251 278 return false; 252 279 280 // TODO: Spread this so that this call only initialises things needed for the Console 281 if (!ogre_->initialiseResources()) 282 return false; 283 284 // Load the InGameConsole 285 InGameConsole::getInstance().initialise(); 286 253 287 // Calls the InputManager which sets up the input devices. 254 288 // The render window width and height are used to set up the mouse movement. … … 257 291 return false; 258 292 259 // TODO: Spread this so that this call only initialises things needed for the GUI260 if (!ogre_->initialiseResources())261 return false;262 263 293 // TOOD: load the GUI here 264 294 // set InputManager to GUI mode … … 303 333 /** 304 334 * Loads everything in the scene except for the actual objects. 305 * This includes HUD, Console..335 * This includes HUD, audio.. 306 336 */ 307 337 bool Orxonox::loadPlayground() … … 316 346 317 347 // Load the HUD 318 COUT(3) << "Orxonox: Loading HUD..." << std::endl; 319 orxonoxHUD_ = &HUD::getSingleton(); 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(); 354 320 355 return true; 321 356 } … … 326 361 bool Orxonox::serverLoad() 327 362 { 328 COUT( 2) << "Loading level in server mode" << std::endl;363 COUT(0) << "Loading level in server mode" << std::endl; 329 364 330 365 //server_g = new network::Server(serverPort_); … … 344 379 bool Orxonox::clientLoad() 345 380 { 346 COUT( 2) << "Loading level in client mode" << std::endl;\381 COUT(0) << "Loading level in client mode" << std::endl;\ 347 382 348 383 if (serverIp_.compare("") == 0) … … 364 399 bool Orxonox::standaloneLoad() 365 400 { 366 COUT( 2) << "Loading level in standalone mode" << std::endl;401 COUT(0) << "Loading level in standalone mode" << std::endl; 367 402 368 403 if (!loadScene()) … … 377 412 bool Orxonox::loadScene() 378 413 { 379 Level* startlevel= new Level("levels/sample.oxw");380 Loader::open(start level);381 414 startLevel_ = new Level("levels/sample.oxw"); 415 Loader::open(startLevel_); 416 382 417 return true; 383 418 } … … 403 438 404 439 405 // Contains the times of recently fired events406 // eventTimes[4] is the list for the times required for the fps counter407 std::deque<unsigned long> eventTimes[3];408 // Clear event times409 for (int i = 0; i < 3; ++i)410 eventTimes[i].clear();411 412 440 // use the ogre timer class to measure time. 413 441 if (!timer_) 414 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 415 458 timer_->reset(); 416 417 float renderTime = 0.0f;418 float frameTime = 0.0f;419 clock_t time = 0;420 421 //Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager();422 //Ogre::Viewport* mViewport = mSceneMgr->getCurrentViewport();423 424 //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "Bloom");425 //Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "MotionBlur");426 427 COUT(3) << "Orxonox: Starting the main loop." << std::endl;428 459 while (!bAbort_) 429 460 { 430 461 // get current time 431 unsigned long now = timer_->getMilliseconds(); 432 433 // create an event to pass to the frameStarted method in ogre 434 Ogre::FrameEvent evt; 435 evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]); 436 evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]); 437 frameTime += evt.timeSinceLastFrame; 438 439 // show the current time in the HUD 440 // HUD::getSingleton().setTime(now); 441 if (mode_ != DEDICATED && frameTime > 0.4f) 442 { 443 HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime); 444 frameTime = 0.0f; 445 renderTime = 0.0f; 446 } 447 448 // tick the core 449 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 450 470 // Call those objects that need the real time 451 471 for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it) 452 it->tick( (float)evt.timeSinceLastFrame);472 it->tick(dt); 453 473 // Call the scene objects 454 474 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 455 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 456 //AudioManager::tick(); 475 it->tick(dt * this->timefactor_); 476 477 // call server/client with normal dt 457 478 if (client_g) 458 client_g->tick( (float)evt.timeSinceLastFrame);479 client_g->tick(dt * this->timefactor_); 459 480 if (server_g) 460 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 461 499 462 500 // don't forget to call _fireFrameStarted in ogre to make sure 463 501 // everything goes smoothly 502 Ogre::FrameEvent evt; 503 evt.timeSinceLastFrame = dt; 504 evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway 464 505 ogreRoot._fireFrameStarted(evt); 465 466 // get current time467 now = timer_->getMilliseconds();468 calculateEventTime(now, eventTimes[2]);469 506 470 507 if (mode_ != DEDICATED) … … 473 510 // This calls the WindowEventListener objects. 474 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); 475 515 476 516 // render … … 478 518 } 479 519 480 // get current time481 now = timer_->getMilliseconds();482 483 // create an event to pass to the frameEnded method in ogre484 evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);485 renderTime += calculateEventTime(now, eventTimes[2]);486 487 520 // again, just to be sure ogre works fine 488 ogreRoot._fireFrameEnded(evt); 489 //msleep(200); 521 ogreRoot._fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted 522 523 ++frameCount; 490 524 } 491 525 … … 497 531 return true; 498 532 } 499 500 /**501 Method for calculating the average time between recently fired events.502 Code directly taken from OgreRoot.cc503 @param now The current time in ms.504 @param type The type of event to be considered.505 */506 float Orxonox::calculateEventTime(unsigned long now, std::deque<unsigned long> ×)507 {508 // Calculate the average time passed between events of the given type509 // during the last frameSmoothingTime_ seconds.510 511 times.push_back(now);512 513 if(times.size() == 1)514 return 0;515 516 // Times up to frameSmoothingTime_ seconds old should be kept517 unsigned long discardThreshold = (unsigned long)(frameSmoothingTime_ * 1000.0f);518 519 // Find the oldest time to keep520 std::deque<unsigned long>::iterator it = times.begin();521 // We need at least two times522 std::deque<unsigned long>::iterator end = times.end() - 2;523 524 while(it != end)525 {526 if (now - *it > discardThreshold)527 ++it;528 else529 break;530 }531 532 // Remove old times533 times.erase(times.begin(), it);534 535 return (float)(times.back() - times.front()) / ((times.size() - 1) * 1000);536 }537 533 } -
code/branches/input/src/orxonox/Orxonox.h
r1535 r1629 62 62 63 63 void abortRequest(); 64 //inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };65 64 66 65 static Orxonox* getSingleton(); 67 66 static void destroySingleton(); 68 67 69 static inline void slomo(float factor) { Orxonox:: getSingleton()->timefactor_ = factor; }70 static inline void setTimeFactor(float factor = 1.0) { Orxonox::getSingleton()->timefactor_ = factor; }68 static inline void slomo(float factor) { Orxonox::setTimeFactor(factor); } 69 static void setTimeFactor(float factor = 1.0); 71 70 static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; } 72 71 static inline void exit() { Orxonox::getSingleton()->abortRequest(); } … … 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/branches/input/src/orxonox/OrxonoxPrereqs.h
r1505 r1629 60 60 //----------------------------------------------------------------------- 61 61 62 namespace orxonox { 63 class GraphicsEngine; 64 class Orxonox; 62 namespace orxonox 63 { 64 namespace LODParticle 65 { 66 enum LOD 67 { 68 off = 0, 69 low = 1, 70 normal = 2, 71 high = 3 72 }; 73 } 65 74 66 // objects 67 class Ambient; 68 class Camera; 69 class Explosion; 70 class Fighter; 71 class Model; 72 class NPC; 73 class Projectile; 74 class Skybox; 75 class SpaceShip; 76 class SpaceShipAI; 77 class WorldEntity; 75 class GraphicsEngine; 76 class Orxonox; 78 77 79 class AmmunitionDump; 80 class Bullet; 81 class BulletManager; 82 class BaseWeapon; 83 class BarrelGun; 84 class WeaponStation; 78 class RadarViewable; 79 class Radar; 80 class RadarListener; 85 81 86 // tools 87 class BillboardSet; 88 class Light; 89 class Mesh; 90 template <class T> 91 class Timer; 92 class TimerBase; 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; 93 94 94 // particle 95 class ParticleInterface; 95 class Projectile; 96 class BillboardProjectile; 97 class RotatingProjectile; 98 class ParticleProjectile; 96 99 97 // hud 98 class BarOverlayElement; 99 class HUD; 100 class Navigation; 101 class RadarObject; 102 class RadarOverlayElement; 100 // tools 101 class BillboardSet; 102 class Light; 103 class Mesh; 104 class ParticleInterface; 105 template <class T> 106 class Timer; 103 107 104 //console 105 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; 106 120 } 107 121 122 namespace Ogre 123 { 124 // some got forgotten in OgrePrerequisites 125 class BorderPanelOverlayElement; 126 class PanelOverlayElement; 127 class TextAreaOverlayElement; 128 } 108 129 109 130 #endif /* _OrxonoxPrereqs_H__ */ -
code/branches/input/src/orxonox/OrxonoxStableHeaders.h
r1543 r1629 37 37 #include "util/OrxonoxPlatform.h" 38 38 39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC 39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && 0 40 40 41 41 // including std headers here is useless since they're already precompiled … … 112 112 #include "network/Synchronisable.h" 113 113 114 #include "tools/Mesh.h"115 #include "tools/Timer.h"116 #include "objects/Model.h"117 #include "objects/Tickable.h"118 #include "objects/WorldEntity.h"114 //#include "tools/Mesh.h" 115 //#include "tools/Timer.h" 116 //#include "objects/Model.h" 117 //#include "objects/Tickable.h" 118 //#include "objects/WorldEntity.h" 119 119 120 120 #endif /* Compiler MSVC */ -
code/branches/input/src/orxonox/objects/Ambient.cc
r1505 r1629 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/branches/input/src/orxonox/objects/Ambient.h
r1505 r1629 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/branches/input/src/orxonox/objects/Model.cc
r1511 r1629 53 53 Model::~Model() 54 54 { 55 if (this->isInitialized() && (this->meshSrc_ != "") && (this->meshSrc_.size() > 0)) 56 this->detachObject(this->mesh_.getEntity()); 55 57 } 56 58 57 59 /** 58 60 @brief XML loading and saving. 59 @p 60 aram xmlelement The XML-element 61 @param xmlelement The XML-element 61 62 @param loading Loading (true) or saving (false) 62 63 @return The XML-element … … 94 95 registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING); 95 96 } 97 98 void Model::changedVisibility() 99 { 100 WorldEntity::changedVisibility(); 101 if (this->isInitialized()) 102 this->mesh_.setVisible(this->isVisible()); 103 } 96 104 } -
code/branches/input/src/orxonox/objects/Model.h
r1505 r1629 44 44 virtual ~Model(); 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 virtual void changedVisibility(); 46 47 void setMesh(const std::string& meshname); 47 48 virtual bool create(); -
code/branches/input/src/orxonox/objects/NPC.cc
r1505 r1629 45 45 NPC::~NPC() 46 46 { 47 }48 49 void NPC::loadParams(TiXmlElement* xmlElem)50 {51 Model::loadParams(xmlElem);52 47 } 53 48 -
code/branches/input/src/orxonox/objects/NPC.h
r1505 r1629 48 48 NPC(); 49 49 virtual ~NPC(); 50 virtual void loadParams(TiXmlElement* xmlElem);51 50 void tick(float dt); 52 51 void update(); -
code/branches/input/src/orxonox/objects/Projectile.cc
r1505 r1629 35 35 #include "core/Executor.h" 36 36 #include "core/ConfigValueIncludes.h" 37 #include "tools/ParticleInterface.h" 37 38 38 #include "SpaceShip .h"39 #include " Explosion.h"39 #include "SpaceShipAI.h" 40 #include "ParticleSpawner.h" 40 41 #include "Model.h" 41 42 42 43 namespace orxonox 43 44 { 44 CreateFactory(Projectile);45 float Projectile::speed_ = 5000; 45 46 46 float Projectile::speed_ = 0; 47 48 Projectile::Projectile(SpaceShip* owner) : 49 owner_(owner) 47 Projectile::Projectile(SpaceShip* owner) : owner_(owner) 50 48 { 51 49 RegisterObject(Projectile); 52 50 53 51 this->setConfigValues(); 54 55 this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 56 this->attachObject(this->billboard_.getBillboardSet()); 57 this->scale(0.5); 52 this->explosionTemplateName_ = "Orxonox/explosion3"; 53 this->smokeTemplateName_ = "Orxonox/smoke4"; 58 54 59 55 if (this->owner_) … … 63 59 this->setPosition(this->owner_->getPosition()); 64 60 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 65 this->setVelocity( Vector3(1, 0, 0) * this->speed_);61 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 66 62 } 67 63 68 64 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject))); 69 // COUT(3) << this->classID << std::endl;70 65 } 71 66 … … 76 71 void Projectile::setConfigValues() 77 72 { 78 SetConfigValue(lifetime_, 10.0).description("The time in seconds a projectile stays alive"); 79 SetConfigValue(speed_, 2000.0).description("The speed of a projectile in units per second"); 73 SetConfigValue(damage_, 15.0).description("The damage caused by the projectile"); 74 SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive"); 75 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second"); 80 76 81 this->setVelocity(Vector3(1, 0, 0) * this->speed_); 77 if(this->owner_) 78 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 82 79 } 83 80 … … 85 82 { 86 83 WorldEntity::tick(dt); 84 85 if (!this->isActive()) 86 return; 87 87 88 88 float radius; … … 95 95 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius)) 96 96 { 97 Explosion *exp = new Explosion(this); 98 exp->create(); 97 // hit 98 if (it->isA(Class(SpaceShipAI))) 99 ((SpaceShipAI*)(*it))->damage(this->damage_); 100 ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0); 101 explosion->setPosition(this->getPosition()); 102 explosion->create(); 103 ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0); 104 smoke->setPosition(this->getPosition()); 105 // smoke->getParticleInterface()->setSpeedFactor(3.0); 106 smoke->create(); 99 107 delete this; 100 108 return; … … 108 116 delete this; 109 117 } 110 111 void Projectile::setColour(const ColourValue& colour)112 {113 this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);114 }115 118 } -
code/branches/input/src/orxonox/objects/Projectile.h
r1505 r1629 33 33 34 34 #include "WorldEntity.h" 35 #include "../tools/BillboardSet.h" 36 #include "../tools/Timer.h" 37 #include "util/Math.h" 35 #include "tools/Timer.h" 38 36 39 37 namespace orxonox … … 42 40 { 43 41 public: 44 Projectile(SpaceShip* owner = 0);45 42 virtual ~Projectile(); 46 43 void setConfigValues(); 47 44 void destroyObject(); 48 45 virtual void tick(float dt); 49 virtual bool create(){return WorldEntity::create();}50 void setColour(const ColourValue& colour);51 46 52 47 static float getSpeed() … … 54 49 55 50 protected: 51 Projectile(SpaceShip* owner = 0); 56 52 SpaceShip* owner_; 57 53 58 54 private: 59 BillboardSet billboard_; 55 std::string explosionTemplateName_; 56 std::string smokeTemplateName_; 60 57 static float speed_; 61 58 float lifetime_; 59 float damage_; 62 60 Timer<Projectile> destroyTimer_; 63 61 }; -
code/branches/input/src/orxonox/objects/RotatingProjectile.cc
r1505 r1629 37 37 CreateFactory(RotatingProjectile); 38 38 39 RotatingProjectile::RotatingProjectile(SpaceShip* owner) : Projectile(owner)39 RotatingProjectile::RotatingProjectile(SpaceShip* owner) : BillboardProjectile(owner) 40 40 { 41 41 RegisterObject(RotatingProjectile); … … 73 73 void RotatingProjectile::tick(float dt) 74 74 { 75 this->time_ += dt; 75 if (this->isActive()) 76 { 77 this->time_ += dt; 76 78 77 this->rotatingNode1_->setPosition(0, 50 * sin(this->time_ * 20), 50 * cos(this->time_ * 20)); 78 this->rotatingNode2_->setPosition(0, -50 * sin(this->time_ * 20), -50 * cos(this->time_ * 20)); 79 this->rotatingNode1_->setPosition(0, 50 * sin(this->time_ * 20), 50 * cos(this->time_ * 20)); 80 this->rotatingNode2_->setPosition(0, -50 * sin(this->time_ * 20), -50 * cos(this->time_ * 20)); 81 } 79 82 80 83 Projectile::tick(dt); 81 84 } 85 86 void RotatingProjectile::changedVisibility() 87 { 88 BillboardProjectile::changedVisibility(); 89 this->rotatingBillboard1_.setVisible(this->isVisible()); 90 this->rotatingBillboard2_.setVisible(this->isVisible()); 91 } 82 92 } -
code/branches/input/src/orxonox/objects/RotatingProjectile.h
r1505 r1629 2 2 #define _RotatingProjectile_H__ 3 3 4 #include " ../OrxonoxPrereqs.h"4 #include "OrxonoxPrereqs.h" 5 5 #include "util/Math.h" 6 #include " Projectile.h"6 #include "BillboardProjectile.h" 7 7 8 8 namespace orxonox 9 9 { 10 class _OrxonoxExport RotatingProjectile : public Projectile/*, public network::Synchronisable*/10 class _OrxonoxExport RotatingProjectile : public BillboardProjectile 11 11 { 12 12 public: … … 15 15 void setConfigValues(); 16 16 virtual void tick(float dt); 17 virtual bool create(){return Projectile::create();}17 virtual void changedVisibility(); 18 18 19 19 private: -
code/branches/input/src/orxonox/objects/Skybox.cc
r1505 r1629 54 54 } 55 55 56 void Skybox:: loadParams(TiXmlElement* xmlElem)56 void Skybox::setSkybox(const std::string& skyboxname) 57 57 { 58 if (xmlElem->Attribute("src")) 59 { 60 skyboxSrc_ = xmlElem->Attribute("src"); 61 this->create(); 58 GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname); 59 } 62 60 63 COUT(4) << "Loader: Set skybox: "<< skyboxSrc_ << std::endl << std::endl; 64 } 65 } 61 void Skybox::setSkyboxSrc(const std::string& src) 62 { 63 this->skyboxSrc_ = src; 64 } 66 65 67 void Skybox::setSkybox(const std::string& skyboxname)68 {69 GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname);70 }71 72 void Skybox::setSkyboxSrc(const std::string& src){73 skyboxSrc_ = src;74 }75 76 66 /** 77 67 @brief XML loading and saving. … … 87 77 create(); 88 78 } 89 90 bool Skybox::create(){ 91 this->setSkybox(skyboxSrc_); 92 return Synchronisable::create(); 79 80 bool Skybox::create() 81 { 82 this->setSkybox(this->skyboxSrc_); 83 return Synchronisable::create(); 93 84 } 94 95 void Skybox::registerAllVariables(){ 96 registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING); 85 86 void Skybox::registerAllVariables() 87 { 88 registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING); 97 89 } 98 90 91 void Skybox::changedVisibility() 92 { 93 BaseObject::changedVisibility(); 94 GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_); 95 } 99 96 } -
code/branches/input/src/orxonox/objects/Skybox.h
r1505 r1629 43 43 virtual ~Skybox(); 44 44 45 void loadParams(TiXmlElement* xmlElem);46 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 virtual void changedVisibility(); 47 47 void setSkybox(const std::string& skyboxname); 48 48 49 49 virtual bool create(); 50 50 void registerAllVariables(); -
code/branches/input/src/orxonox/objects/SpaceShip.cc
r1535 r1629 35 35 #include <OgreSceneNode.h> 36 36 37 #include "CameraHandler.h"38 37 #include "util/Convert.h" 39 38 #include "util/Math.h" 39 40 40 #include "core/CoreIncludes.h" 41 41 #include "core/ConfigValueIncludes.h" 42 42 #include "core/Debug.h" 43 #include "GraphicsEngine.h"44 #include "core/input/InputManager.h"45 #include "particle/ParticleInterface.h"46 #include "Projectile.h"47 #include "RotatingProjectile.h"48 43 #include "core/XMLPort.h" 49 44 #include "core/ConsoleCommand.h" 45 50 46 #include "network/Client.h" 51 #include "hud/HUD.h" 47 48 #include "tools/ParticleInterface.h" 49 50 #include "GraphicsEngine.h" 51 #include "RotatingProjectile.h" 52 #include "ParticleProjectile.h" 53 #include "ParticleSpawner.h" 54 #include "Backlight.h" 55 #include "CameraHandler.h" 52 56 53 57 namespace orxonox … … 69 73 SpaceShip* SpaceShip::instance_s; 70 74 71 75 72 76 SpaceShip *SpaceShip::getLocalShip(){ 73 77 Iterator<SpaceShip> it; … … 79 83 } 80 84 81 SpaceShip::SpaceShip() : 82 //testvector_(0,0,0), 83 //bInvertYAxis_(false), 84 setMouseEventCallback_(false), 85 bLMousePressed_(false), 86 bRMousePressed_(false), 87 camNode_(0), 88 cam_(0), 89 camName_("CamNode"), 90 tt_(0), 91 redNode_(0), 92 greenNode_(0), 93 blinkTime_(0.0f), 94 chNearNode_(0), 95 chFarNode_(0), 96 timeToReload_(0.0f), 97 //reloadTime_(0.0f), 98 maxSideAndBackSpeed_(0.0f), 99 maxSpeed_(0.0f), 100 maxRotation_(0.0f), 101 translationAcceleration_(0.0f), 102 rotationAcceleration_(0.0f), 103 translationDamping_(0.0f), 104 rotationDamping_(0.0f), 105 maxRotationRadian_(0), 106 rotationAccelerationRadian_(0), 107 rotationDampingRadian_(0), 108 zeroRadian_(0), 109 mouseXRotation_(0), 110 mouseYRotation_(0), 111 mouseX_(0.0f), 112 mouseY_(0.0f), 113 emitterRate_(0.0f), 114 myShip_(false), 115 teamNr_(0), 116 health_(100) 85 SpaceShip::SpaceShip() 117 86 { 118 87 RegisterObject(SpaceShip); 119 this->registerAllVariables();120 121 SpaceShip::instance_s = this;122 123 this->setConfigValues();124 125 initialDir_ = Vector3(1.0, 0.0, 0.0);126 currentDir_ = initialDir_;127 initialOrth_ = Vector3(0.0, 0.0, 1.0);128 currentOrth_ = initialOrth_;129 130 this->camName_ = this->getName() + "CamNode";131 88 132 89 this->setRotationAxis(1, 0, 0); 133 90 this->setStatic(false); 134 91 135 COUT(3) << "Info: SpaceShip was loaded" << std::endl; 92 this->zeroRadian_ = 0; 93 this->maxSideAndBackSpeed_ = 0; 94 this->maxSpeed_ = 0; 95 this->maxRotation_ = 0; 96 this->translationAcceleration_ = 0; 97 this->rotationAcceleration_ = 0; 98 this->translationDamping_ = 0; 99 this->rotationDamping_ = 0; 100 this->maxRotationRadian_ = 0; 101 this->rotationAccelerationRadian_ = 0; 102 this->rotationDampingRadian_ = 0; 103 104 this->cam_ = 0; 105 this->tt1_ = 0; 106 this->tt2_ = 0; 107 this->smoke_ = 0; 108 this->fire_ = 0; 109 110 this->backlight_ = 0; 111 112 this->redNode_ = 0; 113 this->greenNode_ = 0; 114 this->blinkTime_ = 0; 115 116 this->timeToReload_ = 0; 117 118 this->bLMousePressed_ = false; 119 this->bRMousePressed_ = false; 120 this->mouseXRotation_ = 0; 121 this->mouseYRotation_ = 0; 122 this->myShip_ = false; 123 124 this->registerAllVariables(); 125 126 SpaceShip::instance_s = this; 127 128 this->setConfigValues(); 129 130 this->initialDir_ = Vector3(1.0, 0.0, 0.0); 131 this->currentDir_ = initialDir_; 132 this->initialOrth_ = Vector3(0.0, 0.0, 1.0); 133 this->currentOrth_ = initialOrth_; 134 135 this->camName_ = this->getName() + "CamNode"; 136 137 this->teamNr_ = 0; 138 this->health_ = 100; 139 140 this->radarObject_ = static_cast<WorldEntity*>(this); 136 141 } 137 142 138 143 SpaceShip::~SpaceShip() 139 144 { 140 if (this->tt_) 141 delete this->tt_; 142 if(setMouseEventCallback_) 143 InputManager::removeMouseHandler("SpaceShip"); 144 if (this->cam_) 145 delete this->cam_; 146 if (!Identifier::isCreatingHierarchy() && !myShip_ && &HUD::getSingleton()!=NULL) 147 //remove the radar object 148 HUD::getSingleton().removeRadarObject(this->getNode()); 145 if (this->isInitialized()) 146 { 147 if (this->tt1_) 148 delete this->tt1_; 149 if (this->tt2_) 150 delete this->tt2_; 151 152 if (this->smoke_) 153 this->smoke_->destroy(); 154 if (this->fire_) 155 this->fire_->destroy(); 156 157 if (this->backlight_) 158 delete this->backlight_; 159 160 if (this->cam_) 161 delete this->cam_; 162 } 149 163 } 150 164 … … 154 168 myShip_=true; 155 169 else 156 HUD::getSingleton().addRadarObject(this->getNode(), 3);170 this->setRadarObjectColour(this->getProjectileColour()); 157 171 } 158 172 if(Model::create()) … … 179 193 void SpaceShip::init() 180 194 { 181 // START CREATING THRUSTER 182 this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); 183 this->tt_->getParticleSystem()->setParameter("local_space","true"); 184 this->tt_->newEmitter(); 185 /* 186 this->tt_->setDirection(Vector3(0,0,1)); 187 this->tt_->setPositionOfEmitter(0, Vector3(20,-1,-15)); 188 this->tt_->setPositionOfEmitter(1, Vector3(-20,-1,-15)); 189 */ 190 this->tt_->setDirection(Vector3(-1,0,0)); 191 this->tt_->setPositionOfEmitter(0, Vector3(-15,20,-1)); 192 this->tt_->setPositionOfEmitter(1, Vector3(-15,-20,-1)); 193 this->tt_->setVelocity(50); 194 195 emitterRate_ = tt_->getRate(); 196 197 Ogre::SceneNode* node2 = this->getNode()->createChildSceneNode(this->getName() + "particle2"); 198 node2->setInheritScale(false); 199 tt_->addToSceneNode(node2); 200 // END CREATING THRUSTER 195 // START CREATING THRUSTERS 196 this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low); 197 this->tt1_->createNewEmitter(); 198 this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir()); 199 this->tt1_->getEmitter(0)->setPosition(Vector3(-15, 20, -1)); 200 this->tt1_->getEmitter(1)->setPosition(Vector3(-15, -20, -1)); 201 this->tt1_->setSpeedFactor(3.0); 202 203 Ogre::SceneNode* node2a = this->getNode()->createChildSceneNode(this->getName() + "particle2a"); 204 node2a->setInheritScale(false); 205 node2a->setScale(1, 1, 1); 206 tt1_->addToSceneNode(node2a); 207 208 this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal); 209 this->tt2_->createNewEmitter(); 210 this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0)); 211 this->tt2_->getEmitter(0)->setPosition(Vector3(-30, 40, -2)); 212 this->tt2_->getEmitter(1)->setPosition(Vector3(-30, -40, -2)); 213 214 Ogre::SceneNode* node2b = this->getNode()->createChildSceneNode(this->getName() + "particle2b"); 215 node2b->setInheritScale(false); 216 node2b->setScale(0.5, 0.5, 0.5); 217 tt2_->addToSceneNode(node2b); 218 219 this->leftThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, -10, -0.5)); 220 this->rightThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, 10, -0.5)); 221 222 Ogre::SceneNode* node2c = this->getNode()->createChildSceneNode(this->getName() + "particle2c"); 223 node2c->setInheritScale(false); 224 node2c->setScale(2, 2, 2); 225 node2c->attachObject(this->leftThrusterFlare_.getBillboardSet()); 226 node2c->attachObject(this->rightThrusterFlare_.getBillboardSet()); 227 // END CREATING THRUSTERS 201 228 202 229 // START CREATING BLINKING LIGHTS … … 216 243 // END CREATING BLINKING LIGHTS 217 244 245 // START CREATING ADDITIONAL EFFECTS 246 this->backlight_ = new Backlight(this->maxSpeed_, 0.8); 247 this->attachObject(this->backlight_); 248 this->backlight_->setPosition(-2.35, 0, 0.2); 249 this->backlight_->setColour(this->getProjectileColour()); 250 251 this->smoke_ = new ParticleSpawner(); 252 this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3); 253 this->attachObject(this->smoke_); 254 255 this->fire_ = new ParticleSpawner(); 256 this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1); 257 this->attachObject(this->fire_); 258 // END CREATING ADDITIONAL EFFECTS 259 218 260 if (this->isExactlyA(Class(SpaceShip))) 219 261 { … … 232 274 this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet()); 233 275 this->chFarNode_->setScale(0.4, 0.4, 0.4); 276 // END of testing crosshair 234 277 } 235 278 236 279 createCamera(); 237 // END of testing crosshair238 280 } 239 281 … … 245 287 } 246 288 289 void SpaceShip::changedVisibility() 290 { 291 Model::changedVisibility(); 292 293 this->tt1_->setEnabled(this->isVisible()); 294 this->tt2_->setEnabled(this->isVisible()); 295 this->redBillboard_.setVisible(this->isVisible()); 296 this->greenBillboard_.setVisible(this->isVisible()); 297 this->crosshairNear_.setVisible(this->isVisible()); 298 this->crosshairFar_.setVisible(this->isVisible()); 299 this->rightThrusterFlare_.setVisible(this->isVisible()); 300 this->leftThrusterFlare_.setVisible(this->isVisible()); 301 this->smoke_->setVisible(this->isVisible()); 302 this->fire_->setVisible(this->isVisible()); 303 this->backlight_->setVisible(this->isVisible()); 304 } 305 306 void SpaceShip::changedActivity() 307 { 308 Model::changedActivity(); 309 310 this->tt1_->setEnabled(this->isVisible()); 311 this->tt2_->setEnabled(this->isVisible()); 312 this->redBillboard_.setVisible(this->isVisible()); 313 this->greenBillboard_.setVisible(this->isVisible()); 314 this->crosshairNear_.setVisible(this->isVisible()); 315 this->crosshairFar_.setVisible(this->isVisible()); 316 this->rightThrusterFlare_.setVisible(this->isVisible()); 317 this->leftThrusterFlare_.setVisible(this->isVisible()); 318 } 319 247 320 void SpaceShip::setCamera(const std::string& camera) 248 321 { 322 myShip_=true; // TODO: this is only a hack 249 323 camName_=camera; 250 324 // change camera attributes here, if you want to ;) … … 266 340 this->camNode_ = this->getNode()->createChildSceneNode(camName_); 267 341 COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl; 268 this->camNode_->setPosition(Vector3(- 50,0,10));342 this->camNode_->setPosition(Vector3(-25,0,5)); 269 343 // Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0)); 270 344 // Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,0,-1)); … … 277 351 Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0)); 278 352 Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(1,0,0)); 279 camNode_->setOrientation(q2*q1);353 this->camNode_->setOrientation(q2*q1); 280 354 if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){ 281 355 this->setBacksync(true); 282 356 CameraHandler::getInstance()->requestFocus(cam_); 283 357 } 284 285 358 } 286 359 … … 318 391 XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode); 319 392 XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode); 320 myShip_=true; // TODO: this is only a hack321 393 322 394 SpaceShip::create(); … … 325 397 } 326 398 327 int sgn(float x)328 {329 if (x >= 0)330 return 1;331 else332 return -1;333 }334 335 399 std::string SpaceShip::whereAmI() { 336 return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x) 337 + " " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y) 338 + " " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z); 339 } 340 341 Vector3 SpaceShip::getDir() { 342 return currentDir_; 343 } 344 345 Vector3 SpaceShip::getOrth(){ 346 return currentOrth_; 347 } 348 349 float SpaceShip::getMaxSpeed() { return maxSpeed_; } 400 return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x) 401 + " " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y) 402 + " " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z); 403 } 350 404 351 405 void SpaceShip::tick(float dt) 352 406 { 407 if (!this->isActive()) 408 return; 409 353 410 currentDir_ = getOrientation()*initialDir_; 354 411 currentOrth_ = getOrientation()*initialOrth_; 355 412 356 413 if (this->cam_) 357 414 this->cam_->tick(dt); 415 416 if (this->smoke_) 417 this->smoke_->setVisible(this->isVisible() && this->health_ < 40); 418 if (this->fire_) 419 this->fire_->setVisible(this->isVisible() && this->health_ < 20); 420 421 if (this->backlight_) 422 { // (there's already fire || we're to slow || we're moving backwards ) 423 if (this->health_ < 20 || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0) 424 this->backlight_->setActive(false); 425 else 426 this->backlight_->setActive(true); 427 } 358 428 359 429 if (this->redNode_ && this->greenNode_) … … 374 444 { 375 445 376 Projectile *p; 377 if (this->isExactlyA(Class(SpaceShip))) 378 p = new RotatingProjectile(this); 379 else 380 p = new Projectile(this); 381 p->setColour(this->getProjectileColour()); 382 p->create(); 383 if(p->classID==0) 446 BillboardProjectile* projectile = new ParticleProjectile(this); 447 projectile->setColour(this->getProjectileColour()); 448 projectile->create(); 449 if (projectile->classID == 0) 450 { 384 451 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output 385 386 p->setBacksync(true); 452 } 453 454 projectile->setBacksync(true); 387 455 this->timeToReload_ = this->reloadTime_; 388 456 } … … 464 532 465 533 if (this->acceleration_.x > 0) 466 this->tt_->setRate(emitterRate_); 534 { 535 this->tt1_->setEnabled(true); 536 this->tt2_->setEnabled(true); 537 } 467 538 else 468 this->tt_->setRate(0); 469 470 if( myShip_ ) 471 { 472 COUT(5) << "steering our ship: " << objectID << std::endl; 473 this->acceleration_.x = 0; 474 this->acceleration_.y = 0; 475 this->momentum_ = 0; 476 this->mouseXRotation_ = Radian(0); 477 this->mouseYRotation_ = Radian(0); 478 this->bLMousePressed_ = false; 479 }/*else 480 COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/ 539 { 540 this->tt1_->setEnabled(false); 541 this->tt2_->setEnabled(false); 542 } 543 544 COUT(5) << "steering our ship: " << objectID << std::endl; 545 this->acceleration_.x = 0; 546 this->acceleration_.y = 0; 547 this->momentum_ = 0; 548 this->mouseXRotation_ = Radian(0); 549 this->mouseYRotation_ = Radian(0); 550 this->bLMousePressed_ = false; 481 551 } 482 552 -
code/branches/input/src/orxonox/objects/SpaceShip.h
r1535 r1629 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: 45 46 47 46 static SpaceShip *getLocalShip(); 48 47 … … 55 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 56 55 virtual void tick(float dt); 56 virtual void changedVisibility(); 57 virtual void changedActivity(); 57 58 58 59 void setCamera(const std::string& camera = ""); … … 65 66 void setRotDamp(float value); 66 67 void getFocus(); 68 69 inline float getMaxSpeed() const 70 { return this->maxSpeed_; } 71 inline float getMaxSideAndBackSpeed() const 72 { return this->maxSideAndBackSpeed_; } 73 inline float getMaxRotation() const 74 { return this->maxRotation_; } 75 inline float getTransAcc() const 76 { return this->translationAcceleration_; } 77 inline float getRotAcc() const 78 { return this->rotationAcceleration_; } 79 inline float getTransDamp() const 80 { return this->translationDamping_; } 81 inline float getRotDamp() const 82 { return this->rotationDamping_; } 67 83 68 84 static std::string whereAmI(); … … 83 99 void doFire(); 84 100 85 float getMaxSpeed(); 86 Vector3 getDir(); 87 Vector3 getOrth(); 101 inline const Vector3& getDir() const 102 { return this->currentDir_; } 103 inline const Vector3& getInitialDir() const 104 { return this->initialDir_; } 105 inline const Vector3& getOrth() const 106 { return this->currentOrth_; } 107 inline const Vector3& getInitialOrth() const 108 { return this->initialOrth_; } 109 88 110 Camera* getCamera(); 89 111 90 112 int getTeamNr() const 91 113 { return this->teamNr_; } 92 int getHealth() const114 float getHealth() const 93 115 { return this->health_; } 94 116 … … 110 132 Vector3 currentOrth_; 111 133 bool bInvertYAxis_; 112 bool setMouseEventCallback_;113 134 bool bLMousePressed_; 114 135 bool bRMousePressed_; … … 118 139 std::string camName_; 119 140 141 ParticleInterface* tt1_; 142 ParticleInterface* tt2_; 143 BillboardSet leftThrusterFlare_; 144 BillboardSet rightThrusterFlare_; 120 145 121 ParticleInterface* tt_;146 Backlight* backlight_; 122 147 123 148 BillboardSet redBillboard_; … … 126 151 Ogre::SceneNode* greenNode_; 127 152 float blinkTime_; 153 154 ParticleSpawner* smoke_; 155 ParticleSpawner* fire_; 128 156 129 157 BillboardSet crosshairNear_; … … 153 181 float mouseY_; 154 182 155 float emitterRate_;156 157 183 protected: 158 184 bool myShip_; 159 185 160 186 int teamNr_; 161 int health_;187 float health_; 162 188 163 189 static SpaceShip* instance_s; -
code/branches/input/src/orxonox/objects/SpaceShipAI.cc
r1505 r1629 32 32 #include <OgreMath.h> 33 33 #include "Projectile.h" 34 #include "ParticleSpawner.h" 34 35 #include "core/CoreIncludes.h" 35 36 #include "core/Iterator.h" … … 37 38 #include "core/ConsoleCommand.h" 38 39 #include "core/XMLPort.h" 40 #include "tools/ParticleInterface.h" 39 41 40 42 #define ACTION_INTERVAL 1.0f … … 51 53 RegisterObject(SpaceShipAI); 52 54 53 this->alive_ = true;54 this->setPosition(Vector3(rnd(-1000, 1000), rnd(-1000, 1000), rnd(-1000, 0000)));55 55 this->target_ = 0; 56 56 this->bShooting_ = 0; … … 70 70 } 71 71 72 SpaceShipAI::~SpaceShipAI() 73 { 74 for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; ++it) 75 it->shipDied(this); 76 } 77 72 78 void SpaceShipAI::XMLPort(Element& xmlelement, XMLPort::Mode mode) 73 79 { 74 80 SpaceShip::XMLPort(xmlelement, mode); 75 myShip_=true;76 81 77 82 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&SpaceShipAI::action))); … … 85 90 newenemy->setMesh("assff.mesh"); 86 91 // newenemy->setPosition(0, 0, 0); 92 newenemy->setPosition(Vector3(rnd(-3000, 3000), rnd(-3000, 3000), rnd(-3000, 3000))); 87 93 newenemy->setScale(10); 88 94 newenemy->setMaxSpeed(500); … … 95 101 Element xmlelement; 96 102 newenemy->XMLPort(xmlelement, XMLPort::LoadObject); 103 104 ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0, 0, newenemy->getOrth()); 105 spawneffect->setPosition(newenemy->getPosition() - newenemy->getOrth() * 50); 106 spawneffect->create(); 97 107 } 98 108 } … … 103 113 for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; ) 104 114 { 105 delete *(it++); 106 ++i; 115 (it++)->kill(); 107 116 if (num && i >= num) 108 117 break; … … 122 131 // search enemy 123 132 random = rnd(maxrand); 124 //std::cout << "search enemy: " << random << std::endl; 125 if (random < 20 && (!this->target_)) 126 { 133 if (random < 15 && (!this->target_)) 127 134 this->searchNewTarget(); 128 }129 135 130 136 // forget enemy 131 137 random = rnd(maxrand); 132 //std::cout << "forget enemy: " << random << std::endl;133 138 if (random < 5 && (this->target_)) 134 {135 139 this->forgetTarget(); 136 }137 140 138 141 // next enemy 139 142 random = rnd(maxrand); 140 //std::cout << "next enemy: " << random << std::endl;141 143 if (random < 10 && (this->target_)) 142 {143 144 this->searchNewTarget(); 144 }145 145 146 146 // fly somewhere 147 147 random = rnd(maxrand); 148 //std::cout << "fly somewhere: " << random << std::endl; 149 if (random < 40 && (!this->bHasTargetPosition_ && !this->target_)) 150 { 148 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 151 149 this->searchNewTargetPosition(); 152 }153 150 154 151 // stop flying 155 152 random = rnd(maxrand); 156 //std::cout << "stop flying: " << random << std::endl;157 153 if (random < 10 && (this->bHasTargetPosition_ && !this->target_)) 158 {159 154 this->bHasTargetPosition_ = false; 160 }161 155 162 156 // fly somewhere else 163 157 random = rnd(maxrand); 164 //std::cout << "fly somewhere else: " << random << std::endl;165 158 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 166 {167 159 this->searchNewTargetPosition(); 168 }169 160 170 161 // shoot 171 162 random = rnd(maxrand); 172 //std::cout << "shoot: " << random << std::endl;173 163 if (random < 75 && (this->target_ && !this->bShooting_)) 174 {175 164 this->bShooting_ = true; 176 }177 165 178 166 // stop shooting 179 167 random = rnd(maxrand); 180 //std::cout << "stop shooting: " << random << std::endl;181 168 if (random < 25 && (this->bShooting_)) 182 {183 169 this->bShooting_ = false; 184 } 170 } 171 172 void SpaceShipAI::damage(float damage) 173 { 174 this->health_ -= damage; 175 if (this->health_ <= 0) 176 { 177 this->kill(); 178 SpaceShipAI::createEnemy(1); 179 } 180 } 181 182 void SpaceShipAI::kill() 183 { 184 ParticleSpawner* explosion = new ParticleSpawner("Orxonox/BigExplosion1part1", LODParticle::low, 3.0); 185 explosion->setPosition(this->getPosition()); 186 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); 187 explosion->setScale(4); 188 explosion->create(); 189 190 explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::normal, 3.0); 191 explosion->setPosition(this->getPosition()); 192 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); 193 explosion->setScale(4); 194 explosion->create(); 195 explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::high, 3.0); 196 explosion->setPosition(this->getPosition()); 197 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); 198 explosion->setScale(4); 199 explosion->create(); 200 201 Vector3 ringdirection = Vector3(rnd(), rnd(), rnd()); 202 ringdirection.normalise(); 203 explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, 0, ringdirection); 204 explosion->setPosition(this->getPosition()); 205 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); 206 explosion->setScale(4); 207 explosion->create(); 208 explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, 0, ringdirection); 209 explosion->setPosition(this->getPosition()); 210 explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true); 211 explosion->setScale(4); 212 explosion->create(); 213 214 delete this; 185 215 } 186 216 187 217 void SpaceShipAI::tick(float dt) 188 218 { 219 if (!this->isActive()) 220 return; 221 189 222 if (this->target_) 190 223 this->aimAtTarget(); … … 193 226 this->moveToTargetPosition(dt); 194 227 195 if (this->bShooting_ && this->isCloseAtTarget(2 000) && this->isLookingAtTarget(Ogre::Math::PI / 10.0f))228 if (this->bShooting_ && this->isCloseAtTarget(2500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0)) 196 229 this->doFire(); 197 230 … … 201 234 void SpaceShipAI::moveToTargetPosition(float dt) 202 235 { 203 static Radian RadianZERO(0); 204 205 // float dotprod = (this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(this->targetPosition_ - this->getPosition()); 206 Quaternion rotation = (this->getOrientation() * Ogre::Vector3::UNIT_X).getRotationTo(this->targetPosition_ - this->getPosition()); 207 /* 208 std::cout << "scalprod: " << dotprod << std::endl; 209 std::cout << "dist: " << this->targetPosition_ - this->getPosition() << std::endl; 210 std::cout << "yaw: " << rotation.getYaw().valueRadians() << std::endl; 211 std::cout << "pitch: " << rotation.getPitch().valueRadians() << std::endl; 212 std::cout << "roll: " << rotation.getRoll().valueRadians() << std::endl; 213 */ 214 this->setMoveYaw(-rotation.getRoll().valueRadians()); 215 this->setMovePitch(rotation.getYaw().valueRadians()); 216 217 if ((this->targetPosition_ - this->getPosition()).length() > 100) 218 { 219 this->setMoveLongitudinal(1); 220 } 221 236 Vector2 coord = get2DViewdirection(this->getPosition(), this->getDir(), this->getOrth(), this->targetPosition_); 237 238 float distance = (this->targetPosition_ - this->getPosition()).length(); 239 if (this->target_ || distance > 50) 240 { 241 // Multiply with 0.8 to make them a bit slower 242 this->setMoveYaw(0.8 * sgn(coord.x) * coord.x*coord.x); 243 this->setMovePitch(0.8 * sgn(coord.y) * coord.y*coord.y); 244 } 245 246 if (this->target_ && distance < 1000 && this->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength()) 247 this->setMoveLongitudinal(-0.5); // They don't brake with full power to give the player a chance 248 else if (!this->target_ && distance <= this->getVelocity().length() / (2 * this->getTransAcc())) 249 this->setMoveLongitudinal(-1.0); 250 else 251 this->setMoveLongitudinal(0.8); 222 252 } 223 253 … … 241 271 Vector3 distanceNew = it->getPosition() - this->getPosition(); 242 272 if (!this->target_ || it->getPosition().squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceNew) / speed / distanceNew.length()) / (2 * Ogre::Math::PI)) 243 < this->targetPosition_.squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / (2 * Ogre::Math::PI)) )273 < this->targetPosition_.squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / (2 * Ogre::Math::PI)) + rnd(-250, 250)) 244 274 { 245 275 this->target_ = (*it); … … 248 278 } 249 279 } 250 }280 } 251 281 252 282 void SpaceShipAI::forgetTarget() … … 260 290 if (!this->target_) 261 291 return; 262 /* 263 Vector3 enemymovement = this->target_->getVelocity(); 264 Vector3 distance_normalised = this->target_->getPosition() - this->getPosition(); 265 distance_normalised.normalise(); 266 267 float scalarprod = enemymovement.dotProduct(distance_normalised); 268 float aimoffset = scalarprod*scalarprod + Projectile::getSpeed() * Projectile::getSpeed() - this->target_->getVelocity().squaredLength(); 269 if (aimoffset < 0) 270 { 271 this->bHasTargetPosition_ = false; 272 return; 273 } 274 aimoffset = -scalarprod + sqrt(aimoffset); 275 this->targetPosition_ = enemymovement + distance_normalised * aimoffset; 276 this->bHasTargetPosition_ = true; 277 278 std::cout << "targetpos: " << this->targetPosition_ << std::endl; 279 */ 280 this->targetPosition_ = this->target_->getPosition(); 281 this->bHasTargetPosition_ = true; 292 293 this->targetPosition_ = getPredictedPosition(this->getPosition(), Projectile::getSpeed(), this->target_->getPosition(), this->target_->getOrientation() * this->target_->getVelocity()); 294 this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO); 282 295 } 283 296 284 297 bool SpaceShipAI::isCloseAtTarget(float distance) 285 298 { 286 return (this->getPosition().squaredDistance(this->targetPosition_) < distance*distance); 299 if (!this->target_) 300 return (this->getPosition().squaredDistance(this->targetPosition_) < distance*distance); 301 else 302 return (this->getPosition().squaredDistance(this->target_->getPosition()) < distance*distance); 287 303 } 288 304 289 305 bool SpaceShipAI::isLookingAtTarget(float angle) 290 306 { 291 return (this->getOrientation() * Ogre::Vector3::UNIT_X).directionEquals(this->targetPosition_ - this->getPosition(), Radian(angle)); 307 return (getAngle(this->getPosition(), this->getDir(), this->targetPosition_) < angle); 308 } 309 310 void SpaceShipAI::shipDied(SpaceShipAI* ship) 311 { 312 if (ship == this->target_) 313 { 314 this->forgetTarget(); 315 this->searchNewTargetPosition(); 316 } 292 317 } 293 318 } -
code/branches/input/src/orxonox/objects/SpaceShipAI.h
r1505 r1629 44 44 public: 45 45 SpaceShipAI(); 46 virtual ~SpaceShipAI(); 47 46 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 49 static void createEnemy(int num); 48 50 static void killEnemies(int num); 51 void shipDied(SpaceShipAI* ship); 52 void damage(float damage); 53 void kill(); 49 54 50 55 private: … … 64 69 Timer<SpaceShipAI> actionTimer_; 65 70 66 bool alive_;67 71 bool bHasTargetPosition_; 68 72 Vector3 targetPosition_; -
code/branches/input/src/orxonox/objects/WorldEntity.cc
r1505 r1629 45 45 unsigned int WorldEntity::worldEntityCounter_s = 0; 46 46 47 WorldEntity::WorldEntity() : 48 velocity_ (0, 0, 0), 49 acceleration_(0, 0, 0), 50 rotationAxis_(0, 1, 0), 51 rotationRate_(0), 52 momentum_ (0), 53 node_ (0), 54 bStatic_ (true) 47 WorldEntity::WorldEntity() 55 48 { 56 49 RegisterObject(WorldEntity); … … 58 51 if (GraphicsEngine::getSingleton().getSceneManager()) 59 52 { 60 std::ostringstream name;61 name << (WorldEntity::worldEntityCounter_s++);62 this->setName("WorldEntity" + name.str());63 this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());53 std::ostringstream name; 54 name << (WorldEntity::worldEntityCounter_s++); 55 this->setName("WorldEntity" + name.str()); 56 this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName()); 64 57 65 registerAllVariables();58 registerAllVariables(); 66 59 } 60 else 61 { 62 this->node_ = 0; 63 } 64 65 this->bStatic_ = true; 66 this->velocity_ = Vector3(0, 0, 0); 67 this->acceleration_ = Vector3(0, 0, 0); 68 this->rotationAxis_ = Vector3(0, 1, 0); 69 this->rotationRate_ = 0; 70 this->momentum_ = 0; 67 71 } 68 72 69 73 70 74 WorldEntity::~WorldEntity() 71 75 { 72 // just to make sure we clean out all scene nodes 73 if(this->getNode()) 74 this->getNode()->removeAndDestroyAllChildren(); 76 if (this->isInitialized()) 77 { 78 this->getNode()->removeAndDestroyAllChildren(); 79 GraphicsEngine::getSingleton().getSceneManager()->destroySceneNode(this->getName()); 80 } 75 81 } 76 82 77 83 void WorldEntity::tick(float dt) 78 84 { 79 if (!this->bStatic_ )85 if (!this->bStatic_ && this->isActive()) 80 86 { 81 87 // COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl; … … 89 95 } 90 96 91 void WorldEntity::loadParams(TiXmlElement* xmlElem)92 {93 94 BaseObject::loadParams(xmlElem);95 create();96 }97 98 97 99 98 void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll) … … 122 121 123 122 XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true); 124 123 125 124 WorldEntity::create(); 126 125 } … … 129 128 void WorldEntity::registerAllVariables() 130 129 { 130 // register inheritec variables from BaseObject 131 registerVar( (void*) &(this->bActive_), sizeof(this->bActive_), network::DATA, 0x3); 132 registerVar( (void*) &(this->bVisible_), sizeof(this->bVisible_), network::DATA, 0x3); 131 133 // register coordinates 132 134 registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3); … … 163 165 { 164 166 this->attachedWorldEntities_.push_back(entity); 167 this->attachObject(entity); 165 168 } 166 169 … … 172 175 return 0; 173 176 } 177 178 void WorldEntity::attachObject(const WorldEntity& obj) const 179 { 180 GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj.getNode()); 181 this->getNode()->addChild(obj.getNode()); 182 } 183 184 void WorldEntity::attachObject(WorldEntity* obj) const 185 { 186 GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj->getNode()); 187 this->getNode()->addChild(obj->getNode()); 188 } 174 189 } -
code/branches/input/src/orxonox/objects/WorldEntity.h
r1535 r1629 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(); } … … 58 57 const WorldEntity* getAttachedWorldEntity(unsigned int index) const; 59 58 60 inline Ogre::SceneNode* getNode() 59 inline Ogre::SceneNode* getNode() const 61 60 { return this->node_; } 62 61 … … 74 73 inline const Vector3& getPosition() const 75 74 { return this->node_->getPosition(); } 76 77 inline void translate(const Vector3 &d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 75 inline const Vector3& getWorldPosition() const 76 { return this->node_->getWorldPosition(); } 77 78 inline void translate(const Vector3& d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 78 79 { this->node_->translate(d, relativeTo); } 79 80 inline void translate(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 80 81 { this->node_->translate(x, y, z, relativeTo); } 81 inline void translate(const Matrix3 &axes, const Vector3 &move, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)82 inline void translate(const Matrix3& axes, const Vector3& move, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 82 83 { this->node_->translate(axes, move, relativeTo); } 83 inline void translate(const Matrix3 &axes, Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)84 inline void translate(const Matrix3& axes, Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT) 84 85 { this->node_->translate(axes, x, y, z, relativeTo); } 85 86 86 inline void yaw(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)87 inline void yaw(const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 87 88 { this->node_->yaw(angle, relativeTo); } 88 inline void pitch(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)89 inline void pitch(const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 89 90 { this->node_->pitch(angle, relativeTo); } 90 inline void roll(const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)91 inline void roll(const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 91 92 { this->node_->roll(angle, relativeTo); } 92 93 void setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll); 93 94 94 inline void setYaw(const Degree &angle)95 inline void setYaw(const Degree& angle) 95 96 { this->node_->yaw(angle, Ogre::Node::TS_LOCAL); } 96 inline void setPitch(const Degree &angle)97 inline void setPitch(const Degree& angle) 97 98 { this->node_->pitch(angle, Ogre::Node::TS_LOCAL); } 98 inline void setRoll(const Degree &angle)99 inline void setRoll(const Degree& angle) 99 100 { this->node_->roll(angle, Ogre::Node::TS_LOCAL); } 100 101 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); } 105 inline void rotate(const Vector3 &axis, const Radian &angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)108 inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 106 109 { this->node_->rotate(axis, angle, relativeTo); } 107 110 inline void setDirectionLoader(Real x, Real y, Real z) 108 111 { this->setDirection(x, y, z); } 109 inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)112 inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector=Vector3::NEGATIVE_UNIT_Z) 110 113 { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); } 111 inline void setDirection(const Vector3 &vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)114 inline void setDirection(const Vector3& vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector=Vector3::NEGATIVE_UNIT_Z) 112 115 { this->node_->setDirection(vec, relativeTo, localDirectionVector); } 113 inline void lookAt(const Vector3 &targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3 &localDirectionVector=Vector3::NEGATIVE_UNIT_Z)116 inline void lookAt(const Vector3& targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector=Vector3::NEGATIVE_UNIT_Z) 114 117 { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); } 115 118 116 inline void setScale(const Vector3 &scale)119 inline void setScale(const Vector3& scale) 117 120 { this->node_->setScale(scale); } 118 121 inline void setScale(Real x, Real y, Real z) … … 124 127 inline const Vector3& getScale(void) const 125 128 { return this->node_->getScale(); } 126 inline void scale(const Vector3 &scale)129 inline void scale(const Vector3& scale) 127 130 { this->node_->scale(scale); } 128 131 inline void scale(Real x, Real y, Real z) … … 131 134 { this->node_->scale(scale, scale, scale); } 132 135 133 inline void attachObject(Ogre::MovableObject *obj) 136 void attachObject(const WorldEntity& obj) const; 137 void attachObject(WorldEntity* obj) const; 138 inline void attachObject(Ogre::MovableObject* obj) const 134 139 { this->node_->attachObject(obj); } 135 inline void attachObject(Mesh &mesh)140 inline void attachObject(Mesh& mesh) const 136 141 { this->node_->attachObject(mesh.getEntity()); } 137 inline void detachObject(Ogre::MovableObject *obj)142 inline void detachObject(Ogre::MovableObject* obj) const 138 143 { this->node_->detachObject(obj); } 139 inline void detachAllObjects() 144 inline void detachAllObjects() const 140 145 { this->node_->detachAllObjects(); } 141 146 … … 179 184 inline void setStatic(bool bStatic) 180 185 { this->bStatic_ = bStatic; } 181 inline bool isStatic() 186 inline bool isStatic() const 182 187 { return this->bStatic_; } 183 188 -
code/branches/input/src/orxonox/tools/BillboardSet.cc
r1505 r1629 46 46 } 47 47 48 void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, int count, const Vector3& position) 48 void BillboardSet::setBillboardSet(const std::string& file, int count) 49 { 50 std::ostringstream name; 51 name << (BillboardSet::billboardSetCounter_s++); 52 this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count); 53 this->billboardSet_->createBillboard(Vector3::ZERO); 54 this->billboardSet_->setMaterialName(file); 55 } 56 57 void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, int count) 58 { 59 std::ostringstream name; 60 name << (BillboardSet::billboardSetCounter_s++); 61 this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count); 62 this->billboardSet_->createBillboard(Vector3::ZERO, colour); 63 this->billboardSet_->setMaterialName(file); 64 } 65 66 void BillboardSet::setBillboardSet(const std::string& file, const Vector3& position, int count) 67 { 68 std::ostringstream name; 69 name << (BillboardSet::billboardSetCounter_s++); 70 this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count); 71 this->billboardSet_->createBillboard(position); 72 this->billboardSet_->setMaterialName(file); 73 } 74 75 void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count) 49 76 { 50 77 std::ostringstream name; -
code/branches/input/src/orxonox/tools/BillboardSet.h
r1505 r1629 33 33 34 34 #include <string> 35 #include <OgreBillboardSet.h> 35 36 36 #include <OgreBillboardSet.h>37 37 #include "util/Math.h" 38 38 … … 44 44 BillboardSet(); 45 45 ~BillboardSet(); 46 void setBillboardSet(const std::string& file, const ColourValue& colour = ColourValue(1.0, 1.0, 1.0), int count = 1, const Vector3& position = Vector3::ZERO); 46 void setBillboardSet(const std::string& file, int count = 1); 47 void setBillboardSet(const std::string& file, const ColourValue& colour, int count = 1); 48 void setBillboardSet(const std::string& file, const Vector3& position, int count = 1); 49 void setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1); 47 50 48 51 inline Ogre::BillboardSet* getBillboardSet() … … 51 54 inline const std::string& getName() const 52 55 { return this->billboardSet_->getName(); } 56 57 inline void setVisible(bool visible) 58 { this->billboardSet_->setVisible(visible); } 59 inline bool getVisible() const 60 { return this->billboardSet_->getVisible(); } 53 61 54 62 private: -
code/branches/input/src/orxonox/tools/Mesh.h
r1505 r1629 51 51 { return this->entity_->getName(); } 52 52 53 inline void setVisible(bool visible) 54 { if (this->entity_) this->entity_->setVisible(visible); } 55 inline bool getVisible() const 56 { if (this->entity_) return this->entity_->getVisible(); else return false; } 57 53 58 private: 54 59 static unsigned int meshCounter_s; -
code/branches/input/src/orxonox/tools/Timer.cc
r1505 r1629 102 102 TimerBase::~TimerBase() 103 103 { 104 if (this->executor_) 105 delete this->executor_; 104 this->deleteExecutor(); 106 105 } 107 106 … … 112 111 { 113 112 (*this->executor_)(); 113 } 114 115 /** 116 @brief Deletes the executor. 117 */ 118 void TimerBase::deleteExecutor() 119 { 120 if (this->executor_) 121 delete this->executor_; 114 122 } 115 123 -
code/branches/input/src/orxonox/tools/Timer.h
r1535 r1629 78 78 79 79 void run() const; 80 void deleteExecutor(); 80 81 81 82 /** @brief Starts the Timer: Function-call after 'interval' seconds. */ … … 94 95 inline bool isActive() const 95 96 { return this->bActive_; } 97 /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */ 98 inline float getRemainingTime() const 99 { return this->time_; } 96 100 /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */ 97 101 inline void addTime(float time) … … 149 153 void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor) 150 154 { 155 this->deleteExecutor(); 156 151 157 this->interval_ = interval; 152 158 this->bLoop_ = bLoop; … … 185 191 void setTimer(float interval, bool bLoop, ExecutorStatic* executor) 186 192 { 193 this->deleteExecutor(); 194 187 195 this->interval_ = interval; 188 196 this->bLoop_ = bLoop; -
code/branches/input/src/tinyxml/ticpp.cc
r1505 r1629 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/branches/input/src/tolua/CMakeLists.txt
r1505 r1629 7 7 ) 8 8 9 ADD_LIBRARY (tolualib ${TOLUALIB_SRC_FILES})9 ADD_LIBRARY (tolualib SHARED ${TOLUALIB_SRC_FILES}) 10 10 11 11 TARGET_LINK_LIBRARIES (tolualib -
code/branches/input/src/util/Convert.h
r1505 r1629 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/branches/input/src/util/Math.cc
r1505 r1629 27 27 */ 28 28 29 #include <OgrePlane.h> 30 29 31 #include "Math.h" 32 #include "Convert.h" 30 33 31 34 /** … … 68 71 return in; 69 72 } 73 74 75 float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition) 76 { 77 orxonox::Vector3 distance = otherposition - myposition; 78 float distancelength = distance.length(); 79 if (distancelength == 0) 80 return 0; 81 else 82 return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)); 83 } 84 85 orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) 86 { 87 orxonox::Vector3 distance = otherposition - myposition; 88 89 // project difference vector on our plane 90 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance); 91 92 float projectionlength = projection.length(); 93 if (projectionlength == 0) return orxonox::Vector2(0, 0); 94 float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1)); 95 96 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0) 97 return orxonox::Vector2(sin(angle), cos(angle)); 98 else 99 return orxonox::Vector2(-sin(angle), cos(angle)); 100 } 101 102 orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) 103 { 104 orxonox::Vector3 distance = otherposition - myposition; 105 106 // project difference vector on our plane 107 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance); 108 109 float projectionlength = projection.length(); 110 if (projectionlength == 0) return orxonox::Vector2(0, 0); 111 float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1)); 112 113 float distancelength = distance.length(); 114 if (distancelength == 0) return orxonox::Vector2(0, 0); 115 float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI; 116 117 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0) 118 return orxonox::Vector2(sin(angle) * radius, cos(angle) * radius); 119 else 120 return orxonox::Vector2(-sin(angle) * radius, cos(angle) * radius); 121 } 122 123 orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity) 124 { 125 float squaredProjectilespeed = projectilespeed * projectilespeed; 126 orxonox::Vector3 distance = targetposition - myposition; 127 float a = distance.squaredLength(); 128 float b = 2 * (distance.x + distance.y + distance.z) * (targetvelocity.x + targetvelocity.y + targetvelocity.z); 129 float c = targetvelocity.squaredLength(); 130 131 float temp = 4*squaredProjectilespeed*c + a*a - 4*b*c; 132 if (temp < 0) 133 return orxonox::Vector3::ZERO; 134 135 temp = sqrt(temp); 136 float time = (temp + a) / (2 * (squaredProjectilespeed - b)); 137 return (targetposition + targetvelocity * time); 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/branches/input/src/util/Math.h
r1505 r1629 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; … … 58 61 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree); 59 62 _UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree); 63 64 _UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition); 65 _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 66 _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition); 67 _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity); 60 68 61 69 template <typename T> … … 156 164 } 157 165 166 _UtilExport unsigned long getUniqueNumber(); 167 _UtilExport std::string getUniqueNumberStr(); 168 158 169 class _UtilExport IntVector2 159 170 { -
code/branches/input/src/util/String.cc
r1505 r1629 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/branches/input/src/util/String.h
r1505 r1629 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/branches/input/src/util/UtilPrereqs.h
r1505 r1629 61 61 //----------------------------------------------------------------------- 62 62 class ArgReader; 63 class Convert;64 63 class MultiTypePrimitive; 65 64 class MultiTypeString; -
code/branches/input/visual_studio/audio_properties.vsprops
r1024 r1629 13 13 <Tool 14 14 Name="VCLinkerTool" 15 AdditionalDependencies="libvorbisfile $(CSS).lib alut$(CS).lib OpenAL32$(CS).lib"15 AdditionalDependencies="libvorbisfile-1.2.0$(CSS).lib alut$(CS).lib OpenAL32$(CS).lib" 16 16 /> 17 17 </VisualStudioPropertySheet> -
code/branches/input/visual_studio/base_properties.vsprops
r1223 r1629 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalIncludeDirectories=""$(RootDir) src";"$(RootDir)src\orxonox";"$(RootDir)src\tolua";"$(RootDir)src\ois";"$(DependencyDir)include""10 AdditionalIncludeDirectories=""$(RootDir)";"$(RootDir)src";"$(RootDir)src\orxonox";"$(RootDir)src\tolua";"$(RootDir)src\ois";"$(LibDir)ogre-1.4.8\OgreMain\include";"$(LibDir)boost-1.35.0";"$(LibDir)enet-1.2\include";"$(LibDir)libogg-1.1.3\include";"$(LibDir)libvorbis-1.2.0\include";"$(LibDir)lua-5.1.3\src";"$(LibDir)openal-1.1\include";"$(LibDir)openal-1.1\alut\include";"$(LibDir)tcl-8.5.\generic";"$(LibDir)zlib-1.2.3"" 11 11 PreprocessorDefinitions="WIN32;__WIN32__;_WIN32;BOOST_ALL_DYN_LINK;OIS_DYNAMIC_LIB; ZLIB_WINAPI" 12 12 WarningLevel="3" … … 33 33 <UserMacro 34 34 Name="DependencyDir" 35 Value="$(RootDir)..\ dependencies\"35 Value="$(RootDir)..\lib_precompiled\" 36 36 /> 37 37 <UserMacro … … 43 43 Value="" 44 44 /> 45 <UserMacro 46 Name="LibDir" 47 Value="$(RootDir)..\lib_src\" 48 /> 49 <UserMacro 50 Name="libOgre" 51 Value="OgreMain$(CS).lib" 52 /> 45 53 </VisualStudioPropertySheet> -
code/branches/input/visual_studio/base_properties_release.vsprops
r1502 r1629 9 9 Name="VCCLCompilerTool" 10 10 Optimization="2" 11 WholeProgramOptimization="false"12 11 PreprocessorDefinitions="NDEBUG" 13 12 RuntimeLibrary="2" -
code/branches/input/visual_studio/core_properties.vsprops
r1223 r1629 12 12 <Tool 13 13 Name="VCLinkerTool" 14 AdditionalDependencies="OgreMain$(CSS).lib lua-5.1 $(CS).lib tcl85t.lib"14 AdditionalDependencies="OgreMain$(CSS).lib lua-5.1.3$(CS).lib tcl85t.lib" 15 15 /> 16 16 </VisualStudioPropertySheet> -
code/branches/input/visual_studio/orxonox_properties.vsprops
r1293 r1629 14 14 <Tool 15 15 Name="VCLinkerTool" 16 AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib enet $(CS).lib zlib$(CS).lib"16 AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib enet-1.2$(CS).lib zlib-1.2.3$(CS).lib" 17 17 OutputFile="$(OutDir)$(ProjectName)$(CS).exe" 18 18 IgnoreDefaultLibraryNames="LIBCMT;LIBCMTD" -
code/branches/input/visual_studio/vc8/audio.vcproj
r1024 r1629 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/branches/input/visual_studio/vc8/core.vcproj
r1543 r1629 82 82 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\core_properties.vsprops" 83 83 CharacterSet="1" 84 WholeProgramOptimization=" 1"84 WholeProgramOptimization="0" 85 85 > 86 86 <Tool -
code/branches/input/visual_studio/vc8/cpptcl.vcproj
r1223 r1629 73 73 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\cpptcl_properties.vsprops" 74 74 CharacterSet="1" 75 WholeProgramOptimization=" 1"75 WholeProgramOptimization="0" 76 76 > 77 77 <Tool -
code/branches/input/visual_studio/vc8/network.vcproj
r1316 r1629 73 73 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\network_properties.vsprops" 74 74 CharacterSet="1" 75 WholeProgramOptimization=" 1"75 WholeProgramOptimization="0" 76 76 > 77 77 <Tool -
code/branches/input/visual_studio/vc8/ois.vcproj
r1293 r1629 24 24 InheritedPropertySheets="..\directory_properties.vsprops" 25 25 CharacterSet="2" 26 WholeProgramOptimization="0" 26 27 > 27 28 <Tool … … 76 77 EnableCOMDATFolding="2" 77 78 OptimizeForWindows98="1" 78 LinkTimeCodeGeneration="1"79 79 ImportLibrary="$(RootDir)lib\$(TargetName).lib" 80 80 /> -
code/branches/input/visual_studio/vc8/orxonox.vcproj
r1535 r1629 84 84 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\orxonox_properties.vsprops" 85 85 CharacterSet="1" 86 WholeProgramOptimization=" 1"86 WholeProgramOptimization="0" 87 87 > 88 88 <Tool … … 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" … … 220 226 </File> 221 227 <File 228 RelativePath="..\..\src\orxonox\objects\Backlight.cc" 229 > 230 </File> 231 <File 232 RelativePath="..\..\src\orxonox\objects\BillboardProjectile.cc" 233 > 234 </File> 235 <File 222 236 RelativePath="..\..\src\orxonox\objects\Camera.cc" 223 237 > … … 228 242 </File> 229 243 <File 230 RelativePath="..\..\src\orxonox\objects\Explosion.cc"231 >232 </File>233 <File234 244 RelativePath="..\..\src\orxonox\objects\Model.cc" 235 245 > … … 237 247 <File 238 248 RelativePath="..\..\src\orxonox\objects\NPC.cc" 249 > 250 </File> 251 <File 252 RelativePath="..\..\src\orxonox\objects\ParticleProjectile.cc" 253 > 254 </File> 255 <File 256 RelativePath="..\..\src\orxonox\objects\ParticleSpawner.cc" 239 257 > 240 258 </File> … … 393 411 </Filter> 394 412 <Filter 395 Name="particle"396 >397 <File398 RelativePath="..\..\src\orxonox\particle\ParticleInterface.cc"399 >400 </File>401 </Filter>402 <Filter403 413 Name="tools" 404 414 > … … 416 426 </File> 417 427 <File 428 RelativePath="..\..\src\orxonox\tools\ParticleInterface.cc" 429 > 430 </File> 431 <File 432 RelativePath="..\..\src\orxonox\tools\TextureGenerator.cc" 433 > 434 </File> 435 <File 418 436 RelativePath="..\..\src\orxonox\tools\Timer.cc" 419 437 > 420 438 </File> 421 </Filter> 422 <Filter 423 Name="console" 424 > 425 <File 426 RelativePath="..\..\src\orxonox\console\InGameConsole.cc" 439 <File 440 RelativePath="..\..\src\orxonox\tools\WindowEventListener.cc" 427 441 > 428 442 </File> … … 452 466 </File> 453 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> 454 524 </Filter> 455 525 <Filter … … 475 545 </File> 476 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 477 559 RelativePath="..\..\src\orxonox\Settings.h" 478 560 > 479 561 </File> 480 <Filter481 Name="hud"482 >483 <File484 RelativePath="..\..\src\orxonox\hud\BarOverlayElement.h"485 >486 </File>487 <File488 RelativePath="..\..\src\orxonox\hud\HUD.h"489 >490 </File>491 <File492 RelativePath="..\..\src\orxonox\hud\Navigation.h"493 >494 </File>495 <File496 RelativePath="..\..\src\orxonox\hud\OverlayElementFactories.h"497 >498 </File>499 <File500 RelativePath="..\..\src\orxonox\hud\RadarObject.h"501 >502 </File>503 <File504 RelativePath="..\..\src\orxonox\hud\RadarOverlayElement.h"505 >506 </File>507 </Filter>508 562 <Filter 509 563 Name="objects" … … 514 568 </File> 515 569 <File 570 RelativePath="..\..\src\orxonox\objects\Backlight.h" 571 > 572 </File> 573 <File 574 RelativePath="..\..\src\orxonox\objects\BillboardProjectile.h" 575 > 576 </File> 577 <File 516 578 RelativePath="..\..\src\orxonox\objects\Camera.h" 517 579 > … … 522 584 </File> 523 585 <File 524 RelativePath="..\..\src\orxonox\objects\Explosion.h"525 >526 </File>527 <File528 586 RelativePath="..\..\src\orxonox\objects\Model.h" 529 587 > … … 531 589 <File 532 590 RelativePath="..\..\src\orxonox\objects\NPC.h" 591 > 592 </File> 593 <File 594 RelativePath="..\..\src\orxonox\objects\ParticleProjectile.h" 595 > 596 </File> 597 <File 598 RelativePath="..\..\src\orxonox\objects\ParticleSpawner.h" 533 599 > 534 600 </File> … … 591 657 </Filter> 592 658 <Filter 593 Name="particle"594 >595 <File596 RelativePath="..\..\src\orxonox\particle\ParticleInterface.h"597 >598 </File>599 </Filter>600 <Filter601 659 Name="tools" 602 660 > … … 614 672 </File> 615 673 <File 674 RelativePath="..\..\src\orxonox\tools\ParticleInterface.h" 675 > 676 </File> 677 <File 678 RelativePath="..\..\src\orxonox\tools\TextureGenerator.h" 679 > 680 </File> 681 <File 616 682 RelativePath="..\..\src\orxonox\tools\Timer.h" 617 683 > 618 684 </File> 619 </Filter> 620 <Filter 621 Name="console" 622 > 623 <File 624 RelativePath="..\..\src\orxonox\console\InGameConsole.h" 685 <File 686 RelativePath="..\..\src\orxonox\tools\WindowEventListener.h" 625 687 > 626 688 </File> … … 633 695 > 634 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> 635 753 </Filter> 636 754 </Filter> -
code/branches/input/visual_studio/vc8/tixml.vcproj
r1209 r1629 73 73 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tixml_properties.vsprops" 74 74 CharacterSet="1" 75 WholeProgramOptimization=" 1"75 WholeProgramOptimization="0" 76 76 > 77 77 <Tool -
code/branches/input/visual_studio/vc8/tolua.vcproj
r1223 r1629 73 73 InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tolua_properties.vsprops" 74 74 CharacterSet="1" 75 WholeProgramOptimization=" 1"75 WholeProgramOptimization="0" 76 76 > 77 77 <Tool -
code/branches/input/visual_studio/vc8/util.vcproj
r1502 r1629 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.