1.攝影視角
2.實作
附錄1:攝影法講解
附錄2:今天的程式碼
#include <GL/glut.h>
#include "glm.h"
GLMmodel* pmodel = NULL;
void
drawmodel(void)
{
if (!pmodel) {
pmodel = glmReadOBJ("data/al.obj");
if (!pmodel) exit(0);
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
}
glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
}
#include <math.h>
float eyex=0, eyey=0, eyez=0;
void timer(int t)
{
glutTimerFunc(33,timer,t+1);
float angle=t/180.0*3.1415926;
eyex=cos(angle);
eyez=sin(angle);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60,1,0.001,1000);
//glOrtho(-1,+1, -1,+1, -10,+10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyex, eyey, eyez,
0.0, 0.8, 0.0,
0, 1, 0);
glutPostRedisplay();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawmodel();
glutSwapBuffers();
}
int main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(600,600);
glutCreateWindow("week15");
glutDisplayFunc(display);
glutTimerFunc(33,timer,0);
GLfloat light_pos[] = { 0.0, 0.0, 1.0, 0.0 };
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
glutMainLoop();
}
沒有留言:
張貼留言