KeysToHoudini
From Odwiki
Contents |
Converting Keys TO Houdini
Here's an example conversion of the slope and acceleration values from other packages to Houdini using Maya as an example. In most other packages, values are relative to frames whereas Houdini's values are relative to seconds (and thus independent of FPS). The following also assumes that the result keys created in Houdini will use the bezier() expression.
Let V be value of the key from Maya (and in Houdini).
Let F be frame of the key from Maya (and in Houdini, assuming the same FPS).
Let Angle and Weight be the Maya key parameters. These are equivalent to "slope" and "accel" in Houdini except that they are with respect to Frames instead of Seconds.
Let S and A be the Houdini slope and accel values respectively.
Let FPS be the frame rate in Maya.
Let DT be some arbitrary time delta, and DF it's corresponding frame delta value.
Let DV be some arbitrary value delta.
Slope
Since,
DF = FPS * DT tan(Angle) = DV / DF S = DV / DT
Then the slope (S), for Houdini can be trivially solved as:
S = FPS * tan(Angle)
Note Make sure your Angle is converted into radians or degrees as required by the tan() function that you use.
Acceleration
The A value for Houdini can be similarly solved according to:
DF = FPS * DT tan(Angle) = DV / DF tan(Angle) = S / FPS (from above) Weight^2 = DF^2 + DV^2 A^2 = DT^2 + DV^2
To obtain:
A = sqrt( (Weight^2 * (S^2 + 1)) / (FPS^2 + S^2) )
Note Weight should be positive since it's not allowed to have a negative acceleration value.
Converting Keys FROM Houdini
Using the formulas above, we can solve in the other direction for exporting animation data from Houdini as well.
Let Angle and Weight be the Maya key parameters. These are equivalent to "slope" and "accel" in Houdini except that they are with respect to Frames instead of Seconds.
Let S and A be the Houdini slope and accel values respectively.
Let FPS be the frame rate of our animation in Maya and Houdini.
Angle
For Angle, we can compute this by re-arranging the S formula above to get:
Angle = atan2(S, FPS)
Note You will have to convert Angle into radians or degrees as required by your animation package.
Note atan2(S, FPS) is equivalent to atan(S / FPS) except it is more robust and can compute the correct quandrant. It should be used instead of atan() where available.
Weight
For Weight, we can re-arrange the A formula from above to get:
Weight = sqrt( (A^2 * (FPS^2 + S^2)) / (S^2 + 1) )
Acceleration Ratios
Some packages (eg. 3DS Max) define their tangent lengths in terms of "acceleration ratios", ie. as a percentage of the segment length. The above formulas can still be used except that the "absolute" acceleration values need to be converted from/to "relative" values first.
Let SEGLEN be the segment length between the key at frame F to (F+1) in seconds. This is simply calculated by subtracting the time values, and then converting to the appropriate units.
Let AR be the acceleration that we're converting from/to Houdini's A value.
Then we can convert from an acceleration ratio by:
A = AR * SEGLEN
Conversely, we convert to an acceleration ratio by:
AR = A / SEGLEN
Note Remember to check for zero SEGLEN values before dividing.



