Using heightmaps

ianski

Newcomer
Joined
May 26, 2004
Messages
10
Heya guys,

Does anyone know how to use a height map in Direct X 9? I can't find a single thing whatsoever that's going to help me load a height map into DX :(

Oh, by the way, I'm referring to the greyscale style heightmap where you get a greyscale image and load that into a 3D program and it goes wha-la! and makes you your landscape :)

Anyone able to help?
 
ianski said:
Heya guys,

Does anyone know how to use a height map in Direct X 9? I can't find a single thing whatsoever that's going to help me load a height map into DX :(

Oh, by the way, I'm referring to the greyscale style heightmap where you get a greyscale image and load that into a 3D program and it goes wha-la! and makes you your landscape :)

Anyone able to help?
Are you trying to make or use a grayscale map?
Make-Im sure theres a better way but you could use mesh.intersect (angle the ray from above) to get the height at any point then smack down a pixel of the corresponding shade and keep going like that?
Use-Again im sure my way is really inefficiant, but create a mesh using an array of verticies, use the x,y for x,y and use the colorscale for z on the positions then run an optimize routine on the mesh when your done.
 
Basically I'm making a *small* (about 50x50m real-life size) piece of landscape. I think the easiest way for me to do this would be to convert the surveyed map of the area (has heights, etc) into a greyscale heightmap. There simply must be a way to say to DirectX "Here is a heightmap, make me some terrain" without the need to work through x and y pixels and calculate z values. If it can't do that, then I must say that Managed DirectX is a little bit silly... heightmaps are so useful.
 
Only limited amount of things can make it to the mdx. They have troubles just covering the things that are already in dx. Here's an idea: create the function yourself and make it available to the public.
 
Creating terrain engines is not as simple as "Here is a heightmap, make me some terrain" :). There are books that focus on that subject alone. (That is of course if you want something efficient which will not slow down your program terribly)
:)
 
Dammit! How dare things not already be done for me so I just bum off someone else's work. Oh well, I have to generate this terrain for a thesis of mine so I'm gonna have to do it. Does anyone have any hints, tips, tutorials that'd prove a boon for using VB.net 2003 + DX9 to load a greyscale heightmap into a terrain. It's not large scale, in fact it's rather small scale (50m x 50m real-life) and will be used for a first-person game.
 
Alright, ta. Also, which do you think would be easier? Converting a contour map of a surveyed area into a height map and then using an algorithm to draw the heightmap on the screen as a mesh so I can play with the vertices OR converting the contour map into a mesh (using a 3D program like 3DSMax or something) then loading the mesh in?
 
I'm looking into getting 3DSM to draw the terrain and texture it and then I'll export that into a .x file to load up with DX. It seems that's the easiest thing to do. Thanks for your help guys.
 
Still need help

Alright, it seems you can't draw up terrain in 3DS Max very easily. I have a contour map of the landscape I need to draw up and I was going to draw in the contours then use a Terrain feature that should turn the contours into a terrain landscape. Unfortunately, you're not allowed to do that.. you have to use AutoCAD to draw up the contours first.

While I'm looking into getting AutoCAD, just how hard is it to write the algorithm needed to read in a heightmap and convert it to a landscape in DX? I'd need to be able to modify the mesh in a specific location (and only that location) to be able to break the trianges down into smaller ones sort of like ROAM does to allow the user to modify the terrain in that spot.

Any advice on a plan of attack, please? I'm currently looking for the easiest method that gives me the quickest results... ta :)
 
ianski said:
Alright, it seems you can't draw up terrain in 3DS Max very easily. I have a contour map of the landscape I need to draw up and I was going to draw in the contours then use a Terrain feature that should turn the contours into a terrain landscape. Unfortunately, you're not allowed to do that.. you have to use AutoCAD to draw up the contours first.

While I'm looking into getting AutoCAD, just how hard is it to write the algorithm needed to read in a heightmap and convert it to a landscape in DX? I'd need to be able to modify the mesh in a specific location (and only that location) to be able to break the trianges down into smaller ones sort of like ROAM does to allow the user to modify the terrain in that spot.

Any advice on a plan of attack, please? I'm currently looking for the easiest method that gives me the quickest results... ta :)
Im Still suggesting my method and then a quick algorythm to make up the index buffer and its all done :D
 
I guess I'm worried that 'a quick algorithm' will actually not be so quick. Also, how easy will it be to use and modify the index buffer? Once I've drawn the terrain I need to be able to modify individual vertices (lowering them, raising them, etc).
 
ianski said:
I guess I'm worried that 'a quick algorithm' will actually not be so quick. Also, how easy will it be to use and modify the index buffer? Once I've drawn the terrain I need to be able to modify individual vertices (lowering them, raising them, etc).
It wouldnt be that quick you would need a number of calculations for each pixel in the height map and to alter the individual verticies you would either a) have to do so before the optimization or b) not optimize or c)try and use the optimized verticies but those would be harder to track.

The system i am thinking of (im sure someone will post a much faster one (or a link to a site about a faster system) but create a vertex array of the (with GreyScale being your image[bitmap?]) desired type [GreyScale.width * GreyScale.height] Example Grid with the numbers representing the heigh scale [0-9]
235
467
098
So you would have 9 Verticies
012
345
678
which requires 8 triangles to be rendered (this is the data you would put into your index buffer)
0 1 3,1 3 4,1 2 4, 2 4 5, 3 4 6, 4 6 7,4 5 7,5 7 8
Both the input and indexing are pretty simple operations the challange comes if you want to play around with the cull mode... in which case you would have to calculate the slope allong a triangle before entering the winding direction.... Anyways i hope this helps. anyways Before you commited these two data arrays (vertex and index buffer) to the mesh you could edit each verticie on its own then use setdata to put them into your mesh, then optamize the mesh and away you go.
 
hightmaps.

if you already have a hightmap, load it into a 2 dimentional byte array, then load that into a vertex buffer as make a triangle strip, the 2 dimentions x and y refer to the position, and z refers to the altitude.

this is a screen shot of the terrain i made using the exact method...
http://my.starstream.net/scorpin/ScreenShot3.jpg
 
Tutorial

There is a nice tutorial at www.32bits.co.uk(but it is in c++)containing a detailed description of algorithm to create a terrain. For me as a absolute beginner it was a great help.

Pan
 
Back
Top