- // Calculate and set the normal for height map entry (x,y)
- void terrain::set_normal(int x, int y)
- {
- //Vektor in X-Richtung
- vec3d vec_x((double)x,0.0f, 0.0f);
- //Vektor in Z-Richtung
- vec3d vec_z(0.0f, 0.0f, get_heightmap_value(x, y));
- //Kreuzprodukt
- vec3d vec_normal = cross(vec_x, vec_z);
- vec_normal.normalize();
- //Übergabe an OpenGL
- glNormal3f(-vec_normal.x(), -vec_normal.y(), -vec_normal.z());
- }