顯示具有 01163025_陳儷今 標籤的文章。 顯示所有文章
顯示具有 01163025_陳儷今 標籤的文章。 顯示所有文章

2014年5月30日 星期五

P

#include<GL/glut.h>
float a=0;
float angle[20]={0,90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
float angleOld[20]={0,90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
float angleNew[20]={90,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(angle[3], angle[4], angle[5]);
glPushMatrix();
glRotatef(angle[0],0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
glTranslatef(0.5,0,0);
glRotatef(angle[1], 0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}

void readNext()
{

a+=0.1;
for(int i=0;i<20;i++) angle[i] = angleOld[i]*(1-a) + angleNew[i]*a;
}
void timer(int t){
glutTimerFunc(100,timer,0);
readNext();
glutPostRedisplay();
}
void keyboard(unsigned char key , int x , int y)
{
if(key=='r'){
readNext();
}else if(key=='p'){
glutTimerFunc(0,timer,0);
}
glutPostRedisplay();
}

int main()
{
 glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
 glutCreateWindow("week15");

 glutKeyboardFunc(keyboard);
 glutDisplayFunc(display);
 glutMainLoop();
}

r

#include<GL/glut.h>
float a=0;
float angle=0;
float angleOld=0;
float angleNew=90;
void display()
{
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 glPushMatrix();
  glRotatef(angle,0,0,1);
  glutSolidTeapot(0.3);
 glPopMatrix();
 glutSwapBuffers();
}

void keyboard(unsigned char key, int x, int y)
{
 if (key=='r'){
  a+=0.1;
  angle = angleOld*(1-a) + angleNew*a;
 }
 glutPostRedisplay();
}

int main()
{
 glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
 glutCreateWindow("week15");

 glutKeyboardFunc(keyboard);
 glutDisplayFunc(display);
 glutMainLoop();
}

2014年5月2日 星期五

123

#include <GL/glut.h>

float angleX =0 , angle2 =0 , angle3=0 ;
void keyboard(unsigned char key, int x, int y)
{
if(key=='1') angleX+=5;
if(key=='2') angleX-=5;
if(key=='3') angle2+=5;
if(key=='4') angle2-=5;
if(key=='5') angle3+=5;
if(key=='6') angle3-=5;
glutPostRedisplay();//請電腦重新畫一次畫面
}

void myLight()
{
const GLfloat light_position[] = { 2.0f, 5.0f, -5.0f, 0.0f };
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
}

void display()
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angleX, 0,1,0);
glutWireTeapot(0.3);

glPushMatrix();
glTranslatef(0.5,0,0);
glutSolidSphere(0.2,30,30);
glPushMatrix();
glRotatef(angle2,0,0,1);
glTranslatef(0.2,0,0);
glScalef(0.4,0.2,0.2);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();

glPushMatrix();
glTranslatef(-0.5,0,0);
glutSolidSphere(0.2,30,30);
glPushMatrix();
glRotatef(angle2,0,0,-1);
glTranslatef(-0.2,0,0);
glScalef(0.4,0.2,0.2);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();

glPushMatrix();
glTranslatef(0,0.5,0);
glutSolidSphere(0.2,30,30);
glPopMatrix();

glPushMatrix();
glTranslatef(-0.15,-0.3,0);
glutSolidSphere(0.2,30,30);
glPushMatrix();
glRotatef(angle3,0,0,1);
glTranslatef(0,-0.2,0);
glScalef(0.2,-0.4,0.2);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();

glPushMatrix();
glTranslatef(0.15,-0.3,0);
glutSolidSphere(0.2,30,30);
glPushMatrix();
glRotatef(angle3,0,0,-1);
glTranslatef(0,-0.2,0);
glScalef(0.2,-0.4,0.2);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();

glPopMatrix();
glutSwapBuffers();
}

int main()
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week11");

glutDisplayFunc(display);
glutKeyboardFunc(keyboard);

myLight();
glutMainLoop();
}

875632


#include <GL/glut.h>

float angleX =0 , angle2 =0 , angle3=0 ;
void keyboard(unsigned char key, int x, int y)
{
if(key=='1') angleX+=5;
if(key=='2') angleX-=5;
if(key=='3') angle2+=5;
if(key=='4') angle2-=5;
glutPostRedisplay();//請電腦重新畫一次畫面
}

void myLight()
{
const GLfloat light_position[] = { 2.0f, 5.0f, -5.0f, 0.0f };
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);  
}

void display()
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angleX, 0,1,0);
glutWireTeapot(0.3);
glPushMatrix();
glTranslatef(0.5,0,0);
glutSolidSphere(0.2,30,30);
glPushMatrix();
glRotatef(angle2,0,0,1);
glTranslatef(0.2,0,0);
glScalef(0.4,0.2,0.2);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef(-0.5,0,0);
glutSolidSphere(0.2,30,30);
glPushMatrix();
glRotatef(angle2,0,0,1);
glTranslatef(-0.2,0,0);
glScalef(0.4,0.2,0.2);
glutSolidCube(1);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef(0,0.5,0);
glutSolidSphere(0.2,30,30);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}

int main()
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week11");
 
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
 
myLight();
glutMainLoop();
}

8423135489


2014年4月25日 星期五

0398398


werkejhkdj


864561564

#include <GL/glut.h>
float angleX=0;
void keyboard(unsigned char key, int x, int y)
{
     if(key=='a') angleX+=5;
     if(key=='b') angleX-=5;
     glutPostRedisplay();
}
void display ()
{
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glPushMatrix();
        glRotatef(angleX, 0,1,0);
        glutSolidTeapot(0.3);
     glPopMatrix();
     glutSwapBuffers();
}

int main()
{
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week10");
   
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
   
    glutMainLoop();
}