Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX Plug-ins Import-Export Discussions / Wrong camera local position
  RSS 2.0 ATOM  

Wrong camera local position
Rate this thread
 
62758
 
Permlink of this thread  
avatar
  • Smekens
  • Posted: 12 December 2011 04:52 AM
  • Total Posts: 2
  • Joined: 12 December 2011 04:19 AM

Hi,

I encounter a problem when importing a basic scene exported from maya 2012.

The scene is composed as followed:

group1 (position 020)
  
camera1 (local position 009)

no rotations and no scaling applied.

It seems that the local position of the camera is wrong when using the EvaluateLocalTransform().

I used the OpenGL axis system. The result should be trivial.

Here is the code I used to dump the informations:

/*-------------------------------------------------------------------------*/

bool __fbxParseNode(KFbxNode *fbxNode);

/*-------------------------------------------------------------------------*/

bool fbxParseScene(KFbxScene *fbxScene)
{
 
if(fbxScene == NULL)
 
{
 
return false;
 
}

 
/**/

 
KFbxAxisSystem sceneAxisSystem fbxScene->GetGlobalSettings().GetAxisSystem()
 KFbxSystemUnit sceneSystemUnit 
fbxScene->GetGlobalSettings().GetSystemUnit();

 
KFbxAxisSystem engineAxisSystem(KFbxAxisSystem::OpenGL)
 KFbxSystemUnit engineSystemUnit
(KFbxSystemUnit::cm);

 if(
sceneSystemUnit != engineSystemUnit)
 
{
 engineSystemUnit
.ConvertScene(fbxScene);
 
}

 
if(sceneAxisSystem != engineAxisSystem)
 
{
 engineAxisSystem
.ConvertScene(fbxScene);
 
}

 
/**/

 
__fbxParseNode(fbxScene->GetRootNode());

 return 
true;
}

/*-------------------------------------------------------------------------*/

bool __fbxParseNode(KFbxNode *fbxNode)
{
 
if(fbxNode == NULL)
 
{
 
return false;
 
}

 
/**/

 
KFbxVector4 vector;
 
KFbxXMatrix matrix;

 
printf("    Geometric Transformations: %s\n"fbxNode->GetName());
 
vector fbxNode->EvaluateLocalTranslation();
 
printf("        Translation:  %f %f %f\n\n"vector[0]vector[1]vector[2]);
 
vector fbxNode->EvaluateLocalRotation();
 
printf("        Rotation:     %f %f %f\n\n"vector[0]vector[1]vector[2]);
 
vector fbxNode->EvaluateLocalScaling();
 
printf("        Scaling:      %f %f %f\n\n"vector[0]vector[1]vector[2]);

 
/**/

 
matrix fbxNode->EvaluateLocalTransform();

 
printf("        LocalMatrix:  %f %f %f %f\n"
        "                      %f %f %f %f\n"
        "                      %f %f %f %f\n"
        "                      %f %f %f %f\n\n"
,
 
matrix[0][0]matrix[0][1]matrix[0][2]matrix[0][3],
 
matrix[1][0]matrix[1][1]matrix[1][2]matrix[1][3],
 
matrix[2][0]matrix[2][1]matrix[2][2]matrix[2][3],
 
matrix[3][0]matrix[3][1]matrix[3][2]matrix[3][3]
 
);

 
matrix fbxNode->EvaluateGlobalTransform();

 
printf("        GlobalMatrix: %f %f %f %f\n"
        "                      %f %f %f %f\n"
        "                      %f %f %f %f\n"
        "                      %f %f %f %f\n\n"
,
 
matrix[0][0]matrix[0][1]matrix[0][2]matrix[0][3],
 
matrix[1][0]matrix[1][1]matrix[1][2]matrix[1][3],
 
matrix[2][0]matrix[2][1]matrix[2][2]matrix[2][3],
 
matrix[3][0]matrix[3][1]matrix[3][2]matrix[3][3]
 
);

 for(
int i 0fbxNode->GetChildCount(); i++)
 
{
 __fbxParseNode
(fbxNode->GetChild(i));
 
}

 
return true;
}

