Notifications
Clear all

[Closed] Resetting XForms – Some questions

So I’m looking to find an elegant way to Reset Transforms on my objects.

At first I thought just using ResetTransform $ would be enough, but that command won’t do anything with the $.objectTransform, so the information about it’s orientation is still stored in the object – which I don’t want.

If I use ResetXForm $, all children of the current object will be offset by the change in the matrix due to the command. However, if I use ResetTransform $ followed by ResetXForm $ it will work, all children will maintain their position/orientation.

So, ResetTransform $ followed by ResetXForm $ will do what I want. There’s just one problem, which is that it will put an XForm modifier in the top of the stack. I don’t want that, I basicly want to move the modifier to the first index ($.baseObject), then collapse it to the mesh (maxOps.CollapseNodeTo $ $.modifiers.count on). However there doesn’t seem to be a good way to reorder the stack, all examples I’ve seen have deleted the modifiers and then re-applied them in the correct order, which is a messy solution imo. I’m looking for a clean way to do this without using XX lines of code just to do something as trivial as resetting transformations.

Coming from Maya, this could be done with one line. It must be a quick way to do this in max also, right?

Just thought I’d show one way to do this, this does what I want, but I’m looking for a cleaner solution:

obj = $
ResetTransform obj
nodeTransform = obj.transform
obj.transform = transMatrix obj.pos
nodePivot = obj.objectTransform * inverse obj.transform
obj.objectOffsetPos = [0,0,0]
obj.objectOffsetRot = (quat 0 0 0 1)
obj.objectOffsetScale = [1,1,1]
nodeTransform.translation = [0,0,0]
nodeTransform = nodePivot * nodeTransform
xformMod = XForm()
modPanel.setCurrentObject obj.baseObject
modPanel.addModToSelection xformMod
xformMod.gizmo.transform = nodeTransform
maxOps.CollapseNodeTo obj obj.modifiers.count on

EDIT:
The code posted above doesn’t actually work as it should, it will always freeze the object to world. So when I parent an object below another, it should inherit the transformation of the object above when I reset the XForms (0,0,0 relative to it’s parent). So the ResetXForm command seems to be the only one that works, I would just want it to collapse itself to the shape.

1 Reply

Checkout my script xFormResetter, it deals with a lot of the issues you’re talking about, and if you still need your own script, feel free to steal any code you’d like…

http://www.neilblevins.com/cg_tools/scripts/3dsmax/soulburnscripts.htm

  • Neil