Change the speed of a carve node for Rollercoaster animation

   1200   2   1
User Avatar
Member
17 posts
Joined: April 2017
Offline
Hi everyone!

I am trying to animate a rollercoaster along a curve. Each point of the curve has an attribute when the train will arrive at the specific point. But the obvious formula of "timeAtPointX / totalTime" does not work when put in a carve node U and the speed does not change at all when the train drops down.

Can anyone help me solve the problem with the carve node?
I am also fine with not using a carve node, as long as my 5 car train rolls along the track with the calculated speed.

Thanks in advance!
User Avatar
Member
2523 posts
Joined: June 2008
Offline
Here is a somewhat convoluted solution. Attributes are fetched from points and converted to keyframes that drive the carve node. Each point contains an arrival time in seconds. Behind it all is the python based fit function for Houdini.
Edited by Enivob - Oct. 22, 2022 13:08:56

Attachments:
roller_coaster_carve.gif (55.2 KB)
ap_carve_with_arrival_times.hiplc (113.7 KB)

Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
17 posts
Joined: April 2017
Offline
Okay, first of all, really big thanks to you @Enivob! This is a really clever way, setting keyframes via python. Would never have come up with this on my own.


However I did some minor debugging and tweaked the code a bit, since your result produced a linear keyframe ramp which had the same speed between all points. In case somebody else should ever need this, I ended up with this:

import hou
node = hou.node('/obj/Achterbahn-Geo/Rollercoaster/Place_Cars/ROLLERCARVE')
parm = node.parm('domainu1')
geo = hou.pwd().geometry()
key = hou.Keyframe()
parm.deleteAllKeyframes()

finaltime = geo.attribValue('final_time')
fps = hou.fps()
lastframe = final_time*fps

pcount = 0 #calulate amount of points
for point in geo.points():
pcount = pcount + 1
numpt = pcount

count = 0
for point in geo.points(): #loop through all points and set keyframes in the specified carve node
count = count + 1
value = point.attribValue('time')
keytime = value
key.setFrame(keytime/finaltime*lastframe)
key.setValue((count/numpt))#+(keytime/finaltime)
parm.setKeyframe(key)
  • Quick Links