terrain

BlitzMax Forums/MiniB3D Module/terrain

Warner(Posted 2009) [#1]
Sorry about this mess, but I couldn't post this code in the archive, due to the license type. In this first post, I demonstrate a terrain system I for minib3d. In the last post, an updated version is available that makes the terrain compatible with collisions and pickmode.
This first version needs no modding of minib3d, and is therefore easier to test.

Mind that this code is optimised to run on slow machines, so you might want to adjust the 'detail' settings. Look for the term "detail" in the source.

[edit: updated]
I found a good tutorial online on ROAM terrains. I was playing around with the code. This is what I have now.
To run it, you need minib3d, and you need to supply a heightmap and two textures. (color+detail) The heightmap is automatically resized.

It has settings to change the detail level. Search for "detail".
---------------------------------------------------------------------------
About the license. Courtesey of Mark Duchaineau. The tutorials license is "free but copyrighted". Please read the license yourself. As I understand it, as long as you provide the terms, or a link to the terms on their site, you may use it freely: http://www.cognigraph.com/ROAM_homepage/COPYING.txt
As far of any parts I wrote, so anything except the basics of RecreateRoam and DrawSub, are public domain.


Chroma(Posted 2009) [#2]
Warner, while your still in the beginning stages of development. Maybe you could utilize the scenegraph code posted by Leadwerks to figure out what terrain to show. And also have an object to dictate the size of the visible segments.

Say you have a terrain that's 100 segments by 100 segments. You want to show the segment that the player is standing on plus all segments withing 10 unit distance. But make it so you can batch them together. Breaking the 100x100 segments into 5x5 sections etc.


Warner(Posted 2009) [#3]
Thank you, Chroma. That is a good suggestion. The Leadwerks scenegraph code is indeed real fast.


Warner(Posted 2009) [#4]
Updated, please see the first post


Warner(Posted 2009) [#5]
<edit>upload further below</edit>


Hezkore(Posted 2009) [#6]
This doesn't seem to compile for me... I keep getting stuck at C_AddVertex() in "inc/TTerrain.bmx".
Compile Error: Identifier 'C_AddVertex' not found


Warner(Posted 2009) [#7]
It seems I forgot 'minib3d.bmx', where the C_ functions are declared. I updated the above post. Also, I uploaded my entire minib3d mod folder to yousendit. It contains the terrain functions, scenegraph and the quat/matrix-rotation commands.
http://www.yousendit.com/transfer.php?action=batch_download&batch_id=YkxJblRwY3k3bUJFQlE9PQ


slenkar(Posted 2009) [#8]
the download has expired, could you upload it again>?


Warner(Posted 2009) [#9]
The terrain supports pickmode 2 and collisions. If you want to get the height of a specific part, use Terrain.GetY(x, z). I never tried moving the terrain, nor did I try to scale it. I think that could work out problematic.
As for uploading, I gave this site a try, hopefully it is any good:
http://www.easy-share.com/1908345153/sidesign.zip
It has my complete minib3d folder in it. If you only need the terrain, you should look into TTerrain.bmx,
as well as the c-functions, tcollisions.bmx, minib3d.bmx and err .. I think that was it. :/

Local terrain:TTerrain = LoadTerrain("") 'empty terrain

Or:
Local terrain:TTerrain = LoadTerrain("heightmap.png")

If you want to replace the heightmap by another, use this:
terrain.Load("heightmap2.png")

Instead of scaling, use:
terrain.vsize = 30.0

Terrain goes from (0,0) to (1024,-1024)
unless you alter 'size' before loading.

<edit> oh yes, also TGlobal.bmx


slenkar(Posted 2009) [#10]
thanks very much,


Charrua(Posted 2009) [#11]
hi
i'm developing a world creator for Blitz3D an BlitzMax+MiniB3D (AWC on the forums), Terrains are supported by Blitz3d and is afeature that i will incorporate on the editor but my knowledge in bmax is very poor.

Warner, may i use your code in my awc_loader.bmx?

thank's

Juan


Warner(Posted 2009) [#12]
Sure, feel free to use it. The parts I wrote are public domain. However, the parts that came from the tutorial I followed are 'free but copyrighted'. If I understood correctly, it should be accompanied by the above copyright notice or a link to the site.
And the code is 'hacked together' -if that is correct English- and might not work perfectly. I should write a clean version from scratch, which is on my to-do list for 2014. In other words: I want to rewrite it one time, but I'm not sure if I'll ever get round to it.


Charrua(Posted 2009) [#13]
ok, thank's

i have to test it some, because, when the user loads a terrain in the editor, he will be using the Terrain feature of Blitz3d, and the object's placement (snap to surface by example) probably do not match when using the above code from BlitzMax...?
if you ever rewrote the code, let me know, probably in 2015 i'll be finishing the version 2.0 of my AWC!
by the way probably in a week i'll been posting the version 1.0, Terrain were goning to be unsuported under bmax but wiht this code i thing it has a chance.

thank's again

Juan