1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-23 11:39:39 +00:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Nikolay Kasyanov 2012-02-15 11:33:53 +04:00
commit ee92da3c4a
22 changed files with 324 additions and 178 deletions

View file

@ -1,11 +1,13 @@
project(OpenMW) project(OpenMW)
IF (APPLE) if (APPLE)
set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app") set(APP_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app")
set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/${APP_BUNDLE_NAME}")
# using 10.6 sdk # using 10.6 sdk
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk") set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk")
ENDIF (APPLE) endif (APPLE)
# Macros # Macros
@ -200,6 +202,13 @@ include_directories("."
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR}) link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR})
if(APPLE)
# List used Ogre plugins
SET(USED_OGRE_PLUGINS "RenderSystem_GL"
"Plugin_OctreeSceneManager"
"Plugin_ParticleFX")
endif(APPLE)
add_subdirectory( extern/caelum ) add_subdirectory( extern/caelum )
add_subdirectory( extern/mygui_3.0.1 ) add_subdirectory( extern/mygui_3.0.1 )
@ -243,22 +252,17 @@ if (APPLE)
"${OpenMW_BINARY_DIR}/plugins.cfg") "${OpenMW_BINARY_DIR}/plugins.cfg")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
"${APP_BUNDLE_DIR}/Contents/Info.plist" COPYONLY) "${APP_BUNDLE_DIR}/Contents/Info.plist")
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
# prepare plugins # prepare plugins
configure_file(${OGRE_PLUGIN_DIR}/RenderSystem_GL.dylib foreach(plugin ${USED_OGRE_PLUGINS})
"${APP_BUNDLE_DIR}/Contents/Plugins/RenderSystem_GL.dylib" COPYONLY) configure_file("${OGRE_PLUGIN_DIR}/${plugin}.dylib"
"${APP_BUNDLE_DIR}/Contents/Plugins/${plugin}.dylib"
configure_file(${OGRE_PLUGIN_DIR}/Plugin_OctreeSceneManager.dylib COPYONLY)
"${APP_BUNDLE_DIR}/Contents/Plugins/Plugin_OctreeSceneManager.dylib" COPYONLY) endforeach()
configure_file(${OGRE_PLUGIN_DIR}/Plugin_ParticleFX.dylib
"${APP_BUNDLE_DIR}/Contents/Plugins/Plugin_ParticleFX.dylib" COPYONLY)
endif (APPLE) endif (APPLE)
@ -268,36 +272,6 @@ if (CMAKE_COMPILER_IS_GNUCC)
add_definitions (-Wall) add_definitions (-Wall)
endif (CMAKE_COMPILER_IS_GNUCC) endif (CMAKE_COMPILER_IS_GNUCC)
# Apple bundling
# TODO REWRITE!
if (APPLE)
set(MISC_FILES
${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 "${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")
set(CPACK_BUNDLE_NAME "OpenMW")
set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO})
set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE})
include(CPack)
set(CMAKE_EXE_LINKER_FLAGS "-arch i386")
set(CMAKE_CXX_FLAGS "-arch i386")
endif (APPLE)
if(DPKG_PROGRAM) if(DPKG_PROGRAM)
SET(CMAKE_INSTALL_PREFIX "/usr") SET(CMAKE_INSTALL_PREFIX "/usr")
@ -351,6 +325,37 @@ if(DPKG_PROGRAM)
include(CPack) include(CPack)
endif(DPKG_PROGRAM) endif(DPKG_PROGRAM)
if(WIN32)
FILE(GLOB files "${OpenMW_BINARY_DIR}/Release/*.*")
INSTALL(FILES ${files} DESTINATION ".")
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg")
INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.cfg" "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION ".")
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".")
SET(CPACK_GENERATOR "NSIS")
SET(CPACK_PACKAGE_NAME "OpenMW")
SET(CPACK_PACKAGE_VENDOR "OpenMW.org")
SET(CPACK_PACKAGE_VERSION ${OPENMW_VERSION})
SET(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO})
SET(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE})
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW;esmtool;Esmtool;omwlauncher;OpenMW Launcher")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenMW_SOURCE_DIR}/readme.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${OpenMW_SOURCE_DIR}/GPL3.txt")
SET(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
SET(CPACK_NSIS_DISPLAY_NAME "OpenMW")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.openmw.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.openmw.org")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "omwlauncher.exe")
if(EXISTS "${OpenMW_BINARY_DIR}/vcredist_x86.exe")
INSTALL(FILES "${OpenMW_BINARY_DIR}/vcredist_x86.exe" DESTINATION "redist")
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\redist\\\\vcredist_x86.exe\\\" /q'" )
endif(EXISTS "${OpenMW_BINARY_DIR}/vcredist_x86.exe")
include(CPack)
endif(WIN32)
# Components # Components
add_subdirectory (components) add_subdirectory (components)
@ -405,3 +410,86 @@ if (WIN32)
#set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") #set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
#set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") #set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif() endif()
# Apple bundling
if (APPLE)
set(INSTALL_SUBDIR OpenMW)
#install(FILES ${MISC_FILES} DESTINATION ../MacOS)
#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Plugins" DESTINATION ..)
#install(DIRECTORY "${APP_BUNDLE_DIR}/Contents/Resources/resources" DESTINATION ../Resources)
install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
set(CPACK_GENERATOR "DragNDrop")
# set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist")
# set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns")
# set(CPACK_BUNDLE_NAME "OpenMW")
set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO})
set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE})
set(APPS "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}")
set(PLUGINS "")
# Scan Plugins dir for *.dylibs
file(GLOB ALL_PLUGINS "${APP_BUNDLE_DIR}/Contents/Plugins/*.dylib")
foreach(PLUGIN ${ALL_PLUGINS})
get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME)
set(PLUGINS ${PLUGINS} "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins/${PLUGIN_FILENAME}")
endforeach()
#For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail
set(DIRS "")
# Overriding item resolving during installation, it needed if
# some library already has be "fixed up", i.e. its id name contains @executable_path,
# but library is not embedded in bundle. For example, it's Ogre.framework from Ogre SDK.
# Current implementation of GetPrerequsities/BundleUtilities doesn't handle that case.
#
# Current limitations:
# 1. Handles only frameworks, not simple libs
INSTALL(CODE "
set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_SYSTEM_FRAMEWORK_PATH})
set(OPENMW_RESOLVED_ITEMS \"\")
function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var)
if(item MATCHES \"@executable_path\" AND NOT \${\${resolved_var}})
if (item MATCHES \"Frameworks\") # if it is a framework
# get last segment of path
get_filename_component(fname \"\${item}\" NAME_WE)
find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks)
if (ri)
message(STATUS \"found \${ri} for \${item}\")
string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item})
set(ri \"\${ri}\${item_part}\")
set(\${resolved_item_var} \${ri} PARENT_SCOPE)
set(\${resolved_var} 1 PARENT_SCOPE)
set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri})
endif()
else()
# code path for standard (non-framework) libs (ogre & qt pugins)
endif()
endif()
endfunction(gp_resolve_item_override)
cmake_policy(SET CMP0009 OLD)
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\")
" COMPONENT Runtime)
include(CPack)
set(CMAKE_EXE_LINKER_FLAGS "-arch i386")
set(CMAKE_CXX_FLAGS "-arch i386")
endif (APPLE)

