Computer graphics butterfly lifecycle project shows the real lifecycle of the butterfly. Their are totally 4 stages in butterfly lifecycle. The first stage is egg stage and the second stage is caterpillar/larva and the third stage is chrysalis/pupa and the last stage that is fourth stage is adult. In the first stage the egg develops and then converted into a caterpillar as a second stage and then it sits on the tree and starts covering itself and convert into again egg like a structure called pupa as a thirst stage and then at the last stage finally it is going to convert into a butterfly and this is the last stage of the butterfly lifecycle. Understanding natural butterfly lifecycle using computer graphics is going to be very beautiful. Here the exact lifecycle of the butterfly is shown and by hitting the mouse buttons you can see every stage of the butterfly lifecycle.
BUTTERFLY CODE
{
float scale=.6;
glPushMatrix();
glTranslatef(0+x,0+y,-80);
glRotatef(90,0,0,1);
if(flap) glRotatef(-40,1,0,0);
glScalef(scale, scale,1);
glBegin(GL_POLYGON);
float cx=0,cy=0,cz=0;
for(int i=0;i<5000;i++)
{
cx+=(1.0/5000);
cy-=(1.0/5000);
cz+=(1.0/5000);
glColor3f(cx,cy,cz);
double t=i*24*3.14159265/5000;
double expr = pow(exp(cos(t))-2*cos(4*t)-sin(t/12),3);
GLfloat X = sin(t)*expr;
GLfloat Y = -cos(t)*expr;
if(Y>=0)
glVertex2f(X,Y);
}
glEnd();
glFlush();
glPopMatrix();
glPushMatrix();
glTranslatef(0+x,0+y,-80);
glRotatef(90,0,0,1);
if(flap) glRotatef(-40,-1,0,0);
glScalef(scale, scale,1);
glScalef(1,-1,1);
cx=0,cy=0,cz=0;
glBegin(GL_POLYGON);
for(int i=0;i<5000;i++)
{
cx+=(1.0/5000);
cy-=(1.0/5000);
cz+=(1.0/5000);
glColor3f(cx,cy,cz);
double t=i*24*3.14159265/5000;
double expr = pow(exp(cos(t))-2*cos(4*t)-sin(t/12),3);
GLfloat X = sin(t)*expr;
GLfloat Y = -cos(t)*expr;
if(Y>=0)
glVertex2f(X,Y);
}
glEnd();
glPopMatrix();
glFlush();
}
KEYBOARD & MOUSE FUNCTIONS
- Click mouse to begin cycle.