Loading terrain's height_data from a file.

Started by
2 comments, last by happy_mingw_user 16 years, 8 months ago
Hi, I need to handle a very big terrain, that I will read from a file that I'll need to create. This is 3D but here we only need to think 2D. Things will be something like loading chunks near my position, max 64x64 per chunk. ( If 4x4 = 1m then a chunk of 64x64 regular grid = 16m in my situation ) The full size of the terrain will be like 1200000x1200000. ^^ From the file I only need the heigh_data, the rest I create them on the fly. The problem is that I need a paper or an example to do it, but, I don't know in what way to search, if someone have a link or something, please help ^^. For the moment I do things in OpenGL with Cpp : ) In advance, thanks for any help, it will be appreciated.
http://grands-secrets.be/http://screens.vndv.com/
Advertisement
Do a google search on streaming with terrain rendering. Also, this article caught my eye:

Abstract
Article
Wow, I actually know this one.

Divide the field into squares, and have a height map for each of these squares. Load and render only the squares adjacent to the one from which you stand (if you want to see into the distance, use large squares. For speed, use small ones).

A height map is usually a bitmap, but that's 3x larger than it needs to be. Essentially you can store a height map as a black and white (not monochrome! 24 bit!) image (think photoshop's "difference clouds" effect), load the image, and use every 3rd value for the height.
ifstream file(/*arguments*/);
//ifstream checks, ect
file.read(heightmap,(ifstream::pos_type)width*height*3);
y = heightmap[3*(z*width+x)];

Again, this is annoying because it's 3x larger. I wrote an app. that cuts filesizes by thirds (by taking only the value of any one of the RGB channels) and eliminates the need for the 3's that keep cropping up.

I'm sure there are better ways (and I'm half alseep), but simple is good, right?
Thank you, actually I need the file to be on my hard-drive, but, these .pdf files are very useful.
Actually, I can create the entire terrain from nothing, all height = 0, and save it,
because I'll edit it later with my editor.
Do I need to create a single file with the heights_data, or it has to be for each square a file?
Which one is more speed_friendly?

"Load and render only the squares adjacent to the one from which you stand
(if you want to see into the distance, use large squares. For speed, use small ones)."

I'll need to learn how to know wich square to load depending on my position.
That's actually my only problem I think.
After this, the Level-Of-Detail is required, but that's almost done.

Merci ^^
http://grands-secrets.be/http://screens.vndv.com/

This topic is closed to new replies.

Advertisement