Area :: Header
Sweat, Swearing & Tears
Meet the team behind Cupcakes & Critters in the latest chapter of Autodesk’s documentary series on indie game makers.
Discussion Groups

FBX SDK

Reply
Active Member
Soth1985
Posts: 9
Registered: ‎10-31-2010

Problem with animated object - mesh

109 Views, 13 Replies
03-22-2012 11:48 AM
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::smileyfrustrated:kinProxy(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::smileytongue:rocessBone(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

Please use plain text.
Active Member
Soth1985
Posts: 9
Registered: ‎10-31-2010

Re: Problem with animated object - mesh

03-22-2012 12:02 PM in reply to: Soth1985
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
Please use plain text.
Distinguished Contributor
jiayang.xu
Posts: 504
Registered: ‎04-21-2008

Re: Problem with animated object - mesh

03-23-2012 03:06 AM in reply to: Soth1985
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.
Please use plain text.
Active Member
Soth1985
Posts: 9
Registered: ‎10-31-2010

Re: Problem with animated object - mesh

03-23-2012 04:23 AM in reply to: Soth1985
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

Please use plain text.
Distinguished Contributor
jiayang.xu
Posts: 504
Registered: ‎04-21-2008

Re: Problem with animated object - mesh

03-25-2012 07:39 PM in reply to: Soth1985
Hello Soth1985, could you report this issue on MotionBuilder forum?
Cause here we only deal with issues about FBX SDK, thanks :smileyhappy:
Please use plain text.
Distinguished Contributor
jiayang.xu
Posts: 504
Registered: ‎04-21-2008

Re: Problem with animated object - mesh

03-25-2012 10:15 PM in reply to: Soth1985
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. :smileyhappy:
Please use plain text.
Active Member
Soth1985
Posts: 9
Registered: ‎10-31-2010

Re: Problem with animated object - mesh

03-26-2012 01:36 AM in reply to: Soth1985
Great, thanks for the fix. By the way can this bug be fixed by means of Python script or Maya SDK?
Please use plain text.
Distinguished Contributor
jiayang.xu
Posts: 504
Registered: ‎04-21-2008

Re: Problem with animated object - mesh

03-26-2012 07:23 PM in reply to: Soth1985
It is just a bug in FBX Maya plugin, have nothing to do with python script or Maya SDK.
Please use plain text.
Active Member
Soth1985
Posts: 9
Registered: ‎10-31-2010

Re: Problem with animated object - mesh

05-04-2012 08:02 AM in reply to: Soth1985
I`ve checked the file in the Maya 2013, seems the bug is still there.
Please use plain text.
Distinguished Contributor
jiayang.xu
Posts: 504
Registered: ‎04-21-2008

Re: Problem with animated object - mesh

05-06-2012 09:09 PM in reply to: Soth1985
Did you try with 2013 FBX Maya plugin?
Please use plain text.