FbxSDK generation model is wrong in Unity (Runtime)

FbxSDK generation model is wrong in Unity (Runtime)

Anonymous
Not applicable
590 Views
0 Replies
Message 1 of 1

FbxSDK generation model is wrong in Unity (Runtime)

Anonymous
Not applicable

vertices   triangles  ... All read out ,but I don't know where the matrix transformation is missing ,

Nodes and nodes are not in a relatively correct position and turn ,How I Can Find a method or a matrix correction error  like this.

 

 

 

flaseflasetureture

 

 

 

NativeCode:


void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetPosition(FbxNode * pNode, Vector3 * value)
{
if (pNode)
{
//
// Translation
//
/*FbxVector4 lTmpVector = pNode->GetGeometricTranslation(FbxNode::eSourcePivot);

value->x = lTmpVector[0] * GlobalScale;
value->y = lTmpVector[1] * GlobalScale;
value->z = lTmpVector[2] * GlobalScale;*/

FbxAMatrix lTmpMtix = pNode->EvaluateGlobalTransform();

FbxVector4 lTmpVector = lTmpMtix.GetT();

value->x = lTmpVector[0] ;
value->y = lTmpVector[1] ;
value->z = lTmpVector[2] ;
}
}

void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetEulerAngles(FbxNode * pNode, Vector3 * value)
{
if (pNode)
{
//
// Rotation
//
//FbxVector4 lTmpVector = pNode->GetGeometricRotation(FbxNode::eSourcePivot);

//value->x = lTmpVector[0];
//value->y = lTmpVector[1];
//value->z = lTmpVector[2];

FbxAMatrix lTmpMtix = pNode->EvaluateGlobalTransform();

FbxVector4 lTmpVector = lTmpMtix.GetR();

value->x = lTmpVector[0];
value->y = lTmpVector[1];
value->z = lTmpVector[2];
}
}

void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetScale(FbxNode * pNode, Vector3 * value)
{
if (pNode)
{
//
// Scaling
//
/* FbxVector4 lTmpVector = pNode->GetGeometricScaling(FbxNode::eSourcePivot);
value->x = lTmpVector[0];
value->y = lTmpVector[1];
value->z = lTmpVector[2];*/

FbxAMatrix lTmpMtix = pNode->EvaluateGlobalTransform();

FbxVector4 lTmpVector = lTmpMtix.GetS();

value->x = lTmpVector[0];
value->y = lTmpVector[1];
value->z = lTmpVector[2];
}
}

void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetLocalPosition(FbxNode * pNode, Vector3 * value)
{
if (pNode)
{
//
// LclTranslation
//
FbxVector4 lTmpVector = pNode->LclTranslation;
value->x = lTmpVector[0] ;
value->y = lTmpVector[1] ;
value->z = lTmpVector[2] ;

}
}

void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetLocalEulerAngles(FbxNode * pNode, Vector3 * value)
{
if (pNode)
{
//
// Rotation
//
FbxVector4 lTmpVector = pNode->LclRotation;
value->x = lTmpVector[0];
value->y = lTmpVector[1];
value->z = lTmpVector[2];

 

}
}

void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetLocalRotation(FbxNode * pNode, Quaternion * value)
{
if (pNode)
{
//
// Rotation
//
FbxVector4 lTmpVector = pNode->LclRotation;

*value = ExtractQuaternionFromFBXEuler(lTmpVector);
}
}
void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API GetLocalScale(FbxNode * pNode, Vector3 * value)
{
if (pNode)
{
//
// LclScaling
//
FbxVector4 lTmpVector = pNode->LclScaling;
value->x = lTmpVector[0];
value->y = lTmpVector[1];
value->z = lTmpVector[2];


}
}

 

 

 

 

 

 

Unity :

 

1.Function

 

IntPtr Node = NativePlugins.GetNode(RooNode, i);
if (Node != IntPtr.Zero)
{
string Name = NativePlugins.GetNodeName(Node);
Vector3 Position = new Vector3();
Vector3 EulerAngles = new Vector3();
Vector3 Scale = new Vector3();
Vector3 LocalPosition = new Vector3();
Vector3 LocalEulerAngles = new Vector3();
Quaternion LocalRotation = new Quaternion();
Vector3 LocalScale = new Vector3();
Vector3 PostTargetRotation = new Vector3();
Vector3 PostRotation = new Vector3();
Vector3 PreRotation = new Vector3();

NativePlugins.GetPosition(Node, ref Position);
NativePlugins.GetEulerAngles(Node, ref EulerAngles);
NativePlugins.GetScale(Node, ref Scale);
NativePlugins.GetLocalPosition(Node, ref LocalPosition);
NativePlugins.GetLocalEulerAngles(Node, ref LocalEulerAngles);
NativePlugins.GetLocalRotation(Node, ref LocalRotation);
NativePlugins.GetLocalScale(Node, ref LocalScale);
NativePlugins.GetPostTargetRotation(Node, ref PostTargetRotation);
NativePlugins.GetPostRotation(Node, ref PostRotation);
NativePlugins.GetPreRotation(Node, ref PreRotation);

GameObject pgameObject = new GameObject();
pgameObject.transform.parent = null;
pgameObject.transform.name = Name;

pgameObject.transform.localPosition = ExtensionVector3.Convert(LocalPosition);
pgameObject.transform.localEulerAngles = ExtensionVector3.Convert(LocalEulerAngles);
pgameObject.transform.localScale = ExtensionVector3.Convert(LocalScale);

 

 

}

 

 

public static class ExtensionVector3
{
public static UnityEngine.Vector3 Convert(Vector3 mvector)
{
UnityEngine.Vector3 vector = new UnityEngine.Vector3(mvector.x, mvector.y, mvector.z);
return vector;
}

}

 

 

 

 

0 Likes
591 Views
0 Replies
Replies (0)