| Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
| Realtime Ogre 1.8 Terrain Component manipulation http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=312 |
Page 2 of 13 |
| Author: | drwbns [ Sat Jan 14, 2012 1:39 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
Sorry, I should have mentioned that I'm using DirectX. I've got the scenenode error with every run of the program. And thanks to both of you for all the information and the article David, its much appreciated. |
|
| Author: | drwbns [ Sat Jan 14, 2012 1:52 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
I get errors with scenenode names like - OGRE EXCEPTION(5:ItemIdentityException): SceneNode '0x-2y3z' not found. but I don't see that name in the createTestWorld() function, is that why the error? |
|
| Author: | GM_Riscvul [ Sat Jan 14, 2012 5:11 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
Discussion of my program should probably be moved over to the showcase thread. I'm going to answer questions regarding its inadequacies over there. |
|
| Author: | drwbns [ Sat Jan 14, 2012 6:37 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
ok |
|
| Author: | drwbns [ Thu Jan 19, 2012 5:21 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
I'm still having some trouble in understanding how I can convert my Ogre::TerrainGroup into a PolyVox volume. I've read about Regions and seen the for loop for using setVoxelat but it still doesn't make a whole lot of sense on how to actually write the code for it. Any more tips on how to achieve something that sounds really basic like this? |
|
| Author: | GM_Riscvul [ Thu Jan 19, 2012 9:36 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
Well its a bit trickier than you might think. Ogre:Terrain is designed for 2d paging and heightmaps it isn't really an optimal way to represent Polyvox volumes. I'm not even sure how you could go about converting the extractor's information into something Ogre:Terrain could use. I suppose you could cast rays for each X and Z and find out the Y value on the collision but that seems rather slow. Are you talking about turning a polyvox volume into Ogre:Terrain data, or creating a volume out of existing Ogre:Terrain data? |
|
| Author: | drwbns [ Fri Jan 20, 2012 6:28 am ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
I was talking about converting the terrain into a polyvox volume, then modifying and redisplaying as a manualObject. |
|
| Author: | David Williams [ Fri Jan 20, 2012 10:13 am ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
drwbns wrote: I was talking about converting the terrain into a polyvox volume, then modifying and redisplaying as a manualObject. This probably isn't the best approach. When working with PolyVox you probably don't want to use the Ogre terrain system. Even if you do use it (and this would be an advanced application) you would use is a destination for PolyVox meshes rather than as a source for PolyVox volume data. Instead, I assume your Ogre terrain is builng generated from a heightmap? It is quite straightforward to convert a heightmap into a volume, then you can the the surface extractors to build the mesh and pass that to Ogre ManualObject. In this way you are bypassing the ogre terrain system completely. To convert your heightmap to a volume, consider that you have a 1024x1024 input image, with grey scale values between 0-255. You could convert this to a 1024x256x1024 volume. Iterate over all the voxels in the volume and, for any given voxel at (x,y,z) look at the corresponding pixel (x,z) in the heightmap. The value in the heightmap is the height of the terrain, so if y is less that the heightmap value then this voxel should be set to be solid. Otherwise os should be empty space. This code will probably not compile but it illustrates the idea. You can focus on the main function. |
|
| Author: | drwbns [ Fri Jan 20, 2012 7:21 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
That makes so much more sense David, thank you! You're definately right that the Terrain component is not necessary at all in this case. |
|
| Author: | drwbns [ Fri Jan 20, 2012 8:51 pm ] |
| Post subject: | Re: Realtime Ogre 1.8 Terrain Component manipulation |
Ok so here's what I have so far. I'm still kind of confused as to what the voxelType parameter should/ could be. It seems as though it's a materialID parameter? Anyways - here's the code I have so far. Any thoughts on it would be great - Code: Ogre::Image myTerrainHM;
myTerrainHM.load("terrain.png","General"); //Create a volume LargeVolume<uint8_t> volData(myTerrainHM.getWidth(),256,myTerrainHM.getHeight()); //Clear volume to zeros. //FIXME - Add function to PolyVox for this. for(unsigned int z = 0; z < volData.getDepth(); ++z) { for(unsigned int y = 0; y < volData.getHeight(); ++y) { for(unsigned int x = 0; x < volData.getWidth(); ++x) { volData.setVoxelAt(x,y,z,0); } } } for(int z = 1; z < volData.getDepth()-1; ++z) { for(int y = 1; y < volData.getHeight()-1; ++y) { for(int x = 1; x < volData.getWidth()-1; ++x) { //We check the red channel, but in a greyscale image they should all be the same. int height = myTerrainHM.getColourAt(x,y,0); //Set the voxel based on the height. if(y <= height) { volData.setVoxelAt(x,y,z,1); } else if(y <= height) { volData.setVoxelAt(x,y,z,2); } //Zero the faces //FIXME - looks like a bug - shouldn't be -2? //if((x == 0) || (y == 0) || (z == 0) || (x == volumeSideLength-2) || (y == volumeSideLength-2) || (z == volumeSideLength-2)) //{ // volIter.setVoxel(0); //} } } } |
|
| Page 2 of 13 | All times are UTC |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|