View file

@ -926,13 +926,13 @@ int update_arg(void *field, char **orig_field,
const char *long_opt, char short_opt, const char *long_opt, char short_opt,
const char *additional_error) const char *additional_error)
{ {
char *stop_char = 0; //char *stop_char = 0;
const char *val = value; //const char *val = value;
int found; //int found;
FIX_UNUSED (field); FIX_UNUSED (field);
stop_char = 0; //stop_char = 0;
found = 0; //found = 0;
if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
{ {
@ -955,8 +955,8 @@ int update_arg(void *field, char **orig_field,
(*prev_given)++; (*prev_given)++;
if (field_given) if (field_given)
(*field_given)++; (*field_given)++;
if (possible_values) //if (possible_values)
val = possible_values[found]; //val = possible_values[found];
switch(arg_type) { switch(arg_type) {
default: default:
@ -996,7 +996,7 @@ cmdline_parser_internal (
int override; int override;
int initialize; int initialize;
int check_required; //int check_required;
int check_ambiguity; int check_ambiguity;
char *optarg; char *optarg;
@ -1008,7 +1008,7 @@ cmdline_parser_internal (
override = params->override; override = params->override;
initialize = params->initialize; initialize = params->initialize;
check_required = params->check_required; //check_required = params->check_required;
check_ambiguity = params->check_ambiguity; check_ambiguity = params->check_ambiguity;
if (initialize) if (initialize)

View file

@ -41,14 +41,25 @@ source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC
find_package(Qt4 REQUIRED) find_package(Qt4 REQUIRED)
set(QT_USE_QTGUI 1) set(QT_USE_QTGUI 1)
find_package(PNG REQUIRED) #find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR}) #include_directories(${PNG_INCLUDE_DIR})
QT4_ADD_RESOURCES(RCC_SRCS resources.qrc) QT4_ADD_RESOURCES(RCC_SRCS resources.qrc)
QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC})
include(${QT_USE_FILE}) include(${QT_USE_FILE})
# list here plugins that can't be detected statically, but loaded in runtime
# it needed for packaging automatisation
#set(USED_QT_PLUGINS imageformats/libqgif
# imageformats/libqico
# imageformats/libqjpeg
# imageformats/libqmng
# imageformats/libqsvg
# imageformats/libqtga
# imageformats/libqtiff)
# It seems that launcher works without this plugins, but it loads them into memory if they exists
# Main executable # Main executable
add_executable(omwlauncher add_executable(omwlauncher
${LAUNCHER} ${LAUNCHER}
@ -60,7 +71,7 @@ target_link_libraries(omwlauncher
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${OGRE_LIBRARIES} ${OGRE_LIBRARIES}
${QT_LIBRARIES} ${QT_LIBRARIES}
${PNG_LIBRARY} # ${PNG_LIBRARY}
components components
) )
@ -73,6 +84,13 @@ if (APPLE)
"${APP_BUNDLE_DIR}/../launcher.qss") "${APP_BUNDLE_DIR}/../launcher.qss")
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
"${APP_BUNDLE_DIR}/../launcher.cfg") "${APP_BUNDLE_DIR}/../launcher.cfg")
# copy used QT plugins into ${APP_BUNDLE_DIR}/Contents/Plugins
#foreach(PLUGIN ${USED_QT_PLUGINS})
# get_filename_component(PLUGIN_FILENAME ${PLUGIN} NAME)
# configure_file("${QT_PLUGINS_DIR}/${PLUGIN}.dylib" "${APP_BUNDLE_DIR}/Contents/Plugins/${PLUGIN_FILENAME}.dylib" COPYONLY)
#endforeach()
else() else()
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss")

View file

@ -86,10 +86,6 @@ target_link_libraries(openmw
if(APPLE) if(APPLE)
find_library(CARBON_FRAMEWORK Carbon) find_library(CARBON_FRAMEWORK Carbon)
target_link_libraries(openmw ${CARBON_FRAMEWORK}) target_link_libraries(openmw ${CARBON_FRAMEWORK})
install(TARGETS openmw
BUNDLE DESTINATION .
RUNTIME DESTINATION ../MacOS
COMPONENT Runtime)
endif(APPLE) endif(APPLE)
if(DPKG_PROGRAM) if(DPKG_PROGRAM)

View file

@ -462,6 +462,28 @@ void OMW::Engine::activate()
} }
} }
void OMW::Engine::screenshot()
{
// Count screenshots.
int shotCount = 0;
const std::string screenshotPath = mCfgMgr.getLocalConfigPath().string();
// Find the first unused filename with a do-while
std::ostringstream stream;
do
{
// Reset the stream
stream.str("");
stream.clear();
stream << screenshotPath << "screenshot" << std::setw(3) << std::setfill('0') << shotCount++ << ".png";
} while (boost::filesystem::exists(stream.str()));
mOgre->screenshot(stream.str());
}
void OMW::Engine::setCompileAll (bool all) void OMW::Engine::setCompileAll (bool all)
{ {
mCompileAll = all; mCompileAll = all;

View file

@ -152,6 +152,9 @@ namespace OMW
/// Activate the focussed object. /// Activate the focussed object.
void activate(); void activate();
/// Write screenshot to file.
void screenshot();
/// Compile all scripts (excludign dialogue scripts) at startup? /// Compile all scripts (excludign dialogue scripts) at startup?
void setCompileAll (bool all); void setCompileAll (bool all);

View file

@ -24,11 +24,12 @@ namespace MWClass
assert (ref->base != NULL); assert (ref->base != NULL);
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty())
{
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
if (!model.empty())
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, "meshes\\" + model);
const int color = ref->base->data.color; const int color = ref->base->data.color;
const float r = ((color >> 0) & 0xFF) / 255.0f; const float r = ((color >> 0) & 0xFF) / 255.0f;
const float g = ((color >> 8) & 0xFF) / 255.0f; const float g = ((color >> 8) & 0xFF) / 255.0f;
@ -36,20 +37,18 @@ namespace MWClass
const float radius = float (ref->base->data.radius); const float radius = float (ref->base->data.radius);
objects.insertLight (ptr, r, g, b, radius); objects.insertLight (ptr, r, g, b, radius);
} }
}
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
{ {
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>(); ptr.get<ESM::Light>();
const std::string &model = ref->base->model;
assert (ref->base != NULL); assert (ref->base != NULL);
const std::string &model = ref->base->model;
if(!model.empty()){ if(!model.empty()){
physics.insertObjectPhysics(ptr, "meshes\\" + model); physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
} }
void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const

View file

@ -19,7 +19,7 @@ namespace MWClass
if (!model.empty()) if (!model.empty())
{ {
MWRender::Objects& objects = renderingInterface.getObjects(); MWRender::Objects& objects = renderingInterface.getObjects();
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true);
objects.insertMesh(ptr, "meshes\\" + model); objects.insertMesh(ptr, "meshes\\" + model);
} }
} }
@ -29,13 +29,12 @@ namespace MWClass
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
ptr.get<ESM::Static>(); ptr.get<ESM::Static>();
const std::string &model = ref->base->model;
assert (ref->base != NULL); assert (ref->base != NULL);
const std::string &model = ref->base->model;
if(!model.empty()){ if(!model.empty()){
physics.insertObjectPhysics(ptr, "meshes\\" + model); physics.insertObjectPhysics(ptr, "meshes\\" + model);
} }
} }
std::string Static::getName (const MWWorld::Ptr& ptr) const std::string Static::getName (const MWWorld::Ptr& ptr) const

