What would be equivalent of standard Align tool in maxscript


#1

Hi,

lately I had a lot of problems with aligning position, rotation or both of one object to another (all the mess with transformation matrixes). I got different results, but I was not able to replicate the trouble-free way of how standard max align tool works, which really seem to work correctly under all conditions even with different plugins and weird hierarchies.

Anyone has idea how exactly does max standard align tool work? Or is it some internal voodoo thing going on in c++?

Thanks


#2

It is just taking all possibilities into account. How have you been trying to do it and in what cases are your methods failing?


#3

Hi

That’s what I was afraid.

It’s failing on some of the CAT objects.

For biped I’m using these for position, rotation and both:
biped.setTransform WhichObject #pos WhereObject.transform.position true
biped.setTransform WhichObject #rotation WhereObject.transform.rotation true

For rest of the objects I use:
WhichObject.transform = WhereObject.transform --for both, position and rotation
WhichObject.pos = WhereObject.pos --position only
in coordsys (transMatrix WhichObject.pos) WhichObject.rotation=WhereObject.rotation --rotation only

I tried to use .position instead of .pos

What I happening with CAT’s palm is that position only or rotation only crashes the script and if i use .transform for both, than only rotation get’s aligned and position seems to be unaffected. On the other hand, it works with CAT’s platform.

Align tool of course works correctly.


#4

CAT is an interesting beast as it flies in the face of what Max would normally do in a hierarchy. I don’t have it installed any more so I can’t do any tests on it so I can’t sort out what method would work.

What you might need to do is only set transform values and not rotations or positions. Since you still need to set just a pos or rot value you will need to create the matrix from parts of itself and the one that you want to align to.

The code below aligns just the rotation part of the matrix to the box. Usually when performing matrix multiplications like this you want to start with the rotation matrix and multiply it by the position matrix. This will return a new matrix from the two parts.

b=Box pos:[-20,0,0]
b.transform=(matrix3 [0.904582,-0.426096,0.0132061] [0.35901,0.744726,-0.562579] [0.229877,0.51364,0.826638] [-20,0,0])
s=sphere segments:4 pos:[20,0,0]

--Rotate the spheres matrix around it's own position. 
s.transform=(b.transform.rotationPart as matrix3*transMatrix s.transform.pos)


Standard Align tool vs Max Script! Score is 2 : 1 ))
#5

Thanks, I will have to have a look later because I’m just leaving work in a few minutes.
Hope to get my head around those matrixes somehow.


#6

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.