PDA

View Full Version : Is there a way to move ffdBox control points with maxscript?


reForm
12-04-2008, 09:49 PM
Its in the title... is there a way to move ffdbox control points using maxscript? I looked in the helpfile but there's no sign of a paramater that allows you to set ffdbox control point positions.

reForm
12-04-2008, 09:58 PM
Oh, my apologies... I should search first!

For those that are interested the following threads provide the answers:-

http://forums.cgsociety.org/showthread.php?f=98&t=619289&highlight=ffd
http://forums.cgsociety.org/showthread.php?f=98&t=490403&highlight=ffd

ZeBoxx2
12-04-2008, 10:00 PM
the control points don't exist as properties until they are 'animated'.


-- animateVertex <FFDBox modifier> <index|#(index,index,...)|#all>
animateVertex $.modifiers[1] #all


Once done, do a "show $.modifiers[1]" and it should show all the control points as new properties of the modifier, ready to get/set.

PiXeL_MoNKeY
12-04-2008, 10:01 PM
It looks like you have to assign controllers to the points usinganimateVertex <FFDBox> <control_point_spec><control_point_spec> must be one of the following:<integer_index>, <integer_index_array>, or #all. From there you need to access them from them using something like:$.modifiers[1].control_Point_1 = [10,10,10]-Eric

reForm
12-04-2008, 11:57 PM
Wow, thanks for the quick replies.
I managed to make some progress using the threads I found... amazing progress for the likes of me!

I'm now stuck... I want to move the control points to the positions defined by vertices in another object. I thought if I had the vector between the two points in world space, I could just add that to the current position of the control point to move it to the position of the reference vertex.... unfortunately its not that easy. What do I need to do to get the right vector to move the control point to the vertex?

reForm
12-05-2008, 12:19 AM
Hah, you might laugh at this lame attempt, but I thought if I did a bit of algebra (its been a long time) I could adjust the formula that returns the control point position in world coords so that it does the reverse and returns the matrix3 of the new control point position in relation to its bounding box. Needless to say, it didn't work! hehe

themaster[k].value = (((cpwpos[k]) - modBBMin) * ( ((inverse modTM) * objTM)) * (modBBMax-modBBMin))

So, any suggestion to where I'm going wrong here?

ZeBoxx2
12-05-2008, 12:33 AM
not sure - but these should work (was working on them while you replied, i guess)..


-- return number of control points (doesn't check if they can be get/set)
fn ffdNumCPs ffdmod = (
ffdmod["Master"].numSubs
)

-- convert FFD local (normalized) coordinates to world coordinates
-- obj = object containing the modifier
-- ffdmod = the actual modifier
-- pos = the local coordinate
fn ffdLocalToWorldPos obj ffdmod pos = (
objTM = obj.objecttransform
modTM = (getModContextTM obj ffdmod) * ffdmod.lattice_transform.value
modBBMin = getModContextBBoxMin obj ffdmod
modBBMax = getModContextBBoxMax obj ffdmod
(modBBMin + (pos * (modBBMax-modBBMin)) * (inverse modTM) * objTM)
)

-- convert world coordinates to FFD local (normalized) coordinates
-- obj = object containing the modifier
-- ffdmod = the actual modifier
-- pos = the world coordinate
fn ffdWorldToLocalPos obj ffdmod pos = (
objTM = obj.objecttransform
modTM = (getModContextTM obj ffdmod) * ffdmod.lattice_transform.value
modBBMin = getModContextBBoxMin obj ffdmod
modBBMax = getModContextBBoxMax obj ffdmod
(pos - modBBMin) * (inverse objTM) * inverse modTM / (modBBMax-modBBMin)
)

-- get an FFD mod's control point's world coordinate
-- obj = object containing the modifier
-- ffdmod = the actual modifier
-- i = control point index
fn ffdGetWorldPos obj ffdmod i = (
cp = ffdmod["Master"][i]
ffdLocalToWorldPos obj ffdmod cp.value
)

-- set an FFD mod's control point's world coordinate
-- obj = object containing the modifier
-- ffdmod = the actual modifier
-- i = control point index
-- pos = new world position
fn ffdSetWorldPos obj ffdmod i pos = (
cp = ffdmod["Master"][i]
cp.value = ffdWorldToLocalPos obj ffdmod pos
)

reForm
12-11-2008, 03:52 PM
Hey, ZeBoxx
Thanks so much for those... It looks like I almost worked out the right formular myself! ... those school maths lessons have obviously paid off.
Thanks again for sharing those.

reForm
12-11-2008, 06:35 PM
Hmm, actually, I've come across a problem with my code, and I was wondering if it has anything to do with my particular use of this function


fn ffdWorldToLocalPos obj ffdmod pos = (
objTM = obj.objecttransform
modTM = (getModContextTM obj ffdmod) * ffdmod.lattice_transform.value
modBBMin = getModContextBBoxMin obj ffdmod
modBBMax = getModContextBBoxMax obj ffdmod
(pos - modBBMin) * (inverse objTM) * inverse modTM / (modBBMax-modBBMin)
)


When I call this from a normal script, everything works well with the control points being mapped to the new positions correctly. But, I'm now trying to get the same code working but from within a simple-geometry plugin.

Do I need to take into account the local coords of the node that the script is running from?

IkerCLoN
01-16-2009, 02:06 PM
Thanks for all the info here. I was wondering how to control the points of a FFD Space-Warp and this thread helped me a lot.

By the way, dealing with code to control the points makes the system (it's FFDBox 3x3x3 only) going very slow, specially when undos. A colleague here told me a little trick to make the thing perform faster...

... skin the control points of the FFD to something else. Works perfect, and fast! :-)

ZeBoxx2
01-16-2009, 02:20 PM
Do I need to take into account the local coords of the node that the script is running from?
Sorry - Didn't see this question. I don't think it would matter unless it somehow changes the coordinate context in which the function is run..could try wrapping 'in coordsys world' around it, perhaps

CGTalk Moderation
01-16-2009, 02:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.