Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Howto form volume mesh efficiently with lots of modification http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=157 |
Page 1 of 1 |
Author: | pumpkin_zch2u [ Thu Mar 03, 2011 2:53 pm ] |
Post subject: | Howto form volume mesh efficiently with lots of modification |
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! |
Author: | ker [ Thu Mar 03, 2011 3:16 pm ] |
Post subject: | Re: Howto form volume mesh efficiently with lots of modifica |
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. |
Author: | David Williams [ Thu Mar 03, 2011 6:24 pm ] |
Post subject: | Re: Howto form volume mesh efficiently with lots of modifica |
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. |
Author: | pumpkin_zch2u [ Fri Mar 04, 2011 12:31 am ] |
Post subject: | Re: Howto form volume mesh efficiently with lots of modifica |
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? |
Author: | beyzend [ Fri Mar 04, 2011 5:08 am ] |
Post subject: | Re: Howto form volume mesh efficiently with lots of modifica |
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(); } |
Author: | ker [ Fri Mar 04, 2011 8:30 am ] |
Post subject: | Re: Howto form volume mesh efficiently with lots of modifica |
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 |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |