2016電腦圖學
2016 電腦圖學 Computer Graphics 授課教師: 葉正聖 銘傳大學資訊傳播工程系 每週主題: 程式環境、點線面顏色、移動/旋轉/縮放與矩陣(Matrix)、階層性關節轉動(T-R-T)、做出機器人、打光、貼圖、glu/glut函式、鍵盤、滑鼠、計時器(timer)、讀入3D模型、粒子系統、聲音、特效、投影矩陣、攝影機與運鏡、機器人2.0、期末作品
2017年3月1日 星期三
2016年6月21日 星期二
2016年6月20日 星期一
2016年6月18日 星期六
2016年6月16日 星期四
㍿ ✘✘✘✘DOPE✘✘✘✘ Week16
貝殼專案
咒語:
Compiler(include)
Line(lib)
freeflut
opengl32
glu32
gdi32
winmm
相機旋轉
濾鏡效果
咒語:
Compiler(include)
Line(lib)
freeflut
opengl32
glu32
gdi32
winmm
相機旋轉
濾鏡效果
#include <stdio.h>
#include <GL/glut.h>
void display ()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glutSolidTeapot(1);
glPopMatrix();
glutSwapBuffers();
}
void motion (int x,int y)
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(x/80.0, y/200.0,5,
0, 0, 0,
0, 1, 0);
glutPostRedisplay();
}
void resize(int w, int h)
{
glViewport(0, 0,(GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(65.0,(GLdouble) w / h,1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0,5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
}
int main (int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("03161042");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutReshapeFunc(resize);
glutMainLoop();
}
㍿ ✘✘✘✘DOPE✘✘✘✘ Week15
在OPENGL/GLUT做
動作內插
10個ROT
去內插播放(TIMER)計時器
程式碼:
可以存入每個位置的數值 利用TIMER函式將兩個數值內插多個數值,可以讓動作變得更平滑流暢
#include <stdio.h>
#include <GL/glut.h>
float pos=0, oldX=0.7, newX=0.1;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(pos, 0,0);
glutSolidTeapot(0.2);
glPopMatrix();
glutSwapBuffers();
}
void timer (int t)
{
float alpha=t/100.0;
pos = newX*alpha+oldX*(1-alpha);
printf("%d %f %f \n",t,alpha,pos);
glutTimerFunc(100,timer,t+1);
glutPostRedisplay();
}
int main (int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("123");
glutDisplayFunc(display);
glutTimerFunc(100,timer,0);
glutMainLoop();
}
訂閱:
意見 (Atom)




