where is an object's intrinsict rotation stored?

fael097
Advocate
Advocate

where is an object's intrinsict rotation stored?

fael097
Advocate
Advocate

Let's say I make a simple cube, then rotate it 45 degrees in any axis, and then apply an ffd modifier. the ffd volume will be aligned to the cube's rotation, so 45 degrees in the same axis.

 

then I want to align the ffd modifier to the world. ok I could use the set volume sub-object mode and rotate it, but I had some bad experiences doing this, specially if your mesh is irregular, you can't auto fit the modifier to include the whole mesh's exact dimensions, doesn't matter, in some cases it can get you undesired results.

 

ok so how do I reset my object's rotation so the ffd modifier will generate aligned to the world? changing the pivot doesn't do anything, freezing transform/rotation won't do it, setting them to 0 won't do it. if I apply a reset xform it works, but it messes the whole modifier stack, you definitely can't mess with modifiers under it, you can't even delete the xform modifier or the mesh base rotation will change and you can't undo it, so it's not an option unless you're collapsing everything.

 

so where is this rotation stored so I can align it to the world without affecting anything else?

 

ps.: it's not just for the ffd modifier, I've experienced countless cases where I need to reset an object's intrinsic rotation and couldn't find how except with the reset xform, which is not an option in most cases

0 Likes
Reply
745 Views
10 Replies
Replies (10)

leeminardi
Mentor
Mentor

The "intrinsic rotation" is stored in the object's transform matrix.  For example,

$Teapot002.transform

will output the following for object Teapot002 that has been rotated by 45° about z and is located at [22.2976,-48.8783,0]

 

(matrix3 [0.707107,0.707107,0] [-0.707107,0.707107,0] [0,0,1] [22.2976,-48.8783,0])

 

I'm not sure if this is what you want.

lee.minardi
0 Likes

fael097
Advocate
Advocate

that must be it. is it accessible via the interface or only by script?

 

I wanted a graphic way to manipulate it, but if there isn't one, at least a quick way to reset the rotation to 0

0 Likes

leeminardi
Mentor
Mentor

Here's the matrix via a Transform script for the Teapot.  The teapot was rotated 45 about z.

matrix3 [0.707107,0.707107,0] [-0.707107,0.707107,0] [0,0, 1] [-34.5061,-263.19,0]

image.png

Changing the matrix values to:

matrix3 [1,0,0][0,1,0] [0,0, 1] [-34.5061,-263.19,0]

would rotate it back square to the world.

image.png

 

lee.minardi
0 Likes

fael097
Advocate
Advocate

yeah I guess that's not it, this just gets the rotation of the pivot of the object. if you rotate your teapot to 45º on Z and then align the pivot to the world, the transform matrix will say 

[1,0,0][0,1,0] [0,0, 1]

but the object's original rotation is stored somewhere else, because when you press the Reset Pivot button, it resets to the 45º rotation.

 

where does it get that information from?

0 Likes

leeminardi
Mentor
Mentor

Perhaps you could post a file with the objects in their original position and with them rotated.   If your final goal is some other then these two states post that too.

lee.minardi
0 Likes

fael097
Advocate
Advocate

well I'm not sure if it's needed to post a file, it's really simple. 

 

I have a teapot rotated 45 degrees, and I want to apply a ffd modifier and I want that modifier to be aligned to the world, not rotated 45 degrees. 

 

the modifier is being applied to 45 degrees because it's following the object's rotation. but how do I reset that rotation to 0 without rotating the object back?

 

reset xform isn't an option in this case, and rotating the object's faces 45 degrees in edit poly mode instead of rotating the object itself to begin with also isn't an option.

 

I mean, the teapot is rotated 45 degrees, k? I aligned the pivot to the world, freezed transform, freezed rotation, not sure what else I can do, but if I apply a ffd modifier, it will still be aligned 45 degrees along with the object.

 

to sum up, all I want to do is to get any model, regardless of its position, orientation, shape, etc. and say ok, this object's current state is rotated 0 degrees in any angle. that's it's default rotation. so i can apply a ffd and it will be a box aligned to the world. 

 

as far as I know that's precisely what the reset xform button does, but the problem is that it adds a modifier to your stack and you cannot ever again edit what's under this modifier in the stack or it will mess your object's previous rotation.

 

so where is this transform that the reset xform resets?

0 Likes

fael097
Advocate
Advocate

so, nowhere?

0 Likes

leeminardi
Mentor
Mentor

I've made a little progress on this.  If you create an object and add a FFD modifier to it and then rotate the object and the the FFD relative to it the following script will output the rotation matrix of the original selected object relative to the world and the rotation matrix of the lattice relative to the object.

obj = $
ffd=obj.modifiers[1]
objTM=obj.objecttransform
modTM=(getModContextTM obj ffd)*ffd.lattice_transform.value
print ("\nObject Matrix is: "	 + objTM as string)
print ("\nLattice Matrix is: "	 + modTM as string)
lee.minardi

fael097
Advocate
Advocate

I guess that's it. if I run $.transform, it will return the transform of the pivot, but if I use $.objecttransform, it returns the actual object's transform, which is intrinsic to the object, but cannot be edited (apart from actually moving or rotating the object, obviously)

 

what I find odd is that when you change the pivot of your object, almost everything will follow it. if you use the move or rotate tools, they use the pivot's transform as their orientation, if you use the align tool same thing, for aligning rotation, the other object will align to the pivot's orientation, not the intrinsic rotation. for location align it has more options, but it can basically align to the pivot location or to the mesh's center of mass (and offsets of that) but not to the actual location of the object (which can be away from your mesh, let's say you grab all the vertices and move them away, and then center your pivot to the mesh, even so the initial location and rotation are still stored). but then if you add a modifier like the ffd, it will encompass the mesh itself yes, would make no sense to apply an ffd into nothing, but the it's orientation will be aligned not to the pivot's rotation, but to the intrinsic rotation (which until now I never knew where it was). and worse, you can't align the ffd to the object's pivot!! and even more funny, if you go to the ffd's set volume mode, select all the control points and align it to the object itself, it CAN move to the location of the object's pivot, but it CAN'T rotate to orient itself according to the pivot!!! 

 

anyway, that's probably me just babbling, hope it's understandable.

 

so I can understand maxscript's syntax and logic, but I definitely can't script in maxscript without any help. you think it's possible to change the object's objecttransform without actually rotating or moving the mesh? like just zero out the numbers and keep the object in place, so the ffd would apply aligned to 0,0,0 instead

 

I feel like it's so close now lol

 

cheers

0 Likes

leeminardi
Mentor
Mentor

I'm not sure I follow all that but if you rotate an object and then add a FFD modifier and rotate its lattice the following will rotate the lattice back to the orientation of the original object.  I added two line of code to my previous script.  

 

Is this what you want?

 

obj = $
ffd=obj.modifiers[1]
objTM=obj.objecttransform
modTM=(getModContextTM obj ffd)*ffd.lattice_transform.value
modTMInv = inverse modTM
print ("\nObject Matrix is: "	 + objTM as string)
print ("\nLattice Matrix is: "	 + modTM as string)
modTM.row4 = [0,0,0]
-- rotates the lattice so it's aligned and positioned with the object
setModContextTM obj ffd modTM	
lee.minardi
0 Likes