how to calculate vertex normal?

This topic is 3471 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Can anyone help me on how to calculate the vertex normal, for instance if i want to calculate the vertex normal of each vertex of a cylinder, also if one can provide me some good articles/tutorials regarding lights in direct3d, as i have understood it is one of the toughest topics in game programming, it would be very helpful.

Share on other sites
Say your cylinder is y-axis-aligned (y pointing up), I mean, with the two disks being parallel to the xz-plane (so their surface normals point up/down), and the main axis of the cylinder going through the point (0,0,0), then the normal for each vertex is just it's position on the xz-plane, and then normalised: n = v(x,0,z) / length (v (x,0,z)). Plugging y into that formula gives you spherical normals.

If you are creating the cylinder using sin/cos methods, then make it on the fly like:
normal.x = cos (angle)normal.z = sin (angle)normal.y = 0x = radius * normal.xy = <some height>z = radius * normal.z

The normals of the disks are then (0,1,0) and (0,-1,0).

1. 1
Rutin
25
2. 2
JoeJ
20
3. 3
4. 4
5. 5

• 9
• 9
• 46
• 41
• 23
• Forum Statistics

• Total Topics
631750
• Total Posts
3002055
×