I have the following function for creating a mesh .I want to make this mesh into 3D terrain.What additions should be make in the following code.I want to create Height fields from this rectangular mesh.How to do that.
I avoid code dumps from other people like the plague however, some at-first-glance-hints
1- Use vertex arrays. Compute once and reuse.
2- “/ 2.0” is evil: “* .5f” is much better.
3- My terrain renderers does not have constants in them. Do you really need?
How to turn a mesh in a terrain?
Depending on how much “elegant”, “nice”, “fast”, “portable” your code is meant to be there may be different apporoaches.
What you are probably asking is to do a brute-force renderer. In that case, you just have to create WxH vertices for a WxH heightmap. Then, look pixel (w,h) from the image and put its value (after adeguate processing) in vertex (w, h), Y coordinate.
If you want to just code fast you can do it in less than a week. If you want to have something elegant, it may take longer. If you want it to be fast it will take much longer.