Billboarding
I want to figure out how to use billboarding. The only tutorial on the net I can find is Nate''s billboarding tutorial but it uses Glut, and I don''t use Glut because I was under the impression that it does alot of win32 code for you and I don''t want to skip that as its a learning thing. Anyways, does anyone know of a tutorial or place I can find out how to do billboarding without Glut.
Thanks
March 08, 2001 10:42 PM
http://nate.scuzzy.net/particles/particles.zip
Look in particle.cpp. You are better off using GLUT though. Just forget about Win32 for now and come back to it later. Focus on learning OpenGL and the nuances of 3D graphics, once you have that down then you can worry about Win32.
Look in particle.cpp. You are better off using GLUT though. Just forget about Win32 for now and come back to it later. Focus on learning OpenGL and the nuances of 3D graphics, once you have that down then you can worry about Win32.
I am wondering how to billboard when using a 3D world kina program because the objects are being rotated all over the place because they are moving and not the camera.......ahhhhhhhhhh I am confusled.
Also, I seen "The Red Book" on the net but can''t find the "aux.h" file anywhere that it uses, it seems their ftp site is down or so Go!zilla tells me anyway.
Thanks
Also, I seen "The Red Book" on the net but can''t find the "aux.h" file anywhere that it uses, it seems their ftp site is down or so Go!zilla tells me anyway.
Thanks
Well a billboard is simply a textured polygon which always faces the camera. So in essence grab the normal of the polygon in order to find out if it''s facing the view port. If not rotate the object until it''s normal is facing the view port.
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
I had this problem some weeks ago, here''s an simple solution I''ve found over this forum:
// Draw billboarded particles: (The particle looks always into the camera)
vect3f tl, tr, bl, br;
vect3f ptl, ptr, pbl, pbr;
vect3f x, y;
float m[16];
glGetFloatv(GL_MODELVIEW_MATRIX, m);
// Get x/y:
x(m[0], m[4], m[8]);
y(m[1], m[5], m[9]);
tl = (x - y) * .02;
tr = (x + y) * .02;
bl = (-x - y) * .02;
br = (-x + y) * .02;
glBegin(GL_QUADS);
for(i = 0; i < MAX_PARTICLES; i++)
{
ptl = Particle.pos + tl;
ptr = Particle.pos + tr;<br>pbl = Particle.pos + bl;<br>pbr = Particle.pos + br;<br><br>glTexCoord2f(0, 1);<br>glVertex3fv(ptl);<br><br>glTexCoord2f(1, 1);<br>glVertex3fv(ptr);<br><br>glTexCoord2f(1, 0);<br>glVertex3fv(pbr);<br><br>glTexCoord2f(0, 0);<br>glVertex3fv(pbl);<br>}<br>glEnd();<br><br><br>It''s easy and it works! </i>
// Draw billboarded particles: (The particle looks always into the camera)
vect3f tl, tr, bl, br;
vect3f ptl, ptr, pbl, pbr;
vect3f x, y;
float m[16];
glGetFloatv(GL_MODELVIEW_MATRIX, m);
// Get x/y:
x(m[0], m[4], m[8]);
y(m[1], m[5], m[9]);
tl = (x - y) * .02;
tr = (x + y) * .02;
bl = (-x - y) * .02;
br = (-x + y) * .02;
glBegin(GL_QUADS);
for(i = 0; i < MAX_PARTICLES; i++)
{
ptl = Particle.pos + tl;
ptr = Particle.pos + tr;<br>pbl = Particle.pos + bl;<br>pbr = Particle.pos + br;<br><br>glTexCoord2f(0, 1);<br>glVertex3fv(ptl);<br><br>glTexCoord2f(1, 1);<br>glVertex3fv(ptr);<br><br>glTexCoord2f(1, 0);<br>glVertex3fv(pbr);<br><br>glTexCoord2f(0, 0);<br>glVertex3fv(pbl);<br>}<br>glEnd();<br><br><br>It''s easy and it works! </i>
Or do a load-identity on the rotation part of your matrix.
In other words - do a load-identity, but save the position, and translate afterwards...
It''s even easier if you have your matrix saved somewhere.
In other words - do a load-identity, but save the position, and translate afterwards...
// your matrix just before drawingfloat M[16];glGetMatrixfv(GL_MODELVIEW_MATRIX, M);glLoadIdentity();glTranslatef(M[12], M[13], M[14]);// your matrix billboardedglVertex...
It''s even easier if you have your matrix saved somewhere.
March 09, 2001 05:28 PM
To AblazeSpace,
The section that you wrote with particle.pos, what is this exactly. You''ll have to excuse my apparent dumbness, but I''m new to opengl and I up to now have used simple coordinated in my vector positions instead of using ''v'' and using a pointer, if you know what I mean. In this section you are adding what seems to be,.......in fact I dunno. Could you tell me what particle.pos is exactly so I can work this out in my head. How dumb do I look? >:o|
Thanks again
The section that you wrote with particle.pos, what is this exactly. You''ll have to excuse my apparent dumbness, but I''m new to opengl and I up to now have used simple coordinated in my vector positions instead of using ''v'' and using a pointer, if you know what I mean. In this section you are adding what seems to be,.......in fact I dunno. Could you tell me what particle.pos is exactly so I can work this out in my head. How dumb do I look? >:o|
Thanks again
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement