mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Create bones for NiTriShape nodes, and attach the entities to them
Otherwise some models don't connect properly. NiTriShapes are more guaranteed to have unique names than their parent nodes.
This commit is contained in:
parent
94be45e07e
commit
c60e858b02
@ -303,9 +303,6 @@ static TextKeyMap extractTextKeys(const Nif::NiTextKeyExtraData *tk)
|
|||||||
|
|
||||||
void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *&animroot, TextKeyMap &textkeys, std::vector<Nif::NiKeyframeController const*> &ctrls, Ogre::Bone *parent=NULL)
|
void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *&animroot, TextKeyMap &textkeys, std::vector<Nif::NiKeyframeController const*> &ctrls, Ogre::Bone *parent=NULL)
|
||||||
{
|
{
|
||||||
if(node->recType == Nif::RC_NiTriShape)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Ogre::Bone *bone;
|
Ogre::Bone *bone;
|
||||||
if(!skel->hasBone(node->name))
|
if(!skel->hasBone(node->name))
|
||||||
bone = skel->createBone(node->name);
|
bone = skel->createBone(node->name);
|
||||||
@ -319,7 +316,8 @@ void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *&animro
|
|||||||
bone->setBindingPose();
|
bone->setBindingPose();
|
||||||
|
|
||||||
if(!(node->recType == Nif::RC_NiNode || /* Nothing special; children traversed below */
|
if(!(node->recType == Nif::RC_NiNode || /* Nothing special; children traversed below */
|
||||||
node->recType == Nif::RC_RootCollisionNode /* handled in nifbullet (hopefully) */
|
node->recType == Nif::RC_RootCollisionNode || /* handled in nifbullet (hopefully) */
|
||||||
|
node->recType == Nif::RC_NiTriShape /* Handled in the mesh loader */
|
||||||
))
|
))
|
||||||
warn("Unhandled "+node->recName+" "+node->name+" in "+skel->getName());
|
warn("Unhandled "+node->recName+" "+node->name+" in "+skel->getName());
|
||||||
|
|
||||||
@ -1073,8 +1071,7 @@ public:
|
|||||||
mesh->setAutoBuildEdgeLists(false);
|
mesh->setAutoBuildEdgeLists(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
meshes.push_back(MeshInfo(mesh->getName(), (shape->parent ? shape->parent->name : shape->name),
|
meshes.push_back(MeshInfo(mesh->getName(), shape->name));
|
||||||
shape->trafo.pos, shape->trafo.rotation, shape->trafo.scale));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(node);
|
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(node);
|
||||||
@ -1108,8 +1105,7 @@ public:
|
|||||||
mesh = meshMgr.createManual(fullname, mGroup, loader);
|
mesh = meshMgr.createManual(fullname, mGroup, loader);
|
||||||
mesh->setAutoBuildEdgeLists(false);
|
mesh->setAutoBuildEdgeLists(false);
|
||||||
}
|
}
|
||||||
meshes.push_back(MeshInfo(mesh->getName(), (node->parent ? node->parent->name : node->name),
|
meshes.push_back(MeshInfo(mesh->getName(), node->name));
|
||||||
node->trafo.pos, node->trafo.rotation, node->trafo.scale));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NIFMeshLoader::LoaderMap NIFMeshLoader::sLoaders;
|
NIFMeshLoader::LoaderMap NIFMeshLoader::sLoaders;
|
||||||
@ -1190,12 +1186,7 @@ EntityList Loader::createEntities(Ogre::SceneNode *parentNode, std::string name,
|
|||||||
parentNode->attachObject(entity);
|
parentNode->attachObject(entity);
|
||||||
}
|
}
|
||||||
else if(entity != entitylist.mSkelBase)
|
else if(entity != entitylist.mSkelBase)
|
||||||
{
|
entitylist.mSkelBase->attachObjectToBone(meshes[i].mTargetNode, entity);
|
||||||
Ogre::TagPoint *tag = entitylist.mSkelBase->attachObjectToBone(meshes[i].mTargetNode, entity);
|
|
||||||
tag->setPosition(meshes[i].mPos);
|
|
||||||
tag->setOrientation(meshes[i].mRot);
|
|
||||||
tag->setScale(Ogre::Vector3(meshes[i].mScale));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1248,12 +1239,7 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(entity->getMesh()->getName().find(filter) != std::string::npos)
|
if(entity->getMesh()->getName().find(filter) != std::string::npos)
|
||||||
{
|
entitylist.mSkelBase->attachObjectToBone(meshes[i].mTargetNode, entity);
|
||||||
Ogre::TagPoint *tag = entitylist.mSkelBase->attachObjectToBone(meshes[i].mTargetNode, entity);
|
|
||||||
tag->setPosition(meshes[i].mPos);
|
|
||||||
tag->setOrientation(meshes[i].mRot);
|
|
||||||
tag->setScale(Ogre::Vector3(meshes[i].mScale));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,9 @@ struct EntityList {
|
|||||||
struct MeshInfo {
|
struct MeshInfo {
|
||||||
std::string mMeshName;
|
std::string mMeshName;
|
||||||
std::string mTargetNode;
|
std::string mTargetNode;
|
||||||
Ogre::Vector3 mPos;
|
|
||||||
Ogre::Matrix3 mRot;
|
|
||||||
float mScale;
|
|
||||||
|
|
||||||
MeshInfo(const std::string &name, const std::string &target,
|
MeshInfo(const std::string &name, const std::string &target)
|
||||||
const Ogre::Vector3 &pos, const Ogre::Matrix3 &rot, float scale)
|
: mMeshName(name), mTargetNode(target)
|
||||||
: mMeshName(name), mTargetNode(target), mPos(pos), mRot(rot), mScale(scale)
|
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
typedef std::vector<MeshInfo> MeshInfoList;
|
typedef std::vector<MeshInfo> MeshInfoList;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user