ZBrushCentral

ISet tool rotate, Rotate all subobjects?

So I’m trying to rotate a mesh at an exact angle, yet the only way I know to do this is with [ISet,Tool:Deformation:Rotate,i]. This obviously only works on the selected subobject since it’s a deformation, but I want the rotation to apply to all subobjects. Is there an easier way than traversing each subobject and rotating it independantly? CanvasRotate would be nice, since when you orbit around the mesh via clicking on the canvas all subobjects rotate at the same time. What’s the best way of going about this?

Hmmm… Are you trying to do this for modeling… or some other purpose, like rendering an image?

There may be some kind of workaround using Svengalis AXIS plugin, or some modified version…or something, depending on the purpose behind the need.

Have a look at the ZScript Command Reference and search for the TransformSet command.

Sven

Well, I’m actually writing a script… so using another script isn’t an option :slight_smile:

Sven: I’d actually looked into that, but it transforms a memory block. How do you get the memory block of the entire mesh, subtools included? I didn’t think there was a way to do that.

I’ve currently scripted it to cycle through all existing subtools and rotate them independantly, but if I can find a more efficient way to do it, it’s obviously preferable than the way I’ve got it right now.

If all you want to do is pose the entire model (subtools and all) to a certain view, you just need to enter the proper values for the nine TransformSet arguments and it assumes that view.

However, if you want to permanently transform the model and all its subtools, then the way you are proceeding is probably what you will need to do.

Storing/retrieving transform information to/from a memory block uses the MTransformGet and MTransformSet but I don’t think you need to do that, do you?

To get some sense of the values you might want to use with TransformSet, activate and manipulate the gizmo with the Move, Scale or Rotate buttons and watch X,Y,Z values in the TRANSFORM > Info submenu.

Sven

As Sven points out, the two pairs of zscript commands that handle positioning on the canvas are TransformSet/Get and MTransformSet/Get. The memory block ones are useful if you want the data stored to persist throughout a ZBrush session as zscripts lose their ordinarily stored values on exit (such as when another zscript/plugin button is called). Essentially the commands work the same way as the gyro which appears if you switch off Edit mode and then switch on Move, Scale or Rotate (without changing ztools). The numerical values you can set in the Transform:Info sliders while in each of these modes are the same values you would set using the zscript commands.

So, supposing you were going to set up a turntable :wink: and you wanted to rotate around Y in five 10 degree steps, your code might look like this:


[Loop,5,/*repeat following commands 5 times*/
[TransformGet,xPos ,yPos ,zPos ,xScale,yScale,zScale,XRotate,YRotate,ZRotate]/*Gets current transform values and stores in variables*/
[VarSet,YRotate,YRotate+10]/*increments the value by ten*/
[TransformSet,xPos,yPos,zPos,xScale,yScale,zScale,XRotate,YRotate,ZRotate]/*transforms object by new value*/
[IPress,Movie:Snapshot]/*takes movie snapshot*/
]//end of looped commands

Urgh, I shouldn’t try writing code before I’ve had my first coffee. I’ve corrected some errors in that posted above. :o

Again. Time I retired from zscripting! :o

marcus: thanks for the concise explanation… that is much faster than what I was doing :slight_smile:

Glad it helped. I hope you got the corrected code! In my half awake state I was forgetting that you need to specify all the variables, whether you’re using them or not. (I’ve been writing too many note interfaces where you simply need the right number of commas.)

Yeah, I saw the original, but didn’t get a chance to try it until after you’d updated it.

However, it does seem to have it’s quirks… For example, change the loop count from 5 to 36 (that way you make a full circle). After a 90 degree rotation, the mesh flips on the Y axis, and then reverts after 180 degrees (So only the first and last quarters of the full rotation are ‘right side up’). Possibly some funny matrix math voodoo at work?

Yeah, I thought I’d wait until you mentioned that one. :slight_smile: It’s called gymbal lock and it occurs when the rotation gets close to 90 degrees. It affects the Y axis particularly and is rather difficult to avoid. Rotations around the Z axis are free of it, so in many ways it is simpler to change your model’s orientation using Deformation:Rotate X +90 first.

I wrote a turntable script a while ago which you might like to take a look at. It will give you the chance to experiment with various settings and may also help solve some other problems for your own script:
http://www.zbrushcentral.com/zbc/showpost.php?p=268447&postcount=3

Ahhh, I remember gimbal lock waaay back in linear algebra. Shows you how much I paid attention :smiley:

At any rate, you are right. What I ended up doing is flipping the mesh around so that it’s Z-up, performing the translations, then flipping Y-up again. So I’ve still gotta rotate each subobject independantly, but at least now I only have to do it once at the beginning, and once at the end. :+1:

Yeah, probably the simplest way. I couldn’t get your Rhino turnatble to run but I look forward seeing it when you get back. Have a good hol.