
ModelView Matrix in OpenGL
The issue is this: I want to do backface culling without writing a 3D engine from scratch. I have calculated normals for all my triangles, but in the basis of the World Coordinates (WC). When I want to do my B-Face check it''s simple in the Observer''s Coordinates (OC) because all you need to do is check that the normal''s z-component is greater than zero.
So how do I get the ModelView Matrix so I can change basis from WC to OC?
Can I instead just locate the observer and calculate the ModelView matrix? If so, how do I locate the variables "eye" (vector pointing on observer''s location) and "at" (vector looking at somewhere from observer''s location)?
Or is there a better way of doing this?
Thank you if you share the wisdom
/para (n00bish)

Backface culling is done automatically in OpenGL and in hardware on cards that support it. Don't do it yourself.
EDIT:
Thats not much information
The method used does not rely on the normal (so you don't need to calculate or pass them in), it instead uses the windings of the faces (either clockwise or counter-clockwise).
BTW simply checking the z component of the normal in eye (observer) space is *not* accurate. Draw it out and you'll see.
[edited by - JuNC on April 13, 2003 9:16:52 AM]
EDIT:
Thats not much information

BTW simply checking the z component of the normal in eye (observer) space is *not* accurate. Draw it out and you'll see.
[edited by - JuNC on April 13, 2003 9:16:52 AM]
Call glEnable( GL_CULL_FACE) and the video card will handle back face culling for you.
ok, I think I get it... glEnable(DEPTH_TEST) isn''t it?
However, it seems it doesn''t work however, because when I plot my traingulated landscape sometimes the hills behind a mountain erases the mountain itself (which is in the foreground) that is why I don''t want to paint them out, nor calculate light on them.
What''s wrong I wonder..?
However, it seems it doesn''t work however, because when I plot my traingulated landscape sometimes the hills behind a mountain erases the mountain itself (which is in the foreground) that is why I don''t want to paint them out, nor calculate light on them.
What''s wrong I wonder..?
got it!
seems like I had misplaced the order of the triangles.
Even though I followed NeHe''s instructions in Lesson19! I must be seriously brain damaged, or maybe it isn''t so easy after all.
seems like I had misplaced the order of the triangles.
Even though I followed NeHe''s instructions in Lesson19! I must be seriously brain damaged, or maybe it isn''t so easy after all.
quote:
Original post by parazyte
ok, I think I get it... glEnable(DEPTH_TEST) isn''t it?
The depth test is another thing.
Backface culling discards triangles that aren''t facing the camera since they won''t be visible, no matter how near/far they are from the camera. It''s a per triangle operation.
The depth test makes sure that far objects don''t hide closer objects. It''s a per fragment operation.
You seem a bit confused. Although NeHe''s tutorials are great for a quick start you should really read the Red Book to improve your "theorical" knowledge. A free online version is available here.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement