资源简介
一、
1.Please download and install the glut library.
2.Write a complete program using the following codes to draw a Sierpinski gasket.
void myinit()
{
// attributes
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(1.0,0.0,0.0);
// set up viewing
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 50.0,0.0,50.0);
glMatrixMode(GL_MODELVIEW);
}
void display()
{
GLfloat vertices[3][3] = {{0.0,0.0,0.0}, {25.0, 50.0,0.0}, {50.0,0.0,0.0}};
// an arbitrary triangle in the plane z = 0;
GLfloat p[3] = {7.5, 5.0, 0.0};
// or set any desired initial point which is inside the triangle;
int j,k;
int rand();
glBegin(GL_POINTS);
for (k = 0; k < 5000; k++)
{
/* pick a random vertex from 0, 1, 2*/
j = rand()%3;
// compute new location;
p[0] = (p[0]+vertices[j][0])/2;
p[1] = (p[1]+vertices[j][1])/2;
// display new point
glVertex3fv(p);
}
glEnd();
glFlush();
}
#include
void main(int argc, char **argv)
{
glutInit(&argc;, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitAWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow(“Simple OpenGL Example”);
glutDisplayFunc(display);
myinit();
glutMainLoop();
}
3.实现 DDA 和 Bresenham 画线算法
(1)画10万以上随机生成的直线段,比较两个算法的平均时间.
(2)分别把屏幕上的1*1,5*5, 9*9像素当作直线段上的一个点,观察线段的走样情况.
二、
请写一个OpenGL (如果熟悉WebGL也可以用)程序完成如下任务
(1)读入三维网格模型的obj文件;
(2)用OpenGL函数glTranslatef()对模型模型进行平移,使得其重心位于原点;
(3)用函数glLookAt()设置视点,并且要求试点绕模型一周,以便用透视投影观察各个侧面;
(4)要求利用真实感绘制对模型进行渲染. (利用OpenGL函数设置光源,材质,计算好每个三角形的法向量后,利用OpenGL的glNormal函数给待绘制的三角形设置法向量). 绘制的结果大概如下:
三、
本实验为综合实验, 任务是利用光线跟踪算法进行Whitted全局光照计算,并对读入场景进行真实感绘制。(特别提醒: 网上类似的projects可以参考,但不能照抄. 如http://tobias.isenberg.cc/graphics/LabSessions/RaytracingProject, http://physbam.stanford.edu/links/ray_tracing/project_ray_tracing.html
https://www.cs.utexas.edu/~fussell/courses/cs354/assignments/raytracing/handout.shtml )
(1)参加对象: 本实验针对所有选课同学,3-5人组成一个小组,共同实现;非15级同学在组队方面有困难的话可与老师沟通.
(2)实验结果提交: 每人都要求提交一份. 内容包括
a.源程序; 可执行代码; 三维场景数据; 同组的同学这部
代码片段和文件信息
#include
#include
void myinit()
{
// attributes
glClearColor(1.0 1.0 1.0 1.0);
glColor3f(1.0 0.0 0.0);
// set up viewing
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0 50.0 0.0 50.0);
glMatrixMode(GL_MODELVIEW);
}
void display()
{
GLfloat vertices[3][3] = { { 0.00.00.0 }{ 25.0 50.00.0 }{ 50.00.00.0 } };
// an arbitrary triangle in the plane z = 0;
GLfloat p[3] = { 7.5 5.0 0.0 };
// or set any desired initial point which is inside the triangle;
int j k;
int rand();
glBegin(GL_POINTS);
for (k = 0; k < 5000; k++)
{
/* pick a random vertex from 0 1 2*/
j = rand() % 3;
// compute new location;
p[0] = (p[0] + vertices[j][0]) / 2;
p[1] = (p[1] + vertices[j][1]) / 2;
// display new point
glVertex3fv(p);
}
glEnd();
glFlush();
}
void main(int argc char **argv)
{
glutInit(&argc argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500500);
glutInitWindowPosition(0 0);
glutCreateWindow(“Simple OpenGL Example“);
glutDisplayFunc(display);
myinit();
glutMainLoop();
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-20 22:42 计算机图形学\
目录 0 2018-05-20 22:41 计算机图形学\一\
目录 0 2018-05-20 22:33 计算机图形学\一\作业1-画Sierpinski gasket\
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\.vs\
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\.vs\homework1\
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\.vs\homework1\v14\
文件 26112 2017-09-29 11:49 计算机图形学\一\作业1-画Sierpinski gasket\homework1\.vs\homework1\v14\.suo
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\Debug\
文件 43008 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\Debug\homework1.exe
文件 320888 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\Debug\homework1.ilk
文件 593920 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\Debug\homework1.pdb
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\
文件 1309 2017-09-19 16:20 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1.sln
文件 32243712 2017-09-29 11:49 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1.VC.db
文件 1146 2017-09-19 16:33 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\1.cpp
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\
文件 9345 2017-09-19 16:33 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\1.obj
文件 54122 2017-09-19 17:54 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\2.obj
文件 57681 2017-09-19 17:54 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\3.obj
文件 84 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.log
目录 0 2018-05-20 22:34 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\
文件 1910 2017-09-19 17:54 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\CL.command.1.tlog
文件 22694 2017-09-19 17:54 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\CL.read.1.tlog
文件 1796 2017-09-19 17:54 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\CL.write.1.tlog
文件 203 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\homework1.lastbuildstate
文件 1126 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\li
文件 3168 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\li
文件 440 2017-09-24 17:56 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\homework1.tlog\li
文件 437248 2017-09-19 17:54 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\vc140.idb
文件 356352 2017-09-19 17:54 计算机图形学\一\作业1-画Sierpinski gasket\homework1\homework1\Debug\vc140.pdb
............此处省略104个文件信息
- 上一篇:HTML5 秘籍 中文完整版 PDF
- 下一篇:大型招聘模板html
评论
共有 条评论