I have seen 3d models of dress items reshape automatically in softwares such as Daz3d, poser, makehuman etc when the model which the dress is put on is modified (usually with a morph). I have a situation where i have to do something similar in opengl es. Can somebody tell me the underlying logic in doing so? Is it again the morphs working or is there some other way?
1 Answers
I would approach it like this:
Mesh
Is usually represented as a network of nested points in some topological grid. For this I would break the clothes into "cylinders". Each "cylinder" would be represented by a grid of points something like this:
struct _pnt { float x,y,z; bool stretch,done; }; _pnt pnt[na][nb][3];where
nashould be dependent on the cylinder diameter but usuallyna=36is more then enough in all casesnbshould be dependent on the "cyliner" height and cloth detail ...
Each of the points has its 3D coordinates
x,y,zwhich are initially set to cloth's shape as would it filled with air like balloon. Thestretchflags if the point is on some rubber band forcing it to stick to skin. Thedoneis just temp flag for the computation.Dynamics
Now if you want to compute the actual cloth shape then you need to:
- set
done=falsefor all points - set all
stretched points to their corresponding position on person/dummy skin (mesh surface) and setdone=truefor them. These points will be usually covering whole slice(b=constant,a=0,1,2,...na-1) for each stretched point
(a0,b0)compute the chained points. The math/physics behind it is this:so scan the points
(a0+1,b0),(a0+2,b0)...if you hit anotherstretchpoint use caternary curve and if not use Newtonian / D'Alembert dynamics simulation to obtain position (for that yu need to add speedvx,vy,vzto the_pnt. When the position is computed set thedone=truefor all computed points.Also if the computed position of a point is inside avatar mesh you have to set its position to the avatar surface and set its speed to zero.
Handle mesh self-collisions (dynamic impact)
search all non computed points
done==falseand interpolate their position from their computed neighbors.
- set
If you got this working you can add more features like ellasticity,mass,... coefficients for each point and more.
- 49,595
- 11
- 110
- 380
