Advertisement

Calculating vertex and surface normals

Started by February 05, 2000 03:39 PM
1 comment, last by 3dModelMan 25 years, 1 month ago
I''m working on a terrain system using series of quad polys within DX7.0 and I''m struggling with the vertex normals. As the ground need never be sloping at an angle over 45 degrees I could possibly get away with one vertex normal that points straight up (positive y) - can anyone show me what this would be in a D3DVERTEX structure? I would also like the option of splitting the normals of adjacent surfaces to make the gourad shading look better, so given three vertices, how do I find a surface normal for this triangle? Any help or pointers to further information will be gratefully received. Thanks Matt
Anyone?
Advertisement
A normal to a triangle is computed with the crossproduct of two of the edges. Check the DirectX SDK for more info on this.

In direct3D you can compute the normal to three vectors V0, V1, V2 with this formula:

D3DVECTOR A = V1 - V0;
D3DVECTOR B = V2 - V0;
D3DVECTOR N = CrossProduct(A,B);
N = Normalize(N);

Hope this helps.

ps. I''m sorry to say this, but this is a question that won''t gain you too much respect as it is very easy to find the information yourself, in books or on the net.

This topic is closed to new replies.

Advertisement