Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am trying to make an axis-aligned billboard with Pyglet. I have looked at several tutorials, but they only show me how to get the up, right, and look vectors. So far this is what I have:

target = cam.pos
look = norm(target - billboard.pos)

right = norm(Vector3(0,1,0) * look)
up = look * right

gluLookAt(
  look.x, look.y, look.z,
  self.pos.x, self.pos.y, self.pos.z,
  up.x, up.y, up.z
)

This does nothing for me visibly. Any idea what I'm doing wrong?

share|improve this question
1  
gluLookAt defines where your camera is looking at, not where the object is facing. –  Jimmy Sep 12 '12 at 17:15
    
Typically, when one says "axis aligned", they are referring to the global axis. I know that you mean the axis of the camera, but it'll be good to know for future reference. –  Byte56 Sep 12 '12 at 17:37
    
will do... thank you –  user19787 Sep 17 '12 at 2:57
add comment

1 Answer

up vote 2 down vote accepted

I tried out billboards a while back. I just created a quad that faced the camera. Using the position I want the object at and the up and right vectors (normalized) of the camera, you can set the four corners of the quad like so:

a = position - ((right + up) * scale);
b = position + ((right - up) * scale);
c = position + ((right + up) * scale);
d = position - ((right - up) * scale);

Where a, b, c and d define the corners, use them clockwise or counter-clockwise depending on the winding order of your graphics library.

The right can be derived from the cross product or the look and the up vectors.

share|improve this answer
    
this is how I've done it as well, you might want to add that you can derive 'right' based on the cross product of the camera direction versus "true up", etc. –  Jimmy Sep 12 '12 at 17:19
    
awesome... thanks –  user19787 Sep 12 '12 at 17:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.