|
buildLandscape()This function is to long to be shown in detail here, but I'll explain its main points: It uses a double for loop to loop through each point in the height field. For each point, it checks the surrounding points to see if it should split the square into two triangles, and if so, which of the two possible diagonals it should use. It must also calculate the surface normal for each square or triangle, this is set with the glNormal3f() function. The surface normal is a vector at 90 degrees to the square/triangle. It is used to calculate how light reflects off surfaces. Grab the sourceThis is all you need to build OpenGL worlds with Qt. Now, if you do a search for "OpenGL" and "tutorial" on the net, hopefully you'll be able to follow some of the more advanced tutorials out there. Oh, and by the way, here is the source: qgl-demo.tar.gz (11 kb) Released under the GPL. Requires: Qt and tmake, available from TrollTech. Qt must be compiled with OpenGL enabled. Build instructions:
If you have any questions, please post a comment to this article! Comment List
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||