去老師的網站:http://jsyeh.org/3dcg10
下載:windows.zip & data.zip
T移動R轉動(按右鍵可SwapTR) glTranslatef( 0.9 , 0.0 , 0.0 ) ; glRotatef( 角度, 0, 1, 0)
可進入老師做的網站練習: https://120.125.80.50/GL/opengl_TRT_demo.html
Ctrl-R 可清空(還原到初始)
按住旁邊的字可拖曳並改寫程式的順序
區別
2-2下周考試
2-3寫程式
file->new->project->GLUT專案,week12_TRT
把10行程式碼放上去(之前的)
把TRT的6行放上去(今天的)
讓他自動轉(float angle=0)配上glRotatef(angle,0,0,1)再加上angle++
glutIdleFunc(display);(上週筆記)
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
///glTranslatef(0, 0, 0);
glRotatef( angle, 0, 0, 1);
///glTransaltef(0, 0, 0);
glutSolidTeapot( 0.2 );///想像它是手臂
glPopMatrix();
glutSwapBuffers();
angle++;
}
int main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE|GLUT_DEPTH );
glutCreateWindow("week12 TRT");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
}
茶壺超人
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);///白色
glutSolidTeapot( 0.3 );///身體
glPushMatrix();
glColor3f(1,0,0);///紅色
glTranslatef(0.2, 0, 0);///(3)把整個往右移動
glRotatef( angle, 0, 0, 1);///(2)旋轉
glTranslatef(0.2, 0, 0); ///(1)把旋轉中心放到中心
glutSolidTeapot( 0.2 ); ///做個小茶壼然後想像是手臂~
glPopMatrix();
glutSwapBuffers();
angle++;
}
int main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE|GLUT_DEPTH );
glutCreateWindow("week12 TRT");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
}
茶壺超人(整隻手)
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);///白
glutSolidTeapot( 0.3 );///身體
glPushMatrix();
glColor3f(1,0,0);///紅
glTranslatef(0.5, 0.2, 0);///(3)把整個往右移動
glRotatef( angle, 0, 0, 1);///(2)旋轉
glTranslatef(0.2, 0, 0); ///(1)把旋轉中心,放到中心
glutSolidTeapot( 0.2 );///上臂
glPushMatrix();
glColor3f(1,0,0);///紅
glTranslatef(0.4, 0.1, 0);
glRotatef( angle, 0, 0, 1);
glTranslatef(0.2, 0, 0);
glutSolidTeapot( 0.2 );///下臂
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
angle++;
}
int main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE|GLUT_DEPTH );
glutCreateWindow("week12 TRT");
glutIdleFunc(display);
glutDisplayFunc(display);
glutMainLoop();
}
.png)
.png)
沒有留言:
張貼留言