mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
Use the Nif node's transform for skinned fixups
This commit is contained in:
parent
544011e096
commit
26cc86ffdc
1 changed files with 3 additions and 7 deletions
|
@ -109,7 +109,6 @@ NIFMeshLoader::LoaderMap NIFMeshLoader::sLoaders;
|
||||||
|
|
||||||
void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape)
|
void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape)
|
||||||
{
|
{
|
||||||
Ogre::SkeletonPtr skel;
|
|
||||||
const Nif::NiTriShapeData *data = shape->data.getPtr();
|
const Nif::NiTriShapeData *data = shape->data.getPtr();
|
||||||
const Nif::NiSkinInstance *skin = (shape->skin.empty() ? NULL : shape->skin.getPtr());
|
const Nif::NiSkinInstance *skin = (shape->skin.empty() ? NULL : shape->skin.getPtr());
|
||||||
std::vector<Ogre::Vector3> srcVerts = data->vertices;
|
std::vector<Ogre::Vector3> srcVerts = data->vertices;
|
||||||
|
@ -139,10 +138,6 @@ void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape
|
||||||
// explicitly attached later.
|
// explicitly attached later.
|
||||||
mesh->setSkeletonName(mName);
|
mesh->setSkeletonName(mName);
|
||||||
|
|
||||||
// Get the skeleton resource, so vertices can be transformed into the bones' initial state.
|
|
||||||
Ogre::SkeletonManager *skelMgr = Ogre::SkeletonManager::getSingletonPtr();
|
|
||||||
skel = skelMgr->getByName(mName);
|
|
||||||
|
|
||||||
// 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
|
||||||
// better to transform the bones into bind position, but there doesn't seem to
|
// better to transform the bones into bind position, but there doesn't seem to
|
||||||
// be a reliable way to do that.
|
// be a reliable way to do that.
|
||||||
|
@ -153,11 +148,10 @@ void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape
|
||||||
const Nif::NodeList &bones = skin->bones;
|
const Nif::NodeList &bones = skin->bones;
|
||||||
for(size_t b = 0;b < bones.length();b++)
|
for(size_t b = 0;b < bones.length();b++)
|
||||||
{
|
{
|
||||||
Ogre::Bone *bone = skel->getBone(bones[b]->name);
|
|
||||||
Ogre::Matrix4 mat;
|
Ogre::Matrix4 mat;
|
||||||
mat.makeTransform(data->bones[b].trafo.trans, Ogre::Vector3(data->bones[b].trafo.scale),
|
mat.makeTransform(data->bones[b].trafo.trans, Ogre::Vector3(data->bones[b].trafo.scale),
|
||||||
Ogre::Quaternion(data->bones[b].trafo.rotation));
|
Ogre::Quaternion(data->bones[b].trafo.rotation));
|
||||||
mat = bone->_getFullTransform() * mat;
|
mat = bones[b]->getWorldTransform() * mat;
|
||||||
|
|
||||||
const std::vector<Nif::NiSkinData::VertWeight> &weights = data->bones[b].weights;
|
const std::vector<Nif::NiSkinData::VertWeight> &weights = data->bones[b].weights;
|
||||||
for(size_t i = 0;i < weights.size();i++)
|
for(size_t i = 0;i < weights.size();i++)
|
||||||
|
@ -310,6 +304,8 @@ void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape
|
||||||
// Assign bone weights for this TriShape
|
// Assign bone weights for this TriShape
|
||||||
if(skin != NULL)
|
if(skin != NULL)
|
||||||
{
|
{
|
||||||
|
Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().getByName(mName);
|
||||||
|
|
||||||
const Nif::NiSkinData *data = skin->data.getPtr();
|
const Nif::NiSkinData *data = skin->data.getPtr();
|
||||||
const Nif::NodeList &bones = skin->bones;
|
const Nif::NodeList &bones = skin->bones;
|
||||||
for(size_t i = 0;i < bones.length();i++)
|
for(size_t i = 0;i < bones.length();i++)
|
||||||
|
|
Loading…
Reference in a new issue