View file

@ -32,8 +32,8 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize)
mBook.pages.pop_back(); mBook.pages.pop_back();
} }
std::string::iterator wordBegin = text.begin(); //std::string::iterator wordBegin = text.begin();
std::string::iterator wordEnd; //std::string::iterator wordEnd;
std::string cText = text; std::string cText = text;

View file

@ -83,27 +83,14 @@ namespace MWInput
MWGui::WindowManager &windows; MWGui::WindowManager &windows;
OMW::Engine& mEngine; OMW::Engine& mEngine;
// Count screenshots.
int shotCount;
/* InputImpl Methods */ /* InputImpl Methods */
// Write screenshot to file.
void screenshot() void screenshot()
{ {
mEngine.screenshot();
// Find the first unused filename with a do-while
char buf[50];
do
{
snprintf(buf, 50, "screenshot%03d.png", shotCount++);
} while (boost::filesystem::exists(buf));
ogre.screenshot(buf);
} }
/* toggleInventory() is called when the user presses the button to toggle the inventory screen. */ /* toggleInventory() is called when the user presses the button to toggle the inventory screen. */
void toggleInventory() void toggleInventory()
{ {
@ -183,8 +170,7 @@ namespace MWInput
poller(input), poller(input),
player(_player), player(_player),
windows(_windows), windows(_windows),
mEngine (engine), mEngine (engine)
shotCount(0)
{ {
using namespace OEngine::Input; using namespace OEngine::Input;
using namespace OEngine::Render; using namespace OEngine::Render;

View file

@ -499,7 +499,7 @@ namespace MWRender{
std::vector<Ogre::Quaternion> quats = iter->getQuat(); std::vector<Ogre::Quaternion> quats = iter->getQuat();
std::vector<float> ttime = iter->gettTime(); std::vector<float> ttime = iter->gettTime();
std::vector<float>::iterator ttimeiter = ttime.begin(); //std::vector<float>::iterator ttimeiter = ttime.begin();
std::vector<float> rtime = iter->getrTime(); std::vector<float> rtime = iter->getrTime();
int rindexJ = 0; int rindexJ = 0;

View file

@ -267,7 +267,7 @@ void NpcAnimation::runAnimation(float timepassed){
} }
handleAnimationTransforms(); handleAnimationTransforms();
Ogre::Vector3 current = insert->_getWorldAABB().getCenter(); //Ogre::Vector3 current = insert->_getWorldAABB().getCenter();
std::vector<std::vector<Nif::NiTriShapeCopy>*>::iterator shapepartsiter = shapeparts.begin(); std::vector<std::vector<Nif::NiTriShapeCopy>*>::iterator shapepartsiter = shapeparts.begin();
std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin(); std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin();

View file

@ -1,11 +1,11 @@
#include "objects.hpp" #include "objects.hpp"
#include <OgreSceneNode.h> #include <OgreSceneNode.h>
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogre_nif_loader.hpp>
using namespace Ogre;
using namespace MWRender; using namespace MWRender;
bool Objects::lightConst = false; bool Objects::lightConst = false;
float Objects::lightConstValue = 0.0f; float Objects::lightConstValue = 0.0f;
@ -23,10 +23,24 @@ bool Objects::lightOutQuadInLin = false;
int Objects::uniqueID = 0; int Objects::uniqueID = 0;
void Objects::setMwRoot(Ogre::SceneNode* root){ void Objects::clearSceneNode (Ogre::SceneNode *node)
{
/// \todo This should probably be moved into OpenEngine at some point.
for (int i=node->numAttachedObjects()-1; i>=0; --i)
{
Ogre::MovableObject *object = node->getAttachedObject (i);
node->detachObject (object);
mRenderer.getScene()->destroyMovableObject (object);
}
}
void Objects::setMwRoot(Ogre::SceneNode* root)
{
mMwRoot = root; mMwRoot = root;
} }
void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_)
{
Ogre::SceneNode* root = mMwRoot; Ogre::SceneNode* root = mMwRoot;
Ogre::SceneNode* cellnode; Ogre::SceneNode* cellnode;
if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end()) if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
@ -49,68 +63,69 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
f = ptr.getCellRef().pos.rot; f = ptr.getCellRef().pos.rot;
// Rotate around X axis // Rotate around X axis
Quaternion xr(Radian(-f[0]), Vector3::UNIT_X); Ogre::Quaternion xr(Ogre::Radian(-f[0]), Ogre::Vector3::UNIT_X);
// Rotate around Y axis // Rotate around Y axis
Quaternion yr(Radian(-f[1]), Vector3::UNIT_Y); Ogre::Quaternion yr(Ogre::Radian(-f[1]), Ogre::Vector3::UNIT_Y);
// Rotate around Z axis // Rotate around Z axis
Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z); Ogre::Quaternion zr(Ogre::Radian(-f[2]), Ogre::Vector3::UNIT_Z);
// Rotates first around z, then y, then x // Rotates first around z, then y, then x
insert->setOrientation(xr*yr*zr); insert->setOrientation(xr*yr*zr);
if (!enabled) if (!enabled)
insert->setVisible (false); insert->setVisible (false);
ptr.getRefData().setBaseNode(insert); ptr.getRefData().setBaseNode(insert);
isStatic = static_; mIsStatic = static_;
} }
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
{
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode(); Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
assert(insert); assert(insert);
NifOgre::NIFLoader::load(mesh); NifOgre::NIFLoader::load(mesh);
Entity *ent = mRend.getScene()->createEntity(mesh); Ogre::Entity *ent = mRenderer.getScene()->createEntity(mesh);
if(!isStatic) if(!mIsStatic)
{ {
insert->attachObject(ent); insert->attachObject(ent);
} }
else else
{ {
Ogre::StaticGeometry* sg = 0; Ogre::StaticGeometry* sg = 0;
if(mSG.find(ptr.getCell()) == mSG.end()) if(mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end())
{ {
uniqueID = uniqueID +1; uniqueID = uniqueID +1;
sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
//Create the scenenode and put it in the map //Create the scenenode and put it in the map
mSG[ptr.getCell()] = sg; mStaticGeometry[ptr.getCell()] = sg;
} }
else else
{ {
sg = mSG[ptr.getCell()]; sg = mStaticGeometry[ptr.getCell()];
} }
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale()); sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000)); sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
mRenderer.getScene()->destroyEntity(ent);
mRend.getScene()->destroyEntity(ent); }
} }
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius)
} {
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){ Ogre::SceneNode* insert = mRenderer.getScene()->getSceneNode(ptr.getRefData().getHandle());
Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle());
assert(insert); assert(insert);
Ogre::Light *light = mRend.getScene()->createLight(); Ogre::Light *light = mRenderer.getScene()->createLight();
light->setDiffuseColour (r, g, b); light->setDiffuseColour (r, g, b);
float cval=0.0f, lval=0.0f, qval=0.0f; float cval=0.0f, lval=0.0f, qval=0.0f;
if(lightConst) if(lightConst)
cval = lightConstValue; cval = lightConstValue;
if(!lightOutQuadInLin) if(!lightOutQuadInLin)
{ {
if(lightLinear) if(lightLinear)
@ -145,8 +160,9 @@ bool Objects::deleteObject (const MWWorld::Ptr& ptr)
mCellSceneNodes.begin()); iter!=mCellSceneNodes.end(); ++iter) mCellSceneNodes.begin()); iter!=mCellSceneNodes.end(); ++iter)
if (iter->second==parent) if (iter->second==parent)
{ {
clearSceneNode (base);
base->removeAndDestroyAllChildren(); base->removeAndDestroyAllChildren();
mRend.getScene()->destroySceneNode (base); mRenderer.getScene()->destroySceneNode (base);
ptr.getRefData().setBaseNode (0); ptr.getRefData().setBaseNode (0);
return true; return true;
} }
@ -157,29 +173,35 @@ bool Objects::deleteObject (const MWWorld::Ptr& ptr)
return true; return true;
} }
void Objects::removeCell(MWWorld::Ptr::CellStore* store){ void Objects::removeCell(MWWorld::Ptr::CellStore* store)
{
if(mCellSceneNodes.find(store) != mCellSceneNodes.end()) if(mCellSceneNodes.find(store) != mCellSceneNodes.end())
{ {
Ogre::SceneNode* base = mCellSceneNodes[store]; Ogre::SceneNode* base = mCellSceneNodes[store];
for (int i=0; i<base->numChildren(); ++i)
clearSceneNode (static_cast<Ogre::SceneNode *> (base->getChild (i)));
base->removeAndDestroyAllChildren(); base->removeAndDestroyAllChildren();
mCellSceneNodes.erase(store); mCellSceneNodes.erase(store);
mRend.getScene()->destroySceneNode(base); mRenderer.getScene()->destroySceneNode(base);
base = 0; base = 0;
} }
if(mStaticGeometry.find(store) != mStaticGeometry.end())
if(mSG.find(store) != mSG.end())
{ {
Ogre::StaticGeometry* sg = mSG[store]; Ogre::StaticGeometry* sg = mStaticGeometry[store];
mSG.erase(store); mStaticGeometry.erase(store);
mRend.getScene()->destroyStaticGeometry (sg); mRenderer.getScene()->destroyStaticGeometry (sg);
sg = 0; sg = 0;
} }
} }
void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell){
if(mSG.find(&cell) != mSG.end()) void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell)
{ {
Ogre::StaticGeometry* sg = mSG[&cell]; if(mStaticGeometry.find(&cell) != mStaticGeometry.end())
{
Ogre::StaticGeometry* sg = mStaticGeometry[&cell];
sg->build(); sg->build();
} }
} }

