manual 'backface' culling
I''ve got a whole bunch of particles ''stuck'' to a rotating sphere (just rotating using glRotate and rendering as 5x5 pixel rectangles with glDrawPixels).
Now I want to cull those ones that are on the ''reverse'' side of the sphere.
So I figure I take the normal for each particle from the sphere''s surface normal(as in the file I''m loading the sphere from), project this into camera space by multiplying by GL_MODELVIEW matrix and then do a dotProduct on the result and the vector of the camera''s view direction. I''ve not changed the camera settings at all so i''ve assumed this to be (0,0,-1)
The result I get is that the particles look like they''re being clipped by a rotating clip plane, it''s kind of hard to explain. It looks like a rotating hemisphere with particles popping in and out of existance at the boundaries.
Any idea where i''ve gone wrong?
It seems like you get the particles culling state at one time and then you keep this state regardless of the modelview evolution.
You should debug the modelview matrix, eg you should look at each frame what your code uses as modelview matrix.
Also, how do you get the modelview matrix ?
Do you use glGetFloatv or glGetDoublev ?
If so, you should take care of getting GL_MODELVIEW_MATRIX, and NOT getting GL_MODELVIEW (eg take care of the syntax of the first argument passed to glGet)
Edited by - vincoof on February 12, 2002 3:30:10 PM
You should debug the modelview matrix, eg you should look at each frame what your code uses as modelview matrix.
Also, how do you get the modelview matrix ?
Do you use glGetFloatv or glGetDoublev ?
If so, you should take care of getting GL_MODELVIEW_MATRIX, and NOT getting GL_MODELVIEW (eg take care of the syntax of the first argument passed to glGet)
Edited by - vincoof on February 12, 2002 3:30:10 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement