Creating an FFD modifier for Away3D

Software: Away3D 4.x

seanClusta, Jr. Member
Posted: 28 August 2014 08:46 AM   Total Posts: 38

Hi all,
I’ve been trying to emulate (in function at least) 3DS Max’s Free Form Deformation modifier and could do witjh some help. I don’t think I’ll need help with the code, it’s more on the concept of how to produce the right weighting to get the same results and as I’m using the Away3D engine I thought this community would be a good place to ask (I’ll happily share the code too if I get it working).

So I am creating some geometry - lets use a cube to keep it simple, and then applying the modifier which creates a ‘lattice’ around the geometry. The lattice fits to the bounding box of the geometry and contains a control point at each corner, so it’s a 2x2 modifier. When i select and drag each of these control points I am affecting the transforms of each of the vertices of the paired geometry (x,y,z positions only at this point).

How i currently have it set up is: when the lattice gets applied it runs through each vertex in the model’s geometry and calculates its distance from each of the 8 control points. I use the distances to calculate a weight between each control point & vertex. The weight is calculated using a formula which means the total of all 8 weights on a vertex (one for each control point) adds up to 1. If the vertex is on the control point (i.e. the cube corner vertices) the distance is 0 and the weight between that cp and vertex is 1 and the 7 remaining is 0. Anything outside of these points is a calculated split using the relative distances. When a control point is moved it uses its weight per vertex to transform the position of the vertex (i.e. if it moves by x + 10 and the weight is 0.8 then the vertex will move by 8 in the x. This works but the falloff is not correct for what the FFD modifier should do, which is to equally interpolate all geometry vertices by the deformation of the surrounding lattice. I hope that makes sense it’s kind of hard to explain!

What i want to achieve is this (just position transforms not scaling for now) but I’m struggling to work out how the individual geometry vertices should get weighted by the handles/control points of the surrounding lattice.

Does anyone know what the algorithm should be for this weighting? Or could point me to a code example of how to do it (any language)?

Thanks!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X