View file

@ -1,20 +1,21 @@
#ifndef _GAME_RENDER_OBJECTS_H #ifndef _GAME_RENDER_OBJECTS_H
#define _GAME_RENDER_OBJECTS_H #define _GAME_RENDER_OBJECTS_H
#include "components/esm_store/cell_store.hpp" #include <openengine/ogre/renderer.hpp>
#include <components/esm_store/cell_store.hpp>
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include <openengine/ogre/renderer.hpp>
namespace MWRender{ namespace MWRender{
class Objects{ class Objects{
OEngine::Render::OgreRenderer &mRend; OEngine::Render::OgreRenderer &mRenderer;
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes; std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mSG; std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometry;
Ogre::SceneNode* mMwRoot; Ogre::SceneNode* mMwRoot;
bool isStatic; bool mIsStatic;
static int uniqueID; static int uniqueID;
static bool lightConst; static bool lightConst;
static float lightConstValue; static float lightConstValue;
@ -30,8 +31,12 @@ class Objects{
static float lightQuadraticRadiusMult; static float lightQuadraticRadiusMult;
static bool lightOutQuadInLin; static bool lightOutQuadInLin;
void clearSceneNode (Ogre::SceneNode *node);
///< Remove all movable objects from \a node.
public: public:
Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){} Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer){}
~Objects(){} ~Objects(){}
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);

View file

@ -54,10 +54,12 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
cameraPitchNode->attachObject(mRendering.getCamera()); cameraPitchNode->attachObject(mRendering.getCamera());
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
mSun = 0;
} }
RenderingManager::~RenderingManager () RenderingManager::~RenderingManager ()
{ {
//TODO: destroy mSun?
delete mPlayer; delete mPlayer;
delete mSkyManager; delete mSkyManager;
} }
@ -204,12 +206,15 @@ void RenderingManager::configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell
// Create a "sun" that shines light downwards. It doesn't look // Create a "sun" that shines light downwards. It doesn't look
// completely right, but leave it for now. // completely right, but leave it for now.
Ogre::Light *light = mRendering.getScene()->createLight(); if(!mSun)
{
mSun = mRendering.getScene()->createLight();
}
Ogre::ColourValue colour; Ogre::ColourValue colour;
colour.setAsABGR (mCell.cell->ambi.sunlight); colour.setAsABGR (mCell.cell->ambi.sunlight);
light->setDiffuseColour (colour); mSun->setDiffuseColour (colour);
light->setType(Ogre::Light::LT_DIRECTIONAL); mSun->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(0,-1,0); mSun->setDirection(0,-1,0);
} }
// Switch through lighting modes. // Switch through lighting modes.

