It is currently Sat Aug 22, 2020 4:14 am


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Howto form volume mesh efficiently with lots of modification
PostPosted: Thu Mar 03, 2011 2:53 pm 

Joined: Fri Sep 10, 2010 5:38 am
Posts: 30
How to form volume mesh efficiently with extensive modification of the voxels?
my situation is:

the User do the operations on "teeth", I am using Ogre framework. each time user shape the teeth, I have to delete the original mesh and generate the new one, It seems to lack the efficiency and got my frame rate very low. How to solve it ?

that's my Question, maybe silly, but I just cannot solve it. sorry!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Howto form volume mesh efficiently with lots of modifica
PostPosted: Thu Mar 03, 2011 3:16 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
are you using the ManualObject from ogre?
because you could split up your volume into cubes (like 16x16x16) and create a draw section for each of those small cubes. If you adjust the region you're extracting exactly to those cube boundaries, you only need to update the cubes that were changed (and maybe sometimes the neighbor cubes)

so basically instead of using getEnclosingRegion() you should only create a region that covers the cube you just changed.

I hope you understand what I mean, otherwise I can offer you a code sample, because I have that setup working for a 64x64x1 cube grid that covers a much larger volume.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Howto form volume mesh efficiently with lots of modifica
PostPosted: Thu Mar 03, 2011 6:24 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Yes, as ker says, rather than creating a single mesh for the whole volume you should create a number of smaller meshes. That way you only need to update the relevant small mesh when a voxel changes. The surface extractors take a 'Region' parameter for exactly this purpose.

You may also modify several neighbouring voxels, in which case you should do all the modifications before regenerating the mesh.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Howto form volume mesh efficiently with lots of modifica
PostPosted: Fri Mar 04, 2011 12:31 am 

Joined: Fri Sep 10, 2010 5:38 am
Posts: 30
thank you Ker and David. I do use Ogre's ManualObject.I now understand the principle. as for I am new to this area(Voxel and Volume), Can you provide a piece of codes for demonstation?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Howto form volume mesh efficiently with lots of modifica
PostPosted: Fri Mar 04, 2011 5:08 am 

Joined: Sat Sep 18, 2010 9:45 pm
Posts: 189
It's actually pretty easy once you read up on manual object in ogre.

http://www.ogre3d.org/tikiwiki/ManualObject

I have some code I will post it, not that much to it once you have a PolyVox::SurfaceMesh.

Code:
void
    VolumeMapView::_manualFromMesh(bool isUpdate, PolyVox::SurfaceMesh<PositionMaterial>* mesh, Ogre::ManualObject* manual)
{

    using std::vector;
    const vector<uint32_t>& indices = mesh->getIndices();
    const vector<PositionMaterial>& vertices = mesh->getVertices();

    if(vertices.size() < 1)
        return;
    _manual->estimateIndexCount(indices.size());
    _manual->estimateVertexCount(vertices.size());
    _manual->begin("PRJZ/Minecraft", Ogre::RenderOperation::OT_TRIANGLE_LIST, "PROJECT_ZOMBIE");
    //_manual->begin("testatlas", Ogre::RenderOperation::OT_TRIANGLE_LIST, "PROJECT_ZOMBIE");

    for (vector<PositionMaterial>::const_iterator itVertex = vertices.begin(); itVertex != vertices.end(); ++itVertex)
    {
        const PositionMaterial& vertex = *itVertex;
        const Vector3DFloat& vertPos = vertex.getPosition();
       
        manual->position(vertPos.getX(), vertPos.getY(), vertPos.getZ());
        size_t material = vertex.getMaterial() + 0.5f;

        manual->textureCoord(material / 256.0f, 0.0, 0.0, 0.0);
    }
    //Then iterate through the indices add create the indices list.
    for (vector<uint32_t>::const_iterator itIdx = indices.begin(); itIdx != indices.end(); ++itIdx)
    {
        manual->index(*itIdx);
        uint32_t ix = *itIdx;
    }
    manual->end();
}


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Howto form volume mesh efficiently with lots of modifica
PostPosted: Fri Mar 04, 2011 8:30 am 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
yes, but instead of updating the whole ogre mesh, (which you aren't doing, you're creating a new section with this), you can update a single section without touching any of the others


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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