rotating a polygone as camera moves
hi..
in my opengl demo i have a camera based on vectors.and i have a polygone. i want my polygone to look at me(camera position) whereever i go in the scene.in other words the polygone will rotate as my camera position change.how i can i do this.thanks...
Ahhhhhh, die one word suggestion man! 
Actually I''ve been kind''ve looking for an answer to this question for my particle engine and I don''t think 1000 rotations sounds like a good idea. I saw a reference to that term, "Billboarding", in the Redbook but the explanation was far too vague. Will someone please elaborate...
Thanks in advance.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________

Actually I''ve been kind''ve looking for an answer to this question for my particle engine and I don''t think 1000 rotations sounds like a good idea. I saw a reference to that term, "Billboarding", in the Redbook but the explanation was far too vague. Will someone please elaborate...
Thanks in advance.

_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
OK, I''m just going to say something so that this thread stays alive. I remember the picture that was supposed to illustrate billboarding implied blending two intersecting polygons together...however I''m not entirely sure if its even possible to do that correctly. Will someone please elaborate?
Hopefully the site isn''t going to update right after my post again!
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
Hopefully the site isn''t going to update right after my post again!

_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
You could just download the source for chapter 15 of the "OpenGL Game Programming book" and see how Billboarding works ... i can''t explain it in my own words and i strongly suggest reading this book ... but perhaps i didn''t understand you (because it''s not my native language) ...
What''s the deal? I''ve seen many people use this term in the past, yet anytime I ask about the subject nobody even opens their mouth as if they were about to say something. I know that this has to be one of those stupid little cheap tricks, but I must know what it is and how to use it. Ahhhhhhhhhh, this would be similar to a programming traffic jam: I''m not getting anywhere and I fear I may start to go backwards soon. 
Will someone at least throw me a link (thought I was going to say bone didn''t you?)
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________

Will someone at least throw me a link (thought I was going to say bone didn''t you?)

_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
You just need the up and right vectors of the model-view
// get the modelview matrix
float mat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mat);
// get the right and up vectors
Vector3D right;
right.fX = mat[0];
right.fY = mat[4];
right.fZ = mat[8];
Vector3D up;
up.fX = mat[1];
up.fY = mat[5];
up.fZ = mat[9];
glTranslatef( pTree->fPosX, pTree->fPosY, pTree->fPosZ );
glBegin(GL_QUADS);
glVertex3f(pTree->fPosX + (-right.fX - up.fX), (pTree->fPosY) + (-right.fY - up.fY), pTree->fPosZ + (-right.fZ - up.fZ));
glVertex3f(pTree->fPosX + (right.fX - up.fX), (pTree->fPosY) + (right.fY - up.fY), pTree->fPosZ + (right.fZ - up.fZ));
glVertex3f(pTree->fPosX + (right.fX + up.fX), (pTree->fPosY) + (right.fY + up.fY), pTree->fPosZ + (right.fZ + up.fZ));
glVertex3f(pTree->fPosX + (up.fX - right.fX), (pTree->fPosY) + (up.fY - right.fY), pTree->fPosZ + (up.fZ - right.fZ));
glEnd();
Obviously a (pTree) is my object that has it''s own position vectors
// get the modelview matrix
float mat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mat);
// get the right and up vectors
Vector3D right;
right.fX = mat[0];
right.fY = mat[4];
right.fZ = mat[8];
Vector3D up;
up.fX = mat[1];
up.fY = mat[5];
up.fZ = mat[9];
glTranslatef( pTree->fPosX, pTree->fPosY, pTree->fPosZ );
glBegin(GL_QUADS);
glVertex3f(pTree->fPosX + (-right.fX - up.fX), (pTree->fPosY) + (-right.fY - up.fY), pTree->fPosZ + (-right.fZ - up.fZ));
glVertex3f(pTree->fPosX + (right.fX - up.fX), (pTree->fPosY) + (right.fY - up.fY), pTree->fPosZ + (right.fZ - up.fZ));
glVertex3f(pTree->fPosX + (right.fX + up.fX), (pTree->fPosY) + (right.fY + up.fY), pTree->fPosZ + (right.fZ + up.fZ));
glVertex3f(pTree->fPosX + (up.fX - right.fX), (pTree->fPosY) + (up.fY - right.fY), pTree->fPosZ + (up.fZ - right.fZ));
glEnd();
Obviously a (pTree) is my object that has it''s own position vectors
i do it a completely different way. it seems a lot easier but it might not be the bes way. ok, the only var you need is a
float playerRot
that that keeps track of the rotation var. they when you go to draw your object, rotate it the oposite of the playerRot var:
glPushMatrix();
glRotatef(-playerRot,0,1,0);
//draw you shape
glPopMatrix();
that it. -PmanC
float playerRot
that that keeps track of the rotation var. they when you go to draw your object, rotate it the oposite of the playerRot var:
glPushMatrix();
glRotatef(-playerRot,0,1,0);
//draw you shape
glPopMatrix();
that it. -PmanC
Thanks a lot BiGCyC!!!!!!!!
I''m not really sure why that code works but it works perfectly. All I had to do was optimize the code for a loop structure and substitute in my variables and it worked! I''ve got a question though...that code looks a lot simpler than some of the code I was scanning through earlier (all kinds of vector and matrix functions) and the "cheating" methods didn''t work for my problem. Are their any assumptions being made in this code (i.e. the texure must have a radial and vertical and horizontal symetry, the camera can''t be moved in a certain way, or you can use the scaling function)? Also, is there any way I can find out why this works (this isn''t essential to know, but I''m a bit of a proof freak)?
Thanks for the suggestions guys, I''m sure that the original poster has his answer as well. THANKS, Thanks, thanks, thnks, tnx, ...
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
I''m not really sure why that code works but it works perfectly. All I had to do was optimize the code for a loop structure and substitute in my variables and it worked! I''ve got a question though...that code looks a lot simpler than some of the code I was scanning through earlier (all kinds of vector and matrix functions) and the "cheating" methods didn''t work for my problem. Are their any assumptions being made in this code (i.e. the texure must have a radial and vertical and horizontal symetry, the camera can''t be moved in a certain way, or you can use the scaling function)? Also, is there any way I can find out why this works (this isn''t essential to know, but I''m a bit of a proof freak)?
Thanks for the suggestions guys, I''m sure that the original poster has his answer as well. THANKS, Thanks, thanks, thnks, tnx, ...

_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement