jhooks1 wrote:You got it working? Can you try an ancestor ghost? What all is different in this code in comparison to your last release? Is it just the Matrix44 mat = data->GetBoneTransform(b) * bones->GetWorldTransform();
The ancestor ghost is mostly correct. The face is positioned wrong, but that's not a skinning problem because it isn't skinned, it's attached directly to the bone like the werewolf head (funny enough the werewolf head works now without needing extra rotations, though Hircine's spear and the ghost face are still wrong).
Code: Select all
Matrix44 mat = data->GetBoneTransform(b) * bones[b]->GetWorldTransform();
Code: Select all
static void buildBones(Ogre::Skeleton *skel, NiNodeRef node, Ogre::Bone *bone = NULL)
{
//if(bone || node->IsSkeletonRoot())
{
Ogre::Bone *newbone = skel->createBone(node->GetName());
if(!node->IsSkeletonRoot() && bone)
bone->addChild(newbone);
Vector3 srcTrans = node->GetLocalTranslation();
Matrix33 srcRot = node->GetLocalRotation();
float scale = node->GetLocalScale();
Ogre::Vector3 trans(srcTrans.x, srcTrans.y, srcTrans.z);
Ogre::Matrix3 rot(srcRot[0][0], srcRot[1][0], srcRot[2][0],
srcRot[0][1], srcRot[1][1], srcRot[2][1],
srcRot[0][2], srcRot[1][2], srcRot[2][2]);
newbone->setOrientation(rot);
newbone->setPosition(trans);
newbone->setScale(Ogre::Vector3(scale));
newbone->setBindingPose();
newbone->setInitialState();
bone = newbone;
}
std::vector<NiAVObjectRef> list = node->GetChildren();
for(size_t i = 0;i < list.size();i++)
{
if(list[i]->IsDerivedType(NiNode::TYPE))
buildBones(skel, StaticCast<NiNode>(list[i]), bone);
}
}
Code: Select all
Ogre::Bone *bone = skel->getBone(targetnames[idx]);
const Ogre::Quaternion startquat = bone->getInitialOrientation();
const Ogre::Vector3 starttrans = bone->getInitialPosition();
const Ogre::Vector3 startscale = bone->getInitialScale();
Ogre::NodeAnimationTrack *nodetrack = (*anim)->getNodeTrack(bone->getHandle());
Ogre::Quaternion lastquat, curquat;
Ogre::Vector3 lasttrans(0.0f), curtrans(0.0f);
Ogre::Vector3 lastscale(1.0f), curscale(1.0f);
if(quatiter != quatkeys.end())
lastquat = curquat = startquat.Inverse() * ConvertQuaternion(quatiter->data);
if(traniter != trankeys.end())
lasttrans = curtrans = ConvertVector3(traniter->data) - starttrans;
if(scaleiter != scalekeys.end())
lastscale = curscale = Ogre::Vector3(scaleiter->data) / startscale;
...
while(quatiter != quatkeys.end() && curtime >= quatiter->time)
{
lastquat = curquat;
curquat = startquat.Inverse() * ConvertQuaternion(quatiter->data);
quatiter++;
}
while(traniter != trankeys.end() && curtime >= traniter->time)
{
lasttrans = curtrans;
curtrans = ConvertVector3(traniter->data) - starttrans;
traniter++;
}
while(scaleiter != scalekeys.end() && curtime >= scaleiter->time)
{
lastscale = curscale;
curscale = Ogre::Vector3(scaleiter->data) / startscale;
scaleiter++;
}
...