rotation


SUBMITTED BY: phroyd

DATE: April 4, 2016, 7:37 p.m.

FORMAT: Text only

SIZE: 1.7 kB

HITS: 3842

  1. Rotations
  2. Rotations are slightly odd in Max in that we need to first create a "rotation object" that we will store as a variable. Then we apply our rotation object to our object (a fencepost in this case!)
  3. As you possibly already know, in Max, there are 3 different types of rotations that you can use. Euler angles, Quaternions and Angleaxis. As you get more advanced, you will want to work with the different types in different scenarios but for now, we will use euler angles.
  4. Eulerangles are defined in the following way: rot_obj = eulerangles x y z
  5. create a cube somewhere in your scene and type the following into the listener:
  6. cubeRotationObject = eulerangles 0 20 0
  7. Maxscript should return: (eulerAngles 0 20 0)
  8. Now we have our rotation object stored in our variable; cubeRotationObject.
  9. All we need to do now is apply the rotation object to our object. Select the cube and type the following:
  10. rotate $ cubeRotationObject
  11. The cube should rotate 20 degrees around the Y axis.
  12. Back to our script. Hopefully you should be ahead of me now with a clear idea how to modify the script to randomly rotate the posts. In case you're lost, here is the code: (this time, type it into our blank new maxscript file)
  13. for obj in $ do
  14. (
  15. randXrot = random -3.0 3.0
  16. randYrot = random -3.0 3.0
  17. randZrot = random -3.0 3.0
  18. rot_obj = eulerangles randXrot randYrot randZrot
  19. rotate obj rot_obj
  20. )
  21. Select all the fence posts (or if you don't have the file from tut3, create an array of fence posts and select them all) and run the maxscript by hitting CTRL+E (evaluate) All the posts should now have random heights, positions and rotations giving a much more organic look than what we started with.

comments powered by Disqus