Triangles -=BillBoarding=-

Hello,
I try to make a Billboarding effect for some triangles, but I’m not totaly sure of what
I need to do and espacialy why

Here is what I’m pretty sure :

 First, I have to find the distance between my object and the camera 
 and normalize the reusult, so :
 DistObjectToCam = CamPos - ObjectPos;
 Normalize( DistObjectToCam ); 
 Secondly, I have to set up an UP vector to my object :
 
     Object_UP = [0.0, 1.0, 0.0 );
     
 Then, I need to make the cross product 
 of [i]DistObjectToCam[/i] and [i]Object_UP[/i] to get a perpendicular vector
 to my camera.
      
     PerpenVect = CrossProduct( DistObjectToCam, Object_UP );
     Normalize( PerpenVect );
     
 [b]Here is what I'm not sure to understand...[/b]

 I have to get the RIGHT vector of my object (Triangle)
 
     Object_RIGHT.x := PerpenVect.x * (WidthTriangle / 2);
     Object_RIGHT.y := PerpenVect.y * (HeightTriangle / 2);
     Object_RIGHT.z := PerpenVect.z * (WidthTriangle / 2);
     
 After, I need to get the UP vector of my object : 
 
     Object_UP.x = 0.0; 
     Object_UP.y = 1.0 * (HeightTriangle / 2);
     Object_UP.z = 0.0; 
     
 To finish, I just have to draw the triangle...
 
     glPushMatrix();
     glBegin( GL_TRIANGLES );
          glVertex3d( ObjectPos.x - Object_RIGHT.x + Object_UP.x),
                      ObjectPos.y - Object_RIGHT.y + Object_UP.y),
                      ObjectPos.z - Object_RIGHT.z + Object_UP.z));

          glVertex3d( ObjectPos.x + (Object_RIGHT.x - Object_UP.x),
                      ObjectPos.y + (Object_RIGHT.y - Object_UP.y),
                      ObjectPos.z + (Object_RIGHT.z - Object_UP.z));

          glVertex3d( ObjectPos.x + (Object_RIGHT.x + Object_UP.x),
                      ObjectPos.y + (Object_RIGHT.y + Object_UP.y),
                      ObjectPos.z + (Object_RIGHT.z + Object_UP.z));
        glEnd();
     glPopMatrix();
     

Thanks
Martin

Oups… I forgot to specify that I need a sperical BillBording cause my camera move UP and DOWN…

If it’s possible, I would like that one helps me with the way that I proceed…

A BIG BIG thanks
Martin.

check out this link
http://www.lighthouse3d.com/opengl/index.shtml

Thanks, for the link but I already have it. The problem ist that I want to modify the triangle vertex depend the position of the camera.

In the 3D Tech tutorial, It’s the camera position that is modify to rotate the object (glRotate*) face to the camera…

Thanks
Martin

There is no “camera” in OpenGL. How you interpret a modelview matrix rotation is really a matter of semantics. What one person calls a rotation of the camera, another could call an opposite rotation of a face.

[This message has been edited by DFrey (edited 12-21-2001).]