From 4e7a056e9e1d3e8c21e107ec3e4d97395144f205 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 27 Mar 2011 23:28:46 +0400 Subject: [PATCH 01/36] Now working mac app bundle generated during build (includes plugins & resources). Still need to copy frameworks before deployment. FindOGRE.cmake finds Ogre plugins dir on OS X. Default OS X data path set to the data subdir near .app. README_Mac updated. --- CMakeLists.txt | 55 ++++++++++++++---- README_Mac.md | 32 +++-------- cmake/FindOGRE.cmake | 21 ++++++- extern/caelum/CMakeLists.txt | 92 ++++++++++++++++--------------- extern/mygui_3.0.1/CMakeLists.txt | 6 +- files/plugins.cfg.mac | 2 +- 6 files changed, 125 insertions(+), 83 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 957fc1b8a..8f21728bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ project(OpenMW) +IF (APPLE) + set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app") +ENDIF (APPLE) + # Sound source selection option(USE_AUDIERE "use Audiere for sound" OFF) option(USE_FFMPEG "use ffmpeg for sound" OFF) @@ -14,7 +18,7 @@ if(DPKG_PROGRAM) else() if (APPLE) # set path inside bundle - set(MORROWIND_DATA_FILES "Contents/Resources/data" CACHE PATH "location of Morrowind data files") + set(MORROWIND_DATA_FILES "../data" CACHE PATH "location of Morrowind data files") set(MORROWIND_RESOURCE_FILES "Contents/Resources/resources" CACHE PATH "location of Morrowind data files") else() set(MORROWIND_DATA_FILES "data" CACHE PATH "location of Morrowind data files") @@ -286,25 +290,47 @@ add_definitions(-DCAELUM_STATIC) # Specify build paths -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}") +if (APPLE) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${APP_BUNDLE_DIR}/Contents/MacOS") +else (APPLE) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}") +endif (APPLE) # Other files if (WIN32) -configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32 - "${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY) + configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32 + "${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY) endif (WIN32) if (LINUX) -configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux - "${OpenMW_BINARY_DIR}/plugins.cfg") + configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux + "${OpenMW_BINARY_DIR}/plugins.cfg") endif (LINUX) if (APPLE) -configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac - "${OpenMW_BINARY_DIR}/plugins.cfg") + configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac + "${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg") + + configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist + "${APP_BUNDLE_DIR}/Contents/Info.plist" COPYONLY) + + configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns + "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) + + + # prepare plugins + configure_file(${OGRE_PLUGIN_DIR}/RenderSystem_GL.dylib + "${APP_BUNDLE_DIR}/Contents/Plugins/RenderSystem_GL.dylib" COPYONLY) + + configure_file(${OGRE_PLUGIN_DIR}/Plugin_OctreeSceneManager.dylib + "${APP_BUNDLE_DIR}/Contents/Plugins/Plugin_OctreeSceneManager.dylib" COPYONLY) + + configure_file(${OGRE_PLUGIN_DIR}/Plugin_ParticleFX.dylib + "${APP_BUNDLE_DIR}/Contents/Plugins/Plugin_ParticleFX.dylib" COPYONLY) + endif (APPLE) configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg - "${OpenMW_BINARY_DIR}/openmw.cfg") + "${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg") # Compiler settings if (CMAKE_COMPILER_IS_GNUCC) @@ -315,10 +341,15 @@ endif (CMAKE_COMPILER_IS_GNUCC) # Apple bundling if (APPLE) set(MISC_FILES - ${OpenMW_BINARY_DIR}/openmw.cfg - ${OpenMW_BINARY_DIR}/plugins.cfg) + ${APP_BUNDLE_DIR}/Contents/MacOS/openmw.cfg + ${APP_BUNDLE_DIR}/Contents/MacOS/plugins.cfg) + + set(OGRE_PLUGINS + ${APP_BUNDLE_DIR}/Contents/Plugins/*) + install(FILES ${MISC_FILES} DESTINATION ../MacOS) -install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ../Resources) +install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..) +install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources) set(CPACK_GENERATOR "Bundle") set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist") set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns") diff --git a/README_Mac.md b/README_Mac.md index ee5faca98..39382e0c9 100644 --- a/README_Mac.md +++ b/README_Mac.md @@ -49,8 +49,8 @@ Getting OpenMW Working --link-shared,static --prefix=$OMW_LIB_PREFIX install -5. Download [Ogre][] SDK (tested with 1.7.2) and move `lib/Release/Ogre.framework` into - `Library/Frameworks`. +5. Download [Ogre][] SDK (tested with 1.7.2), unpack it and move +`lib/Release/Ogre.framework` into `Library/Frameworks`. 6. Download [OIS][] and use the XCode project provided in `ois/Mac/XCode-2.2`. Be sure to set your build architecture to @@ -92,6 +92,7 @@ Getting OpenMW Working $ cd /path/to/open/build/dir $ cmake \ -D CMAKE_OSX_ARCHITECTURES=i386 \ + -D OGRESDK=/path/to/ogre/sdk \ -D BOOST_INCLUDEDIR=$OMW_LIB_PREFIX/include/boost-1_45 \ -D BOOST_LIBRARYDIR=$OMW_LIB_PREFIX/lib \ -D SNDFILE_INCLUDE_DIR=$OMW_LIB_PREFIX/include \ @@ -108,32 +109,17 @@ Getting OpenMW Working You can use -G"Xcode" if you prefer Xcode, or -G"Eclipse CDT4 - Unix Makefiles" if you prefer Eclipse. You also can specify -D CMAKE_BUILD_TYPE=Debug for debug build. - -11. In build directory create directory for game resources: - $ cd /path/to/openmw/build/dir - $ mkdir Contents - $ mkdir Contents/Resources - $ mkdir Contents/Plugins - Copy Ogre plugins from Ogre SDK to Plugins subdir: - $ cp /path/to/ogre/sdk/lib/*.dylib Contents/Plugins - Create symlink to resources subdirectory: - $ ln -s resources Contents/Resources/resources - Create symlinks for *.cfg files: - $ ln -s plugins.cfg Contents/MacOS/plugins.cfg - $ ln -s openmw.cfg Contents/MacOS/openmw.cfg -12. Move your Morrowind `Data Files` directory into the `Contents/Resources` +11. Copy your Morrowind `Data Files` directory into the OpenMW build dir with the name `data` or create symlink: - $ ln -s /path/to/morrowind/data/files Contents/Resources/data + $ ln -s /path/to/morrowind/data/files /path/to/openmw/build/dir/data -13. From your build directory run: - $ ./openmw +12. From your build directory run: + $ OpenMW.app/Contents/MacOS/openmw + or: + $ open OpenMW.app Enjoy! -14. Optionally you can create .app bundle: - $ make package - But for now you shold manually copy Contents directory from build directory to bundle - (because there is no plugins and resources in generated .app). [boost]: http://www.boost.org diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index eebb20338..ce3993805 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -12,9 +12,9 @@ # For details see the accompanying COPYING-CMAKE-SCRIPTS file. CMAKE_POLICY(PUSH) -IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR) +IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR AND OGRE_PLUGIN_DIR) SET(OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent -ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR) +ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR AND OGRE_PLUGIN_DIR) IF (WIN32) #Windows MESSAGE(STATUS "Looking for OGRE") @@ -47,7 +47,16 @@ IF (UNIX AND NOT APPLE) PKG_CHECK_MODULES(OGRE OGRE) ENDIF (UNIX AND NOT APPLE) +# on OS X we need Ogre SDK because framework doesn't include all libs, just Ogre Main lib IF (APPLE) + IF (OGRESDK) + MESSAGE(STATUS "Using Ogre SDK") + SET(OGRE_LIB_DIR ${OGRESDK}/lib) + ELSE (OGRESDK) + MESSAGE(FATAL_ERROR "Path to Ogre SDK not specified. Specify OGRESDK.") + ENDIF (OGRESDK) + + FIND_PATH(OGRE_INCLUDE_DIR Ogre.h PATHS /Library/Frameworks @@ -71,7 +80,12 @@ SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "") if(OGRE_LIB_DIR) CMAKE_POLICY(SET CMP0009 NEW) - FILE(GLOB_RECURSE OGRE_PLUGINS "${OGRE_LIB_DIR}/Plugin_*.so") + IF (NOT APPLE) + FILE(GLOB_RECURSE OGRE_PLUGINS "${OGRE_LIB_DIR}/Plugin_*.so") + ENDIF (NOT APPLE) + IF (APPLE) + FILE(GLOB_RECURSE OGRE_PLUGINS "${OGRE_LIB_DIR}/Plugin_*.dylib") + ENDIF (APPLE) FOREACH (OGRE_PLUGINS_FILE ${OGRE_PLUGINS}) STRING(REGEX REPLACE "/[^/]*$" "" OGRE_PLUGIN_DIR ${OGRE_PLUGINS_FILE}) ENDFOREACH(OGRE_PLUGINS_FILE) @@ -85,6 +99,7 @@ IF (OGRE_FOUND) IF (NOT OGRE_FIND_QUIETLY) MESSAGE(STATUS " libraries : ${OGRE_LIBRARIES} from ${OGRE_LIB_DIR}") MESSAGE(STATUS " includes : ${OGRE_INCLUDE_DIR}") + MESSAGE(STATUS " plugins : ${OGRE_PLUGIN_DIR}") ENDIF (NOT OGRE_FIND_QUIETLY) ELSE (OGRE_FOUND) IF (OGRE_FIND_REQUIRED) diff --git a/extern/caelum/CMakeLists.txt b/extern/caelum/CMakeLists.txt index c1854904c..88ed51fad 100755 --- a/extern/caelum/CMakeLists.txt +++ b/extern/caelum/CMakeLists.txt @@ -19,46 +19,52 @@ add_library(caelum STATIC ${SOURCES}) # # Resources # -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/AtmosphereDepth.png "${OpenMW_BINARY_DIR}/resources/caelum/AtmosphereDepth.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumGroundFog.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumGroundFog.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumLayeredClouds.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumLayeredClouds.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPhaseMoon.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumPhaseMoon.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPointStarfield.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumPointStarfield.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumSkyDome.cg "${OpenMW_BINARY_DIR}/resources/caelum/CaelumSkyDome.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CloudCoverLookup.png "${OpenMW_BINARY_DIR}/resources/caelum/CloudCoverLookup.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.cg "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.compositor "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.compositor" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.material "${OpenMW_BINARY_DIR}/resources/caelum/DepthComposer.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthRender.program "${OpenMW_BINARY_DIR}/resources/caelum/DepthRender.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/EarthClearSky2.png "${OpenMW_BINARY_DIR}/resources/caelum/EarthClearSky2.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.material "${OpenMW_BINARY_DIR}/resources/caelum/GroundFog.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.program "${OpenMW_BINARY_DIR}/resources/caelum/GroundFog.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Haze.program "${OpenMW_BINARY_DIR}/resources/caelum/Haze.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/LayeredClouds.material "${OpenMW_BINARY_DIR}/resources/caelum/LayeredClouds.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.cg "${OpenMW_BINARY_DIR}/resources/caelum/MinimalCompositorVP.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.program "${OpenMW_BINARY_DIR}/resources/caelum/MinimalCompositorVP.program" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon.material "${OpenMW_BINARY_DIR}/resources/caelum/moon.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon_disc.dds "${OpenMW_BINARY_DIR}/resources/caelum/moon_disc.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise1.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise1.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise2.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise2.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise3.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise3.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise4.dds "${OpenMW_BINARY_DIR}/resources/caelum/noise4.dds" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/PointStarfield.material "${OpenMW_BINARY_DIR}/resources/caelum/PointStarfield.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.cg "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.cg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.compositor "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.compositor" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.material "${OpenMW_BINARY_DIR}/resources/caelum/Precipitation.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_drizzle.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_drizzle.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_hail.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_hail.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icecrystals.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_icecrystals.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icepellets.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_icepellets.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_rain.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_rain.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_smallhail.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_smallhail.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snow.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_snow.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snowgrains.png "${OpenMW_BINARY_DIR}/resources/caelum/precipitation_snowgrains.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SkyDome.material "${OpenMW_BINARY_DIR}/resources/caelum/SkyDome.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sphere.mesh "${OpenMW_BINARY_DIR}/resources/caelum/sphere.mesh" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.jpg "${OpenMW_BINARY_DIR}/resources/caelum/Starfield.jpg" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.material "${OpenMW_BINARY_DIR}/resources/caelum/Starfield.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Sun.material "${OpenMW_BINARY_DIR}/resources/caelum/Sun.material" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SunGradient.png "${OpenMW_BINARY_DIR}/resources/caelum/SunGradient.png" COPYONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sun_disc.png "${OpenMW_BINARY_DIR}/resources/caelum/sun_disc.png" COPYONLY) +if (APPLE) + SET(CAELUM_RES_DEST "${APP_BUNDLE_DIR}/Contents/Resources") +else (APPLE) + SET(CAELUM_RES_DEST "${OpenMW_BINARY_DIR}") +endif (APPLE) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/AtmosphereDepth.png "${CAELUM_RES_DEST}/resources/caelum/AtmosphereDepth.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumGroundFog.cg "${CAELUM_RES_DEST}/resources/caelum/CaelumGroundFog.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumLayeredClouds.cg "${CAELUM_RES_DEST}/resources/caelum/CaelumLayeredClouds.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPhaseMoon.cg "${CAELUM_RES_DEST}/resources/caelum/CaelumPhaseMoon.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumPointStarfield.cg "${CAELUM_RES_DEST}/resources/caelum/CaelumPointStarfield.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CaelumSkyDome.cg "${CAELUM_RES_DEST}/resources/caelum/CaelumSkyDome.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/CloudCoverLookup.png "${CAELUM_RES_DEST}/resources/caelum/CloudCoverLookup.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.cg "${CAELUM_RES_DEST}/resources/caelum/DepthComposer.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.compositor "${CAELUM_RES_DEST}/resources/caelum/DepthComposer.compositor" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthComposer.material "${CAELUM_RES_DEST}/resources/caelum/DepthComposer.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/DepthRender.program "${CAELUM_RES_DEST}/resources/caelum/DepthRender.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/EarthClearSky2.png "${CAELUM_RES_DEST}/resources/caelum/EarthClearSky2.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.material "${CAELUM_RES_DEST}/resources/caelum/GroundFog.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/GroundFog.program "${CAELUM_RES_DEST}/resources/caelum/GroundFog.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Haze.program "${CAELUM_RES_DEST}/resources/caelum/Haze.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/LayeredClouds.material "${CAELUM_RES_DEST}/resources/caelum/LayeredClouds.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.cg "${CAELUM_RES_DEST}/resources/caelum/MinimalCompositorVP.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/MinimalCompositorVP.program "${CAELUM_RES_DEST}/resources/caelum/MinimalCompositorVP.program" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon.material "${CAELUM_RES_DEST}/resources/caelum/moon.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/moon_disc.dds "${CAELUM_RES_DEST}/resources/caelum/moon_disc.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise1.dds "${CAELUM_RES_DEST}/resources/caelum/noise1.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise2.dds "${CAELUM_RES_DEST}/resources/caelum/noise2.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise3.dds "${CAELUM_RES_DEST}/resources/caelum/noise3.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/noise4.dds "${CAELUM_RES_DEST}/resources/caelum/noise4.dds" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/PointStarfield.material "${CAELUM_RES_DEST}/resources/caelum/PointStarfield.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.cg "${CAELUM_RES_DEST}/resources/caelum/Precipitation.cg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.compositor "${CAELUM_RES_DEST}/resources/caelum/Precipitation.compositor" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Precipitation.material "${CAELUM_RES_DEST}/resources/caelum/Precipitation.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_drizzle.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_drizzle.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_hail.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_hail.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icecrystals.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_icecrystals.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_icepellets.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_icepellets.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_rain.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_rain.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_smallhail.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_smallhail.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snow.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_snow.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/precipitation_snowgrains.png "${CAELUM_RES_DEST}/resources/caelum/precipitation_snowgrains.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SkyDome.material "${CAELUM_RES_DEST}/resources/caelum/SkyDome.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sphere.mesh "${CAELUM_RES_DEST}/resources/caelum/sphere.mesh" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.jpg "${CAELUM_RES_DEST}/resources/caelum/Starfield.jpg" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Starfield.material "${CAELUM_RES_DEST}/resources/caelum/Starfield.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/Sun.material "${CAELUM_RES_DEST}/resources/caelum/Sun.material" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/SunGradient.png "${CAELUM_RES_DEST}/resources/caelum/SunGradient.png" COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/sun_disc.png "${CAELUM_RES_DEST}/resources/caelum/sun_disc.png" COPYONLY) diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index d7e0bd483..8101ad91a 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -22,7 +22,11 @@ add_subdirectory(OgrePlatform) # Copy resource files into the build directory set(SDIR ${CMAKE_CURRENT_SOURCE_DIR}/openmw_resources) -set(DDIR ${OpenMW_BINARY_DIR}/resources/mygui) +if (APPLE) + set(DDIR ${APP_BUNDLE_DIR}/Contents/Resources/resources/mygui) +else (APPLE) + set(DDIR ${OpenMW_BINARY_DIR}/resources/mygui) +endif (APPLE) configure_file("${SDIR}/bigbars.png" "${DDIR}/bigbars.png" COPYONLY) configure_file("${SDIR}/black.png" "${DDIR}/black.png" COPYONLY) diff --git a/files/plugins.cfg.mac b/files/plugins.cfg.mac index 9fe2798f7..baaca4479 100644 --- a/files/plugins.cfg.mac +++ b/files/plugins.cfg.mac @@ -1,7 +1,7 @@ # Defines plugins to load # Define plugin folder -PluginFolder=${OGRE_PLUGIN_DIR} +PluginFolder= # Define plugins Plugin=RenderSystem_GL.dylib From beb1422c774e433ed3a65b9172d9c58cb8e8a45c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 29 Mar 2011 13:57:56 +0200 Subject: [PATCH 02/36] allow multiple --master and --plugin command line arguments --- apps/openmw/main.cpp | 49 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 4d7e6595c..697b06e93 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -47,8 +47,14 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) "set resources directory") ("start", bpo::value()->default_value ("Beshara"), "set initial cell") - ("master", bpo::value()->default_value ("Morrowind"), - "master file") + ("master", bpo::value >() + ->default_value (std::vector(), "") + ->multitoken(), + "master file(s)") + ("plugin", bpo::value >() + ->default_value (std::vector(), "") + ->multitoken(), + "plugin file(s)") ( "showfps", "show fps counter") ( "debug", "debug mode" ) ( "nosound", "disable all sound" ) @@ -83,26 +89,51 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) return false; } + // directory settings engine.setDataDir (variables["data"].as()); engine.setResourceDir (variables["resources"].as()); - engine.setCell (variables["start"].as()); - engine.addMaster (variables["master"].as()); - if (variables.count ("showfps")) + // master and plugin + std::vector master = variables["master"].as >(); + if (master.empty()) + { + std::cout << "No master file given. Assuming Morrowind.esm" << std::endl; + master.push_back ("Morrowind"); + } + + if (master.size()>1) + { + std::cout + << "Ignoring all but the first master file (multiple master files not yet supported)." + << std::endl; + } + + engine.addMaster (master[0]); + + std::vector plugin = variables["plugin"].as >(); + + if (!plugin.empty()) + std::cout << "Ignoring plugin files (plugins not yet supported)." << std::endl; + + // startup-settings + engine.setCell (variables["start"].as()); + + if (variables.count ("new-game")) + engine.setNewGame(); + + // other settings + if (variables.count ("fps")) engine.showFPS(); if (variables.count ("debug")) engine.enableDebugMode(); - if (variables.count ("nosound")) + if (variables.count ("no-sound")) engine.disableSound(); if (variables.count ("script-verbose")) engine.enableVerboseScripts(); - if (variables.count ("new-game")) - engine.setNewGame(); - if (variables.count ("script-all")) engine.setCompileAll (true); From 08784470bcb449d53478f99f8e467a094f97663b Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 1 Apr 2011 23:23:44 +0200 Subject: [PATCH 03/36] Update default version and add libbullet2.77 as a dependency --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49a4b9ecc..7dc5ba3f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,7 @@ if(DPKG_PROGRAM) set(PACKAGE_MAINTAINER "${GIT_NAME} <${GIT_EMAIL}>") else() #FIXME this should probably be read from some file like ${CMAKE_CURRENT_SOURCE_DIR}/VERSION or something that gets updated when changing version - set(VERSION_STRING "0.9.0") + set(VERSION_STRING "0.10.0") set(PACKAGE_MAINTAINER "unknown") endif() @@ -370,7 +370,7 @@ if(DPKG_PROGRAM) SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW") - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogremain-1.7.1 (>= 1.7.1-1), libboost-filesystem1.42.0 (>= 1.42.0), libboost-program-options1.42.0 (>= 1.42.0), libboost-system1.42.0 (>= 1.42.0), libboost-thread1.42.0 (>= 1.42.0), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.2.0 (>= 1.2.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogremain-1.7.1 (>= 1.7.1-1), libbullet2.77 (>= 2.77), libboost-filesystem1.42.0 (>= 1.42.0), libboost-program-options1.42.0 (>= 1.42.0), libboost-system1.42.0 (>= 1.42.0), libboost-thread1.42.0 (>= 1.42.0), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.2.0 (>= 1.2.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2)") SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") From 2e2d490c78ee606aaf80d67ec92e9616f8ad6122 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 1 Apr 2011 23:25:22 +0200 Subject: [PATCH 04/36] Remove unused variable (compiler warning) --- apps/openmw/mwrender/mwscene.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index 6fab00850..5117f7eb8 100644 --- a/apps/openmw/mwrender/mwscene.cpp +++ b/apps/openmw/mwrender/mwscene.cpp @@ -63,7 +63,6 @@ MWScene::~MWScene() std::pair MWScene::getFacedHandle (MWWorld::World& world) { std::string handle = ""; - float distance = -1; //get a ray pointing to the center of the viewport Ray centerRay = getCamera()->getCameraToViewportRay( From a94de768017996ad1f2838c1c2b190ae3b331aac Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Fri, 1 Apr 2011 23:35:56 +0200 Subject: [PATCH 05/36] Whitespace changes only tabs->spaces and removal of traling space (including mangle and openengline) --- apps/openmw/engine.hpp | 2 +- apps/openmw/mwrender/mwscene.cpp | 88 ++--- apps/openmw/mwrender/mwscene.hpp | 2 +- apps/openmw/mwworld/world.cpp | 4 +- apps/openmw/mwworld/world.hpp | 2 +- components/interpreter/installopcodes.cpp | 86 ++--- components/nif/nif_file.cpp | 4 +- components/nifbullet/bullet_nif_loader.cpp | 360 ++++++++++----------- components/nifbullet/bullet_nif_loader.hpp | 86 ++--- components/nifbullet/test/test.cpp | 270 ++++++++-------- libs/mangle | 2 +- libs/openengine | 2 +- 12 files changed, 454 insertions(+), 454 deletions(-) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 5e38ab28f..2f8a5b1d2 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -60,7 +60,7 @@ namespace OMW boost::filesystem::path mDataDir; boost::filesystem::path mResDir; OEngine::Render::OgreRenderer mOgre; - OEngine::Physic::PhysicEngine* mPhysicEngine; + OEngine::Physic::PhysicEngine* mPhysicEngine; std::string mCellName; std::string mMaster; bool mShowFPS; diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index 5117f7eb8..890bf2cd6 100644 --- a/apps/openmw/mwrender/mwscene.cpp +++ b/apps/openmw/mwrender/mwscene.cpp @@ -20,37 +20,37 @@ using namespace MWRender; using namespace Ogre; MWScene::MWScene(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng) - : rend(_rend) + : rend(_rend) { - eng = physEng; - rend.createScene("PlayerCam", 55, 5); + eng = physEng; + rend.createScene("PlayerCam", 55, 5); - // Set default mipmap level (NB some APIs ignore this) - TextureManager::getSingleton().setDefaultNumMipmaps(5); + // Set default mipmap level (NB some APIs ignore this) + TextureManager::getSingleton().setDefaultNumMipmaps(5); - // Load resources - ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); + // Load resources + ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); - // Turn the entire scene (represented by the 'root' node) -90 - // degrees around the x axis. This makes Z go upwards, and Y go into - // the screen (when x is to the right.) This is the orientation that - // Morrowind uses, and it automagically makes everything work as it - // should. - SceneNode *rt = rend.getScene()->getRootSceneNode(); - mwRoot = rt->createChildSceneNode(); - mwRoot->pitch(Degree(-90)); + // Turn the entire scene (represented by the 'root' node) -90 + // degrees around the x axis. This makes Z go upwards, and Y go into + // the screen (when x is to the right.) This is the orientation that + // Morrowind uses, and it automagically makes everything work as it + // should. + SceneNode *rt = rend.getScene()->getRootSceneNode(); + mwRoot = rt->createChildSceneNode(); + mwRoot->pitch(Degree(-90)); - //used to obtain ingame information of ogre objects (which are faced or selected) - mRaySceneQuery = rend.getScene()->createRayQuery(Ray()); + //used to obtain ingame information of ogre objects (which are faced or selected) + mRaySceneQuery = rend.getScene()->createRayQuery(Ray()); - Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode(); - playerNode->pitch(Degree(90)); - Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode(); - Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode(); - cameraPitchNode->attachObject(getCamera()); + Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode(); + playerNode->pitch(Degree(90)); + Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode(); + Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode(); + cameraPitchNode->attachObject(getCamera()); - mPlayer = new MWRender::Player (getCamera(), playerNode->getName()); + mPlayer = new MWRender::Player (getCamera(), playerNode->getName()); mFreeFly = true; } @@ -82,8 +82,8 @@ void MWScene::doPhysics (float duration, MWWorld::World& world, // stop changes to world from being reported back to the physics system MWWorld::DoingPhysics scopeGuard; - //set the DebugRenderingMode. To disable it,set it to 0 -// eng->setDebugRenderingMode(1); + //set the DebugRenderingMode. To disable it,set it to 0 + //eng->setDebugRenderingMode(1); //set the walkdirection to 0 (no movement) for every actor) for(std::map::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++) @@ -95,7 +95,7 @@ void MWScene::doPhysics (float duration, MWWorld::World& world, for (std::vector >::const_iterator iter (actors.begin()); iter!=actors.end(); ++iter) { - OEngine::Physic::PhysicActor* act = eng->getCharacter(iter->first); + OEngine::Physic::PhysicActor* act = eng->getCharacter(iter->first); //dirty stuff to get the camera orientation. Must be changed! @@ -117,46 +117,46 @@ void MWScene::doPhysics (float duration, MWWorld::World& world, dir = 0.025*(quat*dir1); } - //set the walk direction - act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); + //set the walk direction + act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); } - eng->stepSimulation(duration); + eng->stepSimulation(duration); for(std::map::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++) { OEngine::Physic::PhysicActor* act = it->second; - btVector3 newPos = act->getPosition(); + btVector3 newPos = act->getPosition(); MWWorld::Ptr ptr = world.getPtrViaHandle (it->first); - world.moveObject (ptr, newPos.x(), newPos.y(), newPos.z()); + world.moveObject (ptr, newPos.x(), newPos.y(), newPos.z()); } } void MWScene::addObject (const std::string& handle, const std::string& mesh, const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position) { - OEngine::Physic::RigidBody* body = eng->createRigidBody(mesh,handle); - eng->addRigidBody(body); - btTransform tr; - tr.setOrigin(btVector3(position.x,position.y,position.z)); - tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w)); - body->setWorldTransform(tr); + OEngine::Physic::RigidBody* body = eng->createRigidBody(mesh,handle); + eng->addRigidBody(body); + btTransform tr; + tr.setOrigin(btVector3(position.x,position.y,position.z)); + tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w)); + body->setWorldTransform(tr); } void MWScene::addActor (const std::string& handle, const std::string& mesh, const Ogre::Vector3& position) { - //TODO:optimize this. Searching the std::map isn't very efficient i think. - eng->addCharacter(handle); - OEngine::Physic::PhysicActor* act = eng->getCharacter(handle); - act->setPosition(btVector3(position.x,position.y,position.z)); + //TODO:optimize this. Searching the std::map isn't very efficient i think. + eng->addCharacter(handle); + OEngine::Physic::PhysicActor* act = eng->getCharacter(handle); + act->setPosition(btVector3(position.x,position.y,position.z)); } void MWScene::removeObject (const std::string& handle) { - //TODO:check if actor??? + //TODO:check if actor??? eng->removeCharacter(handle); - eng->removeRigidBody(handle); - eng->deleteRigidBody(handle); + eng->removeRigidBody(handle); + eng->deleteRigidBody(handle); } void MWScene::moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics) diff --git a/apps/openmw/mwrender/mwscene.hpp b/apps/openmw/mwrender/mwscene.hpp index aa567f7de..fd14fcce0 100644 --- a/apps/openmw/mwrender/mwscene.hpp +++ b/apps/openmw/mwrender/mwscene.hpp @@ -40,7 +40,7 @@ namespace MWRender Ogre::SceneNode *mwRoot; Ogre::RaySceneQuery *mRaySceneQuery; - OEngine::Physic::PhysicEngine* eng; + OEngine::Physic::PhysicEngine* eng; MWRender::Player *mPlayer; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index c08dc420b..63019349c 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -412,7 +412,7 @@ namespace MWWorld : mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mCurrentCell (0), mGlobalVariables (0), mSky (false), mCellChanged (false), mEnvironment (environment) { - mPhysEngine = physEng; + mPhysEngine = physEng; boost::filesystem::path masterPath (dataDir); masterPath /= master; @@ -437,7 +437,7 @@ namespace MWWorld mSkyManager = MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera(), resDir); - mPhysEngine = physEng; + mPhysEngine = physEng; } World::~World() diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index d64fa57be..6965aebc6 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -75,7 +75,7 @@ namespace MWWorld bool mCellChanged; Environment& mEnvironment; - OEngine::Physic::PhysicEngine* mPhysEngine; + OEngine::Physic::PhysicEngine* mPhysEngine; // not implemented World (const World&); diff --git a/components/interpreter/installopcodes.cpp b/components/interpreter/installopcodes.cpp index 2e22d10e5..f383ff47c 100644 --- a/components/interpreter/installopcodes.cpp +++ b/components/interpreter/installopcodes.cpp @@ -24,23 +24,23 @@ namespace Interpreter interpreter.installSegment5 (8, new OpNegateFloat); interpreter.installSegment5 (17, new OpIntToFloat1); interpreter.installSegment5 (18, new OpFloatToInt1); - + // local variables, global variables & literals interpreter.installSegment5 (0, new OpStoreLocalShort); interpreter.installSegment5 (1, new OpStoreLocalLong); - interpreter.installSegment5 (2, new OpStoreLocalFloat); - interpreter.installSegment5 (4, new OpFetchIntLiteral); - interpreter.installSegment5 (5, new OpFetchFloatLiteral); + interpreter.installSegment5 (2, new OpStoreLocalFloat); + interpreter.installSegment5 (4, new OpFetchIntLiteral); + interpreter.installSegment5 (5, new OpFetchFloatLiteral); interpreter.installSegment5 (21, new OpFetchLocalShort); interpreter.installSegment5 (22, new OpFetchLocalLong); - interpreter.installSegment5 (23, new OpFetchLocalFloat); + interpreter.installSegment5 (23, new OpFetchLocalFloat); interpreter.installSegment5 (39, new OpStoreGlobalShort); interpreter.installSegment5 (40, new OpStoreGlobalLong); - interpreter.installSegment5 (41, new OpStoreGlobalFloat); + interpreter.installSegment5 (41, new OpStoreGlobalFloat); interpreter.installSegment5 (42, new OpFetchGlobalShort); interpreter.installSegment5 (43, new OpFetchGlobalLong); - interpreter.installSegment5 (44, new OpFetchGlobalFloat); - + interpreter.installSegment5 (44, new OpFetchGlobalFloat); + // math interpreter.installSegment5 (9, new OpAddInt); interpreter.installSegment5 (10, new OpAddInt); @@ -50,57 +50,57 @@ namespace Interpreter interpreter.installSegment5 (14, new OpMulInt); interpreter.installSegment5 (15, new OpDivInt); interpreter.installSegment5 (16, new OpDivInt); - interpreter.installSegment5 (19, new OpSquareRoot); - interpreter.installSegment5 (26, - new OpCompare >); - interpreter.installSegment5 (27, - new OpCompare >); - interpreter.installSegment5 (28, - new OpCompare >); - interpreter.installSegment5 (29, - new OpCompare >); - interpreter.installSegment5 (30, - new OpCompare >); - interpreter.installSegment5 (31, - new OpCompare >); - - interpreter.installSegment5 (32, - new OpCompare >); - interpreter.installSegment5 (33, - new OpCompare >); - interpreter.installSegment5 (34, - new OpCompare >); - interpreter.installSegment5 (35, - new OpCompare >); - interpreter.installSegment5 (36, - new OpCompare >); - interpreter.installSegment5 (37, - new OpCompare >); - + interpreter.installSegment5 (19, new OpSquareRoot); + interpreter.installSegment5 (26, + new OpCompare >); + interpreter.installSegment5 (27, + new OpCompare >); + interpreter.installSegment5 (28, + new OpCompare >); + interpreter.installSegment5 (29, + new OpCompare >); + interpreter.installSegment5 (30, + new OpCompare >); + interpreter.installSegment5 (31, + new OpCompare >); + + interpreter.installSegment5 (32, + new OpCompare >); + interpreter.installSegment5 (33, + new OpCompare >); + interpreter.installSegment5 (34, + new OpCompare >); + interpreter.installSegment5 (35, + new OpCompare >); + interpreter.installSegment5 (36, + new OpCompare >); + interpreter.installSegment5 (37, + new OpCompare >); + // control structures - interpreter.installSegment5 (20, new OpReturn); + interpreter.installSegment5 (20, new OpReturn); interpreter.installSegment5 (24, new OpSkipZero); interpreter.installSegment5 (25, new OpSkipNonZero); interpreter.installSegment0 (1, new OpJumpForward); interpreter.installSegment0 (2, new OpJumpBackward); - + // misc - interpreter.installSegment3 (0, new OpMessageBox); - interpreter.installSegment5 (38, new OpMenuMode); - interpreter.installSegment5 (45, new OpRandom); - interpreter.installSegment5 (50, new OpGetSecondsPassed); + interpreter.installSegment3 (0, new OpMessageBox); + interpreter.installSegment5 (38, new OpMenuMode); + interpreter.installSegment5 (45, new OpRandom); + interpreter.installSegment5 (50, new OpGetSecondsPassed); interpreter.installSegment5 (51, new OpEnable); interpreter.installSegment5 (52, new OpDisable); interpreter.installSegment5 (53, new OpGetDisabled); interpreter.installSegment5 (54, new OpEnableExplicit); interpreter.installSegment5 (55, new OpDisableExplicit); interpreter.installSegment5 (56, new OpGetDisabledExplicit); - + // script control interpreter.installSegment5 (46, new OpScriptRunning); interpreter.installSegment5 (47, new OpStartScript); interpreter.installSegment5 (48, new OpStopScript); - + // spacial interpreter.installSegment5 (49, new OpGetDistance); interpreter.installSegment5 (57, new OpGetDistanceExplicit); diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 6a4eb337c..3c7d7fb17 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -92,8 +92,8 @@ void NIFFile::parse() else if(rec == "NiRotatingParticles") { r = new NiRotatingParticles; r->recType = RC_NiRotatingParticles; } else if(rec == "NiAutoNormalParticles") { r = new NiAutoNormalParticles; r->recType = RC_NiAutoNormalParticles; } else if(rec == "NiCamera") { r = new NiCamera; r->recType = RC_NiCamera; } - else if(rec == "RootCollisionNode"){ r = new NiNode; r->recType = RC_RootCollisionNode; }// a root collision node is exactly like a node - //that's why there is no need to create a new type + else if(rec == "RootCollisionNode"){ r = new NiNode; r->recType = RC_RootCollisionNode; }// a root collision node is exactly like a node + //that's why there is no need to create a new type // Properties else if(rec == "NiTexturingProperty") { r = new NiTexturingProperty; r->recType = RC_NiTexturingProperty; } diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index b3fd9019c..1ff78023d 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -54,264 +54,264 @@ using namespace Mangle::VFS; //==================================================================================================== Ogre::Matrix3 ManualBulletShapeLoader::getMatrix(Nif::Transformation* tr) { - Ogre::Matrix3 rot(tr->rotation.v[0].array[0],tr->rotation.v[0].array[1],tr->rotation.v[0].array[2], - tr->rotation.v[1].array[0],tr->rotation.v[1].array[1],tr->rotation.v[1].array[2], - tr->rotation.v[2].array[0],tr->rotation.v[2].array[1],tr->rotation.v[2].array[2]); - return rot; + Ogre::Matrix3 rot(tr->rotation.v[0].array[0],tr->rotation.v[0].array[1],tr->rotation.v[0].array[2], + tr->rotation.v[1].array[0],tr->rotation.v[1].array[1],tr->rotation.v[1].array[2], + tr->rotation.v[2].array[0],tr->rotation.v[2].array[1],tr->rotation.v[2].array[2]); + return rot; } Ogre::Vector3 ManualBulletShapeLoader::getVector(Nif::Transformation* tr) { - Ogre::Vector3 vect3(tr->pos.array[0],tr->pos.array[1],tr->pos.array[2]); - return vect3; + Ogre::Vector3 vect3(tr->pos.array[0],tr->pos.array[1],tr->pos.array[2]); + return vect3; } btQuaternion ManualBulletShapeLoader::getbtQuat(Ogre::Matrix3 m) { - Ogre::Quaternion oquat(m); - btQuaternion quat; - quat.setW(oquat.w); - quat.setX(oquat.x); - quat.setY(oquat.y); - quat.setZ(oquat.z); - return quat; + Ogre::Quaternion oquat(m); + btQuaternion quat; + quat.setW(oquat.w); + quat.setX(oquat.x); + quat.setY(oquat.y); + quat.setZ(oquat.z); + return quat; } btVector3 ManualBulletShapeLoader::getbtVector(Nif::Vector v) { - btVector3 a(v.array[0],v.array[1],v.array[2]); - return a; + btVector3 a(v.array[0],v.array[1],v.array[2]); + return a; } void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) { - cShape = static_cast(resource); - resourceName = cShape->getName(); + cShape = static_cast(resource); + resourceName = cShape->getName(); cShape->collide = false; - currentShape = new btCompoundShape(); - cShape->Shape = currentShape; + currentShape = new btCompoundShape(); + cShape->Shape = currentShape; - if (!vfs) vfs = new OgreVFS(resourceGroup); + if (!vfs) vfs = new OgreVFS(resourceGroup); - if (!vfs->isFile(resourceName)) - { - warn("File not found."); - return; - } + if (!vfs->isFile(resourceName)) + { + warn("File not found."); + return; + } - // Load the NIF. TODO: Wrap this in a try-catch block once we're out - // of the early stages of development. Right now we WANT to catch - // every error as early and intrusively as possible, as it's most - // likely a sign of incomplete code rather than faulty input. - Nif::NIFFile nif(vfs->open(resourceName), resourceName); + // Load the NIF. TODO: Wrap this in a try-catch block once we're out + // of the early stages of development. Right now we WANT to catch + // every error as early and intrusively as possible, as it's most + // likely a sign of incomplete code rather than faulty input. + Nif::NIFFile nif(vfs->open(resourceName), resourceName); - if (nif.numRecords() < 1) - { - warn("Found no records in NIF."); - return; - } + if (nif.numRecords() < 1) + { + warn("Found no records in NIF."); + return; + } - // The first record is assumed to be the root node - Nif::Record *r = nif.getRecord(0); - assert(r != NULL); + // The first record is assumed to be the root node + Nif::Record *r = nif.getRecord(0); + assert(r != NULL); - Nif::Node *node = dynamic_cast(r); + Nif::Node *node = dynamic_cast(r); - if (node == NULL) - { - warn("First record in file was not a node, but a " + - r->recName.toString() + ". Skipping file."); - return; - } + if (node == NULL) + { + warn("First record in file was not a node, but a " + + r->recName.toString() + ". Skipping file."); + return; + } bool hasCollisionNode = hasRootCollisionNode(node); //do a first pass - handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,false); + handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,false); //if collide = false, then it does a second pass which create a shape for raycasting. if(cShape->collide == false) { - handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,true); + handleNode(node,0,Ogre::Matrix3::IDENTITY,Ogre::Vector3::ZERO,1,hasCollisionNode,false,true); } } bool ManualBulletShapeLoader::hasRootCollisionNode(Nif::Node* node) { - if (node->recType == Nif::RC_NiNode) - { - Nif::NodeList &list = ((Nif::NiNode*)node)->children; - int n = list.length(); - for (int i=0; irecType == Nif::RC_NiNode) + { + Nif::NodeList &list = ((Nif::NiNode*)node)->children; + int n = list.length(); + for (int i=0; irecType == Nif::RC_NiTriShape) + else if (node->recType == Nif::RC_NiTriShape) { return false; } - else if(node->recType == Nif::RC_RootCollisionNode) - { + else if(node->recType == Nif::RC_RootCollisionNode) + { return true; - } - + } + return false; } void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, - Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale,bool hasCollisionNode,bool isCollisionNode,bool raycastingOnly) + Ogre::Matrix3 parentRot,Ogre::Vector3 parentPos,float parentScale,bool hasCollisionNode,bool isCollisionNode,bool raycastingOnly) { - // Accumulate the flags from all the child nodes. This works for all - // the flags we currently use, at least. - flags |= node->flags; + // Accumulate the flags from all the child nodes. This works for all + // the flags we currently use, at least. + flags |= node->flags; - // Check for extra data - Nif::Extra *e = node; - while (!e->extra.empty()) - { - // Get the next extra data in the list - e = e->extra.getPtr(); - assert(e != NULL); + // Check for extra data + Nif::Extra *e = node; + while (!e->extra.empty()) + { + // Get the next extra data in the list + e = e->extra.getPtr(); + assert(e != NULL); - if (e->recType == Nif::RC_NiStringExtraData) - { - // String markers may contain important information - // affecting the entire subtree of this node - Nif::NiStringExtraData *sd = (Nif::NiStringExtraData*)e; + if (e->recType == Nif::RC_NiStringExtraData) + { + // String markers may contain important information + // affecting the entire subtree of this node + Nif::NiStringExtraData *sd = (Nif::NiStringExtraData*)e; - if (sd->string == "NCO" && !raycastingOnly) - { - // No collision. Use an internal flag setting to mark this. - // We ignor this node! - flags |= 0x800; - return; - } - else if (sd->string == "MRK" && !raycastingOnly) - // Marker objects. These are only visible in the - // editor. Until and unless we add an editor component to - // the engine, just skip this entire node. - return; - } - } + if (sd->string == "NCO" && !raycastingOnly) + { + // No collision. Use an internal flag setting to mark this. + // We ignor this node! + flags |= 0x800; + return; + } + else if (sd->string == "MRK" && !raycastingOnly) + // Marker objects. These are only visible in the + // editor. Until and unless we add an editor component to + // the engine, just skip this entire node. + return; + } + } - //transfo of parents node + curent node - Ogre::Matrix3 finalRot; - Ogre::Vector3 finalPos; - float finalScale; + //transfo of parents node + curent node + Ogre::Matrix3 finalRot; + Ogre::Vector3 finalPos; + float finalScale; - Nif::Transformation &final = *((Nif::Transformation*)node->trafo); - Ogre::Vector3 nodePos = getVector(&final); - Ogre::Matrix3 nodeRot = getMatrix(&final); + Nif::Transformation &final = *((Nif::Transformation*)node->trafo); + Ogre::Vector3 nodePos = getVector(&final); + Ogre::Matrix3 nodeRot = getMatrix(&final); - finalPos = nodePos + parentPos; - finalRot = parentRot*nodeRot; - finalScale = final.scale*parentScale; + finalPos = nodePos + parentPos; + finalRot = parentRot*nodeRot; + finalScale = final.scale*parentScale; - // For NiNodes, loop through children - if (node->recType == Nif::RC_NiNode) - { - Nif::NodeList &list = ((Nif::NiNode*)node)->children; - int n = list.length(); - for (int i=0; irecType == Nif::RC_NiNode) + { + Nif::NodeList &list = ((Nif::NiNode*)node)->children; + int n = list.length(); + for (int i=0; irecType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode)) { cShape->collide = true; handleNiTriShape(dynamic_cast(node), flags,finalRot,finalPos,finalScale,raycastingOnly); } - else if(node->recType == Nif::RC_RootCollisionNode) - { - Nif::NodeList &list = ((Nif::NiNode*)node)->children; - int n = list.length(); - for (int i=0; irecType == Nif::RC_RootCollisionNode) + { + Nif::NodeList &list = ((Nif::NiNode*)node)->children; + int n = list.length(); + for (int i=0; i