Merge branch 'master' of git://github.com/zinnschlag/openmw

actorid
lazydev 12 years ago
commit 169a1ff1ce

@ -297,7 +297,7 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
"${OpenMW_BINARY_DIR}/openmw.cfg.install")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (NOT WIN32 AND NOT APPLE)
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.desktop
"${OpenMW_BINARY_DIR}/openmw.desktop")
endif()
@ -378,7 +378,7 @@ if(WIN32)
"${OpenMW_SOURCE_DIR}/readme.txt"
"${OpenMW_SOURCE_DIR}/GPL3.txt"
"${OpenMW_SOURCE_DIR}/OFL.txt"
"${OpenMW_SOURCE_DIR}/Bitstream Vera License.txt"
"${OpenMW_SOURCE_DIR}/DejaVu Font License.txt"
"${OpenMW_SOURCE_DIR}/Daedric Font License.txt"
"${OpenMW_BINARY_DIR}/launcher.qss"
"${OpenMW_BINARY_DIR}/settings-default.cfg"
@ -389,7 +389,7 @@ if(WIN32)
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".")
SET(CPACK_GENERATOR "NSIS")
SET(CPACK_PACKAGE_NAME "OpenMW ${OPENMW_VERSION}")
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})
@ -404,7 +404,7 @@ if(WIN32)
SET(CPACK_RESOURCE_FILE_README "${OpenMW_SOURCE_DIR}/readme.txt")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenMW_SOURCE_DIR}/readme.txt")
SET(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
SET(CPACK_NSIS_DISPLAY_NAME "OpenMW")
SET(CPACK_NSIS_DISPLAY_NAME "OpenMW ${OPENMW_VERSION}")
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")
@ -657,10 +657,18 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
# Install binaries
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/openmw" DESTINATION "${BINDIR}" )
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" )
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" )
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/mwiniimport" DESTINATION "${BINDIR}" )
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/opencs" DESTINATION "${BINDIR}" )
IF(BUILD_LAUNCHER)
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" )
ENDIF(BUILD_LAUNCHER)
IF(BUILD_ESMTOOL)
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" )
ENDIF(BUILD_ESMTOOL)
IF(BUILD_MWINIIMPORTER)
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/mwiniimport" DESTINATION "${BINDIR}" )
ENDIF(BUILD_MWINIIMPORTER)
IF(BUILD_OPENCS)
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/opencs" DESTINATION "${BINDIR}" )
ENDIF(BUILD_OPENCS)
# Install icon and .desktop
INSTALL(FILES "${OpenMW_SOURCE_DIR}/apps/launcher/resources/images/openmw.png" DESTINATION "${ICONDIR}")
@ -674,5 +682,7 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
# Install resources
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${DATADIR}" )
INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${DATADIR}/resources" )
IF(BUILD_LAUNCHER)
INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${DATADIR}/resources" )
ENDIF(BUILD_LAUNCHER)
endif(NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)

@ -289,7 +289,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
case SelectWrapper::Function_PcGender:
return player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female ? 0 : 1;
return player.get<ESM::NPC>()->mBase->isMale() ? 0 : 1;
case SelectWrapper::Function_PcClothingModifier:
{

@ -106,7 +106,7 @@ namespace MWGui
float progress = (float(mCurrentCellLoading)+refProgress) / float(mTotalCellsLoading);
assert(progress <= 1 && progress >= 0);
mLoadingText->setCaption(stage + "... ");
mLoadingText->setCaption(stage);
mProgressBar->setProgressPosition (static_cast<size_t>(progress * 1000));
static float loadingScreenFps = 30.f;

@ -5,6 +5,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
namespace MWGui
{
@ -65,6 +66,7 @@ namespace MWGui
void MainMenu::onButtonClicked(MyGUI::Widget *sender)
{
MWBase::Environment::get().getSoundManager()->playSound("Menu Click", 1.f, 1.f);
if (sender == mButtons["return"])
MWBase::Environment::get().getWindowManager ()->removeGuiMode (GM_MainMenu);
else if (sender == mButtons["options"])

@ -95,31 +95,46 @@ namespace MWGui
// http://www.uesp.net/wiki/Lore:Calendar
std::string month;
int m = MWBase::Environment::get().getWorld ()->getMonth ();
if (m == 0)
month = "#{sMonthMorningstar}";
else if (m == 1)
month = "#{sMonthSunsdawn}";
else if (m == 2)
month = "#{sMonthFirstseed}";
else if (m == 3)
month = "#{sMonthRainshand}";
else if (m == 4)
month = "#{sMonthSecondseed}";
else if (m == 5)
month = "#{sMonthMidyear}";
else if (m == 6)
month = "#{sMonthSunsheight}";
else if (m == 7)
month = "#{sMonthLastseed}";
else if (m == 8)
month = "#{sMonthHeartfire}";
else if (m == 9)
month = "#{sMonthFrostfall}";
else if (m == 10)
month = "#{sMonthSunsdusk}";
else if (m == 11)
month = "#{sMonthEveningstar}";
switch (m) {
case 0:
month = "#{sMonthMorningstar}";
break;
case 1:
month = "#{sMonthSunsdawn}";
break;
case 2:
month = "#{sMonthFirstseed}";
break;
case 3:
month = "#{sMonthRainshand}";
break;
case 4:
month = "#{sMonthSecondseed}";
break;
case 5:
month = "#{sMonthMidyear}";
break;
case 6:
month = "#{sMonthSunsheight}";
break;
case 7:
month = "#{sMonthLastseed}";
break;
case 8:
month = "#{sMonthHeartfire}";
break;
case 9:
month = "#{sMonthFrostfall}";
break;
case 10:
month = "#{sMonthSunsdusk}";
break;
case 11:
month = "#{sMonthEveningstar}";
break;
default:
break;
}
int hour = MWBase::Environment::get().getWorld ()->getTimeStamp ().getHour ();
bool pm = hour >= 12;
if (hour >= 13) hour -= 12;

@ -424,6 +424,12 @@ void WindowManager::updateVisible()
MyGUI::PointerManager::getInstance().setVisible(false);
break;
case GM_Loading:
// Show the pinned windows
mMap->setVisible(mMap->pinned());
mStatsWindow->setVisible(mStatsWindow->pinned());
mInventoryWindow->setVisible(mInventoryWindow->pinned());
mSpellWindow->setVisible(mSpellWindow->pinned());
MyGUI::PointerManager::getInstance().setVisible(false);
break;
case GM_Video:

@ -53,8 +53,6 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
if(!mEntityList.mSkelBase)
return;
Ogre::SkeletonManager &skelMgr = Ogre::SkeletonManager::getSingleton();
mCurrentAnim = NULL;
mCurrentKeys = NULL;
mAnimVelocity = 0.0f;
@ -62,19 +60,14 @@ void Animation::setAnimationSources(const std::vector<std::string> &names)
mNonAccumRoot = NULL;
mSkeletonSources.clear();
std::vector<std::string>::const_iterator nameiter = names.begin();
std::vector<std::string>::const_iterator nameiter;
for(nameiter = names.begin();nameiter != names.end();nameiter++)
{
Ogre::SkeletonPtr skel = skelMgr.getByName(*nameiter);
Ogre::SkeletonPtr skel = NifOgre::Loader::getSkeleton(*nameiter);
if(skel.isNull())
{
NifOgre::Loader::createSkeleton(*nameiter);
skel = skelMgr.getByName(*nameiter);
if(skel.isNull())
{
std::cerr<< "Failed to get skeleton source "<<*nameiter <<std::endl;
continue;
}
std::cerr<< "Failed to get skeleton source "<<*nameiter <<std::endl;
continue;
}
skel->touch();

@ -27,13 +27,10 @@ namespace
{
const MWWorld::Class& class_ =
MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.mList.begin(), &cell));
size_t numRefs = cellRefList.mList.size();
int current = 0;
for (typename T::List::iterator it = cellRefList.mList.begin();
it != cellRefList.mList.end(); it++)
{
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, current, numRefs);
++current;
if (it->mData.getCount() || it->mData.isEnabled())
@ -55,10 +52,6 @@ namespace
}
}
}
else
{
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, 0, 1);
}
}
}
@ -176,12 +169,18 @@ namespace MWWorld
void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
{
Nif::NIFFile::CacheLock cachelock;
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
mRendering.preCellChange(mCurrentCell);
// remove active
MWBase::Environment::get().getMechanicsManager()->remove(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
std::string loadingExteriorText;
loadingExteriorText = gmst.find ("sLoadingMessage3")->getString();
CellStoreCollection::iterator active = mActiveCells.begin();
// get the number of cells to unload
@ -216,8 +215,6 @@ namespace MWWorld
continue;
}
}
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);
unloadCell (active++);
++current;
}
@ -266,7 +263,9 @@ namespace MWWorld
{
CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y);
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, current, numLoad);
//Loading Exterior loading text
MWBase::Environment::get().getWindowManager ()->setLoadingProgress (loadingExteriorText, 0, current, numLoad);
loadCell (cell);
++current;
}
@ -325,6 +324,13 @@ namespace MWWorld
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
{
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
std::string loadingInteriorText;
loadingInteriorText = gmst.find ("sLoadingMessage2")->getString();
CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName);
bool loadcell = (mCurrentCell == NULL);
if(!loadcell)
@ -360,8 +366,6 @@ namespace MWWorld
active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);
unloadCell (active++);
++current;
}
@ -369,7 +373,9 @@ namespace MWWorld
// Load cell.
std::cout << "cellName: " << cell->mCell->mName << std::endl;
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1);
//Loading Interior loading text
MWBase::Environment::get().getWindowManager ()->setLoadingProgress (loadingInteriorText, 0, 0, 1);
loadCell (cell);
mCurrentCell = cell;

