mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Allow specifying an alternate skeleton for mesh skinning
This commit is contained in:
parent
626dcd54dc
commit
5154188110
2 changed files with 12 additions and 8 deletions
|
@ -539,7 +539,7 @@ class NIFMeshLoader : Ogre::ManualResourceLoader
|
||||||
|
|
||||||
// Get the skeleton resource, so vertices can be transformed into the bones' initial state.
|
// Get the skeleton resource, so vertices can be transformed into the bones' initial state.
|
||||||
Ogre::SkeletonManager *skelMgr = Ogre::SkeletonManager::getSingletonPtr();
|
Ogre::SkeletonManager *skelMgr = Ogre::SkeletonManager::getSingletonPtr();
|
||||||
skel = skelMgr->getByName(mName);
|
skel = skelMgr->getByName(mSkelName);
|
||||||
skel->touch();
|
skel->touch();
|
||||||
|
|
||||||
// Convert vertices and normals to bone space from bind position. It would be
|
// Convert vertices and normals to bone space from bind position. It would be
|
||||||
|
@ -808,7 +808,9 @@ public:
|
||||||
const NiTriShape *shape = dynamic_cast<const NiTriShape*>(node);
|
const NiTriShape *shape = dynamic_cast<const NiTriShape*>(node);
|
||||||
|
|
||||||
Ogre::MeshManager &meshMgr = Ogre::MeshManager::getSingleton();
|
Ogre::MeshManager &meshMgr = Ogre::MeshManager::getSingleton();
|
||||||
std::string fullname = mName+"@"+shape->name;
|
std::string fullname = mName+"@shape="+shape->name;
|
||||||
|
if(mSkelName.length() > 0 && mName != mSkelName)
|
||||||
|
fullname += "@skel="+mSkelName;
|
||||||
|
|
||||||
std::transform(fullname.begin(), fullname.end(), fullname.begin(), ::tolower);
|
std::transform(fullname.begin(), fullname.end(), fullname.begin(), ::tolower);
|
||||||
Ogre::MeshPtr mesh = meshMgr.getByName(fullname);
|
Ogre::MeshPtr mesh = meshMgr.getByName(fullname);
|
||||||
|
@ -846,11 +848,12 @@ public:
|
||||||
NIFMeshLoader::LoaderMap NIFMeshLoader::sLoaders;
|
NIFMeshLoader::LoaderMap NIFMeshLoader::sLoaders;
|
||||||
|
|
||||||
|
|
||||||
MeshPairList NIFLoader::load(std::string name, const std::string &group)
|
MeshPairList NIFLoader::load(std::string name, std::string skelName, const std::string &group)
|
||||||
{
|
{
|
||||||
MeshPairList meshes;
|
MeshPairList meshes;
|
||||||
|
|
||||||
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
|
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
|
||||||
|
std::transform(skelName.begin(), skelName.end(), skelName.begin(), ::tolower);
|
||||||
|
|
||||||
Nif::NIFFile nif(name);
|
Nif::NIFFile nif(name);
|
||||||
if (nif.numRecords() < 1)
|
if (nif.numRecords() < 1)
|
||||||
|
@ -873,7 +876,7 @@ MeshPairList NIFLoader::load(std::string name, const std::string &group)
|
||||||
|
|
||||||
bool hasSkel = NIFSkeletonLoader::createSkeleton(name, group, node);
|
bool hasSkel = NIFSkeletonLoader::createSkeleton(name, group, node);
|
||||||
|
|
||||||
NIFMeshLoader meshldr(name, group, (hasSkel ? name : std::string()));
|
NIFMeshLoader meshldr(name, group, (hasSkel ? skelName : std::string()));
|
||||||
meshldr.createMeshes(node, meshes);
|
meshldr.createMeshes(node, meshes);
|
||||||
|
|
||||||
return meshes;
|
return meshes;
|
||||||
|
@ -883,7 +886,7 @@ EntityList NIFLoader::createEntities(Ogre::SceneNode *parent, const std::string
|
||||||
{
|
{
|
||||||
EntityList entitylist;
|
EntityList entitylist;
|
||||||
|
|
||||||
MeshPairList meshes = load(name, group);
|
MeshPairList meshes = load(name, name, group);
|
||||||
if(meshes.size() == 0)
|
if(meshes.size() == 0)
|
||||||
return entitylist;
|
return entitylist;
|
||||||
|
|
||||||
|
@ -928,7 +931,7 @@ EntityList NIFLoader::createEntities(Ogre::Entity *parent, const std::string &bo
|
||||||
{
|
{
|
||||||
EntityList entitylist;
|
EntityList entitylist;
|
||||||
|
|
||||||
MeshPairList meshes = load(name, group);
|
MeshPairList meshes = load(name, parent->getMesh()->getSkeletonName(), group);
|
||||||
if(meshes.size() == 0)
|
if(meshes.size() == 0)
|
||||||
return entitylist;
|
return entitylist;
|
||||||
|
|
||||||
|
@ -953,13 +956,14 @@ EntityList NIFLoader::createEntities(Ogre::Entity *parent, const std::string &bo
|
||||||
|
|
||||||
if(entitylist.mSkelBase)
|
if(entitylist.mSkelBase)
|
||||||
{
|
{
|
||||||
|
entitylist.mSkelBase->shareSkeletonInstanceWith(parent);
|
||||||
parent->attachObjectToBone(bonename, entitylist.mSkelBase);
|
parent->attachObjectToBone(bonename, entitylist.mSkelBase);
|
||||||
for(size_t i = 0;i < entitylist.mEntities.size();i++)
|
for(size_t i = 0;i < entitylist.mEntities.size();i++)
|
||||||
{
|
{
|
||||||
Ogre::Entity *entity = entitylist.mEntities[i];
|
Ogre::Entity *entity = entitylist.mEntities[i];
|
||||||
if(entity != entitylist.mSkelBase && entity->hasSkeleton())
|
if(entity != entitylist.mSkelBase && entity->hasSkeleton())
|
||||||
{
|
{
|
||||||
entity->shareSkeletonInstanceWith(entitylist.mSkelBase);
|
entity->shareSkeletonInstanceWith(parent);
|
||||||
parent->attachObjectToBone(bonename, entity);
|
parent->attachObjectToBone(bonename, entity);
|
||||||
}
|
}
|
||||||
else if(entity != entitylist.mSkelBase)
|
else if(entity != entitylist.mSkelBase)
|
||||||
|
|
|
@ -87,7 +87,7 @@ typedef std::vector< std::pair<Ogre::MeshPtr,std::string> > MeshPairList;
|
||||||
*/
|
*/
|
||||||
class NIFLoader
|
class NIFLoader
|
||||||
{
|
{
|
||||||
static MeshPairList load(std::string name, const std::string &group);
|
static MeshPairList load(std::string name, std::string skelName, const std::string &group);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EntityList createEntities(Ogre::Entity *parent, const std::string &bonename,
|
static EntityList createEntities(Ogre::Entity *parent, const std::string &bonename,
|
||||||
|
|
Loading…
Reference in a new issue