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 (following)
  RSS 2.0 ATOM  

Wrong camera local position (following)
Rate this thread
 
62783
 
Permlink of this thread  
avatar
  • Smekens
  • Posted: 12 December 2011 11:42 PM
  • Total Posts: 2
  • Joined: 12 December 2011 04:19 AM

Hi,

Here is a new issue with the camera postion.

I rendered the following elements in the scene:

- 1 camera (position 1, 2, 3)
- 1 light (position 1, 2, 3)
- 1 cube (position 1, 2, 3)

The three elements have the same location, no scaling and no rotation.

When loading the local matrices I get the same one for the light and the cube but the one for the camera is different !

Same result if I change the Axis System from the default to OpenGL.

Here is the code used to dump the informations:

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

bool __fbxParseNode(KFbxNode *);

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

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

 
/**/

 
KFbxAxisSystem::OpenGL.ConvertScene(fbxScene);

 
/**/

 
__fbxParseNode(fbxScene->GetRootNode());

 return 
true;
}

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

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

 
/**/

 
KFbxVector4 vector;

 
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]);

 
KFbxXMatrix matrix;
 
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]
 
);

 
/**/

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

 
return true;
}

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

Here id the result for the default:

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

    Geometric Transformations
camera3
        Translation
:  1.000000 -3.000000 2.000000

        Rotation
:     0.000000 0.000000 0.000000

        Scaling
:      1.000000 1.000000 1.000000

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

    Geometric Transformations
pCube1
        Translation
:  1.000000 -3.000000 2.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 0.000000 1.000000 0.000000
                      0.000000 
-1.000000 0.000000 0.000000
                      1.000000 
-3.000000 2.000000 1.000000

    Geometric Transformations
pointLight1
        Translation
:  1.000000 -3.000000 2.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 0.000000 1.000000 0.000000
                      0.000000 
-1.000000 0.000000 0.000000
                      1.000000 
-3.000000 2.000000 1.000000

Here is the result for the OpenGL one:

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

    Geometric Transformations
camera3
        Translation
:  1.000000 2.000000 3.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
                      1.000000 2.000000 3.000000 1.000000

    Geometric Transformations
pCube1
        Translation
:  1.000000 2.000000 3.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
                      1.000000 2.000000 3.000000 1.000000

    Geometric Transformations
pointLight1
        Translation
:  1.000000 2.000000 3.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
                      1.000000 2.000000 3.000000 1.000000

We can see that the camera has not the same position as the to other objects.

Is there an issue about the camera position?

Have I done something wrong to get the local matrices?

Cheers,
Chris



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

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: 13 December 2011 07:01 AM