How to Calculate Volume & Surface Area ? [Solved]

Software: Away3D 4.x

Jackal, Newbie
Posted: 08 January 2013 10:50 PM   Total Posts: 10

How to Calculate Volume & Surface Area of a loaded OBJ model ?

thanks for your time

   

Rasterizer, Member
Posted: 09 January 2013 09:56 AM   Total Posts: 69   [ # 1 ]

Surface area is the sum of surface areas of all triangles. How to calculate a triangle’s area can easily be looked up.

Volume is a completely different beast and I don’t think you will calculate it anytime soon without using university-level maths.

BUT

for extra awesomeness, this works for 3DS MAX:

1, import object into 3DS MAX
2, select object
3, go to Utilities (hammer icon)
4, click Measure
5, voila, your object’s surface and volume courtesy of Autodesk

I’m sure other 3D packages provide their own measurement info as well.

 

   

Jackal, Newbie
Posted: 10 January 2013 12:05 AM   Total Posts: 10   [ # 2 ]

Thanks for your reply

I am trying to get such data at runtime in Away3d because of specific need for a 3d printing costs estimation application

As far as i know i need to access raw mesh faces data (coordinates) to calculate the surface area (it should be easy as OBJ files are triangulated) but i don’t know how to reach such raw data

As for the volume i am clueless

 

   

Rasterizer, Member
Posted: 10 January 2013 09:35 AM   Total Posts: 69   [ # 3 ]

After some googling, I was able to find a few examples of how to access vertices.

As for the volume, I can’t help at all as I’m not a maths wiz, but maybe some helpful soul at Autodesk would share their solution with you for free or if your project has corporate character you could buy the solution from them.

As I said, volume of an irregular object is nothing us mere mortals fiddle with. Even in physics they just use water to calculate it.

 

   

John Brookes, Moderator
Posted: 10 January 2013 01:42 PM   Total Posts: 732   [ # 4 ]

This will give you the volume of a closed mesh.

//eg 
//trace(calcVolume(Mymesh));

private function calcVolume(m:Mesh):Number
{
 
var i:uint;
 var 
pointer:uint;
 var 
vtxIndx:uint;
 var 
iData:Vector.<uint> = m.geometry.subGeometries[0].indexData;
 var 
vData:Vector.<Number> = m.geometry.subGeometries[0].vertexData;
 var 
va:Vector3D = new Vector3D();
 var 
vb:Vector3D = new Vector3D();
 var 
vc:Vector3D = new Vector3D();
 var 
vol:Number 0;
 
 for (
0m.subMeshes[0].indexData.length 3i++)
 
{
  pointer 
3;
  
vtxIndx iData[pointer] 3;
  
va.setTo(vData[vtxIndx]vData[vtxIndx 1]vData[vtxIndx 2]);
  
vtxIndx iData[pointer 1] 3;
  
vb.setTo(vData[vtxIndx]vData[vtxIndx 1]vData[vtxIndx 2]);
  
vtxIndx iData[pointer 2] 3;
  
vc.setTo(vData[vtxIndx]vData[vtxIndx 1]vData[vtxIndx 2])
  
  
vol += (va.dotProduct(vb.crossProduct(vc)) / 6);
 
}
 
return vol;

 

   

Rasterizer, Member
Posted: 10 January 2013 01:52 PM   Total Posts: 69   [ # 5 ]

John, when you say “closed” do you by any chance mean “convex” ?

 

   

John Brookes, Moderator
Posted: 10 January 2013 02:16 PM   Total Posts: 732   [ # 6 ]

Closed as in you cant get inside the mesh.

concave, convex doesnt matter.

Should also point out that above is for away 4.0 and assumes only 1 subgeometry.

 

   

Rasterizer, Member
Posted: 10 January 2013 02:51 PM   Total Posts: 69   [ # 7 ]

That code looks really light for all the possibilities out there. Can’t imagine my (really complex concave) character’s volume to be calculated like this.

I really do think this only works for special cases, i.e. convex meshes and with the origin within the mesh, but I will leave the actual proof to someone with better understanding of spatial maths.

 

   

Jackal, Newbie
Posted: 11 January 2013 10:40 AM   Total Posts: 10   [ # 8 ]

Thanks John that works good, i really appreciate your help

 

   

Rasterizer, Member
Posted: 11 January 2013 11:17 AM   Total Posts: 69   [ # 9 ]

Jackal, can you confirm that code gives accurate results for complex concave meshes ? Did you test the results against physical measurements ?

 

   

Jackal, Newbie
Posted: 11 January 2013 01:51 PM   Total Posts: 10   [ # 10 ]

I ve tested a few models, check the included model.

3ds max volume :  27537756.1

Away3d 4 volume : 27537883.74721294

i am not sure if it will behave well with highly complex models.

so far it seems accurate enough or at leaset comparable to 3ds max results as long as the mesh is closed and connected and with proper normals.

 

File Attachments
test.obj  (File Size: 215KB - Downloads: 185)
   

Rasterizer, Member
Posted: 11 January 2013 02:53 PM   Total Posts: 69   [ # 11 ]

That’s good news, maybe they both use the same algorithm.

However I don’t seem to be able to download that file, clicking on it brings me to a blank page and Save As wants to download a webpage. Maybe you could post an image instead ?

 

   

Jackal, Newbie
Posted: 11 January 2013 03:18 PM   Total Posts: 10   [ # 12 ]

here is a direct link to the model: dl.dropbox.com/u/1229065/test.obj

supposedly its a concave disk shape , a quick model i made from lathe applied to an “oo” (infinity character) spline

 

   

Rasterizer, Member
Posted: 11 January 2013 03:40 PM   Total Posts: 69   [ # 13 ]

Got it, thank you!
Does your 3D printer give you volume info about printed objects ? If so, does the calculated volume match that info ?

Sorry to be this inquisitive, but I’m interested in this subject myself. grin

 

   

Jackal, Newbie
Posted: 12 January 2013 03:33 AM   Total Posts: 10   [ # 14 ]
Rasterizer - 11 January 2013 03:40 PM

Got it, thank you!
Does your 3D printer give you volume info about printed objects ? If so, does the calculated volume match that info ?

Sorry to be this inquisitive, but I’m interested in this subject myself. grin

Not at all we are all here to collaborate and help each other

i ve sent you a mail with the 3d printer software you can use it to get accurate measurements

Most of the time the model volume is lower (10%~35%) without the support material volume, i think it depends on many factors like printing resolution, the filling being solid or sparse ..etc

 

   

Jackal, Newbie
Posted: 14 January 2013 03:52 AM   Total Posts: 10   [ # 15 ]

Can anyone help with calculating the surface area ?

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X