PDA

View Full Version : Rotation of objects on spline path


gopherCG
12-23-2003, 05:51 PM
Hi,
I'm trying to create a helper object (dummy or point) on each vertex of a spline, and have the helper object rotate so it follows the tangent of the spline.

I've tried these three ways so far (ptTangent receives a point3 vector; n*fraction was used in a loop to run through all vertices in a selected spline):

1. ptTangent = tangentCurve3D $ 1 (n*fraction)
2. ptTangent = pathTangent $ 1 (n*fraction)
3. ptTangent = normalize ((getOutVec $ 1 n) - (getInVec $ 1 n))

Then I wrote a rectilinear-to-polar coordinate conversion function to find the helper's rotation using the vector, but it only works on the 2D plane since my math is now high school level.

Well, 1. and 2. gave strange results, while 3. was accurate (on 2D plane only).

Mind if you tell me how to use the functions in 1. and 2., or you have an easier alternative?

using Max 4

googlo
12-30-2003, 03:52 AM
You can use the .dir property of an object to change it's z axis orientation.

Like if you set obj.dir=[1,0,0], then the object would be rotated so that it's z-axis would be pointing in the positive x direction in world space with it's y-axis in the positive z direction of world space.

Whatever direction vector you use, the z-axis will be pointed in that direction (or world space) when setting the .dir property of an object. The y axis of the object will be oriented as much as possible in the positive z axis direction of world space.


Also, have you considered using the path constraint controller? That will allow the object to 'stick' to the spline (path) and it has various options for how an object follows the spline's tangent vector.

Using the prior example would probably be easier to use with scripting though.

gopherCG
12-30-2003, 08:54 AM
thanks, I ended up using path constraint and snapshot. .dir would be suitable if I don't want objects to collapse into editable messhes.

CGTalk Moderation
01-17-2006, 01:00 AM
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.