mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Merge branch 'master' into next
Conflicts: apps/openmw/mwclass/light.cpp
This commit is contained in:
commit
e02cba58b1
27 changed files with 450 additions and 357 deletions
184
CMakeLists.txt
184
CMakeLists.txt
|
@ -1,11 +1,13 @@
|
|||
project(OpenMW)
|
||||
|
||||
IF (APPLE)
|
||||
set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app")
|
||||
if (APPLE)
|
||||
set(APP_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app")
|
||||
|
||||
set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/${APP_BUNDLE_NAME}")
|
||||
|
||||
# using 10.6 sdk
|
||||
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk")
|
||||
ENDIF (APPLE)
|
||||
endif (APPLE)
|
||||
|
||||
# Macros
|
||||
|
||||
|
@ -200,6 +202,13 @@ include_directories("."
|
|||
|
||||
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/mygui_3.0.1 )
|
||||
|
||||
|
@ -243,22 +252,17 @@ if (APPLE)
|
|||
"${OpenMW_BINARY_DIR}/plugins.cfg")
|
||||
|
||||
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
|
||||
"${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)
|
||||
|
||||
foreach(plugin ${USED_OGRE_PLUGINS})
|
||||
configure_file("${OGRE_PLUGIN_DIR}/${plugin}.dylib"
|
||||
"${APP_BUNDLE_DIR}/Contents/Plugins/${plugin}.dylib"
|
||||
COPYONLY)
|
||||
endforeach()
|
||||
endif (APPLE)
|
||||
|
||||
|
||||
|
@ -268,36 +272,6 @@ if (CMAKE_COMPILER_IS_GNUCC)
|
|||
add_definitions (-Wall)
|
||||
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)
|
||||
SET(CMAKE_INSTALL_PREFIX "/usr")
|
||||
|
||||
|
@ -351,6 +325,45 @@ if(DPKG_PROGRAM)
|
|||
include(CPack)
|
||||
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")
|
||||
|
||||
SET(VCREDIST "${OpenMW_BINARY_DIR}/vcredist_x86.exe")
|
||||
if(EXISTS ${VCREDIST})
|
||||
INSTALL(FILES ${VCREDIST} DESTINATION "redist")
|
||||
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\redist\\\\vcredist_x86.exe\\\" /q'" )
|
||||
endif(EXISTS ${VCREDIST})
|
||||
|
||||
SET(OALREDIST "${OpenMW_BINARY_DIR}/oalinst.exe")
|
||||
if(EXISTS ${OALREDIST})
|
||||
INSTALL(FILES ${OALREDIST} DESTINATION "redist")
|
||||
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
|
||||
ExecWait '\\\"$INSTDIR\\\\redist\\\\oalinst.exe\\\" /s'" )
|
||||
endif(EXISTS ${OALREDIST})
|
||||
|
||||
include(CPack)
|
||||
endif(WIN32)
|
||||
|
||||
# Components
|
||||
add_subdirectory (components)
|
||||
|
||||
|
@ -405,3 +418,86 @@ if (WIN32)
|
|||
#set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
||||
#set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
|
||||
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)
|
|
@ -926,13 +926,13 @@ int update_arg(void *field, char **orig_field,
|
|||
const char *long_opt, char short_opt,
|
||||
const char *additional_error)
|
||||
{
|
||||
char *stop_char = 0;
|
||||
const char *val = value;
|
||||
int found;
|
||||
//char *stop_char = 0;
|
||||
//const char *val = value;
|
||||
//int found;
|
||||
FIX_UNUSED (field);
|
||||
|
||||
stop_char = 0;
|
||||
found = 0;
|
||||
//stop_char = 0;
|
||||
//found = 0;
|
||||
|
||||
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)++;
|
||||
if (field_given)
|
||||
(*field_given)++;
|
||||
if (possible_values)
|
||||
val = possible_values[found];
|
||||
//if (possible_values)
|
||||
//val = possible_values[found];
|
||||
|
||||
switch(arg_type) {
|
||||
default:
|
||||
|
@ -996,7 +996,7 @@ cmdline_parser_internal (
|
|||
|
||||
int override;
|
||||
int initialize;
|
||||
int check_required;
|
||||
//int check_required;
|
||||
int check_ambiguity;
|
||||
|
||||
char *optarg;
|
||||
|
@ -1008,7 +1008,7 @@ cmdline_parser_internal (
|
|||
|
||||
override = params->override;
|
||||
initialize = params->initialize;
|
||||
check_required = params->check_required;
|
||||
//check_required = params->check_required;
|
||||
check_ambiguity = params->check_ambiguity;
|
||||
|
||||
if (initialize)
|
||||
|
|
|
@ -41,14 +41,25 @@ source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC
|
|||
find_package(Qt4 REQUIRED)
|
||||
set(QT_USE_QTGUI 1)
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
include_directories(${PNG_INCLUDE_DIR})
|
||||
#find_package(PNG REQUIRED)
|
||||
#include_directories(${PNG_INCLUDE_DIR})
|
||||
|
||||
QT4_ADD_RESOURCES(RCC_SRCS resources.qrc)
|
||||
QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC})
|
||||
|
||||
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
|
||||
add_executable(omwlauncher
|
||||
${LAUNCHER}
|
||||
|
@ -60,7 +71,7 @@ target_link_libraries(omwlauncher
|
|||
${Boost_LIBRARIES}
|
||||
${OGRE_LIBRARIES}
|
||||
${QT_LIBRARIES}
|
||||
${PNG_LIBRARY}
|
||||
# ${PNG_LIBRARY}
|
||||
components
|
||||
)
|
||||
|
||||
|
@ -73,6 +84,13 @@ if (APPLE)
|
|||
"${APP_BUNDLE_DIR}/../launcher.qss")
|
||||
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
|
||||
"${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()
|
||||
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
|
||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss")
|
||||
|
|
|
@ -86,10 +86,6 @@ target_link_libraries(openmw
|
|||
if(APPLE)
|
||||
find_library(CARBON_FRAMEWORK Carbon)
|
||||
target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
||||
install(TARGETS openmw
|
||||
BUNDLE DESTINATION .
|
||||
RUNTIME DESTINATION ../MacOS
|
||||
COMPONENT Runtime)
|
||||
endif(APPLE)
|
||||
|
||||
if(DPKG_PROGRAM)
|
||||
|
|
|
@ -445,6 +445,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)
|
||||
{
|
||||
mCompileAll = all;
|
||||
|
|
|
@ -149,6 +149,9 @@ namespace OMW
|
|||
/// Activate the focussed object.
|
||||
void activate();
|
||||
|
||||
/// Write screenshot to file.
|
||||
void screenshot();
|
||||
|
||||
/// Compile all scripts (excludign dialogue scripts) at startup?
|
||||
void setCompileAll (bool all);
|
||||
|
||||
|
|
|
@ -26,18 +26,18 @@ namespace MWClass
|
|||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
const int color = ref->base->data.color;
|
||||
const float r = ((color >> 0) & 0xFF) / 255.0f;
|
||||
const float g = ((color >> 8) & 0xFF) / 255.0f;
|
||||
const float b = ((color >> 16) & 0xFF) / 255.0f;
|
||||
const float radius = float (ref->base->data.radius);
|
||||
objects.insertLight (ptr, r, g, b, radius);
|
||||
}
|
||||
|
||||
const int color = ref->base->data.color;
|
||||
const float r = ((color >> 0) & 0xFF) / 255.0f;
|
||||
const float g = ((color >> 8) & 0xFF) / 255.0f;
|
||||
const float b = ((color >> 16) & 0xFF) / 255.0f;
|
||||
const float radius = float (ref->base->data.radius);
|
||||
objects.insertLight (ptr, r, g, b, radius);
|
||||
}
|
||||
|
||||
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
||||
|
@ -45,13 +45,12 @@ namespace MWClass
|
|||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Light>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace MWClass
|
|||
if (!model.empty())
|
||||
{
|
||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true);
|
||||
objects.insertMesh(ptr, "meshes\\" + model);
|
||||
}
|
||||
}
|
||||
|
@ -30,13 +30,12 @@ namespace MWClass
|
|||
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Static>();
|
||||
|
||||
|
||||
const std::string &model = ref->base->model;
|
||||
assert (ref->base != NULL);
|
||||
const std::string &model = ref->base->model;
|
||||
|
||||
if(!model.empty()){
|
||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string Static::getName (const MWWorld::Ptr& ptr) const
|
||||
|
|
|
@ -32,8 +32,8 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize)
|
|||
mBook.pages.pop_back();
|
||||
}
|
||||
|
||||
std::string::iterator wordBegin = text.begin();
|
||||
std::string::iterator wordEnd;
|
||||
//std::string::iterator wordBegin = text.begin();
|
||||
//std::string::iterator wordEnd;
|
||||
|
||||
std::string cText = text;
|
||||
|
||||
|
|
|
@ -83,27 +83,14 @@ namespace MWInput
|
|||
MWGui::WindowManager &windows;
|
||||
OMW::Engine& mEngine;
|
||||
|
||||
// Count screenshots.
|
||||
int shotCount;
|
||||
|
||||
|
||||
/* InputImpl Methods */
|
||||
|
||||
// Write screenshot to file.
|
||||
void 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);
|
||||
mEngine.screenshot();
|
||||
}
|
||||
|
||||
|
||||
/* toggleInventory() is called when the user presses the button to toggle the inventory screen. */
|
||||
void toggleInventory()
|
||||
{
|
||||
|
@ -183,8 +170,7 @@ namespace MWInput
|
|||
poller(input),
|
||||
player(_player),
|
||||
windows(_windows),
|
||||
mEngine (engine),
|
||||
shotCount(0)
|
||||
mEngine (engine)
|
||||
{
|
||||
using namespace OEngine::Input;
|
||||
using namespace OEngine::Render;
|
||||
|
|
|
@ -101,7 +101,6 @@ namespace MWRender{
|
|||
}
|
||||
|
||||
void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){
|
||||
bool useHandles = skel == creaturemodel->getSkeleton();
|
||||
shapeNumber = 0;
|
||||
|
||||
std::vector<Nif::NiTriShapeCopy>::iterator allshapesiter;
|
||||
|
@ -112,6 +111,9 @@ namespace MWRender{
|
|||
|
||||
Nif::NiTriShapeCopy& copy = *allshapesiter;
|
||||
std::vector<Ogre::Vector3>* allvertices = ©.vertices;
|
||||
std::vector<Ogre::Vector3>* allnormals = ©.normals;
|
||||
|
||||
|
||||
|
||||
//std::set<unsigned int> vertices;
|
||||
//std::set<unsigned int> normals;
|
||||
|
@ -121,8 +123,7 @@ namespace MWRender{
|
|||
//std::cout << "Name " << copy.sname << "\n";
|
||||
Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0);
|
||||
Ogre::Real* pReal = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
|
||||
//Ogre::HardwareVertexBufferSharedPtr vbufNormal = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(1);
|
||||
// Ogre::Real* pRealNormal = static_cast<Ogre::Real*>(vbufNormal->lock(Ogre::HardwareBuffer::HBL_NORMAL));
|
||||
|
||||
|
||||
std::vector<Ogre::Vector3> initialVertices = copy.morph.getInitialVertices();
|
||||
//Each shape has multiple indices
|
||||
|
@ -181,146 +182,76 @@ namespace MWRender{
|
|||
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
|
||||
int verIndex = iter->first;
|
||||
Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
|
||||
Ogre::Vector3 currentNormal = (*allnormals)[verIndex];
|
||||
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
|
||||
Ogre::Bone *bonePtr = 0;
|
||||
if(useHandles)
|
||||
{
|
||||
bonePtr = skel->getBone(boneinfocopy->bonehandle);
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
|
||||
Ogre::Vector3 vecPos;
|
||||
Ogre::Quaternion vecRot;
|
||||
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot>::iterator result = vecRotPos.find(boneinfocopy);
|
||||
|
||||
if(result == vecRotPos.end()){
|
||||
bonePtr = skel->getBone(boneinfocopy->bonename);
|
||||
|
||||
Ogre::Vector3 vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
|
||||
Ogre::Quaternion vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
|
||||
|
||||
|
||||
/*if(vecPosRot.find(boneinfocopy->bonehandle) == vecPosRot.end()){
|
||||
vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
|
||||
vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
|
||||
|
||||
if(useHandles){
|
||||
|
||||
PosAndRot both;
|
||||
both.vecPos = vecPos;
|
||||
both.vecRot = vecRot;
|
||||
vecPosRot[boneinfocopy->bonehandle] = both;
|
||||
}
|
||||
vecRotPos[boneinfocopy] = both;
|
||||
|
||||
}
|
||||
else{
|
||||
PosAndRot both = vecPosRot[boneinfocopy->bonehandle];
|
||||
PosAndRot both = result->second;
|
||||
vecPos = both.vecPos;
|
||||
vecRot = both.vecRot;
|
||||
}*/
|
||||
}
|
||||
|
||||
Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight;
|
||||
|
||||
|
||||
|
||||
for(std::size_t i = 1; i < inds.size(); i++){
|
||||
boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]);
|
||||
if(useHandles)
|
||||
bonePtr = skel->getBone(boneinfocopy->bonehandle);
|
||||
else
|
||||
bonePtr = skel->getBone(boneinfocopy->bonename);
|
||||
vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
|
||||
vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
|
||||
result = vecRotPos.find(boneinfocopy);
|
||||
|
||||
/*if(vecPosRot.find(boneinfocopy->bonehandle) == vecPosRot.end()){
|
||||
|
||||
if(result == vecRotPos.end()){
|
||||
bonePtr = skel->getBone(boneinfocopy->bonename);
|
||||
vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
|
||||
vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
|
||||
|
||||
if(useHandles){
|
||||
PosAndRot both;
|
||||
both.vecPos = vecPos;
|
||||
both.vecRot = vecRot;
|
||||
vecPosRot[boneinfocopy->bonehandle] = both;
|
||||
}
|
||||
vecRotPos[boneinfocopy] = both;
|
||||
|
||||
}
|
||||
else{
|
||||
PosAndRot both = vecPosRot[boneinfocopy->bonehandle];
|
||||
PosAndRot both = result->second;
|
||||
vecPos = both.vecPos;
|
||||
vecRot = both.vecRot;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight;
|
||||
|
||||
|
||||
}
|
||||
Ogre::Real* addr = (pReal + 3 * verIndex);
|
||||
*addr = absVertPos.x;
|
||||
*(addr+1) = absVertPos.y;
|
||||
*(addr+2) = absVertPos.z;
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (unsigned int i = 0; i < boneinfovector.size(); i++)
|
||||
{
|
||||
Nif::NiSkinData::BoneInfoCopy boneinfo = boneinfovector[i];
|
||||
if(skel->hasBone(boneinfo.bonename)){
|
||||
Ogre::Bone *bonePtr = skel->getBone(boneinfo.bonename);
|
||||
Ogre::Vector3 vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfo.trafo.trans;
|
||||
Ogre::Quaternion vecRot = bonePtr->_getDerivedOrientation() * boneinfo.trafo.rotation;
|
||||
|
||||
for (unsigned int j=0; j < boneinfo.weights.size(); j++)
|
||||
{
|
||||
unsigned int verIndex = boneinfo.weights[j].vertex;
|
||||
if(vertices.find(verIndex) == vertices.end())
|
||||
{
|
||||
Ogre::Vector3 absVertPos = vecPos + vecRot * allvertices[verIndex];
|
||||
absVertPos = absVertPos * boneinfo.weights[j].weight;
|
||||
vertices.insert(verIndex);
|
||||
Ogre::Real* addr = (pReal + 3 * verIndex);
|
||||
*addr = absVertPos.x;
|
||||
*(addr+1) = absVertPos.y;
|
||||
*(addr+2) = absVertPos.z;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Ogre::Vector3 absVertPos = vecPos + vecRot * allvertices[verIndex];
|
||||
absVertPos = absVertPos * boneinfo.weights[j].weight;
|
||||
Ogre::Vector3 old = Ogre::Vector3(pReal + 3 * verIndex);
|
||||
absVertPos = absVertPos + old;
|
||||
Ogre::Real* addr = (pReal + 3 * verIndex);
|
||||
*addr = absVertPos.x;
|
||||
*(addr+1) = absVertPos.y;
|
||||
*(addr+2) = absVertPos.z;
|
||||
|
||||
//std::cout << "Vertex" << verIndex << "Weight: " << boneinfo.weights[i].weight << "was seen twice\n";
|
||||
|
||||
}
|
||||
|
||||
if(normals.find(verIndex) == normals.end())
|
||||
{
|
||||
Ogre::Vector3 absNormalsPos = vecRot * allnormals[verIndex];
|
||||
absNormalsPos = absNormalsPos * boneinfo.weights[j].weight;
|
||||
normals.insert(verIndex);
|
||||
Ogre::Real* addr = (pRealNormal + 3 * verIndex);
|
||||
*addr = absNormalsPos.x;
|
||||
*(addr+1) = absNormalsPos.y;
|
||||
*(addr+2) = absNormalsPos.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ogre::Vector3 absNormalsPos = vecRot * allnormals[verIndex];
|
||||
absNormalsPos = absNormalsPos * boneinfo.weights[j].weight;
|
||||
Ogre::Vector3 old = Ogre::Vector3(pRealNormal + 3 * verIndex);
|
||||
absNormalsPos = absNormalsPos + old;
|
||||
|
||||
Ogre::Real* addr = (pRealNormal + 3 * verIndex);
|
||||
*addr = absNormalsPos.x;
|
||||
*(addr+1) = absNormalsPos.y;
|
||||
*(addr+2) = absNormalsPos.z;
|
||||
|
||||
}
|
||||
#endif
|
||||
//}
|
||||
//}
|
||||
|
||||
|
||||
//} //Comment out
|
||||
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -329,11 +260,13 @@ namespace MWRender{
|
|||
Ogre::Vector3 shapetrans = copy.trafo.trans;
|
||||
float shapescale = copy.trafo.scale;
|
||||
std::vector<std::string> boneSequence = copy.boneSequence;
|
||||
std::vector<std::string>::iterator boneSequenceIter = boneSequence.begin();
|
||||
|
||||
Ogre::Vector3 transmult;
|
||||
Ogre::Quaternion rotmult;
|
||||
float scale;
|
||||
if(skel->hasBone(*boneSequenceIter)){
|
||||
if(boneSequence.size() > 0){
|
||||
std::vector<std::string>::iterator boneSequenceIter = boneSequence.begin();
|
||||
if(skel->hasBone(*boneSequenceIter)){
|
||||
Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter);
|
||||
|
||||
|
||||
|
@ -360,6 +293,7 @@ namespace MWRender{
|
|||
|
||||
//std::cout << "Position: " << transmult << "Rotation: " << rotmult << "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transmult = shapetrans;
|
||||
|
@ -392,7 +326,7 @@ namespace MWRender{
|
|||
|
||||
}
|
||||
vbuf->unlock();
|
||||
//vbufNormal->unlock();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -465,22 +399,18 @@ namespace MWRender{
|
|||
|
||||
base->getAllAnimationStates()->_notifyDirty();
|
||||
//base->_updateAnimation();
|
||||
base->_notifyMoved();
|
||||
//base->_notifyMoved();
|
||||
|
||||
for(unsigned int i = 0; i < entityparts.size(); i++){
|
||||
Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
|
||||
for(unsigned int i = 0; i < entityparts.size(); i++){
|
||||
//Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton();
|
||||
|
||||
Ogre::Bone* b = skel->getRootBone();
|
||||
b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick
|
||||
|
||||
skel->_updateTransforms();
|
||||
// skel->_notifyManualBonesDirty();
|
||||
|
||||
entityparts[i]->getAllAnimationStates()->_notifyDirty();
|
||||
//entityparts[i]->_updateAnimation();
|
||||
entityparts[i]->_notifyMoved();
|
||||
}
|
||||
|
||||
|
||||
std::vector<Nif::NiKeyframeData>::iterator iter;
|
||||
int slot = 0;
|
||||
if(transformations){
|
||||
|
@ -488,9 +418,7 @@ namespace MWRender{
|
|||
if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime())
|
||||
{
|
||||
slot++;
|
||||
//iter++;
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
float x;
|
||||
|
@ -511,7 +439,6 @@ namespace MWRender{
|
|||
|
||||
timeIndex(time, ttime, tindexI[slot], tindexJ, x);
|
||||
|
||||
//std::cout << "X: " << x << " X2: " << x2 << "\n";
|
||||
Ogre::Vector3 t;
|
||||
Ogre::Quaternion r;
|
||||
|
||||
|
@ -526,7 +453,6 @@ namespace MWRender{
|
|||
bool bQuats = quats.size() > 0;
|
||||
if(bQuats){
|
||||
r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true);
|
||||
//bone->setOrientation(r);
|
||||
}
|
||||
skel = base->getSkeleton();
|
||||
if(skel->hasBone(iter->getBonename())){
|
||||
|
@ -539,27 +465,10 @@ namespace MWRender{
|
|||
|
||||
|
||||
skel->_updateTransforms();
|
||||
//skel->_notifyManualBonesDirty();
|
||||
base->getAllAnimationStates()->_notifyDirty();
|
||||
//base->_updateAnimation();
|
||||
base->_notifyMoved();
|
||||
}
|
||||
for(std::size_t i = 0; i < entityparts.size(); i++){
|
||||
skel = entityparts[i]->getSkeleton();
|
||||
if(skel->hasBone(iter->getBonename())){
|
||||
Ogre::Bone* bone = skel->getBone(iter->getBonename());
|
||||
if(bTrans)
|
||||
bone->setPosition(t);
|
||||
if(bQuats)
|
||||
bone->setOrientation(r);
|
||||
|
||||
skel->_updateTransforms();
|
||||
//skel->_notifyManualBonesDirty();
|
||||
entityparts[i]->getAllAnimationStates()->_notifyDirty();
|
||||
// entityparts[i]->_updateAnimation();
|
||||
entityparts[i]->_notifyMoved();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ class Animation{
|
|||
Ogre::SceneNode* insert;
|
||||
OEngine::Render::OgreRenderer &mRend;
|
||||
MWWorld::Environment& mEnvironment;
|
||||
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot> vecRotPos;
|
||||
static std::map<std::string, int> mUniqueIDs;
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environme
|
|||
}
|
||||
|
||||
void CreatureAnimation::runAnimation(float timepassed){
|
||||
vecRotPos.clear();
|
||||
if(animate > 0){
|
||||
//Add the amount of time passed to time
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
|
||||
bool female = tolower(secondtolast) == 'f';
|
||||
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
||||
|
||||
/*std::cout << "Race: " << ref->base->race ;
|
||||
if(female){
|
||||
std::cout << " Sex: Female" << " Height: " << race->data.height.female << "\n";
|
||||
|
@ -67,6 +68,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
//stay in the same place when we skipanim, or open a gui window
|
||||
|
||||
|
||||
|
||||
if((transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel))){
|
||||
|
||||
for(unsigned int init = 0; init < transformations->size(); init++){
|
||||
|
@ -177,7 +179,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
if(clavicler)
|
||||
insertBoundedPart("meshes\\" + clavicler->model , "Right Clavicle", base);*/
|
||||
|
||||
|
||||
if(neck)
|
||||
{
|
||||
insertBoundedPart("meshes\\" + neck->model, "Neck");
|
||||
|
@ -213,6 +214,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
|
|||
}
|
||||
|
||||
Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
|
||||
|
||||
NIFLoader::load(mesh);
|
||||
Entity* ent = mRend.getScene()->createEntity(mesh);
|
||||
|
||||
|
@ -225,15 +227,7 @@ void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suf
|
|||
|
||||
Ogre::Entity* ent = mRend.getScene()->createEntity(meshNumbered);
|
||||
|
||||
/*MaterialPtr material = ent->getSubEntity(0)->getMaterial();
|
||||
material->removeAllTechniques();
|
||||
|
||||
Ogre::Technique* tech = material->createTechnique();
|
||||
|
||||
Pass* pass2 = tech->createPass();
|
||||
pass2->setVertexProgram("Ogre/HardwareSkinningTwoWeights");
|
||||
pass2->setColourWriteEnabled(false);
|
||||
//tech->setSchemeName("blahblah");*/
|
||||
|
||||
|
||||
|
||||
insert->attachObject(ent);
|
||||
|
@ -249,6 +243,7 @@ void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suf
|
|||
|
||||
|
||||
void NpcAnimation::runAnimation(float timepassed){
|
||||
|
||||
//1. Add the amount of time passed to time
|
||||
|
||||
//2. Handle the animation transforms dependent on time
|
||||
|
@ -267,22 +262,17 @@ void NpcAnimation::runAnimation(float timepassed){
|
|||
}
|
||||
|
||||
handleAnimationTransforms();
|
||||
Ogre::Vector3 current = insert->_getWorldAABB().getCenter();
|
||||
|
||||
std::vector<std::vector<Nif::NiTriShapeCopy>*>::iterator shapepartsiter = shapeparts.begin();
|
||||
std::vector<Ogre::Entity*>::iterator entitypartsiter = entityparts.begin();
|
||||
while(shapepartsiter != shapeparts.end())
|
||||
{
|
||||
vecRotPos.clear();
|
||||
std::vector<Nif::NiTriShapeCopy>* shapes = *shapepartsiter;
|
||||
Ogre::Entity* theentity = *entitypartsiter;
|
||||
/*
|
||||
Pass* pass = theentity->getSubEntity(0)->getMaterial()->getBestTechnique()->getPass(0);
|
||||
if (pass->hasVertexProgram() && pass->getVertexProgram()->isSkeletalAnimationIncluded())
|
||||
std::cout << "It's hardware\n";
|
||||
else
|
||||
std::cout << "It's software\n";*/
|
||||
|
||||
handleShapes(shapes, theentity, theentity->getSkeleton());
|
||||
|
||||
handleShapes(shapes, theentity, base->getSkeleton());
|
||||
shapepartsiter++;
|
||||
entitypartsiter++;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "objects.hpp"
|
||||
|
||||
#include <OgreSceneNode.h>
|
||||
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace MWRender;
|
||||
|
||||
|
||||
bool Objects::lightConst = false;
|
||||
float Objects::lightConstValue = 0.0f;
|
||||
|
||||
|
@ -23,10 +23,24 @@ bool Objects::lightOutQuadInLin = false;
|
|||
|
||||
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;
|
||||
}
|
||||
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* cellnode;
|
||||
if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
|
||||
|
@ -49,90 +63,91 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
|
|||
f = ptr.getCellRef().pos.rot;
|
||||
|
||||
// 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
|
||||
Quaternion yr(Radian(-f[1]), Vector3::UNIT_Y);
|
||||
Ogre::Quaternion yr(Ogre::Radian(-f[1]), Ogre::Vector3::UNIT_Y);
|
||||
|
||||
// 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);
|
||||
|
||||
if (!enabled)
|
||||
insert->setVisible (false);
|
||||
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();
|
||||
assert(insert);
|
||||
|
||||
NifOgre::NIFLoader::load(mesh);
|
||||
Entity *ent = mRend.getScene()->createEntity(mesh);
|
||||
Ogre::Entity *ent = mRenderer.getScene()->createEntity(mesh);
|
||||
|
||||
if(!isStatic)
|
||||
if(!mIsStatic)
|
||||
{
|
||||
insert->attachObject(ent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ogre::StaticGeometry* sg = 0;
|
||||
if(mSG.find(ptr.getCell()) == mSG.end())
|
||||
if(mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end())
|
||||
{
|
||||
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
|
||||
mSG[ptr.getCell()] = sg;
|
||||
mStaticGeometry[ptr.getCell()] = sg;
|
||||
}
|
||||
else
|
||||
{
|
||||
sg = mSG[ptr.getCell()];
|
||||
sg = mStaticGeometry[ptr.getCell()];
|
||||
}
|
||||
|
||||
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
|
||||
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
|
||||
|
||||
|
||||
mRend.getScene()->destroyEntity(ent);
|
||||
mRenderer.getScene()->destroyEntity(ent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){
|
||||
Ogre::SceneNode* insert = mRend.getScene()->getSceneNode(ptr.getRefData().getHandle());
|
||||
|
||||
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius)
|
||||
{
|
||||
Ogre::SceneNode* insert = mRenderer.getScene()->getSceneNode(ptr.getRefData().getHandle());
|
||||
assert(insert);
|
||||
Ogre::Light *light = mRend.getScene()->createLight();
|
||||
Ogre::Light *light = mRenderer.getScene()->createLight();
|
||||
light->setDiffuseColour (r, g, b);
|
||||
|
||||
float cval=0.0f, lval=0.0f, qval=0.0f;
|
||||
|
||||
if(lightConst)
|
||||
cval = lightConstValue;
|
||||
if(!lightOutQuadInLin)
|
||||
{
|
||||
if(lightLinear)
|
||||
radius *= lightLinearRadiusMult;
|
||||
if(lightQuadratic)
|
||||
radius *= lightQuadraticRadiusMult;
|
||||
|
||||
if(lightLinear)
|
||||
lval = lightLinearValue / pow(radius, lightLinearMethod);
|
||||
if(lightQuadratic)
|
||||
qval = lightQuadraticValue / pow(radius, lightQuadraticMethod);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME:
|
||||
// Do quadratic or linear, depending if we're in an exterior or interior
|
||||
// cell, respectively. Ignore lightLinear and lightQuadratic.
|
||||
}
|
||||
if(!lightOutQuadInLin)
|
||||
{
|
||||
if(lightLinear)
|
||||
radius *= lightLinearRadiusMult;
|
||||
if(lightQuadratic)
|
||||
radius *= lightQuadraticRadiusMult;
|
||||
|
||||
light->setAttenuation(10*radius, cval, lval, qval);
|
||||
if(lightLinear)
|
||||
lval = lightLinearValue / pow(radius, lightLinearMethod);
|
||||
if(lightQuadratic)
|
||||
qval = lightQuadraticValue / pow(radius, lightQuadraticMethod);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME:
|
||||
// Do quadratic or linear, depending if we're in an exterior or interior
|
||||
// cell, respectively. Ignore lightLinear and lightQuadratic.
|
||||
}
|
||||
|
||||
insert->attachObject(light);
|
||||
light->setAttenuation(10*radius, cval, lval, qval);
|
||||
|
||||
insert->attachObject(light);
|
||||
}
|
||||
|
||||
bool Objects::deleteObject (const MWWorld::Ptr& ptr)
|
||||
|
@ -145,8 +160,9 @@ bool Objects::deleteObject (const MWWorld::Ptr& ptr)
|
|||
mCellSceneNodes.begin()); iter!=mCellSceneNodes.end(); ++iter)
|
||||
if (iter->second==parent)
|
||||
{
|
||||
clearSceneNode (base);
|
||||
base->removeAndDestroyAllChildren();
|
||||
mRend.getScene()->destroySceneNode (base);
|
||||
mRenderer.getScene()->destroySceneNode (base);
|
||||
ptr.getRefData().setBaseNode (0);
|
||||
return true;
|
||||
}
|
||||
|
@ -157,29 +173,35 @@ bool Objects::deleteObject (const MWWorld::Ptr& ptr)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Objects::removeCell(MWWorld::Ptr::CellStore* store){
|
||||
void Objects::removeCell(MWWorld::Ptr::CellStore* store)
|
||||
{
|
||||
if(mCellSceneNodes.find(store) != mCellSceneNodes.end())
|
||||
{
|
||||
Ogre::SceneNode* base = mCellSceneNodes[store];
|
||||
|
||||
for (int i=0; i<base->numChildren(); ++i)
|
||||
clearSceneNode (static_cast<Ogre::SceneNode *> (base->getChild (i)));
|
||||
|
||||
base->removeAndDestroyAllChildren();
|
||||
mCellSceneNodes.erase(store);
|
||||
mRend.getScene()->destroySceneNode(base);
|
||||
mRenderer.getScene()->destroySceneNode(base);
|
||||
base = 0;
|
||||
}
|
||||
|
||||
|
||||
if(mSG.find(store) != mSG.end())
|
||||
if(mStaticGeometry.find(store) != mStaticGeometry.end())
|
||||
{
|
||||
Ogre::StaticGeometry* sg = mSG[store];
|
||||
mSG.erase(store);
|
||||
mRend.getScene()->destroyStaticGeometry (sg);
|
||||
Ogre::StaticGeometry* sg = mStaticGeometry[store];
|
||||
mStaticGeometry.erase(store);
|
||||
mRenderer.getScene()->destroyStaticGeometry (sg);
|
||||
sg = 0;
|
||||
}
|
||||
}
|
||||
void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell){
|
||||
if(mSG.find(&cell) != mSG.end())
|
||||
|
||||
void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell)
|
||||
{
|
||||
if(mStaticGeometry.find(&cell) != mStaticGeometry.end())
|
||||
{
|
||||
Ogre::StaticGeometry* sg = mSG[&cell];
|
||||
Ogre::StaticGeometry* sg = mStaticGeometry[&cell];
|
||||
sg->build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
#ifndef _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/ptr.hpp"
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
namespace MWRender{
|
||||
|
||||
class Objects{
|
||||
OEngine::Render::OgreRenderer &mRend;
|
||||
OEngine::Render::OgreRenderer &mRenderer;
|
||||
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;
|
||||
bool isStatic;
|
||||
bool mIsStatic;
|
||||
static int uniqueID;
|
||||
static bool lightConst;
|
||||
static float lightConstValue;
|
||||
|
@ -30,8 +31,12 @@ class Objects{
|
|||
static float lightQuadraticRadiusMult;
|
||||
|
||||
static bool lightOutQuadInLin;
|
||||
|
||||
void clearSceneNode (Ogre::SceneNode *node);
|
||||
///< Remove all movable objects from \a node.
|
||||
|
||||
public:
|
||||
Objects(OEngine::Render::OgreRenderer& _rend): mRend(_rend){}
|
||||
Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer){}
|
||||
~Objects(){}
|
||||
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
|
||||
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
|
|
|
@ -23,6 +23,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
:mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mDebugging(engine)
|
||||
{
|
||||
mRendering.createScene("PlayerCam", 55, 5);
|
||||
//mSkyManager = 0;
|
||||
mSkyManager = MWRender::SkyManager::create(mRendering.getWindow(), mRendering.getCamera(), resDir);
|
||||
|
||||
// Set default mipmap level (NB some APIs ignore this)
|
||||
|
@ -52,10 +53,12 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
cameraPitchNode->attachObject(mRendering.getCamera());
|
||||
|
||||
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
|
||||
mSun = 0;
|
||||
}
|
||||
|
||||
RenderingManager::~RenderingManager ()
|
||||
{
|
||||
//TODO: destroy mSun?
|
||||
delete mPlayer;
|
||||
delete mSkyManager;
|
||||
}
|
||||
|
@ -124,27 +127,32 @@ void RenderingManager::update (float duration){
|
|||
|
||||
void RenderingManager::skyEnable ()
|
||||
{
|
||||
if(mSkyManager)
|
||||
mSkyManager->enable();
|
||||
}
|
||||
|
||||
void RenderingManager::skyDisable ()
|
||||
{
|
||||
mSkyManager->disable();
|
||||
if(mSkyManager)
|
||||
mSkyManager->disable();
|
||||
}
|
||||
|
||||
void RenderingManager::skySetHour (double hour)
|
||||
{
|
||||
mSkyManager->setHour(hour);
|
||||
if(mSkyManager)
|
||||
mSkyManager->setHour(hour);
|
||||
}
|
||||
|
||||
|
||||
void RenderingManager::skySetDate (int day, int month)
|
||||
{
|
||||
mSkyManager->setDate(day, month);
|
||||
if(mSkyManager)
|
||||
mSkyManager->setDate(day, month);
|
||||
}
|
||||
|
||||
int RenderingManager::skyGetMasserPhase() const
|
||||
{
|
||||
|
||||
return mSkyManager->getMasserPhase();
|
||||
}
|
||||
|
||||
|
@ -153,9 +161,9 @@ int RenderingManager::skyGetSecundaPhase() const
|
|||
return mSkyManager->getSecundaPhase();
|
||||
}
|
||||
|
||||
void RenderingManager::skySetMoonColour (bool red)
|
||||
{
|
||||
mSkyManager->setMoonColour(red);
|
||||
void RenderingManager::skySetMoonColour (bool red){
|
||||
if(mSkyManager)
|
||||
mSkyManager->setMoonColour(red);
|
||||
}
|
||||
bool RenderingManager::toggleRenderMode(int mode){
|
||||
return mDebugging.toggleRenderMode(mode);
|
||||
|
@ -202,12 +210,15 @@ void RenderingManager::configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell
|
|||
|
||||
// Create a "sun" that shines light downwards. It doesn't look
|
||||
// completely right, but leave it for now.
|
||||
Ogre::Light *light = mRendering.getScene()->createLight();
|
||||
if(!mSun)
|
||||
{
|
||||
mSun = mRendering.getScene()->createLight();
|
||||
}
|
||||
Ogre::ColourValue colour;
|
||||
colour.setAsABGR (mCell.cell->ambi.sunlight);
|
||||
light->setDiffuseColour (colour);
|
||||
light->setType(Ogre::Light::LT_DIRECTIONAL);
|
||||
light->setDirection(0,-1,0);
|
||||
mSun->setDiffuseColour (colour);
|
||||
mSun->setType(Ogre::Light::LT_DIRECTIONAL);
|
||||
mSun->setDirection(0,-1,0);
|
||||
}
|
||||
// Switch through lighting modes.
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ class RenderingManager: private RenderingInterface {
|
|||
int mAmbientMode;
|
||||
|
||||
Ogre::ColourValue mAmbientColor;
|
||||
Ogre::Light* mSun;
|
||||
|
||||
/// Root node for all objects added to the scene. This is rotated so
|
||||
/// that the OGRE coordinate system matches that used internally in
|
||||
|
|
|
@ -63,10 +63,11 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y)
|
|||
|
||||
result = mExteriors.insert (std::make_pair (
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -79,10 +80,11 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name)
|
|||
const ESM::Cell *cell = mStore.cells.findInt (name);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@ namespace MWWorld
|
|||
std::cout << "Unloading cell\n";
|
||||
ListHandles functor;
|
||||
|
||||
MWWorld::Ptr::CellStore* active = *iter;
|
||||
|
||||
|
||||
|
||||
|
||||
active->forEach<ListHandles>(functor);
|
||||
|
||||
(*iter)->forEach<ListHandles>(functor);
|
||||
|
||||
{
|
||||
|
||||
|
@ -77,13 +77,15 @@ namespace MWWorld
|
|||
mPhysics->removeObject (node->getName());
|
||||
}
|
||||
}
|
||||
mRendering.removeCell(active);
|
||||
mRendering.removeCell(*iter);
|
||||
//mPhysics->removeObject("Unnamed_43");
|
||||
mWorld->getLocalScripts().clearCell (active);
|
||||
mEnvironment.mMechanicsManager->dropActors (active);
|
||||
mEnvironment.mSoundManager->stopSound (active);
|
||||
mActiveCells.erase(active);
|
||||
|
||||
mWorld->getLocalScripts().clearCell (*iter);
|
||||
mEnvironment.mMechanicsManager->dropActors (*iter);
|
||||
mEnvironment.mSoundManager->stopSound (*iter);
|
||||
mActiveCells.erase(*iter);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Scene::loadCell (Ptr::CellStore *cell)
|
||||
|
|
|
@ -181,6 +181,7 @@ namespace MWWorld
|
|||
|
||||
}
|
||||
|
||||
|
||||
World::~World()
|
||||
{
|
||||
delete mWorldScene;
|
||||
|
@ -610,7 +611,7 @@ namespace MWWorld
|
|||
|
||||
bool World::toggleCollisionMode()
|
||||
{
|
||||
return mPhysics->toggleCollisionMode();
|
||||
return mPhysics->toggleCollisionMode();;
|
||||
}
|
||||
|
||||
bool World::toggleRenderMode (RenderMode mode)
|
||||
|
|
|
@ -224,6 +224,7 @@ namespace MWWorld
|
|||
/// references that are currently not in the rendered scene should be ignored.
|
||||
|
||||
void update (float duration);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ void read(NIFFile *nif)
|
|||
int vertCount = nif->getInt();
|
||||
nif->getByte();
|
||||
int magic = nif->getInt();
|
||||
int type = nif->getInt();
|
||||
/*int type =*/ nif->getInt();
|
||||
for(int i = 0; i < vertCount; i++){
|
||||
|
||||
float x = nif->getFloat();
|
||||
|
@ -485,7 +485,7 @@ void read(NIFFile *nif)
|
|||
for(int i=1; i<morphCount; i++)
|
||||
{
|
||||
magic = nif->getInt();
|
||||
type = nif->getInt();
|
||||
/*type =*/ nif->getInt();
|
||||
std::vector<Ogre::Vector3> current;
|
||||
std::vector<float> currentTime;
|
||||
for(int i = 0; i < magic; i++){
|
||||
|
|
|
@ -220,14 +220,15 @@ void NIFLoader::createMaterial(const String &name,
|
|||
|
||||
|
||||
//Hardware Skinning code, textures may be the wrong color if enabled
|
||||
/*if(!mSkel.isNull()){
|
||||
|
||||
/* if(!mSkel.isNull()){
|
||||
material->removeAllTechniques();
|
||||
|
||||
Ogre::Technique* tech = material->createTechnique();
|
||||
//tech->setSchemeName("blahblah");
|
||||
Pass* pass = tech->createPass();
|
||||
pass->setVertexProgram("Ogre/HardwareSkinningFourWeights");
|
||||
}*/
|
||||
pass->setVertexProgram("Ogre/BasicVertexPrograms/AmbientOneTexture");*/
|
||||
|
||||
|
||||
// This assigns the texture to this material. If the texture name is
|
||||
// a file name, and this file exists (in a resource directory), it
|
||||
|
@ -358,7 +359,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
|
|||
HardwareVertexBufferSharedPtr vbuf =
|
||||
HardwareBufferManager::getSingleton().createVertexBuffer(
|
||||
VertexElement::getTypeSize(VET_FLOAT3),
|
||||
numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY, false);
|
||||
numVerts, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false);
|
||||
|
||||
if(flip)
|
||||
{
|
||||
|
@ -424,6 +425,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
|
|||
bind->setBinding(nextBuf++, vbuf);
|
||||
}
|
||||
|
||||
|
||||
// Vertex colors
|
||||
if (data->colors.length)
|
||||
{
|
||||
|
@ -530,6 +532,8 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std
|
|||
{
|
||||
sub->addBoneAssignment(*it);
|
||||
}
|
||||
if(mSkel.isNull())
|
||||
needBoneAssignments.push_back(sub);
|
||||
}
|
||||
|
||||
// Helper math functions. Reinventing linear algebra for the win!
|
||||
|
@ -580,6 +584,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
{
|
||||
assert(shape != NULL);
|
||||
|
||||
bool saveTheShape = inTheSkeletonTree;
|
||||
// Interpret flags
|
||||
bool hidden = (flags & 0x01) != 0; // Not displayed
|
||||
bool collide = (flags & 0x02) != 0; // Use mesh for collision
|
||||
|
@ -738,6 +743,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
std::list<VertexBoneAssignment> vertexBoneAssignments;
|
||||
|
||||
Nif::NiTriShapeCopy copy = shape->clone();
|
||||
|
||||
if(!shape->controller.empty())
|
||||
{
|
||||
Nif::Controller* cont = shape->controller.getPtr();
|
||||
|
@ -747,6 +753,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
copy.morph = morph->data.get();
|
||||
copy.morph.setStartTime(morph->timeStart);
|
||||
copy.morph.setStopTime(morph->timeStop);
|
||||
saveTheShape = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -888,6 +895,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
boneIndex++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -924,10 +932,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
}
|
||||
if(!mSkel.isNull() ){
|
||||
int boneIndex;
|
||||
Ogre::Bone *parentBone = mSkel->getBone(boneSequence[boneSequence.size() - 1]);
|
||||
if(parentBone)
|
||||
boneIndex = parentBone->getHandle();
|
||||
else
|
||||
|
||||
boneIndex = mSkel->getNumBones() - 1;
|
||||
for(int i = 0; i < numVerts; i++){
|
||||
VertexBoneAssignment vba;
|
||||
|
@ -943,7 +948,8 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
{
|
||||
// Add this vertex set to the bounding box
|
||||
bounds.add(optr, numVerts);
|
||||
shapes.push_back(copy);
|
||||
if(saveTheShape)
|
||||
shapes.push_back(copy);
|
||||
|
||||
// Create the submesh
|
||||
createOgreSubMesh(shape, material, vertexBoneAssignments);
|
||||
|
@ -1063,19 +1069,22 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
|
|||
//FIXME: "Bip01" isn't every time the root bone
|
||||
if (node->name == "Bip01" || node->name == "Root Bone") //root node, create a skeleton
|
||||
{
|
||||
inTheSkeletonTree = true;
|
||||
|
||||
mSkel = SkeletonManager::getSingleton().create(getSkeletonName(), resourceGroup, true);
|
||||
}
|
||||
else if (!mSkel.isNull() && !parentBone)
|
||||
inTheSkeletonTree = false;
|
||||
|
||||
if (!mSkel.isNull()) //if there is a skeleton
|
||||
{
|
||||
std::string name = node->name.toString();
|
||||
boneSequence.push_back(name);
|
||||
|
||||
// Quick-n-dirty workaround for the fact that several
|
||||
// bones may have the same name.
|
||||
if(!mSkel->hasBone(name))
|
||||
{
|
||||
boneSequence.push_back(name);
|
||||
bone = mSkel->createBone(name);
|
||||
|
||||
if (parentBone)
|
||||
|
@ -1140,8 +1149,11 @@ void NIFLoader::handleNode(Nif::Node *node, int flags,
|
|||
|
||||
void NIFLoader::loadResource(Resource *resource)
|
||||
{
|
||||
inTheSkeletonTree = false;
|
||||
allanim.clear();
|
||||
shapes.clear();
|
||||
needBoneAssignments.clear();
|
||||
// needBoneAssignments.clear();
|
||||
mBoundingBox.setNull();
|
||||
mesh = 0;
|
||||
mSkel.setNull();
|
||||
|
@ -1150,8 +1162,12 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
char suffix = name.at(name.length() - 2);
|
||||
bool addAnim = true;
|
||||
bool hasAnim = false;
|
||||
bool baddin = false;
|
||||
//bool baddin = false;
|
||||
bNiTri = true;
|
||||
if(name == "meshes\\base_anim.nif" || name == "meshes\\base_animkna.nif")
|
||||
{
|
||||
bNiTri = false;
|
||||
}
|
||||
|
||||
if(suffix == '*')
|
||||
{
|
||||
|
@ -1168,7 +1184,7 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
}
|
||||
else if(suffix == '>')
|
||||
{
|
||||
baddin = true;
|
||||
//baddin = true;
|
||||
bNiTri = true;
|
||||
std::string sub = name.substr(name.length() - 6, 4);
|
||||
|
||||
|
@ -1268,7 +1284,7 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
Nif::Node *o = dynamic_cast<Nif::Node*>(f->target.getPtr());
|
||||
Nif::NiKeyframeDataPtr data = f->data;
|
||||
|
||||
if (f->timeStart == 10000000000000000)
|
||||
if (f->timeStart >= 10000000000000000.0f)
|
||||
continue;
|
||||
data->setBonename(o->name.toString());
|
||||
data->setStartTime(f->timeStart);
|
||||
|
@ -1299,15 +1315,24 @@ void NIFLoader::loadResource(Resource *resource)
|
|||
mesh->_setBounds(mBoundingBox, false);
|
||||
}
|
||||
|
||||
if (!mSkel.isNull())
|
||||
if (!mSkel.isNull() )
|
||||
{
|
||||
for(std::vector<Ogre::SubMesh*>::iterator iter = needBoneAssignments.begin(); iter != needBoneAssignments.end(); iter++)
|
||||
{
|
||||
int boneIndex = mSkel->getNumBones() - 1;
|
||||
VertexBoneAssignment vba;
|
||||
vba.boneIndex = boneIndex;
|
||||
vba.vertexIndex = 0;
|
||||
vba.weight = 1;
|
||||
|
||||
|
||||
(*iter)->addBoneAssignment(vba);
|
||||
}
|
||||
mesh->_notifySkeleton(mSkel);
|
||||
}
|
||||
}
|
||||
|
||||
void NIFLoader::addInMesh(Ogre::Mesh* input){
|
||||
addin.push_back(input);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
std::vector<Nif::NiKeyframeData>* getAnim(std::string name);
|
||||
std::vector<Nif::NiTriShapeCopy>* getShapes(std::string name);
|
||||
std::map<std::string, float>* getTextIndices(std::string name);
|
||||
void addInMesh(Ogre::Mesh* input);
|
||||
|
||||
|
||||
Ogre::Vector3 convertVector3(const Nif::Vector& vec);
|
||||
|
@ -121,8 +120,9 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
void setVerbosePath(std::string path);
|
||||
|
||||
private:
|
||||
|
||||
NIFLoader() : resourceName(""), resourceGroup("General"), flip(false), mNormaliseNormals(false),
|
||||
mFlipVertexWinding(false), mOutputAnimFiles(false) {}
|
||||
mFlipVertexWinding(false), mOutputAnimFiles(false), inTheSkeletonTree(false) {}
|
||||
NIFLoader(NIFLoader& n) {}
|
||||
|
||||
void calculateTransform();
|
||||
|
@ -184,13 +184,16 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
std::string name;
|
||||
std::string triname;
|
||||
std::vector<Nif::NiKeyframeData> allanim;
|
||||
std::map<std::string,float> textmappings;
|
||||
std::map<std::string,std::map<std::string,float>,ciLessBoost> alltextmappings;
|
||||
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost> allanimmap;
|
||||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost> allshapesmap;
|
||||
std::vector<Ogre::Mesh*> addin;
|
||||
|
||||
std::map<std::string,float> textmappings;
|
||||
std::map<std::string,std::map<std::string,float>,ciLessBoost> alltextmappings;
|
||||
std::map<std::string,std::vector<Nif::NiKeyframeData>,ciLessBoost> allanimmap;
|
||||
std::map<std::string,std::vector<Nif::NiTriShapeCopy>,ciLessBoost> allshapesmap;
|
||||
std::vector<Nif::NiKeyframeData> mAnim;
|
||||
std::vector<Nif::NiTriShapeCopy> mS;
|
||||
std::vector<Nif::NiTriShapeCopy> mS;
|
||||
std::vector<Ogre::SubMesh*> needBoneAssignments;
|
||||
bool inTheSkeletonTree;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.10</string>
|
||||
<string>${OPENMW_VERSION}</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>LSRequiresCarbon</key>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6c7e5d00e4f5bf954afe15f10e56f03520abfee4
|
||||
Subproject commit 4a188f2820c037ca4ad8ef35492d3857ea8d7df8
|
Loading…
Reference in a new issue