/*-------------------------------------------------------------------------*/

The result is as follow:

Geometric TransformationsRootNode
        Translation
:  0.000000 0.000000 0.000000

        Rotation
:     0.000000 0.000000 0.000000

        Scaling
:      1.000000 1.000000 1.000000

        LocalMatrix
:  1.000000 0.000000 0.000000 0.000000
                      0.000000 1.000000 0.000000 0.000000
                      0.000000 0.000000 1.000000 0.000000
                      0.000000 0.000000 0.000000 1.000000

        GlobalMatrix
1.000000 0.000000 0.000000 0.000000
                      0.000000 1.000000 0.000000 0.000000
                      0.000000 0.000000 1.000000 0.000000
                      0.000000 0.000000 0.000000 1.000000

    Geometric Transformations
group1
        Translation
:  0.000000 2.000000 0.000000

        Rotation
:     0.000000 0.000000 0.000000

        Scaling
:      1.000000 1.000000 1.000000

        LocalMatrix
:  1.000000 0.000000 0.000000 0.000000
                      0.000000 1.000000 
-0.000000 0.000000
                      0.000000 0.000000 1.000000 0.000000
                      0.000000 2.000000 0.000000 1.000000

        GlobalMatrix
1.000000 0.000000 0.000000 0.000000
                      0.000000 1.000000 
-0.000000 0.000000
                      0.000000 0.000000 1.000000 0.000000
                      0.000000 2.000000 0.000000 1.000000

    Geometric Transformations
camera1
        Translation
:  0.000000 0.000000 9.000000

        Rotation
:     0.000000 0.000000 0.000000

        Scaling
:      1.000000 1.000000 1.000000

        LocalMatrix
:  0.000000 0.000000 -1.000000 0.000000
                      0.000000 1.000000 0.000000 0.000000
                      1.000000 0.000000 0.000000 0.000000
                      0.000000 0.000000 9.000000 1.000000

        GlobalMatrix
0.000000 -0.000000 -1.000000 0.000000
                      0.000000 1.000000 
-0.000000 0.000000
                      1.000000 0.000000 0.000000 0.000000
                      0.000000 2.000000 9.000000 1.000000

The expected output should be the following:

Geometric Transformationscamera1
        LocalMatrix
:  1.000000 0.000000 0.000000 0.000000
                      0.000000 1.000000 0.000000 0.000000
                      0.000000 0.000000 1.000000 0.000000
                      0.000000 0.000000 9.000000 1.000000

        GlobalMatrix
1.000000 0.000000 0.000000 0.000000
                      0.000000 1.000000 0.000000 0.000000
                      0.000000 0.000000 1.000000 0.000000
                      0.000000 2.000000 9.000000 1.000000


Can you tell me what is going on?
It is a real bug or have I done a mistake in the source code?



Attachment Attachment
Replies: 1
/img/forum/dark/default_avatar.png

Hello Smekens,

This problems seems to be same one that you posted earlier, I am copy/pasting the answer here, as well as the link to your question so you can go check it out.

http://area.autodesk.com/for...local-position-following/

Regards,
Carlos

Hello Smekens,

Your code seems to be fine and from what we can see in the matrices, the translation of the camera is the same as the other two objects, it is the pre-rotation that is different.  If you take all the local matrices and look at the last line, the camera, light and cube all have the same values, irregardless whether you used the default Axis System (-z up) or OpenGL (+y up).

On the other hand, the difference between the camera and the other two objects matrices happens because there is a pre-rotation value added for the camera. This pre-rotation (that is also applied to spot lights) is necessary to correctly align the camera. Inside the FBX world (that is a Y-Up coordinate system), a 0,0,0 rotation vector will orient the camera so it is looking down the +X axis. Respectively, a 0,0,0 rotation for a spotlight will aim it toward the –Y axis.

If you have any other questions, please let us know.

Regards,
Carlos

Author: CarlosC

Replied: 03 January 2012 05:56 AM