View Full Version : Help: Transformation question

 Martin Andersen06 June 2005, 11:01 AMHi lets say we have 2 objects. A and B If I link the B to A, then B will use A's coordinate system. By this I can allways tell B to get in the same position / rotation in relation to A's Pos and Rot. Here is my situation: I don't want any of them to be linked. They both have the World coord. as there parent. But I still want to be able to set B's Position/rot in relation to A I know a workaround ( Link a Dummy to A, and then set B's transform to the Dummys pos/rot)... But I like to do this with maxscript and not with a work around. Is this possible? Can this be done with the Transform? Did this make sence?
Wahooney
06 June 2005, 12:09 PM
You could use the in coordsys context.

in coordsys \$obj1
\$obj2.pos = point3 0 0 0

Will move \$obj2 relative to \$obj1's transform, in this case moving obj2 to obj1's position.

Besides that (and using a frozen transform) I don't know what to do.

FatAssasin
06 June 2005, 02:54 PM
You could use the in coordsys context.

in coordsys \$obj1
\$obj2.pos = point3 0 0 0

Will move \$obj2 relative to \$obj1's transform, in this case moving obj2 to obj1's position.

Besides that (and using a frozen transform) I don't know what to do.

What he said. :)

I use 'in coordsys' all the time and works like a charm.

Martin Andersen
06 June 2005, 04:39 PM
Great!

Is it like this ? :

in coordsys \$obj1
\$obj2.rotation = quat 0 0 0 0

That Quat thing is driving me crazy, is there anyone who can explain how that Quat is working?

Did this little ui, that shows how quat ( 0,0,0,0 ) affects A Single Selected Object.

But I just got more confused of how these quats work http://cgtalk.com/images/smilies/surprised.gif

(
spinner spn1 "Val 1" pos:[24,24] width:64 height:16 enabled:true range:[-1,1,0] type:#float
spinner spn2 "Val 2" pos:[24,48] width:64 height:16 enabled:true range:[-1,1,0] type:#float
spinner spn3 "Val 3 " pos:[24,72] width:64 height:16 enabled:true range:[-1,1,0] type:#float
spinner spn4 "Val 4" pos:[24,96] width:64 height:16 enabled:true range:[-1,1,0] type:#float

on spn1 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value ))
)

on spn2 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value ))
)

on spn3 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value ))
)

on spn4 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value ))
)
)

In the Help files it says:

The x, y, z values make up the vector portion. w is the angle of rotation about the vector.

I do understand vectors, but the W thing didn't make sence to me?
Anyone who can help me in the right direction of understanding quats?

Martin Andersen
06 June 2005, 04:45 PM
hmm I think I got it now :scream:

FatAssasin
06 June 2005, 06:05 PM
If you want the same rotation it would be:
in coordsys obj1 (obj2.rotation = (quat 0 0 0 1))

I don't completely understand quats either, like what the "1" is for, but it works. :)

You can also do something like:
in coordsys obj1 (obj2.rotation = (eulerAngles 0 0 90) as quat)

This way lets you think in euler angles, but work in quats.

Bobo
06 June 2005, 08:19 PM
Can this be done with the Transform?

B.transform = A.transform

will align B to A, placing its pivot point at A's pivot, will match the orientation and if A had world-space scaling applied, will also match the scaling.

This copies the complete transformation matrix from A to B.
If you don't want the scaling, you can reset the scaling back to 100% :

B.scale = [1,1,1]

Cheers,
Bobo

Martin Andersen
06 June 2005, 07:25 AM
Thanks all :)

Great input about that scaling Bobo - Thanks!

If i have a Obj C and I want to blend it between ObjA and ObjB's rotation,

I would take the quat values ObjC's quat rotation: -0.352532 0.208981 0.0718038 0.909336

value one and mix it between ObjA and ObjB's Value one in the quat?

((A's value one +B's value one) / 2 ) is that correct?

And then Value 2,3,4 one by one.. is that correct?

[edit:] FatAssasin: yeah quat is a strange world.. hope to get a better understanding of it.

I think I really starts to understand them now.

A quat is Typed like this: quat x y z w

the x y z part is a vector (plz tell me if you don't know what that is)

as we know a vector doesn't contain a rotation value, it is just a direction

Vector = direction

X Y Z descibes how mutch you want to look in eacth direction.

Ex X Y Z = 1 0 0 will make the object look in the X direction.
Ex. X Y Z = .50 .50 0 will make it look 50% in X direction and 50% in Y direction.

Now we have a direction, but we doesn't know how mutch the object is rotating around itself. This is where we have the W value ( remember: quat x y z W )

The W defines how mutch the object is rotating around itself.

Open this scene (max 7):
http://www.3d-designer.dk/QuatOrientationPlaying.max

select the bigbone.

Run this new version of the code:

(
spinner spn1 "X" pos:[32,34] width:64 height:16 enabled:true range:[-1,1,0] type:#float
spinner spn2 "Y" pos:[32,59] width:64 height:16 enabled:true range:[-1,1,0] type:#float
spinner spn3 "Z" pos:[32,83] width:64 height:16 enabled:true range:[-1,1,0] type:#float
spinner spn4 "W Rotation around itself" pos:[79,124] width:142 height:16 enabled:true range:[-1,1,0] type:#float

GroupBox grp1 "Vector Direction" pos:[19,13] width:93 height:104
label lbl1 "Quat Result" pos:[11,169] width:283 height:29

on spn1 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value )
lbl1.caption = ("Quat Result - " + (spn1.value as string) + " " + (spn2.value as string) + " " + (spn3.value as string) + " " + (spn4.value as string))
)
)
on spn2 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value )
lbl1.caption = ("Quat Result - " + (spn1.value as string) + " " + (spn2.value as string) + " " + (spn3.value as string) + " " + (spn4.value as string))
)
)
on spn3 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value )
lbl1.caption = ("Quat Result - " + (spn1.value as string) + " " + (spn2.value as string) + " " + (spn3.value as string) + " " + (spn4.value as string))
)
)
on spn4 changed val do
( if selection.count == 1 do (\$.rotation = (quat spn1.value spn2.value spn3.value spn4.value )
lbl1.caption = ("Quat Result - " + (spn1.value as string) + " " + (spn2.value as string) + " " + (spn3.value as string) + " " + (spn4.value as string))
)
)
)

The code works on the current selected object (in this case the big bone).

If you don't understand vectors, just tell and I'll try tell it in a correct way

CGTalk Moderation
06 June 2005, 07:25 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.

1