Views
Keyframe information
From Odwiki
Contents |
[edit] Retrieve keyfram information with HDK and Houdini 8.2.238
When using keyframe animation with your object. You might want to get the Translation, Rotation and Scale values from the keyframes.
First you need to find the channel/s that you want to retrieve the information from.
[edit] Access The channel
CH_Channel *pChannel OP_Node::findChannel(const char *path)
This function returns a pointer to the channel that you searched for. If the channel doesnt exists, it will return NULL.
You can find the name of the channels inside Houdini Channel Editor. Below is the most common ones that you may want to
access:
(translate) tx, ty, tz (rotate) rx, ry, rz (Scale) sx, sy, sz
[edit] Get values from the channels
Now when you have found the channel of your choice, you will need to get the keyframe information. Each channel will store all the keyframes you have set in Houdini. You set a keyframe in Houdini by clicking alt+LMB (the channel will become green).
So first you need to get the current segment you wish to use. You can choose which segment you want, by using a index variable for the function.
This function will return a pointer to the segment you requested, this 'Value' float represent the keyframe.
CH_Segment *pSegment CH_Channel::getSegment(unsigned int idx); float Value CH_Segment::getInValue();
[edit] Putting it all together
Below I have posted a simple pseudo-code that shows how you can find a channel, loop through all its variables and retrieve the keyframes. In this example I want to access the Translate X-axis:
CH_Channel *pTranslateX = m_pOpNode->findChannel("tx");
int NumOfKeys = pTranslateX->getNKeys();
for(uint Index = 0; Index < NumOfKeys; Index++)
{
float KeyFrameValue = pTranslateX->getSegment(Index)->getInValue();
}
[edit] Also see
frame_information - How to get information from each frame KeysToHoudini - How to convert keys from other packages (eg. Maya) to Houdini



