mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 13:39:42 +00:00
Port BoneOffset
This commit is contained in:
parent
9c4b2ea61a
commit
f7d2a28930
4 changed files with 23 additions and 53 deletions
|
@ -133,32 +133,6 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
|
||||||
//else
|
//else
|
||||||
//mAmmunition.setNull();
|
//mAmmunition.setNull();
|
||||||
|
|
||||||
// FIXME: code duplicated from NpcAnimation
|
|
||||||
/*
|
|
||||||
if(scene->mSkelBase)
|
|
||||||
{
|
|
||||||
Ogre::SkeletonInstance *skel = scene->mSkelBase->getSkeleton();
|
|
||||||
if(scene->mSkelBase->isParentTagPoint())
|
|
||||||
{
|
|
||||||
Ogre::Node *root = scene->mSkelBase->getParentNode();
|
|
||||||
if(skel->hasBone("BoneOffset"))
|
|
||||||
{
|
|
||||||
Ogre::Bone *offset = skel->getBone("BoneOffset");
|
|
||||||
|
|
||||||
root->translate(offset->getPosition());
|
|
||||||
|
|
||||||
// It appears that the BoneOffset rotation is completely bogus, at least for light models.
|
|
||||||
//root->rotate(offset->getOrientation());
|
|
||||||
root->pitch(Ogre::Degree(-90.0f));
|
|
||||||
|
|
||||||
root->scale(offset->getScale());
|
|
||||||
root->setInitialState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateSkeletonInstance(mSkelBase->getSkeleton(), skel);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(scene->mControllers.begin());
|
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(scene->mControllers.begin());
|
||||||
for(;ctrl != scene->mControllers.end();++ctrl)
|
for(;ctrl != scene->mControllers.end();++ctrl)
|
||||||
|
|
|
@ -698,31 +698,6 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if(mObjectParts[type]->mSkelBase)
|
|
||||||
{
|
|
||||||
Ogre::SkeletonInstance *skel = mObjectParts[type]->mSkelBase->getSkeleton();
|
|
||||||
if(mObjectParts[type]->mSkelBase->isParentTagPoint())
|
|
||||||
{
|
|
||||||
Ogre::Node *root = mObjectParts[type]->mSkelBase->getParentNode();
|
|
||||||
if(skel->hasBone("BoneOffset"))
|
|
||||||
{
|
|
||||||
Ogre::Bone *offset = skel->getBone("BoneOffset");
|
|
||||||
|
|
||||||
root->translate(offset->getPosition());
|
|
||||||
|
|
||||||
// It appears that the BoneOffset rotation is completely bogus, at least for light models.
|
|
||||||
//root->rotate(offset->getOrientation());
|
|
||||||
root->pitch(Ogre::Degree(-90.0f));
|
|
||||||
|
|
||||||
root->scale(offset->getScale());
|
|
||||||
root->setInitialState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSkinned(mObjectParts[type]))
|
|
||||||
updateSkeletonInstance(mSkelBase->getSkeleton(), skel);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(mObjectParts[type]->mControllers.begin());
|
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(mObjectParts[type]->mControllers.begin());
|
||||||
for(;ctrl != mObjectParts[type]->mControllers.end();++ctrl)
|
for(;ctrl != mObjectParts[type]->mControllers.end();++ctrl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,9 +165,27 @@ namespace SceneUtil
|
||||||
if (!find.mFoundNode)
|
if (!find.mFoundNode)
|
||||||
throw std::runtime_error(std::string("Can't find attachment node ") + attachNode);
|
throw std::runtime_error(std::string("Can't find attachment node ") + attachNode);
|
||||||
|
|
||||||
|
FindByNameVisitor findBoneOffset("BoneOffset");
|
||||||
|
toAttach->accept(findBoneOffset);
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::PositionAttitudeTransform> trans;
|
||||||
|
|
||||||
|
if (findBoneOffset.mFoundNode)
|
||||||
|
{
|
||||||
|
osg::MatrixTransform* boneOffset = dynamic_cast<osg::MatrixTransform*>(findBoneOffset.mFoundNode);
|
||||||
|
if (!boneOffset)
|
||||||
|
throw std::runtime_error("BoneOffset must be a MatrixTransform");
|
||||||
|
|
||||||
|
trans = new osg::PositionAttitudeTransform;
|
||||||
|
trans->setPosition(boneOffset->getMatrix().getTrans());
|
||||||
|
// The BoneOffset rotation seems to be incorrect
|
||||||
|
trans->setAttitude(osg::Quat(-90, osg::Vec3f(1,0,0)));
|
||||||
|
}
|
||||||
|
|
||||||
if (attachNode.find("Left") != std::string::npos)
|
if (attachNode.find("Left") != std::string::npos)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> trans = new osg::PositionAttitudeTransform;
|
if (!trans)
|
||||||
|
trans = new osg::PositionAttitudeTransform;
|
||||||
trans->setScale(osg::Vec3f(-1.f, 1.f, 1.f));
|
trans->setScale(osg::Vec3f(-1.f, 1.f, 1.f));
|
||||||
|
|
||||||
// Need to invert culling because of the negative scale
|
// Need to invert culling because of the negative scale
|
||||||
|
@ -176,7 +194,10 @@ namespace SceneUtil
|
||||||
osg::FrontFace* frontFace = new osg::FrontFace;
|
osg::FrontFace* frontFace = new osg::FrontFace;
|
||||||
frontFace->setMode(osg::FrontFace::CLOCKWISE);
|
frontFace->setMode(osg::FrontFace::CLOCKWISE);
|
||||||
trans->getOrCreateStateSet()->setAttributeAndModes(frontFace, osg::StateAttribute::ON);
|
trans->getOrCreateStateSet()->setAttributeAndModes(frontFace, osg::StateAttribute::ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trans)
|
||||||
|
{
|
||||||
find.mFoundNode->addChild(trans);
|
find.mFoundNode->addChild(trans);
|
||||||
trans->addChild(toAttach);
|
trans->addChild(toAttach);
|
||||||
return trans;
|
return trans;
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace SceneUtil
|
||||||
traverse(node);
|
traverse(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& mNameToFind;
|
std::string mNameToFind;
|
||||||
osg::Group* mFoundNode;
|
osg::Group* mFoundNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue