(2)會跳舞的機器人
(3)T-R-T 對關節轉
(4)小考 : T-R-T 觀念
(5)作業問題
(6) AlwaysOnTopMaker 一個能讓視窗往上得程式
ver1: 打光茶壺
#include <Gl/glut.h>
float angle=0,oldX=0,oldY=0;
void display()
{
GLfloat pos[]={0, 0, -1, 0};
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle, 0, 0, 1); ///ver 3 :ratating teapot on the handle
glTranslatef(0.5, 0, 0); ///ver 2 :teapot on the right
glutSolidTeapot(0.3); ///ver 1 : A teapot
glPopMatrix();
glFlush();
}
void timer(int t)
{
glutTimerFunc(20, timer, 0);
///angle++; 自動轉才要
glutPostRedisplay();
}
void mouse(int button, int state ,int x,int y)
{
if(state==GLUT_DOWN)
{
oldX=x; oldY=y;
}
}
void motion(int x, int y)
{
angle+=(x-oldX);
oldX=x;
}
int main (int argc, char **argv)
{
glutInit(&argc, argv);
glutCreateWindow("TRT 3D");
glutDisplayFunc(display);
glutTimerFunc(20, timer, 0);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutMainLoop();
}
(4)ver4: 旋轉軸心掛到想放的位置
glPushMatrix();
glTranslatef(0.45, 0.14, 0); ///ver 4 : 把樓下的整個在轉的 往右掛在某個地方 (最終終點)
glRotatef(angle, 0, 0, 1); ///ver 3 :ratating teapot on the handle (旋轉)
glTranslatef(0.45, -0.1, 0); ///ver 2 :teapot on the right (從起始點移動到中點)
glutSolidTeapot(0.3); ///ver 1 : A teapot 畫東西
glPopMatrix();
做出一個貌似運動的人
沒有留言:
張貼留言