Original Post
🔒 Locked
Normal vector
Advertisement
You''ll want to use the crossproduct, like so:
VECTOR V1,V2,V3, N;
N = Normalize(CrossProduct(V2-V1,V3-V1));
Remember that the direction of the normal depends on the order of its arguments so you must be consistent in the ordering.
VECTOR V1,V2,V3, N;
N = Normalize(CrossProduct(V2-V1,V3-V1));
Remember that the direction of the normal depends on the order of its arguments so you must be consistent in the ordering.
That doesn''t calculate the normals, it only normalizes them.
D3DRENDERSTATE_NORMALIZENORMALS should be set to true as your Direct3D drivers are usually much faster at normalizing than anything you can do yourself (unless you do some insane optimizations
). However, for the lighting to work you have to calculate the direction of the surface normal, and that is computed with the crossproduct as in my above answer.
The D3DRENDERSTATE_NORMALIZENORMALS state is usually used to be able to keep the right magnitude of the normals after transformations, for example scaling.
The D3DRENDERSTATE_NORMALIZENORMALS state is usually used to be able to keep the right magnitude of the normals after transformations, for example scaling.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement