Multiple terrain meshes

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Asterisk Man
Posts: 62
Joined: Wed Jun 09, 2004 5:51 am

Multiple terrain meshes

Post by Asterisk Man »

Im kinda trying do work with a repeating seamless world (like Morrowind) for which I'm trying to do the following: create a huge height map (the entire world), chop it into 32x32 bmp or jpg chunks, and let the program load it in chunks of 3x3 at a time.

The problem I get is: when I chop the height map, I get differing altitudes in several parts of the terrain meshes, which I think is because when the terrain mesh is created, some of the triangles that would have been created to join the two pieces of the map together are not made, and therefore leave that height difference.

A solution for this problem, so far, is to clip a lil part of the next sector into the one before it, however, that leaves me with the problem of overlapping meshes, which makes parts of the map look REALLY bad.

Can anyone else think of any solutions to this problem (or setting visibility of a layer of the overlapping meshes?)


Solution: (For me) Create a geometry creator, which simply inverts the faces of the last row and column of the terrain mesh. That way I still get the right triangles, and the ones that overlap with the next mesh face the other way, eliminating Z-Fighting. One problem though: when I move around the zone that used to have z fighting, sometimes i get stuck(as in I cant move at all) to the ground.
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

I would be inclined to devise a way of specifically making the chunks as individual squares to begin with.

Your level editor could hide this, and make it seem like one continuous terrain.
Asterisk Man
Posts: 62
Joined: Wed Jun 09, 2004 5:51 am

Post by Asterisk Man »

I fixed it, now the new meshes generated work fine (I simply made it so that the overlapping polygons wouldn't be drawn at all).

The reason I wanted to do this is because im lazy and don't wanna make sure that every individual terrain sector matches, so I just make a huge height map (like 1024x1024), and divide it into 33x33 or 65x65 chunks, this way, it takes a LOT less time to load, and I can also make a repeating seamless world with barely any effort.
Asterisk Man
Posts: 62
Joined: Wed Jun 09, 2004 5:51 am

Post by Asterisk Man »

hmm... the triangles way didnt work, at least with grids > 2x2.

So i went another approach: Instead of modifying triangles, I just manipulated the SColor data (this is what the geometry creator uses to place vertices). I grab all the height maps I need into an array of IImages, and takethe SColor values of each and every pixel per image, and put them together into another object i created name PixelMap(so shoot me for not being creative :D ) then I created another geometry function that took this class instead of an IImage as the height map, the mesh creator simply thinks I just gave it a 64x64 image, when in fact i just gave it 4 32x32 images!
Post Reply