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 SDK / Getting Camera Animation Rotation & Rotation order problem??
  RSS 2.0 ATOM  

Getting Camera Animation Rotation & Rotation order problem??
Rate this thread
 
46307
 
Permlink of this thread  
avatar
  • Location: Glendale, CA
  • Total Posts: 10
  • Joined: 08 August 2007 06:46 PM

Hi,

Trying to export a file from Maya to Motion Control via FBX.  When I try to get the rotation from the FBX camera it is coming in incorrectly.  The Maya camera rotation goes 180 to 0, the
Matx = lExportScene->GetEvaluator()->GetNodeGlobalTransform(lpNode, nowtime);
vect = Matx.GetR();
gives me -90 to +90 even though my scene is apparently KFbxAxisSystem::eMayaYUp.

If I re-import the FBX file into Maya it appears correct so it is something I am doing :-)

Does anyone know much about correcting for rotation orders?  A normal film camera is zxy meaning it pans, then tilts and then rolls.  Most CG camera are otherwise (xyz) and you cannot easily convert a film camera pan into a Ry if the rotation orders are different.

Simon

PS:

Tried several ways to get the Start and Stop frame of the animation. 

//trying to fill float *pSpeed, float *pStart, float *pStop from KFbxScene *lExportScene

// Get the frame rate = this seems to be fine
KFbxGlobalTimeSettings *lTimeSettings;
lTimeSettings = &lExportScene->GetGlobalTimeSettings();
KTime::ETimeMode lTimeMode = lTimeSettings->GetTimeMode();
double lFrameRate = KTime::GetFrameRate(lTimeMode);
fbxinfo_log("Using Global time settings gives a speed of %f\n”, lFrameRate);
*pSpeed = (float) lFrameRate;

lExportScene->GetGlobalTimeSettings().SetTimeProtocol(KTime::eFRAME);
lTimeSettings->GetTimelineDefautTimeSpan(MoveTimeSpan);

KTime SpanStart = KTIME_INFINITE;
KTime SpanStop = KTIME_MINUS_INFINITE;

SpanStart = MoveTimeSpan.GetStart();
SpanStop = MoveTimeSpan.GetStop();

SpanStart.GetTime(Hour, Minute, Second, Frame, Field, Residual);
// Start time in frames
*pStart = Frame + (Second + (Minute + (Hour * 60.0f)) * 60.0f) * lFrameRate;

SpanStop.GetTime(Hour, Minute, Second, Frame, Field, Residual);
// Stop time in frames
*pStop = Frame + (Second + (Minute + (Hour * 60.0f)) * 60.0f) * lFrameRate;

Isn’t there a better way or this the best?
I would have thought most platforms would deal in frames and it seems VERY laborious for such a needed function.  Tried GetFrame, but that never seemed to work correctly.



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

This is what the SDK uses for each animation take:

KTime gStartgStop;
    
KFbxTakeInfolCurrentTakeInfo gScene->GetTakeInfo(*(gTakeNameArray[pItem]));

    if (
lCurrentTakeInfo)
    
{
        gStart 
lCurrentTakeInfo->mLocalTimeSpan.GetStart();
        
gStop lCurrentTakeInfo->mLocalTimeSpan.GetStop();
    
}
    
else
    
{
        
// Take the time line value
        
KTimeSpan lTimeLineTimeSpan;
        
gScene->GetGlobalTimeSettings().GetTimelineDefautTimeSpan(lTimeLineTimeSpan);

        
gStart lTimeLineTimeSpan.GetStart();
        
gStop  lTimeLineTimeSpan.GetStop();
    
}
Author: TravF

Replied: 18 August 2010 09:43 AM  
avatar

Hi Simon,

If I understand correctly, you have a node with rotation order XYZ that you would like to convert to ZXY.

I suggest using KFbxNode::ConvertPivotAnimationRecursive() in your FBX importer. This is how the code should look:

// Change rotation order for desired nodes
pNode->SetRotationOrder(KFbxNode::eDESTINATION_SET KFbxNode::eEULER_ZXY);

// When the setup is done, call ConvertPivotAnimationRecursive to the scene’s root node.
// Sampling rate e.g. 30.0.
mScene->GetRootNode()->ConvertPivotAnimationRecursive(KFbxNode::eDESTINATION_SETlSamplingRate );

I don’t have time to test this code, so there might be some other adjustments to do: Keep me posted on your results.

Function ConvertPivotAnimationRecursive() is used to bake transform components: pre- and post-rotation, rotation and scale pivots and offsets - inside the standard transforms – Translation, Rotation, Scaling. It is very useful when importing a FBX file inside a system that does not support some of these properties.

Viviane
Autodesk FBX



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 1
/userdata/avatar/65df9nc33.JPG

Hi,

Thank you.  I did try that code, I had to modify a bit to fit with my sdk version, so it ended up as

// Change rotation order for desired nodes
lpNode->SetRotationOrder(KFbxNode::eDESTINATION_SET , /*KFbxNode::*/eEULER_ZXY);

lExportScene->GetRootNode()->ConvertPivotAnimationRecursive(lAnimStack->GetName(), KFbxNode::eDESTINATION_SET, lFrameRate);

That didn’t seem to make a difference.  On further inspection, if I use ImportScene, I can see the rotations are 180 to 0, but when I use:

Matx = lExportScene->GetEvaluator()->GetNodeGlobalTransform(lpNode, nowtime);
vect = Matx.GetR();

I get -90 to +90 and also there are euler inversions in Tilt and Roll (Rx and Rz) flips from 180 to 0 instantly

The default Motion Builder camera appears to look up the -Z axis and be at -90 where the default Maya camera would be saying 0.  Thus I think that GetGlobalTransform returns the MotionBuilder(FBX) transform, and not the Maya one?  I did try:

KFbxAxisSystem SceneAxisSystem = pScene->GetGlobalSettings().GetAxisSystem()
KFbxAxisSystem OurAxisSystem(KFbxAxisSystem::eMayaYUp)
if(SceneAxisSystem != OurAxisSystem)
{
fbxinfo_log("Converting Scene to Maya Y Up\n");
OurAxisSystem.ConvertScene(pScene);
}

All I really want to find out at the point is the Camera Position and Orientation at each frame of the move regardless of how it is animated and parented in Maya Yup space or even FBX space if I have to, I can always convert - but I believe that is a major reason for using FBX…

Thanks

Simon

Author: SimonWakley

Replied: 24 August 2010 10:08 AM  
avatar

Hi,

Further to my earlier posts, I have sorted out my rotation orders by getting the Quaternions and then using code to convert that to my rotation order which is “Pan, Tilt, Roll” like most films cameras.  I am somewhat surprised by the odd gimbal locks that occur when panning CG cameras, a film camera will standardly gimbal lock when looking straight up or straight down.  Then the roll (horizon) becomes an issue and I use a 3Node camera to solve that but it does not come up that much.

I am however having some very strange issues with GetStart and GetStop.  The values being returned are huge and look suspiciously un-initialised.  Start should be 0 and Stop a few tens of frames, but I am getting tens of thousands…

I follow the ViewScene app as far as I can see, but when I call

gCurrentAnimationStack =lExportScene->FindMember(FBX_TYPE(KFbxAnimStack), gAnimStackNameArray[pItem]->Buffer());
gCurrentAnimationLayer = gCurrentAnimationStack->GetMember(FBX_TYPE(KFbxAnimLayer), 0);
lExportScene->GetEvaluator()->SetContext(gCurrentAnimationStack);
lCurrentTakeInfo = lExportScene->GetTakeInfo(*(gAnimStackNameArray[pItem]));

KTime SpanStart = lCurrentTakeInfo->mLocalTimeSpan.GetStart();
KTime SpanStop = lCurrentTakeInfo->mLocalTimeSpan.GetStop();

I get SpanStart mTime=0x0000cdcdcd010000
and SpanStop mtime=0xd7b000000000000

from the humanoid.fbx sample file, needless to say ViewScene works fine.

I could post more code, but I didn’t want to bore you endlessly, any pointers would be appreciated.

Thanks

Simon
PS: Why the typo GetTimelineDefautTimeSpan(..);



Replies: 1
/userdata/avatar/3yvwf23us_doug100x100.png

Try using GetSecondDouble() from KTime.

Author: Doug Rogers

Replied: 03 December 2010 04:56 AM  
avatar

Hi,
That doesn’t work either, I still get strange values.  If I look at my Scene pointer, the mGlobalTimeSetting member looks corrupt right from the InitializeSdkObjects(..) compared to ViewScene, so there must be something more basic out…
Thanks for the suggestion though :-)
I have built a simple console app that works and the pSdkManager and lExportScene seem to be fine, in my not-working scene, these pointers are apparently valid but contain some odd values (a lot of cdcdcd) See attached jpgs.  I can only imagine it is a mistake on the #defines or the linking or sthg, but as far as I can see the projects are identical in these regards.



Replies: 0