PDA

View Full Version : Scripting a curve


CPX
12-11-2007, 05:51 PM
Hey all, I've been trying my hand at using float scripts on objects to make them behave like they were in a spline.

So far I've been using (p1+((p2-p1)*T)) to be able to get an object to go any percentage between two points, but that's just getting them to be linear, as if it's a corner to corner spline. Would anyone know how to make them like a smoothed spline?

PEN
12-11-2007, 06:21 PM
We have had laong discussions on this in the Max Scrpt forum, you might want to have a look at it. I believe that I even posted my code for a quadratic curve. I use this instead of a spline for my characters as it is faster.

CPX
12-11-2007, 07:41 PM
Took a while to find, but I'm assuming you mean this one
http://forums.cgsociety.org/showthread.php?t=470089

CPX
12-11-2007, 09:54 PM
Wow I think I got something going on!!
By the way, thanks for the excellent reference and example on the other thread, Paul.
For those of you who are interested, check out http://www.ibiblio.org/e-notes/Splines/Bezier.htm
This gives an awesome visual demonstration of how the curvature works.

I'll post my max file in a bit. I'm not completely sure if I'm doing it right since I'm just trying different ideas, but it's giving me a nice curve.

PEN
12-12-2007, 11:26 AM
Yep that is the one. Glad you have something working.

CPX
12-12-2007, 05:10 PM
I've posted the file under the thread I've posted earlier. Anyone who's interested, go check it out and let me know what you think!

CPX
12-17-2007, 10:59 PM
I was messing around with scripting a quadratic spline, and this is what I came up with. You can use the blue nodes to manipulate it, and unhide the layers to see how it's working. I've also made it so you can rotate the helpers to smoothly twist the bones. After looking at it, I'm sure I can get the same result without the need of the red balls, but using doing a few more calculations in the float_scripts instead.

I'm having problems trying to get this method working with more than 3 points so that all the points along the path stay consistent. Does anybody know how I can tackle that?

Here's the file with 3 points.
http://files-upload.com/files/67466...CurveTest02.max (http://files-upload.com/files/674662/scriptedCurveTest02.max)

CGTalk Moderation
12-17-2007, 10:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.