ArchMiffo
09-03-2002, 08:14 AM
Ok, let's start with the code:
glMatrixMode(GL_MODELVIEW_MATRIX);
glPushMatrix();
float modelview[16];
glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
for(int i=0; i<3; i++ )
for(int j=0; j<3; j++ ) {
if ( i==j )
modelview[i*4+j] = 1.0;
else
modelview[i*4+j] = 0.0;
}
// set the modelview with no rotations
glLoadMatrixf(modelview);
//glPopMatrix();
ParticleVec::iterator itend = m_Particles.end();
for(ParticleVec::iterator it=m_Particles.begin(); it!=itend; ++it)
{
glBegin(GL_TRIANGLE_STRIP); // Build Quad From A Triangle Strip
glColor3ub(it->m_Col.r, it->m_Col.g, it->m_Col.b); // Use particle's color
glTexCoord2d(1,1);
glVertex3f(it->m_Pos.x+it->m_Size,it->m_Pos.y+it->m_Size,it->m_Pos.z); // Top Right
glTexCoord2d(0,1);
glVertex3f(it->m_Pos.x-it->m_Size,it->m_Pos.y+it->m_Size,it->m_Pos.z); // Top Left
glTexCoord2d(1,0);
glVertex3f(it->m_Pos.x+it->m_Size,it->m_Pos.y-it->m_Size,it->m_Pos.z); // Bottom Right
glTexCoord2d(0,0);
glVertex3f(it->m_Pos.x-it->m_Size,it->m_Pos.y-it->m_Size,it->m_Pos.z); // Bottom Left
glEnd(); // Done Building Triangle Strip
//it->Render();
} // end for
glPopMatrix();
As you se I'm trying to use billboarding but something ain't right. This works fine if the particlesystem is on coordinates 0,0,0 but if I try to move it it dissappers. I know there is something wrong with my coordinates but I don't know what. If someone could show me what I've forgotten that would be nice. Now don't think I'm asking here becouse I'm lazy, I've already tried several things but nothing worked abd I've read a tutorial on billboarding but didn't understand it all. Appart from showing me what to do an explaination would be very nice.
Thanks
glMatrixMode(GL_MODELVIEW_MATRIX);
glPushMatrix();
float modelview[16];
glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
for(int i=0; i<3; i++ )
for(int j=0; j<3; j++ ) {
if ( i==j )
modelview[i*4+j] = 1.0;
else
modelview[i*4+j] = 0.0;
}
// set the modelview with no rotations
glLoadMatrixf(modelview);
//glPopMatrix();
ParticleVec::iterator itend = m_Particles.end();
for(ParticleVec::iterator it=m_Particles.begin(); it!=itend; ++it)
{
glBegin(GL_TRIANGLE_STRIP); // Build Quad From A Triangle Strip
glColor3ub(it->m_Col.r, it->m_Col.g, it->m_Col.b); // Use particle's color
glTexCoord2d(1,1);
glVertex3f(it->m_Pos.x+it->m_Size,it->m_Pos.y+it->m_Size,it->m_Pos.z); // Top Right
glTexCoord2d(0,1);
glVertex3f(it->m_Pos.x-it->m_Size,it->m_Pos.y+it->m_Size,it->m_Pos.z); // Top Left
glTexCoord2d(1,0);
glVertex3f(it->m_Pos.x+it->m_Size,it->m_Pos.y-it->m_Size,it->m_Pos.z); // Bottom Right
glTexCoord2d(0,0);
glVertex3f(it->m_Pos.x-it->m_Size,it->m_Pos.y-it->m_Size,it->m_Pos.z); // Bottom Left
glEnd(); // Done Building Triangle Strip
//it->Render();
} // end for
glPopMatrix();
As you se I'm trying to use billboarding but something ain't right. This works fine if the particlesystem is on coordinates 0,0,0 but if I try to move it it dissappers. I know there is something wrong with my coordinates but I don't know what. If someone could show me what I've forgotten that would be nice. Now don't think I'm asking here becouse I'm lazy, I've already tried several things but nothing worked abd I've read a tutorial on billboarding but didn't understand it all. Appart from showing me what to do an explaination would be very nice.
Thanks