Fiante Endurcie

11-23-2000, 06:43 PM

Sorry to nag you guys with this question as you may find it trivial but I have failed over and over again while trying to get my billboards going and I really really need them to do nefty special effects as it seems that they are used so often in great games for different tasks (particule systems, trees, lights etc)

What I have:

The eye position (x,y,z), the up vector for the eye.

I know how to retrieve the modelview and the projection matrix.

What I want:

After calling glLookAt and glPerspective I want to be able to draw spherical and cylindrical billboards. I want these to drawn at a given spot. By that I mean after some calls to gltranslate and glrotate I want to be able to do math equations giving me the theta needed to turn my 2 triangles so that it is flat to the camera.

I have looked in the message board alot of time and over the internet and I have not found what I was looking for. There was some code but it seemed that it didn't fit my needs.

I have tried to implement Sisgraph97 section 5.7 only to fail miserably. The code is the following on that page:

Veye = [M] [0 0 -1 0]

where M is the modelview at a given time and where [M] -1 is the inverse to that matrix (I

think). Then:

cos Theta = Veye DOT Vfront = val1

sin Theta = Veye DOT Vright = val2

where

vfront = [0 0 1]

vright = [1 0 0]

So the rotation along Y is if i am not mistaken:

sin theta / cos theta = val2 / val1

= > tetha = atan2 (val2 / val1)

It doesn't work.

I know the basic algebra:

a DOT b = ax * bx + ay * by+ az * bz = angle between 2 pts

a CROSS b = [aybz-azby bxaz-axbz axby-aybx] = An ortogonal vector between a and b (thumbs rule)

I have tried other things such as multiplying [0 0 1] and [1 0 0] by the modelview then using the same atan2 thing with the view direction only to fail again and again.

I am seeking the solution I admit defeat (and alot of wasted time) please help me!

[This message has been edited by Fiante Endurcie (edited 11-23-2000).]

What I have:

The eye position (x,y,z), the up vector for the eye.

I know how to retrieve the modelview and the projection matrix.

What I want:

After calling glLookAt and glPerspective I want to be able to draw spherical and cylindrical billboards. I want these to drawn at a given spot. By that I mean after some calls to gltranslate and glrotate I want to be able to do math equations giving me the theta needed to turn my 2 triangles so that it is flat to the camera.

I have looked in the message board alot of time and over the internet and I have not found what I was looking for. There was some code but it seemed that it didn't fit my needs.

I have tried to implement Sisgraph97 section 5.7 only to fail miserably. The code is the following on that page:

Veye = [M] [0 0 -1 0]

where M is the modelview at a given time and where [M] -1 is the inverse to that matrix (I

think). Then:

cos Theta = Veye DOT Vfront = val1

sin Theta = Veye DOT Vright = val2

where

vfront = [0 0 1]

vright = [1 0 0]

So the rotation along Y is if i am not mistaken:

sin theta / cos theta = val2 / val1

= > tetha = atan2 (val2 / val1)

It doesn't work.

I know the basic algebra:

a DOT b = ax * bx + ay * by+ az * bz = angle between 2 pts

a CROSS b = [aybz-azby bxaz-axbz axby-aybx] = An ortogonal vector between a and b (thumbs rule)

I have tried other things such as multiplying [0 0 1] and [1 0 0] by the modelview then using the same atan2 thing with the view direction only to fail again and again.

I am seeking the solution I admit defeat (and alot of wasted time) please help me!

[This message has been edited by Fiante Endurcie (edited 11-23-2000).]