How to set the rotation of an object with Maxscript that already has a rotation


#1

Hi everyone,

Tutorials only describe how to rotate an object that has a rotation of [0,0,0].

Apparently I still don’t understand the transformation process inside Max at all.

So setting $.transform.rotation doesn’t work as expected.

I have objects that have a random rotation to start with, and I then want to ‘correct’ their rotation and set the rotation to a specific angle and not increase the rotation with an amount (as all tutorials explain or maybe I just don’t understand).

When I get the current rotation with quatToEuler it doesn’t match the rotation I see in the interface.

Anyone who can explain this to me will be my hero forever, I will pray for you and your family and will be eternally greatful and probably prevent a mental breakdown.

Thanks!


#2
--    Get the angles displayed in the Transform Type In dialog
quatToEuler2 $.rotation.controller.value

--	zero rotation
$.rotation = quat 0 0 0 1

--rotate 45 deg on X axis
$.rotation = eulerAngles 45 0 0

--rotate 53 deg on Y axis
$.rotation = eulerAngles 0 53 0

--rotate 18 deg on Z axis
$.rotation = eulerAngles 0 0 18

--rotate 40 deg on X axis
$.rotation = (angleaxis 40 [1,0,0])

--rotate 40 deg on Y axis
$.rotation = (angleaxis 40 [0,1,0])

--rotate 40 deg on Z axis
$.rotation = (angleaxis 40 [0,0,1])

#3

You can fIrst set the object’s rotateion to 0 and then rotate it to desired angle.
But wait the maxscript’s professionalists to show you how to do it in the right way.


#4

Hi miauu,

Thank you so much for replying.

Your “quatToEuler2 $.rotation.controller.value” doesn’t always show the current Transform Type-in values.

But I now think it has something to do with the object types maybe, they are bones.

I have attached a demo file with 3 helper object/bones.

The first bone gives the same rotation with “quatToEuler2 $.rotation.controller.value”, but the other two do not.

Do these types of objects need a different approach?

Thanks again!

bones.max (732 KB)


#5

The second and third bones are linked , the first one is not, so:

 quatToEuler2 $.transform.rotation

#6

Okay great, that gives the right values for linked bones.

But when I try to rotate bone1 or bone2, ‘strange’ things keep happening.

For example, when I try “$.rotation = quat 0 0 0 1” for bone1, it shouldn’t rotate or move, right? But it jumps in position and rotation.

Also, trying to rotate bone2 for an amount of 30 degrees on the Y axis with “$.rotation = eulerAngles 0 30 0” makes it jump and rotate elsewhere.

Why do these changes in position occur? Is Maxscript using some kind of (to me) unknown rotation center?

I still feel I’m missing a large piece of the puzzle :blush:

Thanks again!


#7
$.rotation.x_rotation 
$.rotation.y_rotation
$.rotation.z_rotation