Week05 T-R-T對特定旋轉軸
https://jsyeh.org/3dcg10/
下載
- data data.zip
- win32 windows.zip
解壓縮後將data資料夾丟進windows
下載\windows\Transtation.exe
開啟codeblock =>File => New => project => GLUT Project
選擇桌面,命名為week05_TRT_rotate_translate
開啟github下載week04-1程式
讓紅綠杯子旋轉
#include <GL/glut.h>
float angle =0;
void display()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f(0,1,0);
glPushMatrix();
glTranslatef(0.8,0,0);
glRotatef(angle,0,0,1);
glutSolidTeapot( 0.3 );
glPopMatrix();
glColor3f(1,0,0);
glPushMatrix();
glRotatef(angle,0,0,1);
glTranslatef(0.8,0,0);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
angle++;
}
int main(int argc, char* argv[] )
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week03");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
}
劃出大的身體,畫出手臂
#include <GL/glut.h>
float angle =0;
void display()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f(0,1,0);
glPushMatrix();
glutSolidCube(0.5);
glPushMatrix();
glTranslatef(0.25,0.25,0);
glRotatef(angle,0,0,1);
glTranslatef(0.25,0.25,0);
///glTranslatef(0.5,0.5,0);
glColor3f(1,0,0);
glutSolidCube(0.5);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
angle++;
}
int main(int argc, char* argv[] )
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week03");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言