# Billboarding

11 replies to this topic

### #1Smokey97

New Member

• Members
• 12 posts

Posted 04 August 2003 - 04:15 AM

hey, can someone explain ot me how todo world oriented billboarding, i read a tutorial on it, done everyhtign it said, but still didnt work... :wtf:

So i was wondering if someone could quicly explain the math of it all, or if oyu have to some sample code.... (explaining the math behind it all is prefereable)
There's only one thing we're incapable of doing; thats being incapable of doing something.

### #2davepermen

Senior Member

• Members
• 1306 posts

Posted 04 August 2003 - 01:17 PM

uhm.. just from brain, for some ideas..

your billboard has a point, where it rotates around, and a "prefered up vector"..

now, you want the point-to-cam vector, simply to_cam = normalized(cam - midpoint).
next, you want a "right" vector, wich simply is perpendicular to your to_cam and the up vector, so you use a crossproduct.. to_right = normalized(cross(to_cam,up)) (or the other way around.. don't know from brain).

finally you want to adjust your up vector (but you let the original up vector still exist..), by crossing your current to_right vector with the to_cam vector..

to_up = cross(to_right,to_cam) (again, or the other way around.. :| )

with those three, you can transform all your billboard points of that specific billboard by these 3 vectors (they build a rotational 3x3 matrix.. look up orthogonal bases.. or so).

i hope that helps a bit..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

### #3UnknownStranger

Valued Member

• Members
• 139 posts

Posted 04 August 2003 - 01:45 PM

I bet that within the next few hours at least one person comes in here and says something like "Hey cool davepermen, why don't you write an article about it?"... :P
M.E.
-----
"Human stupidity is something you can rely on." -- M.A.
"I didn't design life." -- J.G.
"It's almost finished..." -- EHD

### #4davepermen

Senior Member

• Members
• 1306 posts

Posted 04 August 2003 - 01:52 PM

because i only write snippets..

now, the question will be "why no snippet?"

answer: because right now i could not get arsed to write one..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

### #5Julio

New Member

• Members
• 7 posts

Posted 04 August 2003 - 03:46 PM

check out the billboarding tutorial at nate.scuzzy.net. it's opengl, but the theory and math carries over.
<a href='http://julio.programmers-unlimited.com' target='_blank'>My Crappy Homepage</a>

### #6Smokey97

New Member

• Members
• 12 posts

Posted 04 August 2003 - 11:53 PM

ok, well thats umm *checks code* (which i seem have to deleted sience it didnt work) *checks the tutorial he leaarned from* ok, i was doing exactly what you said, except your cross products are around hte wrong way (accordign to the billboarding tutorial on flipcode)

So either my matrix transformations are wrong (which they arent, i checked that) or my computer hates me. :lol: ...oh or i'm nto constructing the matrix correctly.

Anyway, i'll start again and if i have no luck i'll post here again with big capitol letters saying 'argh' (but alot longer ;))

P.S. i'm doing world oriented billboarding, so you use the up vector of the world, or in my case (due to the architecture of my engine) the particle system up vector; not the camera up vector
There's only one thing we're incapable of doing; thats being incapable of doing something.

### #7davepermen

Senior Member

• Members
• 1306 posts

Posted 05 August 2003 - 04:32 AM

as long as you don't overwrite your original up vector..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

### #8davepermen

Senior Member

• Members
• 1306 posts

Posted 05 August 2003 - 04:35 AM

possibly you'll have to transform by the transpose rotation matrix in the end (inverse rotation..)

i've set up some code for my raytracing cam yesterday and had to do exactly that..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

### #9davepermen

Senior Member

• Members
• 1306 posts

Posted 05 August 2003 - 06:21 AM

would be helpful btw to see whats wrong.. demo, or pics, or what ever..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

### #10starboarder2001

Member

• Members
• 35 posts

Posted 18 August 2003 - 12:08 AM

I have been doing this so far...is there anything wrong with it??
It seems to work fine.

float modelview[16];
glGetFloatv(GL_MODELVIEW_MATRIX ,modelview);

modelview[0] = 1;
modelview[5] = 1;
modelview[10] = 1;

glPushMatrix();
// -> all transformations here
// -> must do scaling here
// -> render  here
glPopMatrix();

1000
0100
0010
0001

### #11baldurk

Senior Member

• Members
• 1057 posts

Posted 19 August 2003 - 07:08 PM

if it works, why complain?

off-topic: this is my 666th post!
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

### #12davepermen

Senior Member

• Members
• 1306 posts

Posted 19 August 2003 - 08:45 PM

it depends on what you do.. it essencially sets the billboarding point, the one you rotate around, to the current 0,0,0 point of your world matrix. thats about it.. if you can life with that, fine
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users