View file

@ -118,6 +118,7 @@ class RenderingManager: private RenderingInterface {
int mAmbientMode; int mAmbientMode;
Ogre::ColourValue mAmbientColor; Ogre::ColourValue mAmbientColor;
Ogre::Light* mSun;
/// Root node for all objects added to the scene. This is rotated so /// Root node for all objects added to the scene. This is rotated so
/// that the OGRE coordinate system matches that used internally in /// that the OGRE coordinate system matches that used internally in

View file

@ -1,5 +1,5 @@
#include "statsextensions.hpp" #include "controlextensions.hpp"
#include <components/compiler/extensions.hpp> #include <components/compiler/extensions.hpp>
@ -48,7 +48,7 @@ namespace MWScript
bool enabled = context.getWorld().toggleCollisionMode(); bool enabled = context.getWorld().toggleCollisionMode();
context.report (enabled ? "Collsion -> On" : "Collision -> Off"); context.report (enabled ? "Collision -> On" : "Collision -> Off");
} }
}; };

View file

@ -63,10 +63,11 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y)
result = mExteriors.insert (std::make_pair ( result = mExteriors.insert (std::make_pair (
std::make_pair (x, y), Ptr::CellStore (cell))).first; std::make_pair (x, y), Ptr::CellStore (cell))).first;
result->second.load (mStore, mReader);
} }
if (result->second.mState!=Ptr::CellStore::State_Loaded)
result->second.load (mStore, mReader);
return &result->second; return &result->second;
} }
@ -79,10 +80,11 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name)
const ESM::Cell *cell = mStore.cells.findInt (name); const ESM::Cell *cell = mStore.cells.findInt (name);
result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first; result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first;
result->second.load (mStore, mReader);
} }
if (result->second.mState!=Ptr::CellStore::State_Loaded)
result->second.load (mStore, mReader);
return &result->second; return &result->second;
} }

