PDA

View Full Version : Conform splline controllers to a displaced terrain?



marchermitte
10-05-2017, 12:52 AM
hello!
I'm trying to animate a caterpillar moving on a displaced plane. I used a bone chain and a spline controll to animate the caterpillar along a path.Now I'd like to constrain the spline control's nulls to the terrain. Sticky doesn't work well as the spline doesn't read the proper y position of the nulls (still have to move them up/down to get the spline to follow)
Could I use nodes for that (raycast)?
I think there was a way to use the procedural texture used to displaced the terrain to offset the nulls over the surface...
I'd like to be able to change the terrain displacement on the fly and have the spine control nulls automatically adjust.
Any suggestion?

Thank you.

pinkmouse
10-05-2017, 08:26 AM
Right, you can use raycast to offset the nulls that make up your spline to conform to the terrain, but I'm loath to give you exact details as I'm still on 11.6 and raycast functionality seems to be different with every release. Using the same texture is a little more difficult, as you can't transfer variables such as texture size easily between node editor windows, a workaround is to use nulls to hold data, (I have a video about that below), but it's still a fiddle.Good luck!

raw-m
10-05-2017, 12:56 PM
Try applying the same displacement to a 2 Point poly chain with the same number of points as nodes in your spline. For each spline node apply Motion Options/Node texture and use DP Kit Point info to constrain each null to each point of the 2 ppc. Sorry, a bit vague as LW is in front of me but hopefully there’s enough to go on there!

MonroePoteet
10-05-2017, 05:59 PM
As pinkmouse said, you can use the Raycast Geometry node to "detect" where each node in the Spline intersects the ground downward. However, if the ground is "rough enough", the intervening curvature of the Spline between nodes may pass through the ground or fly above it. Attached is a sample scene demonstrating the setup and the problem. Although the Spline nodes correctly "ride" the surface as it changes, the green arrow passes *through* the ground because there isn't an intermediate Node to detect the rise.

138195

The basic nodal setup per Spline node is the Nodal Motion motion modifier, with a DPKit Item Info node's World Position going into the Ray Origin of the Raycast Geometry node. The Raycast Geometry node is set to detect the Ground Plane, and the Intersect output goes into the Position on the NodalMotion output. The entire Spline path must be above the displaced Ground Plane for the Raycast Geometry node to detect it, since the default Ray Direction is (0,-1,0).

138193

I had to use DPKit's Item Info rather than the LW built-in because the built-in apparently doesn't "see" the correct node positions down the Spline. Also, setup is relatively cumbersome since you can't add and edit the Nodal Motion node graph for all the Spline nodes at once, but instead have to Copy-and-Paste it into each subsequent Spline node's Motion Modifiers panel (Right-click on Nodal Motion to Copy, use the Edit pulldown in subsequent Spline nodes).

So, with the intervening curvature problem and the relatively cumbersome setup, it might not be a good method for what you're trying to accomplish. The 2-point poly chain suggested by raw-m may have the same intervening curvature problem if the point density isn't sufficient.

I'm not sure what you mean by wanting to change the terrain displacement on the fly. Do you want the moving Displacement Map that I demonstrate in the attached scene? Or is it just you want to adjust the terrain until it's "right", and then it's fixed for the shot and the Spline needs to conform to the fixed terrain? If it's the latter, it might be easier to Save Transformed Object on the displaced terrain, get it into Modeler and lay a curve on top of the displaced geometry using Conform to Background, Heatshrink or just select points on the transformed object and use CTRL-P to create a curve. You could then use Curve to Spline in Layout to create a Spline that conforms to the terrain.

Best of luck!
mTp

P.S. DPKit is available here:

http://dpont.pagesperso-orange.fr/plugins/nodes/Additionnal_Nodes_2.html

raw-m
10-06-2017, 01:29 AM
Good suggestions there but as mtp says, splines are not always the best solution for angular terrains. Thought it might also be worth mentioning Oliver Hotzís excellent OD Tools, this one creates splines on a surface where you want: https://vimeo.com/114391061

marchermitte
10-06-2017, 01:40 PM
wow! Thank you for those exhaustive answers and lots of options. (Even a scene file, It's christmas)
Raycast is definitely interesting and I'm experimenting with It right now. Now I did notice that too many nulls on my spline result in inaccuracy and strange behavior (extrapolation between the spine points when those are too close to each other) and I'll get the best result if the terrain isn't heavily displaced with too small details.
Raw-m, I do own OD tools but never really took time to use It completely so thank you for pointing that one out.
Thank you MonroePoteet , I use DPkit on a regular basis and your example is a good idea too. The terrain will be frozen on a per shot basis so It might change from scene to scene yes.
Going to try all your suggestions and see what works the best.

MonroePoteet
10-06-2017, 07:05 PM
...
The terrain will be frozen on a per shot basis so It might change from scene to scene yes.


In that case, I'd probably fit a spline to the transformed terrain. I've attached a sample scene using the technique described below. More expert people may have a better way of fitting the curve to the transformed terrain, but this seems to work pretty well. There are a few places where the snake goes under the sand, but those spline nodes could be fixed manually (the spline used was directly out of Curve To Spline), or additional control points added to the Curve before saving to be converted to a Spline in Layout.

138216

In Layout, use Save Transformed Object to save the displaced terrain.

In Modeller:
Bring in the Transformed terrain
Use Add Point to draw the path of the spline (or use the one you set up in Layout) and CTRL-P to create the curve

NOTE: Use F7 to specify curve in the foreground, transformed terrain in the background
Use Extrude in the Y axis to extrude the spline path large enough to surround the displaced terrain, which incidentally subdivides the curve nicely.
Use Construct=>Boolean=>Intersect to cut the extruded path.
Use Point statistics to delete points which only belong to 1 polygon (except the corners!), and which have 0 polygons.
Select the first two points on the top edge of the extruded path, use right-arrow to select connected
Unselect the bottom edge points and use CTRL-P to create the fitted curve and save to be used with Curve to Spline in Layout


Have fun!
mTp

138219 138220 138221
138222 138223 138224
138225 138226 138227
138218 138217

marchermitte
10-16-2017, 06:57 AM
VERY cool!
Thank you for your screen capt and scene. It's all perfectly clear. I appreciate that you took the time to help me out and go through so much details.
Please forgive my late answer, I'm also working into makeup fx and under lots of deadlines right now. (I'm a lab guy)