• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
scientiphic

Computing volume from marching cubes

14 posts in this topic

Hey graphics-gurus, I am using the marching cubes algorithm to construct an isosurface from a 3d field of data. I have the triangular facets, etc. all done, but now I need to compute the volume enclosed in the iso-surface. I can think of one way to do this: using the triangular facets and the vertices of the cube, I create several tetrahedra and then simply calculate the volume of each tet. However, I noticed that as the number of facets in each cube increases, it can become non-trivial to automate the creation of the tets. Could someone point me to a reference that describes the algorithm to automate this process? Or has anybody created a table of vertices for all combinations of tets that are possible corresponding to each of the 256 cases of the MC tritable? Or is there a more efficient way to compute the volume using the MC information? Will greatly appreciate any help!
0

Share this post


Link to post
Share on other sites
If you already have the triangles, computing the volume is easy. Just loop over all your created triangles, and sum up the quantity dot(v0, cross(v1,v2)) where v0, v1, v2 are the vertices of your triangle.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Pragma
If you already have the triangles, computing the volume is easy. Just loop over all your created triangles, and sum up the quantity dot(v0, cross(v1,v2)) where v0, v1, v2 are the vertices of your triangle.


Are there any limitations to the type of mesh one can use this on? e.g.: convex hulls only?
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Pragma
If you already have the triangles, computing the volume is easy. Just loop over all your created triangles, and sum up the quantity dot(v0, cross(v1,v2)) where v0, v1, v2 are the vertices of your triangle.


Does your approach work even if the isosurface does not enclose the origin? I guess the expression you have suggested is for determining the volume of tets with one vertex at the origin...

In my case, I can have several closed isosurfaces in one data field (say like several spheres distributed in space - except that the geometry need not be as simple as spheres). So the origin need not necessarily be enclosed within the isosurface.
0

Share this post


Link to post
Share on other sites
The mesh does not need to be convex, and it doesn't need to enclose the origin. To prove to yourself that this is true, try drawing some examples in 2D on paper. You'll see that sometimes dot(v0, cross(v1,v2)) is negative, but that when all contributions are added up the negative terms cancel with even larger positive terms.

The only requirement is that your mesh has to be closed and your triangles have to be consistently oriented. This should happen automatically with data from marching cubes.

EDIT: It should actually be dot(v0, cross(v1,v2)) / 6

[Edited by - Pragma on January 14, 2009 7:57:48 AM]
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Pragma
The mesh does not need to be convex, and it doesn't need to enclose the origin. To prove to yourself that this is true, try drawing some examples in 2D on paper. You'll see that sometimes dot(v0, cross(v1,v2)) is negative, but that when all contributions are added up the negative terms cancel with even larger positive terms.

The only requirement is that your mesh has to be closed and your triangles have to be consistently oriented. This should happen automatically with data from marching cubes.

EDIT: It should actually be dot(v0, cross(v1,v2)) / 6


Well, this is great. Thank you for this. I'll do some testing today and see how it flies. I am concerned with things like quaternion Julia sets, which have all kinds of interesting surface properties. If anything fails, this will be it. Should have the results within an hour or two.
0

Share this post


Link to post
Share on other sites
Yeah, I'm a bonehead! Took me a second to make the link with determinants... Thanks for pointing this out.

[Edited by - taby on January 14, 2009 1:43:56 PM]
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Pragma
The mesh does not need to be convex, and it doesn't need to enclose the origin. To prove to yourself that this is true, try drawing some examples in 2D on paper. You'll see that sometimes dot(v0, cross(v1,v2)) is negative, but that when all contributions are added up the negative terms cancel with even larger positive terms.

The only requirement is that your mesh has to be closed and your triangles have to be consistently oriented. This should happen automatically with data from marching cubes.

EDIT: It should actually be dot(v0, cross(v1,v2)) / 6


Thanks for clarifying this. However, I missed a detail in my original question that could complicate matters. The way my code works is I compute the volume corresponding to each closed isosurface at the level of the individual cells and then sum up the individual volumes by cycling through all the cells (this way it is just easier to run on parallel machines; each processor computes its portion of the volume. Furthermore, a closed isosurface may be shared by several processors.). In other words, if I take a marching cube, then I really need the volume formed by the intersection of the triangular facets with the cube. Once this is done, I store the contribution of each cube to the total volume in each cell (cube).
0

Share this post


Link to post
Share on other sites
Do you care about the volume contained in each cell? Or do you just need to know the total volume?

If it's the former then you'll need to use a different trick. But if it's the latter, you can compute dot(v0, cross(v1,v2)) / 6 for all the triangles in each cell and store them in the cell. Then you can add this up for all the cells. You can easily do this in parallel over multiple machines.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Pragma
Do you care about the volume contained in each cell? Or do you just need to know the total volume?

If it's the former then you'll need to use a different trick. But if it's the latter, you can compute dot(v0, cross(v1,v2)) / 6 for all the triangles in each cell and store them in the cell. Then you can add this up for all the cells. You can easily do this in parallel over multiple machines.


Yes, I see that your suggested approach will work regardless of whether the isosurface is on one processor or shared across several processors, and it should work perfectly fine if I only needed the total volume.

However, I do need the volume in each cell. One primary reason is that I do not a priori know the total number of closed isosurfaces in the data field. Once I am done calculating the "volume" present in each cell, I will then need to search through the entire data field for connected "volumes". To be more precise, I will need to compute the volume distribution (say for instance, the pdf of sphere volumes) of the closed isosurfaces in the data field.

I can think of one **laborious** procedure at the moment: construct a table (similar to the tritable in the mc-algorithm) that contains all the triangle facets that enclose the required volume in each cube (this would mean breaking up the relevant part of the cube faces into triangular facets). I could then use your suggested approach for the tabulated triangles in each cube. So essentially I will have a "closed" volume in each cube.

Do you have other suggestions?


0

Share this post


Link to post
Share on other sites
Sorry for resurrecting this age old thread. Did you find a easy solution for calculating the volume per marching cube?
0

Share this post


Link to post
Share on other sites
Considering the OP was last active in 2009, it is highly likely they will not see your 3 year later response asking them for clarification.
0

Share this post


Link to post
Share on other sites
Isn't this basically trivial? In order to implement marching cubes you need to have some classification of cases, and in each case you generate triangles in some specific way. In each of those cases, you can compute what the volume contained in this cube is without too much trouble. Am I missing anything?
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0