Billboarding Problem
Hi All. I have one question about Billboard. I''m implementing a particles system and I have
some problems with the orientation of this particles with respect to the camera.
First of all, my Draw() function is basically:
Draw()
{
PrincipalView->View(false); // Render all the object in the scene
ParticleSystem->Update(fTime,Pitch,Yaw);
ParticleSystem->Draw();
TextOnScreen->Update();
}
And the View(bool Lights) is:
View(bool Lights)
{
...
glLoadIdentity();
glClearColor( fBackGroundColor.r, fBackGroundColor.g,fBackGroundColor.b,fBackGroundColor.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
float y = RAD2DEG(m_kCamera->m_Position.GetRotY());
RotarAngulo(y,180);
glRotatef(RAD2DEG(m_kCamera->m_Position.GetRotZ()),0,0,-1);
glRotatef(RAD2DEG(m_kCamera->m_Position.GetRotX()),-1,0,0);
glRotatef(y,0,-1,0);
glTranslatef( -m_kCamera->m_Position.GetPosition().GetX(),
-m_kCamera->m_Position.GetPosition().GetY(),
-m_kCamera->m_Position.GetPosition().GetZ() );
m_kFrustum.UpdateFrustum();
...
(( Render all object))
...
}
Finally the ParticleSystem->Draw()
for (i= 0; i < MAX_PARTICLES; i++)
{
...
glPushMatrix();
glTranslatef(m_rParticles.m_vPosition[0],
m_rParticles.m_vPosition[1],
m_rParticles.m_vPosition[2]);
glRotatef(Yaw,0.0f,1.0f,0.0f);
glRotatef(Pitch,1.0f,0.0f,0.0f);
glPopMatrix();
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(1.0f, 1.0f); glVertex3f( m_rParticles.m_fTamano, m_rParticles.m_fTSize, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-m_rParticles.m_fTamano, m_rParticles.m_fSize, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( m_rParticles.m_fTamano,-m_rParticles.m_fSize, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-m_rParticles.m_fTamano,-m_rParticles.m_fSize, 0.0f);
glEnd();
glPopMatrix();
…
}
…
Well, my problem is that I think that the parameters that I passed to the Draw function (Yaw y Pitch) are incorrect, I calcule
this two using the inverse of the Yaw and Pitch of the camera but this not work and in some views the particles are perpendicular
to the camera. Can anybody help me? :**
Thank <img src="wink.gif" width=15 height=15 align=middle> </i>
If you use a little matix math....this might get a little easyer for you! 
I don''t have this in my head right now...so i won''t post any code....But i am sure that you can find good examples on this out there! Try Nate''s page! (Link on NeHe''s main page)
Take Care!
- -- ---[XaOs]--- -- -
[ project fy ]

I don''t have this in my head right now...so i won''t post any code....But i am sure that you can find good examples on this out there! Try Nate''s page! (Link on NeHe''s main page)
Take Care!
- -- ---[XaOs]--- -- -
[ project fy ]
i don''t think you should use rotate commands before rendering the particles. i''m no expert at openGL but since you use it right before you render the particles all you do is change the way the particles are facing. if you load the identity matrix before running your particle systems and do the transformations relating to the camera angle at the same time then the particles should be rendered in the direction of the camera (i''m not sure though with the variable names you use for coordinates and stuff)
mmm... particle system.
Edited by - ATronic on October 31, 2001 2:52:35 PM
Edited by - ATronic on October 31, 2001 2:53:01 PM
|
Edited by - ATronic on October 31, 2001 2:52:35 PM
Edited by - ATronic on October 31, 2001 2:53:01 PM
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement