AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / Problem with animated object - mesh
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

Problem with animated object - mesh
Rate this thread
 
65470
 
Permlink of this thread  
avatar
  • Soth1985
  • Posted: 22 March 2012 07:48 AM
  • Total Posts: 9
  • Joined: 31 October 2010 11:46 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::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[boneIndex];
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[v] == 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);
}
}



Attachment Attachment
Replies: 0
avatar
  • Soth1985
  • Posted: 22 March 2012 08:02 AM

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



Replies: 0
avatar

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.



Jiayang Xu
Maya Data Platform
Autodesk

Replies: 0
avatar
  • Soth1985
  • Posted: 23 March 2012 12:23 AM

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.



Attachment Attachment
Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

Hello Soth1985, could you report this issue on MotionBuilder forum?
Cause here we only deal with issues about FBX SDK, thanks :)

Author: Jiayang Xu

Replied: 25 March 2012 03:39 PM  
avatar

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. :)



Jiayang Xu
Maya Data Platform
Autodesk

Replies: 0
avatar
  • Soth1985
  • Posted: 25 March 2012 09:36 PM

Great, thanks for the fix. By the way can this bug be fixed by means of Python script or Maya SDK?



Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

It is just a bug in FBX Maya plugin, have nothing to do with python script or Maya SDK.

Author: Jiayang Xu

Replied: 26 March 2012 03:23 PM  
avatar

I`ve checked the file in the Maya 2013, seems the bug is still there.



Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

Did you try with 2013 FBX Maya plugin?

Author: Jiayang Xu

Replied: 06 May 2012 05:09 PM  
avatar

Yes, I`ve tried the file out in Maya 2013 x64, Plugin version is 2013.1 according to Maya plugin information window.



Replies: 0
avatar

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?



Jiayang Xu
Maya Data Platform
Autodesk

Attachment Attachment
Replies: 0
avatar

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.



Attachment Attachment
Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

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

Author: Jiayang Xu

Replied: 10 May 2012 02:40 PM