We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › 3D terrain - proof of concept
Page Index Toggle Pages: 1
3D terrain - proof of concept (Read 2047 times)
3D terrain - proof of concept
Jun 26th, 2009, 11:44am
 
3D terrain - proof of concept

I had a stab at this when I first started dabbling with Processing and didn't get very far...  I've obviously improved substantially since then as it only took me an afternoon to get my original code working and to then get it to read height and colour data from images Smiley.  (IIRC it took me somewhat longer to produce the original code that didn't even work!)

I've no idea if this is the best approach to this kind of project - I'd initially considered using arrays to store height and colour data but I'm assuming that using images in this way is at least no less efficient...  If nothing else it's a heck of a lot easier to generate the data Cheesy (I tested the array version by randomly populating the arrays!)

Next I'd quite like to add objects to the terrain - I think I'll start with some trees - and I suspect it's at this point that I'll discover whether this approach is actually practical...

Any feedback gratefully received!
Re: 3D terrain - proof of concept
Reply #1 - Jun 26th, 2009, 12:18pm
 
It is quite common to use greyscale images for height maps because they are easy to create, Using an image for the color map is neat but eventually you might want to use textures for the terrain to add realism.

Nice one. Smiley
Re: 3D terrain - proof of concept
Reply #2 - Jun 26th, 2009, 4:00pm
 
Thanks Smiley

I guess I didn't phrase my comments too well: I did know that greyscale maps were often used for this purpose, but what I wasn't sure of was how they were converted to 3D.  I did wonder whether they'd be used to create a complete 3D mesh and then some other method was used to mask the sections of the mesh not on screen, but that didn't seem to make a lot of sense.

I have discovered and now fixed one slight issue (though not yet uploaded it): namely that the number of 'tiles' is actually less than the number of points, so the index reference for the colour map is slightly off.  You don't see this in the demo I've posted, but I eventually want to get it to wrap around at which point there would be obvious seams...  I'm still trying to figure out how to avoid outOfBounds errors on wrapping at the moment though; but need a break first!

I take your point on using proper image textures, but I rather like the retro look - it takes me back to my younger days.  Actually my inspiration for this was Zarch later released as Virus.  Back in the day people weren't scared to release games with fiendishly difficult control-schemes Smiley

Out of curiosity I'd be interested in knowing the relative benefits/costs (i.e. regarding memory and processor load) of using an image to store and process array data, rather than using an actual array.  It also strikes me that I could potentially use one channel of the terrain map to store height information and use the other two channels for other information - or is that asking for trouble
Re: 3D terrain - proof of concept
Reply #3 - Jun 27th, 2009, 6:12am
 
heightmaps are an easy way to get landscapes working. its a 2d plant that you extrude and voilá. has a problem. its finite

you could also use perlin noise to render infinite landscapes, no need for height maps and wasting memory. but you wouldnt get the customization you have with height maps.

you could also import landscapes from a modelling tool. that would also work and no need for heightmaps. just import the 3d data. would also be good because u already have color/texture maps, normals, etc easily.

about handling the data, you should divide the landscape in tiles, simply divide and reject when not on screen or using a quadtree for rejecting whats not on sight.

adding shadows should be easy too, you should find over the internet ways to create a shadowmap for grid landscapes.

also easy would be to place things on the landscape. find the polygon you on and interpoate the vertices to find your altitude.

well quite some things to do =) wish you good luck and have fun.
this landscapes are giving me some itch, maybe i should build one of my own =)
Re: 3D terrain - proof of concept
Reply #4 - Jul 4th, 2009, 9:07am
 
Hi,

these kinds of questions are a common part of raycasting actually.  i would suggest checking out

http://www.flipcode.com/archives/Realtime_Voxel_Landscape_Engines-Part_1_Introduction.shtml

and

http://www.advsys.net/ken/voxlap/voxlap03.htm
Page Index Toggle Pages: 1