@ -2,7 +2,7 @@
macro (add_openmw_dir dir)
set (files)
foreach (u ${ARGN})
file (GLOB ALL ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.[ch]pp")
file (GLOB ALL "${dir}/${u}.[ch]pp")
foreach (f ${ALL})
list (APPEND files "${f}")
list (APPEND OPENMW_FILES "${f}")
@ -14,7 +14,7 @@ endmacro (add_openmw_dir)
macro (add_component_dir dir)
set (files)
foreach (u ${ARGN})
file (GLOB ALL ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.[ch]pp")
file (GLOB ALL "${dir}/${u}.[ch]pp")
foreach (f ${ALL})
list (APPEND files "${f}")
list (APPEND COMPONENT_FILES "${f}")
@ -26,12 +26,12 @@ endmacro (add_component_dir)
macro (add_component_qt_dir dir)
set (files)
foreach (u ${ARGN})
file (GLOB ALL ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.[ch]pp")
file (GLOB ALL "${dir}/${u}.[ch]pp")
foreach (f ${ALL})
list (APPEND files "${f}")
list (APPEND COMPONENT_FILES "${f}")
endforeach (f)
file (GLOB MOC_H ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.hpp")
file (GLOB MOC_H "${dir}/${u}.hpp")
foreach (fi ${MOC_H})
list (APPEND COMPONENT_MOC_FILES "${fi}")
endforeach (fi)

@ -77,8 +77,7 @@ void ESMReader::open(Ogre::DataStreamPtr _esm, const std::string &name)
// Get the header
getHNT(mCtx.header, "HEDR", 300);
if (mCtx.header.version != VER_12 && mCtx.header.version != VER_13)
fail("Unsupported file format version");
// Some mods abuse the header.version field for the version of the mod instead of the version of the file format, so we can only ignore it.
while (isNextSub("MAST"))
{

@ -1,25 +1,3 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/fixedpath.hpp */
#ifndef COMPONENTS_FILES_FIXEDPATH_HPP
#define COMPONENTS_FILES_FIXEDPATH_HPP

@ -1,25 +1,3 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/linuxpath.cpp */
#include "linuxpath.hpp"
#if defined(__linux__) || defined(__FreeBSD__)

@ -1,25 +1,3 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/linuxpath.hpp */
#ifndef COMPONENTS_FILES_LINUXPATH_H
#define COMPONENTS_FILES_LINUXPATH_H

@ -1,25 +1,3 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/macospath.cpp */
#include "macospath.hpp"
#if defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)

@ -1,25 +1,3 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/macospath.hpp */
#ifndef COMPONENTS_FILES_MACOSPATH_H
#define COMPONENTS_FILES_MACOSPATH_H

@ -1,25 +1,3 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/ogreplugin.hpp */
#ifndef COMPONENTS_FILES_OGREPLUGIN_H
#define COMPONENTS_FILES_OGREPLUGIN_H

@ -1,25 +1,3 @@
/**
* Open Morrowind - an opensource Elder Scrolls III: Morrowind
* engine implementation.
*
* Copyright (C) 2011 Open Morrowind Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file components/files/windowspath.hpp */
#ifndef COMPONENTS_FILES_WINDOWSPATH_HPP
#define COMPONENTS_FILES_WINDOWSPATH_HPP

@ -256,6 +256,7 @@ void NIFFile::parse()
else if(rec == "NiDitherProperty") { r = new NiDitherProperty; r->recType = RC_NiDitherProperty; }
else if(rec == "NiWireframeProperty") { r = new NiWireframeProperty; r->recType = RC_NiWireframeProperty; }
else if(rec == "NiSpecularProperty") { r = new NiSpecularProperty; r->recType = RC_NiSpecularProperty; }
else if(rec == "NiStencilProperty") { r = new NiStencilProperty; r->recType = RC_NiStencilProperty; }
// Controllers
else if(rec == "NiVisController") { r = new NiVisController; r->recType = RC_NiVisController; }

@ -158,6 +158,7 @@ public:
short getShort() { return read_le16(); }
unsigned short getUShort() { return read_le16(); }
int getInt() { return read_le32(); }
unsigned int getUInt() { return read_le32(); }
float getFloat() { return read_le32f(); }
Ogre::Vector2 getVector2()
{

@ -257,9 +257,66 @@ struct S_AlphaProperty
}
};
/*
Docs taken from:
http://niftools.sourceforge.net/doc/nif/NiStencilProperty.html
*/
struct S_StencilProperty
{
// Is stencil test enabled?
unsigned char enabled;
/*
0 TEST_NEVER
1 TEST_LESS
2 TEST_EQUAL
3 TEST_LESS_EQUAL
4 TEST_GREATER
5 TEST_NOT_EQUAL
6 TEST_GREATER_EQUAL
7 TEST_ALWAYS
*/
int compareFunc;
unsigned stencilRef;
unsigned stencilMask;
/*
Stencil test fail action, depth test fail action and depth test pass action:
0 ACTION_KEEP
1 ACTION_ZERO
2 ACTION_REPLACE
3 ACTION_INCREMENT
4 ACTION_DECREMENT
5 ACTION_INVERT
*/
int failAction;
int zFailAction;
int zPassAction;
/*
Face draw mode:
0 DRAW_CCW_OR_BOTH
1 DRAW_CCW [default]
2 DRAW_CW
3 DRAW_BOTH
*/
int drawMode;
void read(NIFFile *nif)
{
enabled = nif->getChar();
compareFunc = nif->getInt();
stencilRef = nif->getUInt();
stencilMask = nif->getUInt();
failAction = nif->getInt();
zFailAction = nif->getInt();
zPassAction = nif->getInt();
drawMode = nif->getInt();
}
};
typedef StructPropT<S_AlphaProperty> NiAlphaProperty;
typedef StructPropT<S_MaterialProperty> NiMaterialProperty;
typedef StructPropT<S_VertexColorProperty> NiVertexColorProperty;
typedef StructPropT<S_StencilProperty> NiStencilProperty;
} // Namespace
#endif

@ -48,6 +48,7 @@ enum RecordType
RC_NiDitherProperty,
RC_NiWireframeProperty,
RC_NiSpecularProperty,
RC_NiStencilProperty,
RC_NiVisController,
RC_NiGeomMorpherController,
RC_NiKeyframeController,

@ -452,7 +452,8 @@ void loadResource(Ogre::Resource *resource)
}
}
bool createSkeleton(const std::string &name, const std::string &group, const Nif::Node *node)
static Ogre::SkeletonPtr createSkeleton(const std::string &name, const std::string &group, const Nif::Node *node)
{
/* We need to be a little aggressive here, since some NIFs have a crap-ton
* of nodes and Ogre only supports 256 bones. We will skip a skeleton if:
@ -463,7 +464,7 @@ bool createSkeleton(const std::string &name, const std::string &group, const Nif
if(!node->boneTrafo)
{
if(node->recType == Nif::RC_NiTriShape)
return false;
return Ogre::SkeletonPtr();
if(node->controller.empty() && node->name != "AttachLight")
{
if(node->recType == Nif::RC_NiNode || node->recType == Nif::RC_RootCollisionNode)
@ -474,67 +475,61 @@ bool createSkeleton(const std::string &name, const std::string &group, const Nif
{
if(!children[i].empty())
{
if(createSkeleton(name, group, children[i].getPtr()))
return true;
Ogre::SkeletonPtr skel = createSkeleton(name, group, children[i].getPtr());
if(!skel.isNull())
return skel;
}
}
return false;
return Ogre::SkeletonPtr();
}
}
}
Ogre::SkeletonManager &skelMgr = Ogre::SkeletonManager::getSingleton();
skelMgr.create(name, group, true, &sLoaders[name]);
return true;
return skelMgr.create(name, group, true, &sLoaders[name]);
}
};
NIFSkeletonLoader::LoaderMap NIFSkeletonLoader::sLoaders;
// Conversion of blend / test mode from NIF -> OGRE.
// Not in use yet, so let's comment it out.
/*
static SceneBlendFactor getBlendFactor(int mode)
// Conversion of blend / test mode from NIF
static const char *getBlendFactor(int mode)
{
switch(mode)
switch(mode)
{
case 0: return SBF_ONE;
case 1: return SBF_ZERO;
case 2: return SBF_SOURCE_COLOUR;
case 3: return SBF_ONE_MINUS_SOURCE_COLOUR;
case 4: return SBF_DEST_COLOUR;
case 5: return SBF_ONE_MINUS_DEST_COLOUR;
case 6: return SBF_SOURCE_ALPHA;
case 7: return SBF_ONE_MINUS_SOURCE_ALPHA;
case 8: return SBF_DEST_ALPHA;
case 9: return SBF_ONE_MINUS_DEST_ALPHA;
// [Comment from Chris Robinson:] Can't handle this mode? :/
// case 10: return SBF_SOURCE_ALPHA_SATURATE;
default:
return SBF_SOURCE_ALPHA;
case 0: return "one";
case 1: return "zero";
case 2: return "src_colour";
case 3: return "one_minus_src_colour";
case 4: return "dest_colour";
case 5: return "one_minus_dest_colour";
case 6: return "src_alpha";
case 7: return "one_minus_src_alpha";
case 8: return "dest_alpha";
case 9: return "one_minus_dest_alpha";
case 10: return "src_alpha_saturate";
}
std::cerr<< "Unexpected blend mode: "<<mode <<std::endl;
return "src_alpha";
}
// This is also unused
static CompareFunction getTestMode(int mode)
static const char *getTestMode(int mode)
{
switch(mode)
switch(mode)
{
case 0: return CMPF_ALWAYS_PASS;
case 1: return CMPF_LESS;
case 2: return CMPF_EQUAL;
case 3: return CMPF_LESS_EQUAL;
case 4: return CMPF_GREATER;
case 5: return CMPF_NOT_EQUAL;
case 6: return CMPF_GREATER_EQUAL;
case 7: return CMPF_ALWAYS_FAIL;
default:
return CMPF_ALWAYS_PASS;
case 0: return "always_pass";
case 1: return "less";
case 2: return "equal";
case 3: return "less_equal";
case 4: return "greater";
case 5: return "not_equal";
case 6: return "greater_equal";
case 7: return "always_fail";
}
std::cerr<< "Unexpected test mode: "<<mode <<std::endl;
return "less_equal";
}
*/
class NIFMaterialLoader {
@ -567,8 +562,8 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String
Ogre::Vector3 emissive(0.0f);
float glossiness = 0.0f;
float alpha = 1.0f;
int alphaFlags = -1;
// ubyte alphaTest = 0;
int alphaFlags = 0;
int alphaTest = 0;
Ogre::String texName;
bool vertexColour = (shape->data->colors.size() != 0);
@ -592,6 +587,8 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String
m = static_cast<const Nif::NiMaterialProperty*>(pr);
else if (pr->recType == Nif::RC_NiAlphaProperty)
a = static_cast<const Nif::NiAlphaProperty*>(pr);
else if (pr->recType == Nif::RC_NiStencilProperty)
/* unused */;
else
warn("Skipped property type: "+pr->recName);
}
@ -640,7 +637,7 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String
if (a)
{
alphaFlags = a->flags;
// alphaTest = a->data.threshold;
alphaTest = a->data.threshold;
}
// Material
@ -674,6 +671,7 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String
boost::hash_combine(h, texName);
boost::hash_combine(h, vertexColour);
boost::hash_combine(h, alphaFlags);
boost::hash_combine(h, alphaTest);
std::map<size_t,std::string>::iterator itr = MaterialMap.find(h);
if (itr != MaterialMap.end())
@ -705,57 +703,37 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String
instance->setProperty ("has_vertex_colour", sh::makeProperty<sh::BooleanValue>(new sh::BooleanValue(true)));
// Add transparency if NiAlphaProperty was present
if (alphaFlags != -1)
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName);
if (result.first)
{
// The 237 alpha flags are by far the most common. Check
// NiAlphaProperty in nif/property.h if you need to decode
// other values. 237 basically means normal transparencly.
if (alphaFlags == 237)
{
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName);
if (result.first)
{
instance->setProperty("alpha_rejection",
sh::makeProperty<sh::StringValue>(new sh::StringValue("greater_equal " + boost::lexical_cast<std::string>(result.second))));
}
else
{
// Enable transparency
instance->setProperty("scene_blend", sh::makeProperty<sh::StringValue>(new sh::StringValue("alpha_blend")));
instance->setProperty("depth_write", sh::makeProperty<sh::StringValue>(new sh::StringValue("off")));
}
}
else
warn("Unhandled alpha setting for texture " + texName);
alphaFlags = (1<<9) | (6<<10); /* alpha_rejection enabled, greater_equal */
alphaTest = result.second;
}
else
instance->getMaterial ()->setShadowCasterMaterial ("openmw_shadowcaster_noalpha");
// As of yet UNTESTED code from Chris:
/*pass->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
pass->setDepthFunction(Ogre::CMPF_LESS_EQUAL);
pass->setDepthCheckEnabled(true);
// Add transparency if NiAlphaProperty was present
if (alphaFlags != -1)
if((alphaFlags&1))
{
std::cout << "Alpha flags set!" << endl;
if ((alphaFlags&1))
{
pass->setDepthWriteEnabled(false);
pass->setSceneBlending(getBlendFactor((alphaFlags>>1)&0xf),
getBlendFactor((alphaFlags>>5)&0xf));
}
else
pass->setDepthWriteEnabled(true);
std::string blend_mode;
blend_mode += getBlendFactor((alphaFlags>>1)&0xf);
blend_mode += " ";
blend_mode += getBlendFactor((alphaFlags>>5)&0xf);
if ((alphaFlags>>9)&1)
pass->setAlphaRejectSettings(getTestMode((alphaFlags>>10)&0x7),
alphaTest);
instance->setProperty("depth_write", sh::makeProperty(new sh::StringValue("off")));
instance->setProperty("scene_blend", sh::makeProperty(new sh::StringValue(blend_mode)));
}
else
instance->getMaterial()->setShadowCasterMaterial("openmw_shadowcaster_noalpha");
pass->setTransparentSortingEnabled(!((alphaFlags>>13)&1));
if((alphaFlags>>9)&1)
{
std::string reject;
reject += getTestMode((alphaFlags>>10)&0x7);
reject += " ";
reject += Ogre::StringConverter::toString(alphaTest);
instance->setProperty("alpha_rejection", sh::makeProperty(new sh::StringValue(reject)));
}
*/
instance->setProperty("transparent_sorting", sh::makeProperty(new sh::StringValue(((alphaFlags>>13)&1) ?
"off" : "on")));
return matname;
}
@ -1165,10 +1143,7 @@ MeshInfoList Loader::load(const std::string &name, const std::string &group)
bool hasSkel = Ogre::SkeletonManager::getSingleton().resourceExists(name);
if(!hasSkel)
{
NIFSkeletonLoader skelldr;
hasSkel = skelldr.createSkeleton(name, group, node);
}
hasSkel = !NIFSkeletonLoader::createSkeleton(name, group, node).isNull();
NIFMeshLoader meshldr(name, group);
if(hasSkel)
@ -1231,14 +1206,20 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
if(meshes.size() == 0)
return entitylist;
bool isskinned = false;
Ogre::SceneManager *sceneMgr = parentNode->getCreator();
std::string filter = "@shape=tri "+bonename;
Misc::StringUtils::toLower(filter);
for(size_t i = 0;i < meshes.size();i++)
{
Ogre::Entity *ent = sceneMgr->createEntity(meshes[i].mMeshName);
if(!entitylist.mSkelBase && ent->hasSkeleton())
entitylist.mSkelBase = ent;
if(!entitylist.mSkelBase)
{
if(ent->hasSkeleton())
entitylist.mSkelBase = ent;
}
else if(!isskinned && ent->hasSkeleton())
isskinned = true;
entitylist.mEntities.push_back(ent);
}
@ -1246,7 +1227,7 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
if(bonename.find("Left") != std::string::npos)
scale.x *= -1.0f;
if(entitylist.mSkelBase)
if(isskinned)
{
for(size_t i = 0;i < entitylist.mEntities.size();i++)
{
@ -1278,30 +1259,35 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
}
bool Loader::createSkeleton(const std::string &name, const std::string &group)
Ogre::SkeletonPtr Loader::getSkeleton(std::string name, const std::string &group)
{
Nif::NIFFile::ptr pnif = Nif::NIFFile::create(name);
Nif::NIFFile &nif = *pnif.get();
if(nif.numRecords() < 1)
Ogre::SkeletonPtr skel;
Misc::StringUtils::toLower(name);
skel = Ogre::SkeletonManager::getSingleton().getByName(name);
if(!skel.isNull())
return skel;
Nif::NIFFile::ptr nif = Nif::NIFFile::create(name);
if(nif->numRecords() < 1)
{
nif.warn("Found no NIF records in "+name+".");
return false;
nif->warn("Found no NIF records in "+name+".");
return skel;
}
// The first record is assumed to be the root node
Nif::Record const *r = nif.getRecord(0);
const Nif::Record *r = nif->getRecord(0);
assert(r != NULL);
Nif::Node const *node = dynamic_cast<Nif::Node const *>(r);
const Nif::Node *node = dynamic_cast<const Nif::Node*>(r);
if(node == NULL)
{
nif.warn("First record in "+name+" was not a node, but a "+
r->recName+".");
return false;
nif->warn("First record in "+name+" was not a node, but a "+
r->recName+".");
return skel;
}
NIFSkeletonLoader skelldr;
return skelldr.createSkeleton(name, group, node);
return NIFSkeletonLoader::createSkeleton(name, group, node);
}

@ -74,7 +74,7 @@ public:
std::string name,
const std::string &group="General");
static bool createSkeleton(const std::string &name, const std::string &group="General");
static Ogre::SkeletonPtr getSkeleton(std::string name, const std::string &group="General");
};
}

@ -8,7 +8,8 @@
<Widget type="Widget" skin="HUD_Box" position="0 200 300 60" align="Bottom HCenter">
<Widget type="AutoSizedTextBox" skin="SandText" position="20 12 260 24" name="LoadingText">
<Widget type="TextBox" skin="SandText" position="20 12 260 20" name="LoadingText">
<Property key="TextAlign" value="Center"/>
</Widget>
<Widget type="ProgressBar" skin="MW_Progress_Loading" position="20 36 260 8" name="ProgressBar">

Loading…
Cancel
Save