PDA

View Full Version : Move and rotate to a face


f97ao
09-21-2004, 11:26 PM
Well this should be very simple, but I kept banging my head against it last night and couldn't get it to work.

What I want to do is to place an object and rotate it correctly onto a face of an poly. So exactly like the autogrid.

This is what I write:

tPos=polyOp.getFaceCenter $ iFace node:#World
tNormal=polyOp.getFaceNormal $ iFace
tm=matrix3 1
tm=matrixFromNormal tNormal
newObject.rotation=inverse tm-rotationpart
newObject.pos=tPos

I'm thinking that perhaps I'm mixing coordinate systems or something like that.
/Andreas

soshiant
09-22-2004, 06:41 AM
Well this should be very simple, but I kept banging my head against it last night and couldn't get it to work.

What I want to do is to place an object and rotate it correctly onto a face of an poly. So exactly like the autogrid.

This is what I write:

tPos=polyOp.getFaceCenter $ iFace node:#World
tNormal=polyOp.getFaceNormal $ iFace
tm=matrix3 1
tm=matrixFromNormal tNormal
newObject.rotation=inverse tm-rotationpart
newObject.pos=tPos

I'm thinking that perhaps I'm mixing coordinate systems or something like that.
/Andreas
rotation in max 6.0 is a quaternion var. so you have to convert it to quat. See max ref for details on quats and converting them to other types and vise versa. Hope it works.:)

magicm
09-23-2004, 02:53 PM
newObject.rotation=inverse tm-rotationpart

This might not solve your problem, but it seems you have a typo in this line:
tm-rotationpart should probably be tm.rotationpart.

- Martijn

CGTalk Moderation
01-19-2006, 08: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.