Hi all, I’m trying to get comfortable with matrix manipulation and stuff, so I thought I’d have a go at backface culling an object thats been transformed and rotated by the modelview matrix.
I have the viewing position set at the default 0,0,0 looking down the –z axis, this stays put and is not transformed.
If I use the code below to cull the backfaces this works fine when the object is drawn in its default position, but obviously when I rotate the object the viewPos vector has no way of knowing how the object has been transformed, say for example I’m displaying a ball, alls I’m getting is a half ball rotating around.
viewPos.set (0, 0, -1);
if(dot < 0) draw face
I’m guessing I need to perform some magic with the modelview matrix and the viewPos vector but I’m not sure what exactly, I’ve tried setting the viewPos to x =ModelMatrix., y=ModelMatrix., z=-ModelMatrix., this culls the backfaces if I rotate on X while the other rotation angles are set to 0 and likewise, but as soon as more than two rotation angles are none 0 it all goes wrong.
So anyone got any ideas of what I need to do?