Changeset 5789
- Timestamp:
- Sep 26, 2009, 12:44:49 AM (15 years ago)
- Location:
- sandbox_light
- Files:
-
- 33 added
- 55 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox_light/CMakeLists.txt
r5695 r5789 37 37 ################ General Config ################# 38 38 39 # Version info40 SET(ORXONOX_VERSION_MAJOR 0)41 SET(ORXONOX_VERSION_MINOR 0)42 SET(ORXONOX_VERSION_PATCH 3)43 SET(ORXONOX_VERSION 0.0.3)44 SET(ORXONOX_VERSION_NAME "Arcturus")45 46 39 # Standard path suffixes 47 40 SET(DEFAULT_RUNTIME_PATH bin) 48 41 SET(DEFAULT_LIBRARY_PATH lib) 49 42 SET(DEFAULT_ARCHIVE_PATH lib/static) 50 SET(DEFAULT_MODULE_PATH lib/modules)51 43 SET(DEFAULT_DOC_PATH doc) 52 44 SET(DEFAULT_DATA_PATH data) … … 58 50 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH}) 59 51 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH}) 60 SET(CMAKE_MODULE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH})61 52 SET(CMAKE_DOC_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_DOC_PATH}) 62 53 # Data directories are only inputs, no delclaration here 63 54 SET(CMAKE_CONFIG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH}) 64 55 SET(CMAKE_LOG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH}) 65 66 # Set the extension of the dynamic modules67 SET(ORXONOX_MODULE_EXTENSION ".module")68 56 69 57 # Sets where to find the external libraries like OgreMain.dll at runtime -
sandbox_light/INSTALL
r2710 r5789 9 9 (for windows there are already precompiled packages on the website) 10 10 11 OGRE 3D Graphics Engine 1.4 (1.6 not yet supported)12 CEGUI (Crazy Eddie's GUI System) 0.513 Boost libraries 1.3414 ENet (Network library) 1.115 11 Lua (scripting language) 5.0 or 5.1 16 Tcl (shell script language) 8.4 or 8.517 OpenAL (audio) (no version requirements specified yet)18 ALUT (audio) (no version requirements specified yet)19 LibOgg (no version requirements specified yet)20 LibVorbis (no version requirements specified yet)21 ZLib (compression) (no version requirements specified yet)22 23 OGRE supports both OpenGL and DirectX9 rendering. You will also need OGRE for the dedicated server!24 25 Further information about installing and running this application can be found on26 http://www.orxonox.net/wiki/Running -
sandbox_light/cmake/InstallConfig.cmake
r5695 r5789 43 43 SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH}) 44 44 SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH}) 45 SET(MODULE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MODULE_PATH})46 45 SET(DOC_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH}) 47 46 SET(DATA_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DATA_PATH}) … … 55 54 SET(LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/orxonox) 56 55 SET(ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static) 57 SET(MODULE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/orxonox/modules)58 56 SET(DOC_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox) 59 57 SET(DATA_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/orxonox) -
sandbox_light/cmake/LibraryConfig.cmake
r5782 r5789 73 73 # Performs the search and sets the variables # 74 74 75 FIND_PACKAGE(OGRE 1.4 REQUIRED)76 75 ##### Lua ##### 77 76 IF(CEGUILUA_USE_EXTERNAL_LIBRARY) … … 102 101 IF(WIN32) 103 102 OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE) 104 OPTION(LINK_OGRE_DYNAMIC "Link OGRE dynamically on Windows" TRUE)105 103 COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison) 106 104 IF(_version_comparison LESS 0) … … 113 111 MARK_AS_ADVANCED( 114 112 LINK_BOOST_DYNAMIC 115 LINK_OGRE_DYNAMIC116 113 LINK_LUA_DYNAMIC 117 114 ) -
sandbox_light/cmake/LibraryConfigTardis.cmake
r5782 r5789 45 45 SET(BOOST_LIBRARYDIR "/usr/pack/boost-1.36.0-sd/i686-debian-linux4.0/lib") 46 46 SET(ENV{LUA_DIR} "/usr/pack/lua-5.1.4-sd;/usr/pack/lua-5.1.4-sd/i686-debian-linux4.0") 47 SET(ENV{OGRE_HOME} "/usr/pack/ogre-1.4.9-sd;/usr/pack/ogre-1.4.9-sd/i686-debian-linux4.0")48 47 ENDIF(TARDIS) -
sandbox_light/cmake/PackageConfig.cmake
r5782 r5789 59 59 SET(ENV{BOOST_ROOT} ${DEP_INCLUDE_DIR}/boost) 60 60 SET(ENV{LUA_DIR} ${DEP_INCLUDE_DIR}/lua) 61 SET(ENV{OGRE_HOME} ${DEP_INCLUDE_DIR}/ogre)62 61 63 62 ### INSTALL ### -
sandbox_light/cmake/TargetUtilities.cmake
r5695 r5789 188 188 IF(_arg_VERSION) 189 189 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${_arg_VERSION}) 190 ELSEIF(NOT _arg_ORXONOX_EXTERNAL)191 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${ORXONOX_VERSION})192 190 ENDIF() 193 191 -
sandbox_light/data/CMakeLists.txt
r5782 r5789 21 21 # Reto Grieder 22 22 # Description: 23 # Finds the external data directory and configures the data installation. 24 # Default search paths are: ../../data and ../data_extern 23 # Connfigures the data installation. 25 24 # 26 25 -
sandbox_light/src/CMakeLists.txt
r5782 r5789 39 39 ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) 40 40 ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA_DYNAMIC) 41 # If no defines are specified, these libs get linked dynamically42 ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" WIN32 NOT LINK_OGRE_DYNAMIC)43 41 44 42 ############## Include Directories ############## … … 47 45 INCLUDE_DIRECTORIES( 48 46 # External 49 ${OGRE_INCLUDE_DIR}50 47 ${Boost_INCLUDE_DIRS} 51 48 ${LUA_INCLUDE_DIR} … … 74 71 ADD_SUBDIRECTORY(libraries) 75 72 ADD_SUBDIRECTORY(orxonox) 76 ADD_SUBDIRECTORY(modules)77 73 78 74 ################ Executable ################ -
sandbox_light/src/OrxonoxConfig.h.in
r5695 r5789 108 108 109 109 /*--------------------------------- 110 * Version information111 *-------------------------------*/112 #define ORXONOX_VERSION_MAJOR @ORXONOX_VERSION_MAJOR@113 #define ORXONOX_VERSION_MINOR @ORXONOX_VERSION_MINOR@114 #define ORXONOX_VERSION_PATCH @ORXONOX_VERSION_PATCH@115 #define ORXONOX_VERSION_NAME "@ORXONOX_VERSION_NAME@"116 117 //! Defines version info encoded as 0xMMIIPP (M: Major version, I: Minor version, P: Patch version, all as hex)118 #define ORXONOX_VERSION \119 ((ORXONOX_VERSION_MAJOR << 16) | (ORXONOX_VERSION_MINOR << 8) | ORXONOX_VERSION_PATCH)120 121 122 /*---------------------------------123 * Unix settings124 *-------------------------------*/125 #ifdef ORXONOX_PLATFORM_UNIX126 127 // TODO: Check what this actually is and whether we need it or not128 #if 0129 # ifdef ORXONOX_PLATFORM_APPLE130 # define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle"131 # else // ORXONOX_PLATFORM_LINUX132 # define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"133 # endif134 #endif135 136 #endif /* Patform Unix */137 138 139 /*---------------------------------140 * Apple Settings141 *-------------------------------*/142 143 144 /*---------------------------------145 110 * Options 146 111 *-------------------------------*/ -
sandbox_light/src/SpecialConfig.h.in
r5782 r5789 70 70 const char defaultLibraryPath[] = "@DEFAULT_LIBRARY_PATH@"; 71 71 const char defaultArchivePath[] = "@DEFAULT_ARCHIVE_PATH@"; 72 const char defaultModulePath[] = "@DEFAULT_MODULE_PATH@";73 72 const char defaultDocPath[] = "@DEFAULT_DOC_PATH@"; 74 73 const char defaultDataPath[] = "@DEFAULT_DATA_PATH@"; … … 79 78 // INSTALLATION PATHS 80 79 const char dataInstallDirectory[] = "@DATA_INSTALL_DIRECTORY@"; 81 const char moduleInstallDirectory[] = "@MODULE_INSTALL_DIRECTORY@";82 80 #endif 83 81 … … 85 83 const char dataDevDirectory[] = "@DATA_DIRECTORY@"; 86 84 #ifdef CMAKE_CONFIGURATION_TYPES 87 const char moduleDevDirectory[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE);88 85 const char configDevDirectory[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE); 89 86 const char logDevDirectory[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE); 90 87 #else 91 const char moduleDevDirectory[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@";92 88 const char configDevDirectory[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@"; 93 89 const char logDevDirectory[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@"; … … 97 93 const char dependencyLibraryDirectory[] = "@DEP_LIBRARY_DIR@"; 98 94 #endif 99 100 // Module extension101 const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@";102 95 } } 103 96 -
sandbox_light/src/external/CMakeLists.txt
r5782 r5789 20 20 ################ Sub Directories ################ 21 21 22 ADD_SUBDIRECTORY(ogremath) 22 23 ADD_SUBDIRECTORY(tolua) -
sandbox_light/src/libraries/core/CMakeLists.txt
r5782 r5789 20 20 SET_SOURCE_FILES(CORE_SRC_FILES 21 21 Clock.cc 22 ConfigFileManager.cc 23 ConfigValueContainer.cc 22 CommandLine.cc 24 23 Core.cc 25 DynLib.cc26 DynLibManager.cc27 Game.cc28 GameState.cc29 Language.cc30 24 LuaState.cc 31 ObjectListBase.cc32 OrxonoxClass.cc33 34 # command35 CommandLine.cc36 Executor.cc37 38 # hierarchy39 Factory.cc40 Identifier.cc41 MetaObjectList.cc42 43 # level44 BaseObject.cc45 46 # multithreading47 Thread.cc48 ThreadPool.cc49 25 ) 50 26 … … 55 31 DEFINE_SYMBOL 56 32 "CORE_SHARED_BUILD" 57 PCH_FILE58 CorePrecompiledHeaders.h59 33 LINK_LIBRARIES 60 ${OGRE_LIBRARY}61 34 ${Boost_FILESYSTEM_LIBRARY} 62 35 ${Boost_SYSTEM_LIBRARY} # Filesystem dependency 63 ${Boost_THREAD_LIBRARY}64 ${Boost_DATE_TIME_LIBRARY} # Thread dependency65 36 ${LUA_LIBRARIES} 37 ogremath_orxonox 66 38 tolua++_orxonox 67 39 util -
sandbox_light/src/libraries/core/Clock.cc
r5738 r5789 33 33 34 34 #include "Clock.h" 35 #include < OgreTimer.h>35 #include <ogremath/OgreTimer.h> 36 36 37 37 namespace orxonox -
sandbox_light/src/libraries/core/CommandLine.cc
r5738 r5789 31 31 #include <algorithm> 32 32 #include <sstream> 33 #include <boost/filesystem.hpp>34 33 35 34 #include "util/Convert.h" … … 348 347 { 349 348 std::string filename = CommandLine::getValue("optionsFile").getString(); 350 boost::filesystem::path filepath(Core::getConfigPath() / filename);351 349 352 350 // look for additional arguments in given file or start.ini as default 353 351 // They will not overwrite the arguments given directly 354 352 std::ifstream file; 355 file.open( filepath.string().c_str());353 file.open((Core::getConfigPathString() + filename).c_str()); 356 354 std::vector<std::string> args; 357 355 if (file) -
sandbox_light/src/libraries/core/Core.cc
r5782 r5789 64 64 #include "Clock.h" 65 65 #include "CommandLine.h" 66 #include "ConfigFileManager.h"67 #include "ConfigValueIncludes.h"68 #include "CoreIncludes.h"69 #include "DynLibManager.h"70 #include "Factory.h"71 #include "Identifier.h"72 #include "Language.h"73 66 #include "LuaState.h" 74 67 … … 85 78 Core* Core::singletonPtr_s = 0; 86 79 87 SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");88 80 SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files"); 89 81 SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file"); … … 98 90 destruction in the Core destructor. 99 91 */ 100 class CoreConfiguration : public OrxonoxClass92 class CoreConfiguration 101 93 { 102 94 public: … … 106 98 107 99 void initialise() 108 {109 RegisterRootObject(CoreConfiguration);110 this->setConfigValues();111 }112 113 /**114 @brief Function to collect the SetConfigValue-macro calls.115 */116 void setConfigValues()117 100 { 118 101 #ifdef NDEBUG … … 125 108 const unsigned int defaultLevelShell = 3; 126 109 #endif 127 SetConfigValue(softDebugLevelConsole_, defaultLevelConsole) 128 .description("The maximal level of debug output shown in the console") 129 .callback(this, &CoreConfiguration::debugLevelChanged); 130 SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile) 131 .description("The maximal level of debug output shown in the logfile") 132 .callback(this, &CoreConfiguration::debugLevelChanged); 133 SetConfigValue(softDebugLevelShell_, defaultLevelShell) 134 .description("The maximal level of debug output shown in the ingame shell") 135 .callback(this, &CoreConfiguration::debugLevelChanged); 136 137 SetConfigValue(language_, Language::getInstance().defaultLanguage_) 138 .description("The language of the ingame text") 139 .callback(this, &CoreConfiguration::languageChanged); 140 SetConfigValue(bInitializeRandomNumberGenerator_, true) 141 .description("If true, all random actions are different each time you start the game") 142 .callback(this, &CoreConfiguration::initializeRandomNumberGenerator); 110 softDebugLevelConsole_ = defaultLevelConsole; 111 softDebugLevelLogfile_ = defaultLevelLogfile; 112 softDebugLevelShell_ = defaultLevelShell; 113 this->debugLevelChanged(); 114 115 bInitializeRandomNumberGenerator_ = true; 116 this->initializeRandomNumberGenerator(); 143 117 } 144 118 … … 159 133 OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_); 160 134 OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell, this->softDebugLevelShell_); 161 }162 163 /**164 @brief Callback function if the language has changed.165 */166 void languageChanged()167 {168 // Read the translation file after the language was configured169 Language::getInstance().readTranslatedLanguageFile();170 }171 172 /**173 @brief Sets the language in the config-file back to the default.174 */175 void resetLanguage()176 {177 ResetConfigValue(language_);178 135 } 179 136 … … 193 150 int softDebugLevelLogfile_; //!< The debug level for the logfile 194 151 int softDebugLevelShell_; //!< The debug level for the ingame shell 195 std::string language_; //!< The language196 152 bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called 197 153 … … 199 155 boost::filesystem::path rootPath_; 200 156 boost::filesystem::path executablePath_; //!< Path to the executable 201 boost::filesystem::path modulePath_; //!< Path to the modules202 157 boost::filesystem::path dataPath_; //!< Path to the data file folder 203 158 boost::filesystem::path configPath_; //!< Path to the config file folder … … 208 163 Core::Core(const std::string& cmdLine) 209 164 // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands) 210 : identifierDestroyer_(Identifier::destroyAllIdentifiers) 211 , configuration_(new CoreConfiguration()) // Don't yet create config values! 165 : configuration_(new CoreConfiguration()) // Don't yet create config values! 212 166 , bDevRun_(false) 213 167 { 214 168 // Set the hard coded fixed paths 215 169 this->setFixedPaths(); 216 217 // Create a new dynamic library manager218 this->dynLibManager_.reset(new DynLibManager());219 220 // Load modules221 try222 {223 // We search for helper files with the following extension224 std::string moduleextension = specialConfig::moduleExtension;225 size_t moduleextensionlength = moduleextension.size();226 227 // Search in the directory of our executable228 boost::filesystem::path searchpath = this->configuration_->modulePath_;229 230 // Add that path to the PATH variable in case a module depends on another one231 std::string pathVariable = getenv("PATH");232 putenv(const_cast<char*>(("PATH=" + pathVariable + ";" + configuration_->modulePath_.string()).c_str()));233 234 boost::filesystem::directory_iterator file(searchpath);235 boost::filesystem::directory_iterator end;236 237 // Iterate through all files238 while (file != end)239 {240 std::string filename = file->BOOST_LEAF_FUNCTION();241 242 // Check if the file ends with the exension in question243 if (filename.size() > moduleextensionlength)244 {245 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)246 {247 // We've found a helper file - now load the library with the same name248 std::string library = filename.substr(0, filename.size() - moduleextensionlength);249 boost::filesystem::path librarypath = searchpath / library;250 251 try252 {253 DynLibManager::getInstance().load(librarypath.string());254 }255 catch (...)256 {257 COUT(1) << "Couldn't load module \"" << librarypath.string() << "\": " << Exception::handleMessage() << std::endl;258 }259 }260 }261 262 ++file;263 }264 }265 catch (...)266 {267 COUT(1) << "An error occurred while loading modules: " << Exception::handleMessage() << std::endl;268 }269 170 270 171 // Parse command line arguments AFTER the modules have been loaded (static code!) … … 293 194 setThreadAffinity(static_cast<unsigned int>(limitToCPU)); 294 195 #endif 295 296 // Manage ini files and set the default settings file (usually orxonox.ini)297 this->configFileManager_.reset(new ConfigFileManager());298 this->configFileManager_->setFilename(ConfigFileType::Settings,299 CommandLine::getValue("settingsFile").getString());300 301 // Required as well for the config values302 this->languageInstance_.reset(new Language());303 304 // creates the class hierarchy for all classes with factories305 Factory::createClassHierarchy();306 196 307 197 // Do this soon after the ConfigFileManager has been created to open up the … … 360 250 } 361 251 362 /**363 @brief Returns the configured language.364 */365 /*static*/ const std::string& Core::getLanguage()366 {367 return Core::getInstance().configuration_->language_;368 }369 370 /**371 @brief Sets the language in the config-file back to the default.372 */373 /*static*/ void Core::resetLanguage()374 {375 Core::getInstance().configuration_->resetLanguage();376 }377 378 252 /*static*/ const boost::filesystem::path& Core::getDataPath() 379 253 { … … 524 398 COUT(1) << "Running from the build tree." << std::endl; 525 399 Core::bDevRun_ = true; 526 configuration_->modulePath_ = specialConfig::moduleDevDirectory;527 400 } 528 401 else … … 539 412 if (configuration_->rootPath_.empty()) 540 413 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?"); 541 542 // Module path is fixed as well543 configuration_->modulePath_ = configuration_->rootPath_ / specialConfig::defaultModulePath;544 545 #else546 547 // There is no root path, so don't set it at all548 // Module path is fixed as well549 configuration_->modulePath_ = specialConfig::moduleInstallDirectory;550 414 551 415 #endif … … 626 490 } 627 491 } 628 629 void Core::preUpdate(const Clock& time)630 {631 }632 633 void Core::postUpdate(const Clock& time)634 {635 }636 492 } -
sandbox_light/src/libraries/core/Core.h
r5782 r5789 65 65 typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard; 66 66 friend class Singleton<Core>; 67 friend class Game;68 67 69 68 public: … … 82 81 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 83 82 static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); 84 static const std::string& getLanguage();85 static void resetLanguage();86 83 87 84 //! Returns the path to the data files as boost::filesystem::path … … 107 104 Core(const Core&); //!< Don't use (undefined symbol) 108 105 109 void preUpdate(const Clock& time);110 void postUpdate(const Clock& time);111 112 106 void setFixedPaths(); 113 107 void setConfigurablePaths(); … … 115 109 116 110 // Mind the order for the destruction! 117 scoped_ptr<DynLibManager> dynLibManager_;118 111 scoped_ptr<SignalHandler> signalHandler_; 119 SimpleScopeGuard identifierDestroyer_;120 scoped_ptr<ConfigFileManager> configFileManager_;121 scoped_ptr<Language> languageInstance_;122 112 scoped_ptr<CoreConfiguration> configuration_; 123 113 -
sandbox_light/src/libraries/util/CMakeLists.txt
r5782 r5789 19 19 20 20 SET_SOURCE_FILES(UTIL_SRC_FILES 21 CRC32.cc22 21 Exception.cc 23 ExprParser.cc24 22 Math.cc 25 23 MultiType.cc 26 24 OutputBuffer.cc 27 25 OutputHandler.cc 28 Scope.cc29 26 SignalHandler.cc 30 27 Sleep.cc … … 43 40 "UTIL_SHARED_BUILD" 44 41 LINK_LIBRARIES 45 ${CEGUI_LIBRARY} 46 ${OGRE_LIBRARY} 42 ogremath_orxonox 47 43 SOURCE_FILES 48 44 ${UTIL_SRC_FILES} -
sandbox_light/src/libraries/util/Math.cc
r5738 r5789 34 34 #include "Math.h" 35 35 36 #include <OgrePlane.h>37 38 36 #include "MathConvert.h" 39 37 #include "SubString.h" 40 // Do not remove this include, it avoids linker errors.41 #include "mbool.h"42 38 43 39 namespace orxonox … … 81 77 degree = temp; 82 78 return in; 83 }84 85 86 /**87 @brief Gets the angle between my viewing direction and the direction to the position of the other object.88 @param myposition My position89 @param mydirection My viewing direction90 @param otherposition The position of the other object91 @return The angle92 93 @example94 If the other object is exactly in front of me, the function returns 0.95 If the other object is exactly behind me, the function returns pi.96 If the other object is exactly right/left to me (or above/below), the function returns pi/2.97 */98 float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition)99 {100 orxonox::Vector3 distance = otherposition - myposition;101 float distancelength = distance.length();102 if (distancelength == 0)103 return 0;104 else105 return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1));106 }107 108 /**109 @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object.110 @param myposition My position111 @param mydirection My viewing direction112 @param myorthonormal My orthonormalvector (pointing upwards through my head)113 @param otherposition The position of the other object114 @return The viewing direction115 116 @example117 If the other object is exactly in front of me, the function returns Vector2(0, 0).118 If the other object is exactly at my left, the function returns Vector2(-1, 0).119 If the other object is exactly at my right, the function returns Vector2(1, 0).120 If the other object is only a bit at my right, the function still returns Vector2(1, 0).121 If the other object is exactly above me, the function returns Vector2(0, 1).122 */123 orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)124 {125 orxonox::Vector3 distance = otherposition - myposition;126 127 // project difference vector on our plane128 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);129 130 float projectionlength = projection.length();131 if (projectionlength == 0)132 {133 if (myposition.dotProduct(otherposition) >= 0)134 return orxonox::Vector2(0, 0);135 else136 return orxonox::Vector2(0, 1);137 }138 139 float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);140 float sin_value = sqrt( 1 - cos_value*cos_value );141 142 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)143 return orxonox::Vector2( sin_value, cos_value );144 else145 return orxonox::Vector2( -sin_value, cos_value );146 }147 148 /**149 @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0° = 0, 180° = 1).150 @param myposition My position151 @param mydirection My viewing direction152 @param myorthonormal My orthonormalvector (pointing upwards through my head)153 @param otherposition The position of the other object154 @return The viewing direction155 156 @example157 If the other object is exactly in front of me, the function returns Vector2(0, 0).158 If the other object is exactly at my left, the function returns Vector2(-0.5, 0).159 If the other object is exactly at my right, the function returns Vector2(0.5, 0).160 If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).161 If the other object is exactly above me, the function returns Vector2(0, 0.5).162 */163 orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)164 {165 orxonox::Vector3 distance = otherposition - myposition;166 167 // project difference vector on our plane168 orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);169 170 float projectionlength = projection.length();171 if (projectionlength == 0)172 {173 if (myposition.dotProduct(otherposition) >= 0)174 return orxonox::Vector2(0, 0);175 else176 return orxonox::Vector2(0, 1);177 }178 //float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));179 180 float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);181 float sin_value = sqrt( 1 - cos_value*cos_value );182 183 float distancelength = distance.length();184 if (distancelength == 0) return orxonox::Vector2(0, 0);185 float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI;186 187 if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)188 return orxonox::Vector2( sin_value * radius, cos_value * radius);189 else190 return orxonox::Vector2( -sin_value * radius, cos_value * radius);191 }192 193 /**194 @brief Returns the predicted position I have to aim at, if I want to hit a moving target with a moving projectile.195 @param myposition My position196 @param projectilespeed The speed of my projectile197 @param targetposition The position of my target198 @param targetvelocity The velocity of my target199 @return The predicted position200 201 The function predicts the position based on a linear velocity of the target. If the target changes speed or direction, the projectile will miss.202 */203 orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity)204 {205 float squaredProjectilespeed = projectilespeed * projectilespeed;206 orxonox::Vector3 distance = targetposition - myposition;207 float a = distance.squaredLength();208 float b = 2 * (distance.x + distance.y + distance.z) * (targetvelocity.x + targetvelocity.y + targetvelocity.z);209 float c = targetvelocity.squaredLength();210 211 float temp = 4*squaredProjectilespeed*c + a*a - 4*b*c;212 if (temp < 0)213 return orxonox::Vector3::ZERO;214 215 temp = sqrt(temp);216 float time = (temp + a) / (2 * (squaredProjectilespeed - b));217 return (targetposition + targetvelocity * time);218 79 } 219 80 -
sandbox_light/src/libraries/util/Math.h
r5738 r5789 40 40 #include <cmath> 41 41 42 #include < OgreMath.h>43 #include < OgreVector2.h>44 #include < OgreVector3.h>45 #include < OgreVector4.h>46 #include < OgreQuaternion.h>47 #include < OgreColourValue.h>42 #include <ogremath/OgreMath.h> 43 #include <ogremath/OgreVector2.h> 44 #include <ogremath/OgreVector3.h> 45 #include <ogremath/OgreVector4.h> 46 #include <ogremath/OgreQuaternion.h> 47 #include <ogremath/OgreColourValue.h> 48 48 49 49 // Certain headers might define unwanted macros... … … 63 63 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree); 64 64 _UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree); 65 66 _UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);67 _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);68 _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);69 _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);70 65 71 66 /** -
sandbox_light/src/libraries/util/MultiType.h
r5738 r5789 71 71 #include <cassert> 72 72 #include <string> 73 #include < OgreVector2.h>74 #include < OgreVector3.h>75 #include < OgreVector4.h>76 #include < OgreQuaternion.h>77 #include < OgreColourValue.h>73 #include <ogremath/OgreVector2.h> 74 #include <ogremath/OgreVector3.h> 75 #include <ogremath/OgreVector4.h> 76 #include <ogremath/OgreQuaternion.h> 77 #include <ogremath/OgreColourValue.h> 78 78 79 79 #include "TypeTraits.h" -
sandbox_light/src/orxonox/CMakeLists.txt
r5782 r5789 26 26 SET_SOURCE_FILES(ORXONOX_SRC_FILES 27 27 Main.cc 28 GSRoot.cc29 28 ) 30 29 31 30 ORXONOX_ADD_LIBRARY(orxonox 32 31 FIND_HEADER_FILES 32 TOLUA_FILES 33 Main.h 33 34 DEFINE_SYMBOL 34 35 "ORXONOX_SHARED_BUILD" -
sandbox_light/src/orxonox/Main.cc
r5782 r5789 35 35 36 36 #include "OrxonoxPrereqs.h" 37 #include "SpecialConfig.h"38 37 39 #include "util/Exception.h"40 38 #include "core/CommandLine.h" 41 #include "core/Game.h" 39 #include "core/Core.h" 40 #include "core/Clock.h" 42 41 #include "core/LuaState.h" 42 #include "ToluaBindOrxonox.h" 43 43 #include "Main.h" 44 45 DeclareToluaInterface(Orxonox); 44 46 45 47 namespace orxonox 46 48 { 49 void sandbox() 50 { 51 } 52 47 53 /** 48 54 @brief … … 51 57 int main(const std::string& strCmdLine) 52 58 { 53 Game* game = new Game(strCmdLine); 59 // Create the Core 60 Core* core = new Core(strCmdLine); 61 // Set up a basic clock to keep time 62 Clock* clock = new Clock(); 54 63 55 game->setStateHierarchy( 56 "root" 57 ); 64 sandbox(); 58 65 59 game->requestState("root"); 60 61 game->run(); 62 delete game; 63 66 delete clock; 67 delete core; 64 68 return 0; 65 69 }
Note: See TracChangeset
for help on using the changeset viewer.