Week 6 Assignment

 

Problem1

void drawWireframeCylinder(){

float rad= 160;
float height=320;
int steps=20;


glPushMatrix();
glRotatef(mouseY, 1,0,0);//angle,x,y,z
for (int i=0; i<=steps; i++){
glBegin(GL_LINE_LOOP);
for(int A=0; A<30; A++){

float ang= A/30.0*PI*2.0;
float x= cos(ang)*rad;
float y= i*(height/steps)-300;
float z= sin(ang)*rad;
glColor4f( 1,1,1,0.5 );
glVertex3f(x,y,z);



}

glEnd();


}



for (int j=0; j<=steps; j++){

for(int A=0; A<30; A++){
glBegin(GL_LINE_STRIP);

float ang= A/30.0*PI*2.0;
float x= rad* cos(ang);
float z= rad*sin(ang);
glColor4f( 1,j/20,0,0.5);
glVertex3f(x,-300,z);
glVertex3f(x,height-300,z);


glEnd();
}


}

glPopMatrix();

}