It is currently Sat Aug 22, 2020 1:34 pm


All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Ogre mesh to PolyVox
PostPosted: Mon Sep 03, 2012 10:38 am 

Joined: Fri Aug 31, 2012 9:42 pm
Posts: 9
The problem was the .mesh file it self was corrupted....
lol ^^...
now everything works the way it should....

now i have to fill the gaps between the voxels... let's see if i get this done ^^


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Ogre mesh to PolyVox
PostPosted: Tue Sep 04, 2012 8:10 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Crash(Overwrite()) wrote:
now i have to fill the gaps between the voxels... let's see if i get this done ^^


I can describe an approach I have used in the past (though I can't say if it is the best solution). Basically, try iterating over triangles in your mesh rather than iterating over vertices. Write a function which takes a triangle as input and does one of two things:

  • If the vertices of the triangle are all very close together (all inside the same voxel) then set this voxel to solid.
  • Else split the triangle into three triangles by creating a new vertex at the centre, and then apply the process recursively to those.

This should fill in the gaps between the vertices, though you will still end up with a hollow shell.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Ogre mesh to PolyVox
PostPosted: Tue Sep 04, 2012 8:27 am 

Joined: Fri Aug 31, 2012 9:42 pm
Posts: 9
David Williams wrote:
can describe an approach I have used in the past (though I can't say if it is the best solution). Basically, try iterating over triangles in your mesh rather than iterating over vertices. Write a function which takes a triangle as input and does one of two things:If the vertices of the triangle are all very close together (all inside the same voxel) then set this voxel to solid.Else split the triangle into three triangles by creating a new vertex at the centre, and then apply the process recursively to those.This should fill in the gaps between the vertices, though you will still end up with a hollow shell.


yep i will try that thx again ...^^

and a hollow shell is ok for now ....
i can try to fill it later if that is neccessary....


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Ogre mesh to PolyVox
PostPosted: Sat Oct 06, 2012 3:46 am 

Joined: Fri Sep 14, 2012 10:54 pm
Posts: 15
The hollow shell could be filled with a 3D implementation of floodfill or similar recursive algorithms.
The problem is, that the mesh has to be closed for that or it will mess up horribly.


One other way would be to generate the voxeldata in a complete different way...
I decided to use a divide and conquer algorithm for Voxelization... (Later on in process of my project)


Code:
1. Decide on a size for the Volume. ( I am going to compute it from a wanted resolution and the bounding volume of the given meshes. )

2. Test the given "CollisionBox" against the Mesh.
    - If it collides:
        - Is it as small as a Voxel? -> Set it solid.
        - Else: Split it into 8 smaller CollisionBoxes and repeat step 2.
    -If not: Discard the whole box.

3. You got it... Save the Volume. ( You could convenietly save it as an octree that way. )



The given Term "CollisionBox" ( Im not very creative with names... And english isn't my native language, so i apologize... ) simply means, that we got a defined area which we can test against the mesh. We have to test against a meshaccurate bounding, not against the mesh boundingbox, which makes this approach kinda expensive and nothing suitable for a real time approach if it isn't done on an extern thread...

( Does this method even sound viable? :D )


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Ogre mesh to PolyVox
PostPosted: Sat Oct 06, 2012 3:05 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I guess this sounds reasonable... it's quite hard to imagine. So the idea is that this creates a filled in volume rather than a hollow shell? But it can still fail if the mesh isn't closed?

There are other approaches you can use, for example you can iterate over each voxel and determine whether it is inside the mesh by casting a ray and counting how many triangles it intersects. If it's an odd number the voxel is inside, otherwise it is outside. i.e a 3D version of the 'point in polygon' test.

Maybe check out this article as well: http://blog.wolfire.com/2009/11/Triangle-mesh-voxelization

Overall I don't know what the best approach is... you will have to experiment a bit :-)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Ogre mesh to PolyVox
PostPosted: Sat Oct 06, 2012 3:21 pm 

Joined: Fri Sep 14, 2012 10:54 pm
Posts: 15
David Williams wrote:
I guess this sounds reasonable... it's quite hard to imagine. So the idea is that this creates a filled in volume rather than a hollow shell? But it can still fail if the mesh isn't closed?



The 3D Floodfill could fail. Therefor i thought about using the second method. I guess it should work fine. The problem is that one has to generate accurate Meshboundings.


Does this "point" in polygon" thing realy work? In case of holes it could fail again, wouldnt it?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Ogre mesh to PolyVox
PostPosted: Mon Oct 08, 2012 12:53 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
KuroSei wrote:
Does this "point" in polygon" thing realy work? In case of holes it could fail again, wouldnt it?


The point in polygon test will indeed fail if there are holes in the mesh. So are you saying that your proposed solution would work even if there are holes? Will it also work if the mesh is concave, or if it consists of more than one components?

If you can find an algotirhm which behaves well in all these situations then that's great, but you might find it is easier to just make sure your input mesh is closed.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net