Jump to content
  • Advertisement
Sign in to follow this  
wiegje85

[Maya API] Check if Animation curve is between frames

This topic is 2542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A good evening once again.

Now that my joint animation is nicely working, I am having trouble with a small issue: how to check if the scene node that I am exporting on Frame N has an animation curve that has a start and ending frame that start before frame N and end after frame N, i.e. "is this node being animated on this frame?"

How do I check for that? What I do right now is I get the start key frame and end key frame and then retrieve the current time of the MAnimControl class. Then do a simple comparison for those 3 values. However, this doesn't seem to work as I get all these random values. I reference the MFnAnimCurve the way Rob The Bloke does it on his website: http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/index.html

[source]
bool NodeHasAnimationCurve(MObject& object)
{
MTime currentTime = MAnimControl::currentTime(); // Get current key time, in PAL format
MPlugArray connectedPlugs;
MFnDependencyNode fnDepNode(object);
fnDepNode.getConnections(connectedPlugs);
for(unsigned int c = 0; c < connectedPlugs.length(); ++c)
{
MPlug& plug = connectedPlugs[c];
MPlugArray connectedConnections;
plug.connectedTo(connectedConnections, true, false);
for(unsigned int i = 0; i < connectedConnections.length(); ++i)
{
MObject connected = connectedConnections.node();
const char* connectedType = connected.apiTypeStr();
if(connected.hasFn(MFn::kAnimCurve))
{
MFnAnimCurve fnAnim(connected);
for(unsigned int t = 0; t < fnAnim.numKeys(); ++t)
{
MTime keyTime = fnAnim.time(t); // This returns crazy values (PAL)
if(keyTime < currentTime || keyTime > currentTime)
{
return false;
}
}

return true;
}
}
}

return false;
}
[/source]

So right now I'm exporting all nodes, even those that are not animated for the currently selected frame, (i.e. don't have an animation curve attached for frame N).

How does one fix this? Thank you in advance.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!