Another simple way of calculating the volume of a arbitary closed 3d mesh is 

Choose an arbitary point ( let's call it o )
For each triangle with vertices ( a,b,c ) 
Calculate the volume of the tetrahedron ( a,b,c,o ) using a scalar triple 
product ( ((b-a)x(c-a)).(o-a)/3 ).
Add the volumes of all of the tetrahedrons together, some of these volume will 
be negative and some will be positive, depending on whether the triangle is 
facing the arbitary point or not. These negative volumes cancel out the 
positive ones, leaving only the enclosed area.

This relies on the 2 assumptions:-
1) All of the triangles in the 3d object have the same winding order, otherwise 
the volumes' sign cannot be trusted.
2) The object has no holes.

If the object has holes then the placing of the arbitary point will affect the 
volume of the object, a triangular hole will mean that the volume of a 
tetrahedron between the hole and the arbitary point will be missed in the 
calcalation. As a result of this placing it in the centroid of the 3d object is 
probably the best plan.

I hope this helps.

Colin.

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Alberto Luaces
> Sent: 27 November 2008 08:42
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] Calculating the volume of a model through OSG
> 
> Hi,
> 
> in addition to Janusz pointers, if you need also the rest of 
> the mass properties, you could take a look at this famous paper:
> 
> http://www.cs.berkeley.edu/~jfc/mirtich/massProps.html
> 
> Alberto
> 
> El Jueves 27 Noviembre 2008ES 09:09:34 [EMAIL PROTECTED] escribió:
> > Dusten:
> >
> > You might find these two helpful:
> >
> > accurate: http://tetgen.berlios.de/
> > approximate & simple:
> > http://www.gamedev.net/reference/articles/article2247.asp
> >
> > The second one could be easily added to osg I guess.
> > Janusz
> >
> > Dnia Wed, 26 Nov 2008 23:47:57 -0600, Dusten Sobotta napisał(a):
> > > Hello,
> > >
> > > Manually modifying various attributes of models is quite tedious, 
> > > and tends to set back the development of games.  To work 
> around this 
> > > issue, I'd like to implement a feature to calculate the 
> volume of an 
> > > in-game model, so that given a surface attribute such as 
> 'wood' or 
> > > 'metal', (which have pre-defined density values), the mass of an 
> > > object can be computed and later exported. Might anyone have an 
> > > example for finding the approximate volume of an object 
> through OSG?
> > >
> > >
> > > Thanks in advance,
> > >
> > > Dusten
> > > _______________________________________________
> > > osg-users mailing list
> > > osg-users@lists.openscenegraph.org
> > > 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegrap
> > > h.org
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users@lists.openscenegraph.org
> > 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
> > org
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opensce
> negraph.org
> 
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to