hello,

i got some different questions about WM:

i guess you are using OpenGL…

are you rendering QUADS or TRIANGLES?

how did you get the shading of the terrain?

thanks.

hello,

i got some different questions about WM:

i guess you are using OpenGL…

are you rendering QUADS or TRIANGLES?

how did you get the shading of the terrain?

thanks.

Hi emzic,

the implementation of the OpenGL view is dirt simple, since visualization is not really WM’s specialty. The landscape is rendered brute-force style, with each pair of rows forming a triangle strip. The terrain color is determinated by altitude (the color map), and then modulated by the lighting (Simple dotproduct lighting based on the sun angle).

thanks a lot for the answer.

so you get the normal of each vertex by doing a dot-product of … what?

sorry, im very new to rendering, but interested.

The vertex normals are actually computed by finding the X and Y slopes at that point in the heightfield, and then turning that into a vector. IE, if you have a set of points specified by (x,y), and the current location in the heightfield is (a,b), then the slopes are found by (a+1, b) - (a-1, b) in the X direction, and (a, b+1) - (a, b-1) in the Y.

The vertex normal vector is then dotted with the sun vector to create a value 0…1 that describes how directly the two vectors are in alignment. This is directly used for diffuse shading.

thanks a lot for the answer so far!!!

how do you turn the slopes into a vector exactly?

and for the second part? dotting the normal vector with the sun… isnt that done automatically by OpenGL?

thanks!

Hi,

Excuse a newbie question once again. I want to take the mesh output from WM and generate it in OpenGL ES. Let me see if I’m following you: you take two rows a time of the array and tell OpenGL to render them as a triangle strip, then repeat this through the array? I’m confused.

I’ve managed to parse a 32 x 32 .obj file (small for testing) into an array of floats but I’m unsure what to do with it. Is there a bit of sample code somewhere that takes this array of floats and renders it?

Thanks, I know these are awfully basic questions.

You mean float like… one single float value containing the “height”?

Make yourself a small sketch of what you are trying to do and ask yourself how the position in the array and the associated height translate into (x,y,z) coordinates. For example if your array works something like this: `float array[32][32]; array[a][b]=height_at_that_position`

you could simply use (a,b,c) as the coordinates of that vertex and work on from there.

No, as in an array of vertexes for rendering as triangle strips.

I figured it out, wow, that was interesting! I know a whole lot more about how OpenGL works now, lol…

I basically read the data in, reformatted it into triangle strips, and linked the triangle strips with degenerate triangles, and presto.