PDA

View Full Version : Apply same FFD modifier to different meshs ,but different orientations happen


gohkgohk
10-22-2009, 09:54 AM
i used the following script to apply mesh2's FFD modifier on mesh1
addModifier $Mesh1 $Mesh2.modifiers[1];
However , the final orientation of mesh1's FFD modifier is different from mesh2's FFD modifier, so those two meshs are deformed in two different directions with the same FFD modifier (instanced) .
How can i make sure the orientation of FFD modifier will be the same for both two meshes?
Please help!
thx

PEN
10-22-2009, 01:27 PM
You need to set the transform of the FFD in both to be what you need.

I would have to look at the FFD to be exact and I can't at the moment but something like

for x in selection do x.modifiers[1].gizmo.transform=matrix3 1

gohkgohk
10-22-2009, 04:10 PM
Here is the test scene for this case. (in 3dsMax)
One Sphere (Mesh1) exactly placed at the Sphere part of Mesh2.
After i applyed FFD on Mesh2, i want the Mesh1 undergo the same FFD with Mesh1.
Which means the result will be exactly the same as "selecting both meshes and applying single FFD on them".

I have try the following step but still fail to get what i want.
1. run "$Mesh1.pivot=$Mesh2.pivot"
2. run "$Mesh1.transform=$Mesh2.transform"
3. perform FFD4x4x4 on Mesh2
4. run "addModifier $Mesh1 $Mesh2.modifiers[1];"

Please help
thx

biddle
10-22-2009, 07:47 PM
It appears that the components need to have the same transform in order to share a FFD modifier.

One way to do it is to transform the verts in mesh1 so that we can set its transform to mesh2's and have everything look the same.

deltaMat = $Mesh1.transform * (inverse $Mesh2.transform)

convertToMesh $mesh1
for v = 1 to $mesh1.numverts do
(
setVert $mesh1 v ((getVert $mesh1 v) * deltaMat)
)

$mesh1.transform = $Mesh2.transform

m = FFD_4x4x4()

addModifier $mesh1 m
addModifier $mesh2 m

gohkgohk
10-22-2009, 09:05 PM
It appears that the components need to have the same transform in order to share a FFD modifier.

One way to do it is to transform the verts in mesh1 so that we can set its transform to mesh2's and have everything look the same.

deltaMat = $Mesh1.transform * (inverse $Mesh2.transform)

convertToMesh $mesh1
for v = 1 to $mesh1.numverts do
(
setVert $mesh1 v ((getVert $mesh1 v) * deltaMat)
)

$mesh1.transform = $Mesh2.transform

m = FFD_4x4x4()

addModifier $mesh1 m
addModifier $mesh2 m
thx so much for your reply
Can the size of the FFD Modifier be exactly the same?
Now the mesh1 hv a smaller FFD Modifier.

Also, can i not addModifier at the same time?
I want to create FFD modifier on mesh2 first, then modify the FFD,
and then finally apply the same FFD on mesh1.

biddle
10-22-2009, 11:17 PM
I thought you wanted one modifier instanced onto two objects (that's why you see two cages each scaled to fix a mesh)


If you want one modifier displayed you can use a group:

max modify mode

m2mat = $mesh2.transform

g = group #($mesh1,$mesh2)

-- Save the group transform
savemat = g.transform

-- Orient the group so that mesh2 is at the origin
g.transform = inverse m2mat

-- Add an FFD to the group (aligned with mesh2)
select g
modPanel.addModToSelection (FFD_4x4x4 ())

-- restore the group orientation
g.transform = savemat

ungroup g



[EDIT: I missed the 'ungroup' on the last line]

gohkgohk
10-23-2009, 04:03 AM
I thought you wanted one modifier instanced onto two objects (that's why you see two cages each scaled to fix a mesh)


If you want one modifier displayed you can use a group:

max modify mode

m2mat = $mesh2.transform

g = group #($mesh1,$mesh2)

-- Save the group transform
savemat = g.transform

-- Orient the group so that mesh2 is at the origin
g.transform = inverse m2mat

-- Add an FFD to the group (aligned with mesh2)
select g
modPanel.addModToSelection (FFD_4x4x4 ())

-- restore the group orientation
g.transform = savemat

ungroup g



[EDIT: I missed the 'ungroup' on the last line]
thx so much~
that's what i need:)

CGTalk Moderation
10-23-2009, 04:03 AM
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.