View file

@ -473,7 +473,7 @@ void read(NIFFile *nif)
int vertCount = nif->getInt(); int vertCount = nif->getInt();
nif->getByte(); nif->getByte();
int magic = nif->getInt(); int magic = nif->getInt();
int type = nif->getInt(); /*int type =*/ nif->getInt();
for(int i = 0; i < vertCount; i++){ for(int i = 0; i < vertCount; i++){
float x = nif->getFloat(); float x = nif->getFloat();
@ -485,7 +485,7 @@ void read(NIFFile *nif)
for(int i=1; i<morphCount; i++) for(int i=1; i<morphCount; i++)
{ {
magic = nif->getInt(); magic = nif->getInt();
type = nif->getInt(); /*type =*/ nif->getInt();
std::vector<Ogre::Vector3> current; std::vector<Ogre::Vector3> current;
std::vector<float> currentTime; std::vector<float> currentTime;
for(int i = 0; i < magic; i++){ for(int i = 0; i < magic; i++){

View file

@ -358,7 +358,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
HardwareVertexBufferSharedPtr vbuf = HardwareVertexBufferSharedPtr vbuf =
HardwareBufferManager::getSingleton().createVertexBuffer( HardwareBufferManager::getSingleton().createVertexBuffer(
VertexElement::getTypeSize(VET_FLOAT3), VertexElement::getTypeSize(VET_FLOAT3),
numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false); numVerts, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
if(flip) if(flip)
{ {
@ -1150,7 +1150,7 @@ void NIFLoader::loadResource(Resource *resource)
char suffix = name.at(name.length() - 2); char suffix = name.at(name.length() - 2);
bool addAnim = true; bool addAnim = true;
bool hasAnim = false; bool hasAnim = false;
bool baddin = false; //bool baddin = false;
bNiTri = true; bNiTri = true;
if(suffix == '*') if(suffix == '*')
@ -1168,7 +1168,7 @@ void NIFLoader::loadResource(Resource *resource)
} }
else if(suffix == '>') else if(suffix == '>')
{ {
baddin = true; //baddin = true;
bNiTri = true; bNiTri = true;
std::string sub = name.substr(name.length() - 6, 4); std::string sub = name.substr(name.length() - 6, 4);

View file

@ -19,7 +19,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.10</string> <string>${OPENMW_VERSION}</string>
<key>CSResourcesFileMapped</key> <key>CSResourcesFileMapped</key>
<true/> <true/>
<key>LSRequiresCarbon</key> <key>LSRequiresCarbon</key>

@ -1 +1 @@
Subproject commit 6c7e5d00e4f5bf954afe15f10e56f03520abfee4 Subproject commit 4a188f2820c037ca4ad8ef35492d3857ea8d7df8