• Advertisement

Archived

This topic is now archived and is closed to further replies.

Quads facing at the camera

This topic is 6046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Any tutorial somewhere where is explained how to make quads, triangles, polygons, whatever always facing at the camera? Or if someone can help me with this. -- YartZ

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You can try this http://nate.scuzzy.net/docs/billboard/ and this http://nate.scuzzy.net/gltut/billboard.zip.

Share this post


Link to post
Share on other sites
Call this just before you draw the quad:


void Billboard(void)
{
float temp[16]={ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, m[16];

glGetFloatv(GL_MODELVIEW_MATRIX, m);

temp[0]=matrix[0];
temp[1]=matrix[4];
temp[2]=matrix[8];
temp[4]=matrix[1];
temp[5]=matrix[5];
temp[6]=matrix[9];
temp[8]=matrix[2];
temp[9]=matrix[6];
temp[10]=matrix[10];

glMultMatrixf(temp);
}

Share this post


Link to post
Share on other sites
Is that faster than:

glGetFloatv(GL_MODELVIEW_MATRIX,m);
glLoadIdentity();
glTranslatef(m[12],m[13],m[14]);

?


Or do they do different things?



I do a LOT of these in my game, so maybe I''ll go ahead and try the other method to see if I can get a speed improvement...

Share this post


Link to post
Share on other sites
Thank you verymuch. I''ll try these when I have time.

-- YartZ

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i have been messing with a program for a long time & cant seem to see the problem . the blue book thingy i downloaded from the www doesnt explain what the APIs do in realistic terms so im not sure what i am doing . i want to make 3D objects from 2D polygons using the maximum amount so the objects can be taken apart . i want the polygons to always face forwards but the objects have to rotate etc. . i want to make a loop so i dont have to rewrite the gltranslate x,y,z etc. more than once . i want it to be taken care of so all i have to do is program like i am using DMA with algebra,trig,logic in masm32 with formulas .
is that @ all possible ? what is , what isint ?
> steverowe5@aol.com or hotmail
are there any more explanitory examples of these APIs ?
i am a programmer only when there is documentation that is defined or with definitions .

Share this post


Link to post
Share on other sites
What you''re talking about is billboarding. Check this out
:

http://reality.sgi.com/blythe/sig99/advanced99/notes/node73.html

Share this post


Link to post
Share on other sites
quote:
Original post by NitroGL
Call this just before you draw the quad:


void Billboard(void)
{
float temp[16]={ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, m[16];

glGetFloatv(GL_MODELVIEW_MATRIX, m);

temp[0]=matrix[0];
temp[1]=matrix[4];
temp[2]=matrix[8];
temp[4]=matrix[1];
temp[5]=matrix[5];
temp[6]=matrix[9];
temp[8]=matrix[2];
temp[9]=matrix[6];
temp[10]=matrix[10];

glMultMatrixf(temp);
}



What is that matrix[x] thing?

-- YartZ

Share this post


Link to post
Share on other sites
It works now, but not like I want it to. I need to make it like in Wolf3d or Doom.

Screenshot from my product:
http://mbnet.fi/yartz/gaeh.jpg

Now it goes around circle when its X or Z is more than 0 and I think I have to somehow lock the Y. If anyone can help me with this?

-- YartZ

Edited by - YartZ on July 26, 2001 7:02:37 PM

Edited by - YartZ on July 26, 2001 7:03:34 PM

Share this post


Link to post
Share on other sites
quote:
Original post by Parveen Kaler
I think he meant m[x] instead of matrix[x].


Yeah, opps

I guess I missed something when I posted the code

Share this post


Link to post
Share on other sites
If I understand, you''re saying you want it only to aim at the camera in regards to a Y-Rotation, but X and Z should be normal. (Assuming Y is up). Like Doom''s sprites. Of course, Doom had no camera rotation which would illustrate the problems in this technique...

While I think I understand the problem, I don''t know the fast efficient solution. I''m sure there''s one related to the matrix transposing technique above...

Share this post


Link to post
Share on other sites
Hey!
I''m writing a tutorial for NeHe which, amongst other things, adds a particle engine to lesson 10, I needed to make the particles face the camera so I will make a point of explaining it. I can only quickly tell you here how I did it but I can say off the top of my head that I used the code from lesson 10 to move forward and back. all that sin() and cos() stuff. I hacked that into the drawing code for glvertex3f in the drawing of the triangle strip. What it does is rotate the quad (by changing the coordinates appropriately) by how much YOU have turned. You''ll maybe understand in the tut .

baldurkarlsson

Share this post


Link to post
Share on other sites
Try something like:


float m[16],angle;

glGetFloatv(GL_MODELVIEW_MATRIX,m);

angle = atan2(m[12],m[14])*180.0/M_PI;

glRotate(angle, 0.0, 1.0, 0.0);


You might try swapping m[12] and m[14], or inverting, or adding 90/180/270 to the angle value...

I just made this up off the top of my head, so maybe it''s totally wrong...

Share this post


Link to post
Share on other sites
check out my new class on my new page. =)


Never underestimante the power of stupid people in large groups.

Share this post


Link to post
Share on other sites
Julio, can''t download that on your page. Link is broken :I

-- YartZ

Share this post


Link to post
Share on other sites
hmm, I''ll check that out.


Never underestimante the power of stupid people in large groups.

Share this post


Link to post
Share on other sites
seems to work ok for me. I''ll e-mail you the file.


Never underestimante the power of stupid people in large groups.

Share this post


Link to post
Share on other sites

  • Advertisement