Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

TerrainEditorDemo source?
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=97
Page 1 of 1

Author:  psquare [ Mon Dec 06, 2010 7:32 am ]
Post subject:  TerrainEditorDemo source?

Hi,

We are working on a project that involves using PolyVox.

Specifically, we are interested in the Ogre integration. I grabbed the entire svn, but I cannot see the source code for this editor.

Is it possible to have this source. It doesn't even have to be buildable. We are just interested in pointers on how to achieve the ogre integration.

PS: I am talking about this demo that's on the website:

http://www.thermite3d.org/releases/Ther ... er2009.zip

Many Thanks

Author:  David Williams [ Mon Dec 06, 2010 8:08 pm ]
Post subject:  Re: TerrainEditorDemo source?

Hi,

The editor was simply written as a test of some features for Thermite. As features have been added to Thermite I've changed what Thermite actually does so as to demonstrate those features. First I added the physics support and then made Thermite load the castle/rigid bodies to demonstrate that, and then I took out the ridid bodies demo and turned it into a terrain editor instead. Now things have evolved, and it loads and executes JavaScript files on startup to define application specific behaviour.

In other words, the terrain editor doesn't exist as a stand alone program, it's simply the state Thermite was in about a year ago.

Of course, all the code is still there behind the scenes, it's just that I've taken out the user interface. So you can look at the Thermite code to find the information you are looking for. Have a look for two functions called 'buildRenderOperationFrom' which take PolyVox meshes and put the data into Ogre hardware buffers. The simpler version is for the cubic terrain (like Minecraft) where as the more complex version is for the Marching Cubes terrain (which you want).

Note that the main reason the Marching Cubes terrain version is more complex is that it performs some rather fiddely duplication of triangles as it copies the data across. This is so that triangles with multiple materials get rendered several times, once for each material. This is a more advanced trick and you don't need to bother with it initially.

You may find an easier approach is to use the Ogre ManualObject class (at least initially). Be sure to check out the PolyVox BasicExample as this demonstrates extracting data and rendering with OpenGL. Porting to Ogre::ManualObject should be quite straight forward. Also read the tutorial here:

http://www.thermite3d.org/joomla/index.php?option=com_wrapper&view=wrapper&Itemid=32

Code is very slightly out of date but you should be able to work it out if you look at the BasicExample at the same time.

Just ask if you have more questions :-)

Author:  psquare [ Wed Dec 08, 2010 6:18 am ]
Post subject:  Re: TerrainEditorDemo source?

Hi David,

I found what I was looking for:

Code:
//The SurfaceMesh needs to be broken into pieces - one for each material. Iterate over the materials...
for(std::map< std::string, std::set<uint8_t> >::iterator iter = volume.m_mapMaterialIds.begin(); iter != volume.m_mapMaterialIds.end(); iter++)
{
 ...
 meshWhole.extractSubset(voxelValues);
 ...
}


I basically wanted to know the way to extract different materials out of a volume, so that I can make a separate ManualObject section (with a different material/textures) for each such section. The OpenGL sample has a single buffer because you effect different shading via vertex coloring. I can't do that in a single buffer (or one section for ManualObject) because I have different textures. Unless ofcourse I use a texture atlas.

I do something like the code above and it works :-). I can now do the shading like the editor demo.

Thanks also for this tip:
Quote:
Note that the main reason the Marching Cubes terrain version is more complex is that it performs some rather fiddely duplication of triangles as it copies the data across. This is so that triangles with multiple materials get rendered several times, once for each material. This is a more advanced trick and you don't need to bother with it initially.

Author:  David Williams [ Wed Dec 08, 2010 7:04 pm ]
Post subject:  Re: TerrainEditorDemo source?

Ok, great, I'm glad you got it working. The only other thing I would mention regarding terrain is you should be able to get much smoother terrain than I had in the demo, because I've since added support for density values (rather than voxels simply being on or off).

You might find more useful info in this thread (rather long...): http://www.thermite3d.org/phpBB3/viewtopic.php?f=2&t=63

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/