PDA

View Full Version : Removing a path constraint, but maintain world space position and rotation


EverZen
01-18-2005, 01:45 PM
Hi guys,

I have use maxscript to position a series of objects along a curve, so tehy touch back to back. This was done successfully with the path constraint, and follow commands. However, it is really important that once the objects are in place along the curve, then their path constraint is removed. But removing the pathconstraint must not change the position and rotation of the object in work space. The objects are stored in an array called Stonearray. I tried using:

for obj in Stonearray do
(
obj.rotation.controller = Orientation_Constraint ()
obj.pos.controller = Position_Constraint ()
obj.pos.controller = Position_XYZ ()
obj.rotation.controller = Euler_XYZ ()
)

This way, I thought I might be able to freeze the position and rotation, then restore a normal euler rotation and position to them. This still results in the objects jumping off the line.

I then tried storing the objects position and rotation while on the path, and then movingt he object back to these values after the path constraint has been removed. Once again this resuklts in the objects jumping.

Is there any way to strip the path constraint but maintain the objects position and rotation in world space?

Or is there a way to record accurately an objects world space position and rotation whilst on a path. So they can be restored to these positions after the path constraint has been stripped.

Thanks to anyone who can shed light on this, I am in desperate need :)

Take care all,

Everzen

magicm
01-18-2005, 02:13 PM
Hi EverZen,

Something along these lines should do it:

for obj in Stonearray do
(
-- apply path controllers
obj.rotation.controller = Orientation_Constraint ()
obj.pos.controller = Position_Constraint ()

--
-- insert code to position the objects on the path
--

-- backup object transform matrix
objTM = obj.transform

-- reset controllers
obj.pos.controller = Position_XYZ ()
obj.rotation.controller = Euler_XYZ ()

-- apply backupped transform matrix
obj.transform = objTM
)

- Martijn

EverZen
01-18-2005, 04:09 PM
Just to say, Thanks for sorting out my lame posting attempts, and then giving me a very concise answer that has solved my dilema perfectly :)

The obj.transform - is a exceedingly useful, I am sure I will be in need of it again in the future.

Thanks for the speedy reply, you are a star,

Take care,

Rich

CGTalk Moderation
01-20-2006, 11: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.