Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with animated object - mesh

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
488 Views, 13 Replies

Problem with animated object - mesh

Hi, I`m using Fbx SDK to export our simulated scene into Maya/3d Max. Currently my problem is that a character`s skeleton is animated correctly, but his mesh goes in the wrong direction and has some additional rotation (it is not distorted, the mesh is skinned correctly). This problem happens in Maya, in 3d Max all is right. I`ve attached an fbx file (which is not the original one written by me, but imported into the 3d max and then exported back to fbx). Maybe this happens because I don`t create the bind pose when i write the file using the SDK. Below is the code I use to process a skin, computeBindPose is called after the skin is processed, it is commented out because it does not fix the problem and makes the resulting fbx import time very long, it is taken from SDK sample and maybe I`ve adapted it in a wrong way:

SkinProxy::SkinProxy(const SkeletonProxyPtr& skeleton, FbxWriter* writer)
:
mSkeleton(skeleton),
mWriter(writer)
{
mFbxSkin = KFbxSkin::Create(mWriter->getFbxScene(), "");
}
//----------------------------------------------------------------------------------------
KFbxSkin* SkinProxy::getFbxSkin()
{
return mFbxSkin;
}
//----------------------------------------------------------------------------------------
void SkinProxy::addInfluence(unsigned int boneIndex, unsigned int vertexIndex, float weight, const Ogre::Mesh::IndexMap& indexMap)
{
//boneIndex = indexMap;
Clusters_t::iterator i = mClusters.find(boneIndex);
KFbxCluster* cluster = 0;

if(boneIndex >= mSkeleton->getOgreSkeleton()->getNumBones())
{
for (size_t v = 0; v < indexMap.size(); ++v)
{
if (indexMap == boneIndex)
{
boneIndex = v;
break;
}
}
}

if (i == mClusters.end())
{
Ogre::Bone* ogreBone = mSkeleton->getOgreSkeleton()->getBone(boneIndex);

if (!ogreBone)
{
LOG_ERROR("Failed to find a bone in Ogre skeleton");
return;
}

const BoneProxy* proxy = mSkeleton->findBone(ogreBone->getHandle());

if (!proxy)
{
LOG_ERROR("Failed to find a bone " << ogreBone->getName() << " in FBX skeleton");
return;
}

cluster = KFbxCluster::Create(mWriter->getFbxScene(), "");
cluster->SetLinkMode(KFbxCluster::eTOTAL1);
cluster->SetLink(proxy->getFbxBone());

KFbxXMatrix transformMatrix, transformLinkMatrix;
transformMatrix.SetIdentity();
// all joints have the same transformMatrix.
cluster->SetTransformMatrix(transformMatrix);
//cluster->SetTransformAssociateModelMatrix(transformMatrix);
//cluster->SetTransformParentMatrix(transformMatrix);
// compute global transformation of each joint and set it as transformLinkMatrix.
transformLinkMatrix = cluster->GetLink()->EvaluateGlobalTransform();
cluster->SetTransformLinkMatrix(transformLinkMatrix);

mFbxSkin->AddCluster(cluster);
mClusters.insert(Clusters_t::value_type(boneIndex, cluster));
}
else
{
cluster = i->second;
}

cluster->AddControlPointIndex(vertexIndex, weight);
}
//----------------------------------------------------------------------------------------
void SkinProxy::computeBindPose()
{
/*for (auto root = mSkeleton->getFbxSkeletonRoots().begin(); root != mSkeleton->getFbxSkeletonRoots().end(); ++root)
{
KFbxNode* rootBone = *root;
//create a pose by the node array and set it as bindpose.
KFbxPose* pose = KFbxPose::Create(mWriter->getFbxScene(), rootBone->GetName());
pose->SetIsBindPose(true);
//add the bindpose to the scene.
processBone(rootBone, pose);
mWriter->getFbxScene()->AddPose(pose);
}*/
}
//----------------------------------------------------------------------------------------
void SkinProxy::processBone(KFbxNode* bone, KFbxPose* pose)
{
KFbxMatrix bindMatrix = bone->EvaluateGlobalTransform();
pose->Add(bone, bindMatrix);

for (int i = 0; i < bone->GetChildCount(); ++i)
{
processBone(bone->GetChild(i), pose);
}
}

character_2.zip

13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

Btw have some problem with attaching a file - it doesnot show up in the post. It is only 1.3 mb.
*Update* zipping it fixed the problem - it appeared instantly
Message 3 of 14
jiayang.xu
in reply to: Anonymous

Hello, Soth1985
I did reproduce the issue you described.
Will do more investigation and let you know if any workaround or this is a bug.
Message 4 of 14
Anonymous
in reply to: Anonymous

Hi, thanks for reply.
I`d like to add that this file also crashes the MotionBuilder 2012 when you File->Open... the file, but you can still do File->Motion File Import... and get only the animation from the file. According to the log (which i`ll attach to the message along with a crashdump) it seems to be some MB`s renderer issue. I have an ATI video card and get a "Warning! Hardware acceleration is disabled, slow performance might occur." on MB startup.

2012x64.zip

Message 5 of 14
jiayang.xu
in reply to: Anonymous

Hello Soth1985, could you report this issue on MotionBuilder forum?
Cause here we only deal with issues about FBX SDK, thanks 🙂
Message 6 of 14
jiayang.xu
in reply to: Anonymous

Hello Soth1985, I confirmed this bug is already fixed and included in the coming release in early April. Please wait until then and try out the new 2013 Maya plug-in, it imports your character properly to Maya.
Thanks. 🙂
Message 7 of 14
Anonymous
in reply to: Anonymous

Great, thanks for the fix. By the way can this bug be fixed by means of Python script or Maya SDK?
Message 8 of 14
jiayang.xu
in reply to: Anonymous

It is just a bug in FBX Maya plugin, have nothing to do with python script or Maya SDK.
Message 9 of 14
Anonymous
in reply to: Anonymous

I`ve checked the file in the Maya 2013, seems the bug is still there.
Message 10 of 14
jiayang.xu
in reply to: Anonymous

Did you try with 2013 FBX Maya plugin?
Message 11 of 14
Anonymous
in reply to: Anonymous

Yes, I`ve tried the file out in Maya 2013 x64, Plugin version is 2013.1 according to Maya plugin information window.
Message 12 of 14
jiayang.xu
in reply to: Anonymous

Just re-tested with Maya2013 and FBX Maya plugin 2013.1, the result is as follow, no mismatch between the mesh and skeleton anymore and the animation can play correctly, is that good enough for you?

Message 13 of 14
Anonymous
in reply to: Anonymous

Have you tried this on x32 or on x64 version of Maya? In my case this file imports with the same error as in Maya 2012, see the attached pic.

Message 14 of 14
jiayang.xu
in reply to: Anonymous

x64, I also tried with Maya 2012, with 2013.1 FBX Maya Plugin, also works fine on my side.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report