Center of mass [solved].

vadimtvadimt Posts: 33

Is there a standard way of finding the center of mass of a posed figure? I adopted a way which works for me, but I'd like to know whether ther is a simpler one.

When I do a "balancing act" pose I export the figure to *.obj file, then I import it to Meshmixer, convert the figure to solid and then use Stability analysis, to see the center of mass and the contact area. Then, if needed, I adjust the pose and repeat. As I am using the Autodesk's Meshmixer as my go-to programm for 3D printing needs, it's not too complicated for me. But I am sure, that there are more straitforward ways, are there? There was mCasual's CofMA3 script, but it's very limited and out of date.

What do you use to balance your models?

Post edited by vadimt on

Comments

  • Cayman StudiosCayman Studios Posts: 1,136
    edited November 2015

    I would have thought the centre of mass for a human being who is balancing in some way is only one of many components we can use to determine the plausibility of a pose.  We use various muscles, we use our mind.  A tired or injured or drunk person will balance in very different ways, and so knowing the centre of mass is probably not as reliable an indicator of plausibility as simply gauging it intuitively.

    Post edited by Chohole on
  • Centre of mass does, however, need to be within the area supported by the feet (or hands, or knees, or whatever) if the pose is to look possible.

  • vadimtvadimt Posts: 33

    Thank you, Cayman.

    You pointed to important aspects of plausibility and intuition is definitely most important among them. However there are two important points you missed. 

    First is that your comment (and your illustration) is mostly about dynamic balance, where the pose is a capture of the moment (in that case the physics is less important: the next moment the model will correct itself, or will fall - we don't really care). I was talking (and my illustration) was about static balancing. You probably didn't click the link - to adhere to prudish rules of this forum I dressed my model in ugly overalls and did a quick re-render here. Still intuition about using muscles and brains is important. And even understanding how the model get to the pose may be important (though, for all we care, 5 assistants posed him and left to balance).

    The second point is more important, though. We all use DAZ3D in different ways and for different purposes. If you check my deviantart gallery, you'll see that I am trying to deconstruct the most challenging and the least probable poses. Exactly those were the intuition may lie. And DAZ3D helps me find where the body proportions are changed, where the bones position is suspect andd so on. For such use I'd like to use some physics based tools. The illustrated pose was based on a photo, so I knew it was generally plausible. But the angles of thighs and torso depend solely on distribution of mass and couple degrees (or bigger muscle mass in upper or lower body) makes all the difference.

    So, thank you, and I will wait if the more technically minded people here have any other suggestions.

    For CoM discussion.jpg
    400 x 400 - 56K
  • mjc1016mjc1016 Posts: 15,001
    edited November 2015

    Centre of mass does, however, need to be within the area supported by the feet (or hands, or knees, or whatever) if the pose is to look possible.

    Yeah, otherwise it looks like the figure had a little too much to drink or is auditioning for the latest low budget space flick...

    vadimmt, have you tried PMing mCasual to see if he has plans to update his CoM script?  He is fairly active on the forums...

    http://www.daz3d.com/forums/profile/358729/mCasual

    Post edited by mjc1016 on
  • vadimtvadimt Posts: 33

    The mCasual's CofMA3 script is based on oversimplified assumtions, which won't be very useful for my usecase. I have found a standalone Python library, which suposedly can do such calculation on obj file. Now, if I would learn how to get obj file via scripting and how to return results - I'd be golden. Off to read documentation.

  • mCasualmCasual Posts: 4,607
    edited November 2015

     

    cofmA3 and i think there's a cofmV3 work pretty well if the objective is to obtain figure poses that look well balanced 

    as long as the figure are about the size of Aiko3 or Victoria3 

    you could improve the results if you can come up with more precise volume measurements for each limb

    To obtain even more precise results you'd need to modify the code to position the center of mass of each limb properly

    ---------

    on my web site there's a plugin for daz studio 3 and 4 called mcjCollider

    using this and a well written script, one could make a virtual 3d scanner

    which transforms a figure into cubes ( voxels / minecraft )

    knowing the positions of those cubes and assuming each cube has the same mass,

    you can compute the center of mass

     

    ---

    with a program like Autodesk 123 Make, you could slice your figure then combine the centers of mass of each slice

    --

    possibly not very exact results but fast : center of mass of the vertices - average vertex position

    // select the root node of the figure before running this !!!node = Scene.getPrimarySelection(); obj = node.getObject();geo = obj.getCachedGeom();n = geo.getNumVertices();averagePos = new DzVec3( 0, 0, 0 );for( i = 0; i < n; i++ ){	averagePos = averagePos.add( geo.getVertex( i ) );}averagePos.x = averagePos.x / n;averagePos.y = averagePos.y / n;averagePos.z = averagePos.z / n;COFMarker = new DzNode();COFMarker.setLabel( "COFMarker" );Scene.addNode( COFMarker );COFMarker.setWSPos( averagePos );

     

    since the head and hands have a high vertex density, you could reduce their mass

    for example, all vertices in the head's bounding box are considered 1/2 vertex mass

    or all the vertices with a position.Y higher than the center of the head's position.Y are excluded

    cofmGen.jpg
    935 x 914 - 75K
    Post edited by mCasual on
  • vadimtvadimt Posts: 33
    edited November 2015

    Thanks, mCasual!

    It's a nice initial approximation, and very good sample script. To do real work I'll have to use not vertices, but the faces. There is unexpectedly easy way of calculating center of mass based on triangles (if you know their orientation) for STL file (it's in C++, from this discussion):

    class data // 3 vertices of each triangle{public:    float x1,y1,z1;    float x2,y2,z2;    float x3,y3,z3;};int main (){    int numTriangles; // pull in the STL file and determine number of triangles    data * triangles = new triangles [numTriangles];    // fill the triangles array with the data in the STL file    double totalVolume = 0, currentVolume;    double xCenter = 0, yCenter = 0, zCenter = 0;    for (int i = 0; i < numTriangles; i++)    {        totalVolume += currentVolume = (triangles[i].x1*triangles[i].y2*triangles[i].z3 -              triangles[i].x1*triangles[i].y3*triangles[i].z2 -              triangles[i].x2*triangles[i].y1*triangles[i].z3 +              triangles[i].x2*triangles[i].y3*triangles[i].z1 +              triangles[i].x3*triangles[i].y1*triangles[i].z2 -              triangles[i].x3*triangles[i].y2*triangles[i].z1) / 6;        xCenter += ((triangles[i].x1 + triangles[i].x2 + triangles[i].x3) / 4) * currentVolume;        yCenter += ((triangles[i].y1 + triangles[i].y2 + triangles[i].y3) / 4) * currentVolume;        zCenter += ((triangles[i].z1 + triangles[i].z2 + triangles[i].z3) / 4) * currentVolume;    }    cout << endl << "Total Volume = " << totalVolume << endl;    cout << endl << "X center = " << xCenter/totalVolume << endl;    cout << endl << "Y center = " << yCenter/totalVolume << endl;    cout << endl << "Z center = " << zCenter/totalVolume << endl;}

    Of course, most of the faces in DAZ are not triangles but quads, but it's trivial enough to convert quads and polygons to triangles for the purposes of this calculation. This programs relies on the correct ordering of vertices in STL format (so that normal is always "outward" following the right hand rule). There is a hope that order of DzHalfEdges inDzFace is not random, but if it is there should be reasonably easy way to take into account the normal information.

    Seems to be doable and having your scripts as an example I'll probably try and do it.

    Post edited by vadimt on
  • vadimtvadimt Posts: 33
    edited November 2015

    I've got my solution, based on the Python library, I mentioned: trimesh. My script does silent OBJ export to a file, then executes the short Python script

    Calling of the Python is copied from the sample Render to RIB and in the end of this script I read the output of Python and create the marker the same way as suggested in mCasual's script. Voila!

    The detailed instructions and the full code of the CoMMarker script are posted at DeviantArt. The only slightly non-trivial aspect is to have a Python installation with math library, and install the trimesh module. Otherwise the DSA script is quite self-contained.

    Post edited by vadimt on
  • Hello,

    Just to add some informaton to this thread. I wrote a Poser Python script that computes the center of mass based from on biomechanical data (Weight of segment and location of segment center of gravity). The script also calculates the base of support and test if the figure is out of balance. The script is for Victoria 4 but can be adapted for other figures. You can find the script at:

    https://www.renderosity.com/mod/freestuff/balance-helper-python-script/73550

    Allstereo

Sign In or Register to comment.