Help to Gizmo & Center modifier

Hi all

My question is simple; I must fit the Gizmo and Center of any modifier with a pivot of object, but I can not do this.

I tried like this:

help = Point pos:[50,0,0] -- create help point
p = Plane () -- create plane
mod_bend = addModifier p (Bend ()) -- add modifier bend to plane
modPanel.setCurrentObject p.bend -- set the mod panel
subobjectLevel = 1 -- select the gizmo bend
p.bend.gizmo.pos = help.pos -- move the gizmo in help centerpivot 

Now, with the example above, I can move the gizmo at the center of point, but if I write like this:

 
p = Plane transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,17.5]) isSelected:on
CenterPivot p
		help = Point pos:[0,0,0] isSelected:on
		CenterPivot help
		help.pos = p.pos
		help.pos = [p.pos.x,0,0]
		p.pivot = help.pos
		mod_bend = addModifier p (Bend ())
		modPanel.setCurrentObject p.bend
		subobjectLevel = 1
		p.bend.gizmo.pos = help.pos

it does not work ... why? thanks for any help :)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Michele71's picture

Thanks Branko :) I tried

Thanks Branko :) I tried first to use "Node Transform Matrix" but without any success, but as I see, it was the right way! This function remains in my favorite bookmark :D +1!

P.S: However, I still have not figured out why it does not work with the second example, even transforming the coordinates of the center and gizmo from local to world (the corresponding subcontroller for the node's transform) bha...

Thanks again

Michele

barigazy's picture

...

Not works because modifier use object space not world space.
Read about matrix in mxs help. This is the most difficult topic in maxscript at least for me :)

bga

Michele71's picture

Heheheh I was reading right

Heheheh I was reading right now :D

"In MAXScript, the values of modifier sub-object transform properties, such as centers and gizmo position, rotation and scale, are not given in the current working coordinate system, but rather are typically in the coordinate system of the object to which it is applied. This is in contrast to scene node transform properties. The values given are exactly as would be seen in the sub-object’s corresponding track view or as might be referenced in an Expression controller track variable for that sub-object property. To convert from local to world coordinates, you multiply the local coordinates by the node’s objecttransform matrix. To convert from world to local coordinates, you multiple the world coordinates by the inverse of the node’s objecttransform matrix."

 

This last comment I was literally confused ideas when I did the tests before asking here! So I would try to use "getModContextTM" for the create align from gizmo and pivot...

barigazy's picture

...

Simply use this fn

fn alignModifier mody target = if isKindOf mody modifier and isValidNode target do
(
	if isProperty mody #gizmo and isProperty mody #center do
	(
		node = (refs.dependentnodes mody)[1]
		mody.gizmo.transform = target.transform * inverse node.transform 
	)
)

EXAMPLE:

_plane = Plane name:"Source" transform:(matrix3 [0.5,-0.6,0.7] [0.5,0.8,0.2] [-0.6,0.1,0.7] [20,30,80])
_point = Point name:"Target" pos:[60,-40,20]
_bend = Bend()
addModifier _plane _bend
alignModifier _bend _point

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.