Home » Featured, Houdini, Miscellaneous

Houdini CHOPs: Curves from animation

21 July 2009 108,118 views 12 Comments

Creating the curve with the correct number of points

Press u to navigate back to the first level inside the Subnet and switch your main view back to Scene View. Add a Geometry Node called “geo_Curve”, and go inside it. Delete the default File SOP inside, and add a new Line SOP. In the Points parameter you need to enter the following expression:


($TEND - $TSTART + 1/$FPS) * ch("../../chop_GetAnim/fetch_Anim/rate")
 

If the Line SOP gives an error, then chances are that you have either named a node incorrectly or mistyped your expression (I’d recommend copy and pasting it). Try retracing the steps of the tutorial to find where the mistake is.

The value produced by this expression is used to set the number of points in the curve so that it exactly matches the number of samples in the CHOPs curve. Left clicking on the parameter name will show you the result of the expression.

While this syntax might look complicated; it’s actually quite simple. See the box below for an explanation.

Technical Detail

I’ll Introduce you to the components of the expression first:

$TEND
The time at the last frame in our scene.

$TSTART
The time at the first frame in our scene.

1/$FPS
The amount of time in a single frame. Dividing one by frames per second, gives you seconds per frame.

ch( )
An expression function that retrieves the value of a parameter.

../../chop_GetAnim/fetch_Anim/rate
The relative path to the Sample Rate parameter of the Fetch CHOP. This value is measured in “samples per second”. For more information on paths and relative paths see the help files at Houdini10 > Network and parameters > Node and parameter paths or search for “Node and parameter paths”.

So now you know what each part means, the rest of the expression becomes more understandable:

($TEND – $TSTART)
This is the amount of time in our scene from the start of the first frame to the start of the last frame.

($TEND – $TSTART + 1/$FPS)
This is a slightly subtle point. This is actually the amount of time in our scene from the start of the first frame to the end of the last frame. Without this little bit of extra time added, you won’t have a curve that completes the entire animation. The last bit of the curve would be missed off.

($TEND – $TSTART + 1/$FPS) * ch(“../../chop_GetAnim/fetch_Anim/rate”)
Multiplying the sample rate by an amount of time gives us the number of samples in that duration. So the expression gives us the total number of samples in the scene from the start of the first frame to the end of the last frame.

Using the data from CHOPs

Now that you have created the curve geometry, you need to import the data from CHOPs.

Step4Create a Channel SOP and connect the output of the Line SOP into it.

Find the CHOP parameter and use the button to its right to navigate to the OUT node in the CHOP network. When doing this, make sure you turn on “Export Relative Path” so that it gives you the result “../../chop_GetAnim/OUT”.

Relative paths are essential when creating a digital asset because assets can be created in different locations. Using relative paths allows the nodes contained within the asset to still reference each other, regardless of the location of the enclosing digital asset.

The default values of the Channel SOP are exactly what you need to pull in the correct channels from CHOPs. Each sample from the tx, ty, and tz channel is used to set the (x,y,z) position of a corresponding point belonging to the curve. To find out how to assign channels to your own attributes, have a look at the help card for the Channel SOP.

Step5

Turn on the display flag for the Channel SOP. You should see your plotted curve appear in the viewport.

Changing the curve type to “Bezier” or “NURBS” will show a smoother curve, but keep it set to “Polygon” to make it easier see the resolution of the curve.

Step6 Go back up to the top object level and have a play around with the animation of the Null. Notice that the curve follows to match.

The next page will show how to add your own controls for ease of use.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

12 Comments »

  • Dragos Stefan said:

    A great and clear tutorial! As an option, one can use an Object CHOP instead of the Fetch CHOP to get the animation into CHOPs. However, while the Object CHOP can be more flexible in some cases, it is also much slower, especially if it has to compute the whole timeline.

  • varomix said:

    HI Andy

    I totally loved this one, very useful one

    Do you think this could be made so that the curve(SOP) can shape the animation curves?

    or maybe add a little manipulator at each key an move it around?

    that would be awesome

    thank you Andy, please keep sharing this nice techniques

    varomix

  • AndyN (author) said:

    Great, thanks for the feedback.

    As far as I know, you wouldn’t be able to feed this system back into the animation again, because you’d end up with cyclical evaluation. I did try it when I was putting this tutorial together and Houdini bombed on me. In the docs, it says that you can’t export CHOPs back to parameters if you’re already importing data from them in the same CHOP network.

    It would be trivial to drive a different object with that curve though.

  • Jason said:

    Awesome tutorial. I’m just starting to get into CHOP’s and this really helps out on learning it. This is probably realy simple, but do you have any suggestions on animating a curve through CHOPs that controls an IK rig. I tried hand animating it, but I didn’t get the look I was going for. Anyways, like I said this really helped me in getting started with CHOPs.
    –Jason

  • AndyN (author) said:

    Hi Jason,
    No problem, glad you found it helpful.

    It’s hard to give any recommendations based on what you’ve said about the curve animation. If you can send me more info, I might be able to help.

    You can email me here:
    http://www.andynicholas.com/?page_id=224

    Cheers,

    Andy

  • Helene said:

    Hi Andy,

    Just wanted to say ‘Hi’ and thank you for a great tutorial. I’m just beginning to get into CHOPs – am finding it fascinating. This is a lovely introduction. Just to say you tutorials are greatly appreciated. Keep up the great work. 🙂

    Regards,
    Helene

  • AndyN (author) said:

    No problem Helene, thanks!

  • MJ said:

    Hi Andy,

    Does this work with OP control channels such as with the position (‘pos’) of an object following a path ? I could not make it work.

    Great tutorial !

  • ArturM said:

    Thank you very much, this is a very useful resource.

  • Gotta Getmedat said:

    so in python you have to do something like this?…
    (float(expandString(‘$TEND’)) – float(expandString(‘$TSTART’)) + (1/float(expandString(‘$FPS’)))) * ch(“../../chop_GetAnim/fetch_Anim/rate”)

    is there a better way?

  • AndyN (author) said:

    Hi MJ,
    Off the top of my head, no, I don’t believe this method would work, but I’d have to try.

    I’m sure there must be a workaround though. I’ll have to investigate further!

    A

  • AndyN (author) said:

    Hi Gotta,
    I don’t usually use Python for expressions so I can’t advise. Using the standard Houdini expression language is nearly always less verbose (and in my experience, a more common and standard approach), so I’d recommend sticking with that where possible.

    A

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.