Anyone have any decent hightmap to polygrid fpu algorithms? Post if you do. I already have some C ones, and I currently have those implemented in my program, but I want to see if there are any other ways or optimizations I didn't think of.

Thanks,
Kenny
Posted on 2001-09-04 04:05:05 by Kenny
Sorry to post when I don't have an answer, but whats a polygrid? Is this some sort of terrain heightmap which you want to view in 3D?

If you do you don't need to convert it to a height map. You can use a rendering algo which takes the location of each element of the array as x and y coords and the value of the element as z coords.
Posted on 2001-09-04 06:15:06 by Eóin
Yeah, that's exactly what a polygrid is.

Think a bunch of squares, and the height of each edge of the squares are determines by the hight of something. Right now in my program it's a raw file.

What I'm mainly asking for is implementation tips. The way to do it is to just use normal polygons, but is there some faster way to do it? I don't know, so that's why I'm asking :)
Posted on 2001-09-04 06:45:06 by Kenny
Afternoon, Kenny.

Are you talking about using Directx8, or are you going to implement the heightmap in another way?

If you are talking about Directx8, you could load the info into a vertexbuffer and use 'DrawPrimitive', or load the info into a mesh and use 'DrawSubset'.

If you want to go the Directx8 route, post the heightmap so I can come up with an algo.

Cheers,
Scronty
Posted on 2001-09-04 07:19:27 by Scronty
Ok, I was planning on doing it in DX8, and I was going to use the drawprimitave method. I was kind of unsure whether I should use triangles or trangle_strips. The trangle strip will take more FPU power, but will be less memory for the vertex buffer, and isn't as flexible for doing LOD algorithms to it.

This is the best I can come up with:

create a vertex buffer about ((4096*2)*3) ((number of vertexes*2=number of faces because of polygrid)*3 vertexes a poly)*the size of the struct in the unitialized struct section.

The triangle strip way to calculating the vertex positions is a rather complex algorithm (I have it in my head, but I don't know enough math to put it on paper).

The way to get the height values of each vertex in the raw file is like this:

;4096 vertexes or 64x64 (8 bit values)
mov addr file, esi
L1
mov offset esi, eax
fild al
fild ah
shl eax 16
fild al
fild ah
jmp L1

That's an infinite loop, so maybe make ecx hold (1024) so you and check it so you load all 4096bytes.

P.S. This is not a text file, it wouldn't let me load a .raw file.
Posted on 2001-09-04 07:33:11 by Kenny
I can only speak from OpenGL, however in OGL triangle strips are always faster. Plus they work very nicely for terrain maps.

I don't understand why they would use more FPU power in DX8. If anythiong they'd reduce it as they allow N triangles for N+1 points.

But maybe triangle strips in OGL are something completly different from what you're talking about.
Posted on 2001-09-04 11:01:42 by Eóin
In OpenGL you just make a bunch of columns or rows that make up a box....

----------------------
----------------------
----------------------

Like that... that would be 3 strips. In DirectX it would be impractical because of the overhead it takes to refill the vertex buffer then call DrawPrimitave again.

So, to use triangle strips in DX8, I need to make the entire polygrid a single row...

start here:
>----------------------|
|----------------------<
>----------------------|
End here:
Posted on 2001-09-04 11:32:14 by Kenny
Ahh, I see. Thanks for clearing that up.
Posted on 2001-09-04 12:35:13 by Eóin