Original Post
I''ve made an algorithm to show always the polygon faceing to the camera....
here is the algorithm:
posx,posy and posz are the position of the polygon.
difx=CAM[actual].posx-posx;
dify=CAM[actual].posy-posy;
difz=CAM[actual].posz-posz;
if (difz==0) {
if (difx>=0) yaw=-3.14/2;
else yaw=-3*3.14/2;
if (dify>=0) pitch=-3.14/2;
else pitch=-3*3.14/2;
}
else {
yaw=-atan(difx/difz);
pitch=-atan(dify/difz);
}
if (difz<0) {
rotx=pitch*180/3.14+180;
roty=yaw*180/3.14+180;
}
else {
rotx=pitch*180/3.14;
roty=-yaw*180/3.14+180;
}
glLoadIdentity();
gluLookAt(CAM[actual].posx,
CAM[actual].posy,CAM[actual].posz,
CAM[actual].x,CAM[actual].y,
CAM[actual].z,0,1,0);
glTranslatef(posx,posy,posz);
glRotatef(rotx,1.0f,0.0f,0.0f);
glRotatef(roty,0.0f,1.0f,0.0f);
well... here is the problem... When the -1