Week10
今天是第10週!
要教的是公轉vs自轉
一樣到 http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/ 下載win32,data,glut32.dll
然後開啟Transformation.exe
調整一下glTranslatef跟glRotatef的值
再來小葉老師講了線性代數跟電腦圖學的關聯
接著一樣打茶壺程式!!
#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);
glutSwapBuffers( );
}
int main( int argc , char ** argv )
{
glutInit( &argc , argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( "first window" );
glutDisplayFunc( display );
glutMainLoop( );
}
----------------------------------------------------------------------------------------------------------------------------------------
對這些程式碼做一些小許的修改
#include <GL/glut.h>
void display()
{
glPushMatrix();
glTranslatef(0,0.5,0);
glutWireTeapot(0.3);
glPopMatrix();
glPushMatrix();
glTranslatef(0.51,0.63,0);\\希望讓會動的手從肚臍移到茶壺上
glRotatef(-90,0,0,1);\\手的旋轉
glTranslatef(0.6,0,0);\\旋轉中心移到畫面中心
glRotatef(-90,0,1,0);
glutWireCone(0.1,0.6,10,10);
glPopMatrix();
glutSwapBuffers();
}
int main( int argc , char ** argv )
{
glutInit( &argc , argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( "first window" );
glutDisplayFunc( display );
glutMainLoop( );
}
再來小葉老師講了線性代數跟電腦圖學的關聯
接著一樣打茶壺程式!!
#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);
glutSwapBuffers( );
}
int main( int argc , char ** argv )
{
glutInit( &argc , argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( "first window" );
glutDisplayFunc( display );
glutMainLoop( );
}
----------------------------------------------------------------------------------------------------------------------------------------
對這些程式碼做一些小許的修改
#include <GL/glut.h>
void display()
{
glPushMatrix();
glTranslatef(0,0.5,0);
glutWireTeapot(0.3);
glPopMatrix();
glPushMatrix();
glTranslatef(0.51,0.63,0);\\希望讓會動的手從肚臍移到茶壺上
glRotatef(-90,0,0,1);\\手的旋轉
glTranslatef(0.6,0,0);\\旋轉中心移到畫面中心
glRotatef(-90,0,1,0);
glutWireCone(0.1,0.6,10,10);
glPopMatrix();
glutSwapBuffers();
}
int main( int argc , char ** argv )
{
glutInit( &argc , argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( "first window" );
glutDisplayFunc( display );
glutMainLoop( );
}
沒有留言:
張貼留言