Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got my particle system out but now my star that is formed keeps growing and I dont know how to stop it....
I am using glTranslated() and am setting the z value so that it will stop translating at that point in the z axis but it is not working as desired. Any ideas?

This is my function to set the z value:
const double z = 0.0;
const double movez = z + 0.01;
else {
     if(movez >= 20.0){          
       float  movez = 20.0; 
     }
          
     glColor3f(1.0,1.0,1.0);
     glPushMatrix();
     glTranslated(0,0,movez);
     glutSolidSphere(14,40,40);
     glPopMatrix();   
}

Thanks
Posted
Updated 16-Apr-11 19:24pm
v2

1 solution

MIDL
glColor3f(1.0,1.0,1.0);
    glPushMatrix();
    glTranslated(0,0,movez);
    glutSolidSphere(14,40,40);
    glPopMatrix();

glTranslated multiplies current matrix by a translation matrix.
Each rendering multiply previous matrix, which cause translation on translated matrix.
We can solve this issue by resetting current matrix with identity matrix.
MIDL
glColor3f(1.0,1.0,1.0);
     glPushMatrix();
     glLoadIdentity();// This will load identity matrix.
     glTranslated(0,0,movez);
     glutSolidSphere(14,40,40);
     glPopMatrix();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900