It is currently Sat Aug 22, 2020 2:12 pm


All times are UTC




Post new topic Reply to topic  [ 128 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 13  Next
Author Message
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Sat Jan 14, 2012 1:39 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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.


Last edited by drwbns on Sat Jan 14, 2012 1:54 pm, edited 1 time in total.

Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Sat Jan 14, 2012 1:52 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Sat Jan 14, 2012 5:11 pm 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
Discussion of my program should probably be moved over to the showcase thread.

I'm going to answer questions regarding its inadequacies over there.

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Sat Jan 14, 2012 6:37 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
ok


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Thu Jan 19, 2012 5:21 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Thu Jan 19, 2012 9:36 pm 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
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?

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Fri Jan 20, 2012 6:28 am 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
I was talking about converting the terrain into a polyvox volume, then modifying and redisplaying as a manualObject.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Fri Jan 20, 2012 10:13 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Fri Jan 20, 2012 7:21 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Fri Jan 20, 2012 8:51 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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); 
                            //} 
                    } 
            } 
    }


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 128 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 13  Next

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 5 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