Jump to content
  • Advertisement
Sign in to follow this  
Jemburula

C++ Terrains for a Nooblet

This topic is 4338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello there, I've been playing with DX for a while now and I want to begin playing with terrains, it doesn't have to be fancy but I'm just looking for a place to start so that when the camera moves in my application, it actually looks like it is moving and not just the objects are moving. So I'm just wondering what prerequisites you think I should know and other than that any resources you have found useful. Thanks a million Jemburula

Share this post


Link to post
Share on other sites
Advertisement
Take a look at the clipmap implementation that Hughes Hoppe et al put up here for something fairly recent.

Quite a lot of the other stuff you see on terrain rendering on the web is not really appropriate anymore for newer hardware.

Share this post


Link to post
Share on other sites
Oh... not really appropriate? How come? Thanks for the link though, I'll have a look. Anyone else have any beginners material? [smile]

Edit: Could a moderator move this to the For Beginners section.

Share this post


Link to post
Share on other sites
You could always develop your own terrain mapping system. For instance...

class Map {
public:
Map();
void loadMapFromFile(char *filename);
void createBuffer(); // creates a index buffer or w/e to speed up rendering times
void draw();
void setHeight(int x, int z, int h);
int getHeight(int x, int z);
private:
int width, length;
int *heights; // array to be allocated in constructor OR in the loadMapFromFile
};

void Map::loadMapFromFile(char *filename) {
ifstream s(filename);
int w, l;
s >> w >> l;
width = w; length = l;
heights = (int*)malloc(sizeof(int) * w * l);
s.close();
}



Or something to that effect. Not too sure if the file i/o is correct lol.. prolly not. Hmm, class structure could def be better.

But think about it. All a terrain is is a bunch of ordered triangles that make up a big bumpy sqare on the screen.

Share this post


Link to post
Share on other sites
tendifo: Yeah I know, that's the part I was getting stuck on like it just got confusing in my head when I thought about triangles and then going on to the next 'strip' of triangles above it etc.

chadmv: Thanks mate that looks great, just what I need I think. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Jemburula
Oh... not really appropriate? How come?


Well, in the old days, it made a lot of sense to try to spend a lot of effort minimizing the number of triangles that you rendered, because rendering individual triangles was slow - especially back when we were doing triangle rasterization in software.

As time went by, triangle processing/rendering speed increased faster than CPU speed increased.

So, these days, it's more important to efficiently feed triangles to the GPU than it is to worry about exactly how many triangles you're really drawing. Which is not to say that you want to pointlessly feed the GPU millions of triangles you aren't going to end up seeing.

Anyways, a lot of the material/advice on terrain rendering that's out there is focused on solving problems that aren't relevant anymore. The clip mapping stuff I pointed at before represents a much more "modern" approach to terrain rendering than most of the other stuff out there.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!