Quote:
Originally Posted by mauriceatron
Hi gravity,
Perhaps, don't really remember what I was trying to achieve there as that diagram is a bit pointless except that it shows that the normal is perpendicular to a primitive's face. Also, that's a surface normal.
Nah, that section isn't my best work (not that I have any particularly good work). I'll re-write that bit.
Oh, and to answer your question, the normal is the dot product of two of the polygon's edges. That's what gives you the direction, not the right hand rule.
Simon
|
Well, I thought it was done quite well- all of your tutorials are succinct, but clear, which makes it easy to tackle one subject at a time. Especially when you bring in screenshots for when you pass differ GL_* parameters in as arguments.
The dot product actually does not return a vector, rather a scalar (which is just a number without a direction). Rather the cross product would return a direction, and using the cross product on any two sides of the polygon in order (going in a loop) will follow the right hand rule.
If somebody is reading this and doesn't know what the right hand rule is, here is a quick definition. If you were to curl your four fingers in the direction that the vertices are loaded, the normal would be in the direction of your upright thumb. It's easier to show visually, here is a quick youtube video showing this, it's the magnetic field induced by an electric current, but don't let that confuse you, just imagine the red circles as the shapes being drawn and the arrows represent the vertices, and they are pointing in the direction that they are created in your array. The blue arrow coming out orthogonal (perpendicular in 3d) from your surface is the normal.
You load the vertices in anti-clockwise direction if you were looking down upon the surface of the polygon, which defines the normal as going outwards. The right-hand rule gives you the normal, which is also the axis that glRotate() calls will rotate around (in the same anti-clockwise direction). As well, when you drop a texture onto it, it faces normal side up (or so I've been led to believe).