# Geometry problem

I’d like to draw an object which always face the camera. Because my english is not so good, i attached three shots of what i’d like to achieve. As you can see i’d like to render an object (also a simple quad, represented by the orange box) which has the position and orientation shown in the shots.
Billboarding wouldn’t do, because i lose one axis.
http://www.web-discovery.net/temp/1.jpg http://www.web-discovery.net/temp/2.jpg http://www.web-discovery.net/temp/3.jpg

Just do an additional negative rotate on your modelview matrix after the translation e.g.

glMatrixMode(GL_MODELVIEW);
glRotatef(Viewangle,ViewX,ViewY,ViewZ);
glTranslatef(PosX,PosY,PosZ);
glRotatef(-Viewangle,ViewX,ViewY,ViewZ);

multiply by the inverse for the rotational part (upper 3x3) of your lookat matrix:

gluLookAt(…);
glMultMatrixd(lookatmat.invrot);

[This message has been edited by tellaman (edited 11-29-2003).]

hi tellaman, i suppose i should use the glMultMatrix function ? could you make an example please ?

Hi, i’ve been trying all the evening and finally i get the quad always facing the camera. The last problem is that i’d like to position the quad near the tail of the aircraft (while now is centered in the middle of it). I’ve been trying to move it along the z axis, but i am not able to do it, it always remain centered in the middle of the aircraft. Here is my code:

glTranslatef(x,y,z); // this has no effect, doesn’t move the quad
glRotatef(cameraz_pov, 0.0, 0.0, 1.0);
glRotatef(camerax_pov, 1.0, 0.0, 0.0);
glRotatef(cameray_pov, 0.0, -1.0, 0.0);
glGetDoublev(GL_MODELVIEW_MATRIX,m_mt) ; // get current matrix

// start calculate inverse matrix
result_mt=m_mt;
result_mt=m_mt;
result_mt=m_mt;
result_mt=0.0f;
result_mt=m_mt;
result_mt=m_mt;
result_mt=m_mt;
result_mt=0.0f;
result_mt=m_mt;
result_mt=m_mt;
result_mt=m_mt;
result_mt=0.0f;
result_mt=-(m_mt*m_mt)-(m_mt*m_mt)-(m_mt*m_mt);
result_mt=-(m_mt*m_mt)-(m_mt*m_mt)-(m_mt*m_mt);
result_mt=-(m_mt*m_mt)-(m_mt*m_mt)-(m_mt*m_mt);
result_mt=1.0f;
// end calculate inverse matrix

glMultMatrixd((GLdouble *)result_mt); // multiply matrix