《地学可视化与景观模拟实验报告(17页).docx》由会员分享,可在线阅读,更多相关《地学可视化与景观模拟实验报告(17页).docx(17页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、-地学可视化与景观模拟实验报告中 国 矿 业 大 学China University of Mining and Technology地学可视化与景观模拟实验报告学 号: 姓 名: 指导老师: 余 接 情 班 级: 测绘13-2班 中国矿业大学环境与测绘学院实验一 ArcGIS 地形可视化实验目的了解地形可视化的基本方法, 学会使用 ArcGIS 进行地形可视化增强。实验内容对给定的 DEM 分别做如下操作:1) 制作等高线2) 立体等高线3) 分成设色法显示地形4) 明暗等高线法显示地形5) 晕渲法显示地形6) 混合显示实验要求学号尾数为经度,班级为纬度每人下载一份 DEM 数据。 每人提交
2、一份实验报告。实验步骤及实验结果1) DEM 数据下载strm.csi.cgiar.org在下载过程中输入网址会进入下载网页。如下图所示:下载第2行第24列。2)用ArcGIS打开下载好的DEM如下图(由于原始的DEM比较大,所以我从原始数据中剪切一部分DEM作为本次实验数据)。3) 提取等高线;4)制作立体等高线5)分层设色法显示地形;6)提取坡向;7) 提取背光面与受光面;8) 将受光与背光区域转为矢量; 9) 将矢量受光与背光区域与等高线叠加;10)明暗显示设置11)明暗等高线结果图。12)提取阴影。13)设置透明度60%,结果如下。实验结果1、等高线+分层设色法2、晕眩法+高度映射法3
3、、 立体等高线+高度映射法+分层设色法4、明暗等高线+高度映射法实验体会初步了解了Arcgis 软件的使用,对简单的操作技能有所加深,同时深刻体会到arcgis 软件的强大。在实验过程中会遇到很多不懂得地方,一定要虚心请教老师和同学的帮助。实验二 OpenGL 编程入门实验目的了解 OpenGL 程序基本结构,掌握基本图元的创建及颜色的定义方法。实验内容1) 采用指定图元及颜色绘制下列物体。2)图示如下:实验要求每人一份独立完成实验,每人提交一份实验报告(封面、实验目的、实验内容、实验步骤、实验结果、实验体会)。实验过程和实验结果新建项目与文件配置-第 17 页#ifndef GLUT_DIS
4、ABLE_ATEXIT_HACK#define GLUT_DISABLE_ATEXIT_HACK#endif#include#include #include #include /包含相应的头文件#pragma comment( lib, glu32.lib)#pragma comment( lib, glut32.lib)#pragma comment( lib, glut32.lib)void display(void);void init(void);int main(int argc, char* argv)glutInit(&argc, argv);glutInitDisplayMo
5、de (GLUT_SINGLE | GLUT_RGB);glutInitWindowSize (800, 600); glutInitWindowPosition (0, 0);glutCreateWindow (argv0);init();glutDisplayFunc(display);glutMainLoop();return 0;void init(void)glClearColor (0.0, 0.0, 0.0, 0.0);/用当前颜色清屏幕glMatrixMode (GL_PROJECTION);/设置矩阵的模式glLoadIdentity ();/将当前堆栈矩阵清零glOrtho
6、(0,1,0,1,-1,1);/设置平行投影矩阵glMatrixMode(GL_MODELVIEW);glLoadIdentity ();/将当前堆栈矩阵清零void display(void)glClear (GL_COLOR_BUFFER_BIT);/清除颜色缓存区glColor3f (1.0, 1.0, 1.0);/定义颜色glBegin(GL_POLYGON);/构造几何图元glVertex3f(0.25,0.25,0);glVertex3f(0.75,0.25,0);glVertex3f(0.75,0.75,0);glVertex3f(0.25,0.75,0);glEnd();glF
7、lush ();/强制刷新#ifndef GLUT_DISABLE_ATEXIT_HACK#define GLUT_DISABLE_ATEXIT_HACK#endif#include#include #include #include /包含相应的头文件#pragma comment( lib, glu32.lib)#pragma comment( lib, glut32.lib)#pragma comment( lib, opengl32.lib)void display(void);void init(void);int main(int argc, char* argv)glutInit
8、(&argc, argv);glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);glutInitWindowSize (800, 600); glutInitWindowPosition (0, 0);glutCreateWindow (argv0);init();glutDisplayFunc(display);glutMainLoop();return 0;void init(void)glClearColor (0.0, 0.0, 0.0, 0.0);/用当前颜色清屏幕glMatrixMode (GL_PROJECTION);/设置矩阵的模式glLo
9、adIdentity ();/将当前堆栈矩阵清零glOrtho(0,1,0,1,-1,1);/设置平行投影矩阵glMatrixMode(GL_MODELVIEW);glLoadIdentity ();/将当前堆栈矩阵清零void display(void)glClear (GL_COLOR_BUFFER_BIT);/清除颜色缓存区glColor3f (1.0, 0.0, 0.0);/定义颜色glBegin(GL_POLYGON);/构造几何图元glVertex3f(0.25,0.25,0);glVertex3f(0.75,0.25,0);glVertex3f(0.75,0.75,0);glVe
10、rtex3f(0.25,0.75,0);glEnd();glFlush ();/强制刷新/ openGL.cpp : 定义控制台应用程序的入口点。#include stdafx.h#include #include void background(void) glClearColor(0.0,0.0,0.0,0.0); void myDisplay(void) glClear(GL_COLOR_BUFFER_BIT); /*图形1*/glBegin(GL_LINE_STRIP);glVertex3f(-10,8,0);glVertex3f(-1,8,0);glVertex3f(-1,6,0);
11、glVertex3f(-4,6,0);glVertex3f(-4,4,0);glVertex3f(-7,4,0);glVertex3f(-7,6,0);glVertex3f(-10,6,0);glVertex3f(-10,8,0);glEnd();/*图形2*/glBegin(GL_LINES); glVertex3f(1,8,0);glVertex3f(10,8,0);glVertex3f(10,8,0);glVertex3f(10,6,0);glVertex3f(10,6,0);glVertex3f(7,6,0);glVertex3f(7,6,0);glVertex3f(7,4,0);gl
12、Vertex3f(7,4,0);glVertex3f(4,4,0);glVertex3f(4,4,0);glVertex3f(4,6,0);glVertex3f(4,6,0);glVertex3f(1,6,0);glVertex3f(1,6,0);glVertex3f(1,8,0);glEnd();/*图形3*/glBegin(GL_QUADS); glColor3f(1,0,0);glVertex3f(-10,2,0);glVertex3f(-7,2,0);glVertex3f(-7,0,0);glVertex3f(-10,0,0);glVertex3f(-7,0,0);glVertex3f
13、(-7,2,0);glVertex3f(-4,2,0);glVertex3f(-4,0,0);glVertex3f(-7,0,0);glVertex3f(-4,0,0);glVertex3f(-4,-2,0);glVertex3f(-7,-2,0);glVertex3f(-4,0,0);glVertex3f(-4,2,0);glVertex3f(-1,2,0);glVertex3f(-1,0,0);glEnd();/*图形4*/glBegin(GL_POLYGON);glColor3f(0,0,1); glVertex3f(4,0,0); glVertex3f(1,0,0);glVertex3
14、f(1,2,0);glVertex3f(10,2,0);glVertex3f(10,0,0);glVertex3f(7,0,0);glVertex3f(7,-2,0);glVertex3f(4,-2,0);glEnd();/*图形5*/glBegin(GL_TRIANGLE_STRIP);glColor3f(0,0,1); glVertex3f(-4,-8,0); glVertex3f(-4,-6,0); glVertex3f(-7,-8,0); glVertex3f(-7,-6,0); glVertex3f(-5.5,-4,0); glVertex3f(-1,-4,0); glVertex3
15、f(-1,-6,0); glVertex3f(-5.5,-4,0); glVertex3f(-7,-6,0); glVertex3f(-10,-4,0); glVertex3f(-10,-6,0);glEnd();/*图形6*/glBegin(GL_TRIANGLES); glColor3f(1,0,0); glVertex3f(1,-6,0); glVertex3f(4,-6,0); glVertex3f(1,-4,0);glColor3f(0,0,1); glVertex3f(4,-6,0); glVertex3f(1,-4,0); glVertex3f(5.5,-4,0); glColo
16、r3f(1,0,0); glVertex3f(4,-6,0); glVertex3f(5.5,-4,0); glVertex3f(7,-6,0);glColor3f(0,0,1);glVertex3f(7,-6,0); glVertex3f(5.5,-4,0); glVertex3f(10,-4,0);glColor3f(1,0,0);glVertex3f(7,-6,0);glVertex3f(10,-4,0);glVertex3f(10,-6,0);glColor3f(0,0,1); glVertex3f(4,-6,0); glVertex3f(7,-6,0); glVertex3f(4,-
17、8,0);glColor3f(1,0,0); glVertex3f(4,-8,0); glVertex3f(7,-6,0); glVertex3f(7,-8,0);glEnd();glFlush(); void myReshape(GLsizei w,GLsizei h)glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION);glLoadIdentity(); if(w = h) gluOrtho2D(-1.0,1.5,-1.5,1.5*(GLfloat)h/(GLfloat)w); else gluOrtho2D(-1.0,1.5*(GLfloat)
18、w/(GLfloat)h,-1.5,1.5); glMatrixMode(GL_MODELVIEW); glTranslatef(0.15,0.1,0.0); /平移 glScalef(0.1,0.1,0.0);/缩放int main(int argc, char* argv) /*初始化*/ glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(200,200); /*创建窗口*/ glutCreateWindow
19、(实验二); /*绘制与显示*/ background(); glutReshapeFunc(myReshape); glutDisplayFunc(myDisplay); glutMainLoop(); return 0;实验结果实验体会理解图元定义,并基于图元绘制各种复杂图形,理解各种图元定义函数并能灵活运用。学习到了很多知识,非常不错的一次实验。实验三/四/五 利用 OpenGL绘制三维地形实验目的 利用 OpenGL 对给定的 DEM 数据进行三维可视化。 实验内容分别做如下操作: 1) 用 ARCGIS 将 DEM.tif 转换为 ASCII 格式 2) 使用 C 语言将 DEM 数
20、据读入 3) 显示地形 4) 使用投影变换、几何变换并设置各参数。 5) 通过 gluLookAt 改变默认视点位置 6) 增加光照效果,设置光源。 实验要求 每人提交一份实验报告(封面、实验目的、实验内容、实验步骤、实验结果、实验体会)。实验步骤Dem数据转换编程将转换的数据载入实验代码#ifndef GLUT_DISABLE_ATEXIT_HACK #define GLUT_DISABLE_ATEXIT_HACK #endif #include stdio.h #include #include #include #include #include #include using names
21、pace std; #pragma comment(lib,glu32.lib) #pragma comment(lib,glut32.lib) #pragma comment(lib,opengl32.lib) void display(void); void init(void); void reshape(int w, int h); void keyboard(unsigned char key, int x, int y);int dx = 0, dy = 0, bigger = 0, smaller = 0, MAX = 0; long ncols; long nrows; lon
22、g *data;/定义为全局变量,方便 display 调用 int main(int argc,char*argv) ifstream ifile(abc.txt); /abc.txt为原始DEM数据经处理后得到的文本数据,可自己定义路径string temp; double xllcorner, yllcorner, cellsize, NODATA_value; ifile temp ncols; ifile temp nrows; ifile temp xllcorner; ifile temp yllcorner; ifile temp cellsize; ifile temp NO
23、DATA_value;/ 读取头文件数据 data = (long *)malloc(ncols*sizeof(long *); for (long j = 0; jncols; j+) dataj = (long*)malloc(nrows*sizeof(long); /动态二维数组定义 for (long i = 0; inrows; i+) /printf(nnn); for (long j=0;jdataij; /printf(%d ,dataij); /读取灰度值数据,初始化 ifile.end; glutInit(&argc, argv); glutInitDisplayMode(
24、GLUT_SINGLE | GLUT_RGB);glutInitWindowSize(500, 500); glutInitWindowPosition(50, 50); glutCreateWindow(argv0); init(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard);glutMainLoop(); return 0;void init(void) glClearColor(0, 0, 0, 0); glMatrixMode(GL_PROJECTION); glLoad
25、Identity(); glOrtho(0, 1, 0, 1, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glShadeModel(GL_SMOOTH);/设置 着色模式 glEnable(GL_DEPTH_TEST); /开 启深度测试 glEnable(GL_LIGHTING);/开启光 照 glEnable(GL_NORMALIZE);/开启 法向量自动规范化 /创建一个白色光源 GLfloat light_position = -1.0,- 1.0, 0.0, 0.0 ; GLfloat light_ambient =
26、1, 1, 1, 1.0 ; GLfloat light_diffuse = 1.0, 1.0, 1.0, 1.0 ; GLfloat light_specular = 1.0, 1.0, 1.0, 1.0 ; glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_AMBIENT,light_ambient);glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specula
27、r); glEnable(GL_LIGHT0);/启用第 0 个光源void display(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /glColor3f(1,0,1); glPolygonMode(GL_FRONT_AND_BACK, GL_LINES); glPushMatrix(); glRotatef (GLfloat) dx, 1.0, 0.0, 0.0); glRotatef(GLfloat) dy,0.0,1.0,0.0); glTranslatef(0,0,bigger); glTranslatef(0
28、,0,smaller); glTranslatef (-nrows/2, ncols/2, -MAX/2); glPushMatrix(); GLfloat mat_ambient1 = 0.2, 0.2, 0.2, 1.0 ; GLfloat mat_diffuse1 = 0.8, 0.8, 0.8, 1.0 ; GLfloat mat_specular1 = 0.0, 0.0, 0, 1.0 ; glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient1); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse1)
29、; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular1); glTranslatef(1, 0, 0); glPushMatrix();glColor3f(1, 1, 1); /gluLookAt (0, 0.0, 5, 0.0, 0.0,0, 0.0, 1.0, 0.0); glBegin(GL_QUADS); for(long i=0;inrows-1;i+) for(long j=0;jncols-1;j+) glNormal3f(datai+1j+datai j-dataij+1-datai+1j+1,dataij+datai j+1-d
30、atai+1j+1-datai+1j,2); glVertex3f(j,i,0.06*dataij); glNormal3f(datai+1j+datai j-dataij+1-datai+1j+1,dataij+datai j+1-datai+1j+1-datai+1j,2); glVertex3f(j,(i+1),0.06*datai+1 j); glNormal3f(datai+1j+datai j-dataij+1-datai+1j+1,dataij+datai j+1-datai+1j+1-datai+1j,2); glVertex3f(j+1),(i+1),0.06*data i+
31、1j+1); glNormal3f(datai + 1j + dataij - dataij + 1-datai + 1j + 1, dataij + dataij + 1 - datai + 1j + 1-datai + 1j, 2); glVertex3f(j + 1), i, 0.06*dataij + 1);glEnd(); glPopMatrix(); glPopMatrix(); glPopMatrix();glFlush();void reshape(int w, int h) glViewport(0, 0, (GLsizei)w, (GLsizei)h); glMatrixM
32、ode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (GLfloat)w / (GLfloat)h, 1.0, 2000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, 300, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);void keyboard(unsigned char key, int x, int y) switch (key) case w: dx = (dx + 1) % 360; glutPostRedisp
33、lay(); break; case s: dx = (dx - 1) % 360; glutPostRedisplay(); break; case a: dy = (dy + 1) % 360; glutPostRedisplay(); break; case d: dy = (dy - 1) % 360; glutPostRedisplay(); break; case q: bigger += 10; glutPostRedisplay(); break; case e: smaller += 10; glutPostRedisplay(); break;default: break;
34、运行结果截图如下:实验体会在这三个实验中自己学到了很多,从一开始什么都不懂到懵懵懂懂,再到后来有一定的思路,这是一个艰难的过程,一个辛苦的过程,在对OpenGL各种函数慢慢认识和熟悉的过程中发现编程语言也有很有趣的一面。在这次实验中,明白了计算机可视化成图的基本原理和方法,首先要建立三维模型,然后又各种投影变换,然后确可见面,在根据真实物体材质确定光照、纹理等特征。为自己的思路提供了一个清晰的画面。增加了自己思维能力。实验六 VRML 创建三维场景实验目的 学习 VRML 编程知识,掌握 VRML 基本编程技能 实验内容分别做如下操作: 利用 VRML 构建具有地形、房子及汽车的三维场景并在该
35、场景中实现汽车奔跑的动画。其中, 地形和房子的三维造型需通过原始数据自行构建,汽车造型通过 inline 方式载入已给定的 wrl 文件。 实验要求 撰写实验报告,内容包括:实验目的、实验内容、实验要求、实验步骤、实验结果。报告要 求有封面、标题、姓名学号等信息,格式要求规范。实验数据部分截图:实验代码实验代码如下: #VRML V2.0 utf8Shape appearance Appearance material Material texture ImageTexture urlC:abc.jpg geometry ElevationGrid xDimension 320 zDimens
36、ion 220 xSpacing 1.0 zSpacing 1.0 creaseAngle 0.1 height 注;括号内为原始Dem数据 Transform rotation 0 1 0 0.677016 translation186 16 92children Shape appearance Appearance material Material texture ImageTexture urlC:acd.jpggeometry Box size 60 10 36Group children DEF car Transform children Inline url C:car.wr
37、lbboxCenter 86 10 213bboxSize 40 40 40DEF clock TimeSensor cycleInterval 20loop TRUEDEF carpath PositionInterpolator key0.00 0.25 0.50 0.75 1.00 keyValue 86 10 213 88 10 181 107 10 161 136 10 135 155 10 107 ROUTEclock.fraction_changedTO carpath.set_fraction ROUTEcarpath.value_changed TO car.translatio实验结果如图:实验体会:结合理论与实践了解了VRML编程的相关知识,对VRML语言有一定深入认识。通过本次实验,我进一步掌握了课程所学知识,懂得了理论联系实践的应用,也增强了一定编程能力。遇到问题及时向老师同学请教。综上,本次实验不仅巩固了理论知识,又增强了个人动手能力。在今后的学习过程中,我会再接再厉,不断提高自己的编程水平。