billboard

BlitzMax Forums/OpenGL Module/billboard

amonite(Posted 2005) [#1]
hi,
does anyone know how to code a simple billborard ?
I spent all the weekend trying to understand tuts written in C/C++ but couldn't find any way to make a simple billboard in OpenGL using BlitzMax. (i have very poor knowledge in maths & C++)


Ibmurai(Posted 2005) [#2]
Huh? Billboard? Do you mean a textured square?


amonite(Posted 2005) [#3]
yes, exactly, a textured square (quad) that always faces the camera. i need that to try coding a small particle system using OpenGL.


amonite(Posted 2005) [#4]
As far as i know, to make a billboard i would have to know the normal of the quad and then have it match with the normal of the camera. if anyone knows how to do this in blitzMax i would be very happy if he could show me an exemple code or pseudo code.


tonyg(Posted 2005) [#5]
Have you tried...
here
and
Blitzmax specific Nehe tutorials


amonite(Posted 2005) [#6]
thank you very much tonyg for helping here :)
i've already looked through all the nehe samples and it looks like none of them are using billboards (or maybe i missed it)
i'm going to have a look at the samples on codesampler.com and hope i'll be able to do something with.
if i manage to have a working blitzmax code to make a billboard i will post it here :)


Dreamora(Posted 2005) [#7]
There are special articles on nehe.gamedev.net (under articles) that focus on billboard - particle

Perhaps you will find there what you are looking for? :-)


amonite(Posted 2005) [#8]
@Dreamora yes first place i checked, but nehe's tut 19 does not use billboards and yeah there is a great article about billboards but eventhough i somehow understand the theory behind billboards i'm having much of a trouble trying to to that in blitzMax (it's not that hard i know).
I then tried to do my particles with ARB_Point_Sprites which is supposed to be faster and easier but it happens to be an extension of OpenGL and i have to call the extension first and i don't know how to do that either.
at the moment i paused working on this till i feel more confortable with vectors (how to calculate,store and use them).
thanks for all your replies :)


salric(Posted 2005) [#9]
You can convert Nehe 19 to use billboards in the following manner:

Make your camera move etc, with keys - putting it's rotation & translation after the loadmatrix & before the loop.

In the loop itself add the lines:
glPushMatrix()
glTranslate(x,y,z)
glRotate(-camx,0.1,0,0) 'reverse rotate what your camera x
glRotate(-camy,0,0.1,0) 'reverse rotate your camera y (if you're doing this)

Modify the 4 lines of triangle strip drawing code stripping the x,y & z parameters (but keeping the signs & replacing z with 0)
i.e. glVertexf(x+0.5,y-0.5,z) becomes glVertexf(0.5,-0.5,0)

after the glEnd()
glPopMatrix()

The basic theory (although there are many ways to do billboards - this is the simplest) is to glPushMatrix(), reverse all your previous camera rotations, draw your object & then glPopMatrix() to put the model view matrix back to its previous state.

There you have it - billboards.


Skurcey(Posted 2005) [#10]
http://www.lighthouse3d.com/opengl/billboarding/


amonite(Posted 2005) [#11]
thank you very much salric and Skurcey, i'm going back to coding my particle system as soon as this evening, thanks to your piece of code + other infos i' ve found, now i feel motivated again to give it another go :)