ImageVerifierCode 换一换
格式:DOCX , 页数:21 ,大小:1.81MB ,
资源ID:4398283      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4398283.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(虚拟现实与仿真技术实验报告DOC 20页.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

虚拟现实与仿真技术实验报告DOC 20页.docx

1、虚拟现实与仿真技术实验报告DOC 20页虚拟现实与仿真技术-实验报告(DOC 20页)实验一一.实验名称Ogre部分仿真实验二.实验过程或实验程序(增加的代码及代码注解)1.从3Dmax8中导出mesh并添加mesh到场景1.1启动3Dmax1.在安装有3Dmax8的计算机上,可以使用两种不同的方法来启动3Dmax8: (1)在桌面上双击“3Dmax8”图标 (2)点击“开始”菜单,在“程序”中的选择“3Dmax8”2.观察3Dmax8主窗口的布局。3Dmax8主要由若干元素组成:菜单栏、工具栏、以及停靠在右边的命令面板和底部的各种工具窗口。1.2使用3Dmax8建模并导出mesh1.2.1导

2、出mesh的步骤如下: 1.启动3Dmax8 2.在停靠在右边的命令面板中,点击几何体按钮 3.选择标准几何体 4.在对象类型中选择对象(如:长方体),在“前”视口中,通过单击鼠标左键,创建出模型 5.在工具栏中单击“材质编辑器”按钮,通过上步操作,可开启“材质编辑器”对话框 6.在“材质编辑器”对话框中,点击漫反射旁方形按钮,进入到“材质/贴图浏览器” 7.在“材质/贴图浏览器”中选择位图,鼠标左键双击位图 8.弹出选择位图图像文件对话框,从本地电脑中选择一张图片 9.选择好图片,在材质编辑器对话框中,点击将材质指令给选定对象 10.点击菜单栏上的oFusion按钮,在弹出的菜单栏中选择Ex

3、port Scene 11选择文件夹并输入文件名qiu,点击保存,在弹出的对话框中勾选Copy Textures,点击Export按钮,此时mesh文件已成功导出1.3导出的mesh文件放入到指定位置 1.找到mesh文件,把mesh文件放到当前电脑的OgreSDK的models中,以我的电脑为例,OgerSDK放在C盘中; 2.打开C盘,找到OgreSDK,打开OgreSDK,找到media,打开media文件夹,找到models,打开models文件夹,将mesh文件复制到此文件夹中; 3.将导出mesh文件附带的材质文件qiu.material放到OgreSDK的scripts(C:Og

4、reSDKmediamaterialsscripts)中;4.将导出mesn文件时同时导出的图片放到OgreSDK的textures(C:OgreSDKmediamaterialstextures)中。1.4 mesh文件导入到场景中1.4.1 mesh文件导入到场景中步骤: 1.启动vs2008 2.在“文件”菜单中选择“打开”,然后单击“项目/解决方案” 3.找到项目MFCOgre1,选择MFCOgre1.sln,点击打开按钮 4.打开MFCOgre1View.h,创建节点变量,SceneNode *node1(MFCOgre1View.h 中的第55行),创建实体变量 Entity* e

5、nt1(MFCOgre1View.h 中的第57行); 5.打开MFCOgre1View.cpp, 在MFCOgre1View.cpp的构造函数中对创建的节点和实体对象初始化node1(NULL)、 ent1(NULL)(在MFCOgre1View.cpp 的第37行和第39行) 6.获取根节点的子节点,并将其赋值给节点node1( MFCOgre1View.cpp 的第225行) 7.给创建的实体对象ent1赋值( MFCOgre1View.cpp 的第224行) 8.设置节点的位置( MFCOgre1View.cpp 的第226行)9.将实体附在节点上( MFCOgre1View.cpp

6、的第227行)1.5生成项目 使用“生成项目”功能可以将程序的源代码文件编译为可执行的二进制文件,方法十分简单:在“生成”菜单中选择“生成解决方案”。 在项目生成过程中,“输出”窗口会实时显示生成的进度和结果。如果源代码中不包含语法错误,会在最后提示生成成功,如下图所示:1.6执行项目 在MFCOgre1中选择“调试”菜单中的“开始执行(不调试)”,可以执行刚刚生成的程序,运行出实验要求的结果。2.键盘输入控制摄像机的移动2.1添加按键消息响应 1.在菜单栏中选择视图 2.点击视图,在弹出的菜单窗口中,选择类视图 3.在类视图中,选择类MFCOgre1View 4.再次选择菜单栏中的视图,在菜

7、单的菜单窗口中,选择其他窗口 5.在其他窗口中,选择属性窗口 6.在属性窗口中,点击消息按钮7.找到WM_KEYDOWN,添加OnKeyDown()消息响应函数2.2在OnKeyDown()消息响应函数中,添加按键控制1.找到MFCOgre1View.cpp的onKeyDown()( MFCOgre1View.cpp 的第296行)2.创建一个3维变量Vector3 trans = Vector3:ZERO;2.使用switch语句,判断用户按下的按键3.如果用户按下的是A键,将变量trans的x坐标减10,然后将摄像机移动到当前的trans坐标处(注:按键消息获取的都是大写字母),则摄像机向

8、左移动,代码如下:caseA: trans.x -=10; m_pCamera-moveRelative(trans); break;4. 如果用户按下的是D键,将变量trans的x坐标加10,然后将摄像机移动到当前的trans坐标处(注:按键消息获取的都是大写字母),则摄像机向左移动caseD: trans.x +=10; m_pCamera-moveRelative(trans); break;2.3生成项目 使用“生成项目”功能可以将程序的源代码文件编译为可执行的二进制文件,方法十分简单:在“生成”菜单中选择“生成解决方案”。 在项目生成过程中,“输出”窗口会实时显示生成的进度和结果。如

9、果源代码中不包含语法错误,会在最后提示生成成功,如下图所示:2.4执行项目 在MFCOgre1中选择“调试”菜单中的“开始执行(不调试)”,可以执行刚刚生成的程序,运行出实验要求的结果。3.添加动画3.1添加动画 1.在MFCOgreView1.h中创建void CreateAnimation(Ogre:String MyAnimation);( MFCOgreView1 中第77行) 2.创建一个全局变量AnimationState *as( MFCOgreView1.cpp 中第17行) 3.实现void CreateAnimation(Ogre:String MyAnimation);(

10、MFCOgre1View.cpp中第319行) 4.判断动画是否存在,如果动画存在,删除已有的动画 5.使用sceneManager来创建一个animation,同时指定动画的名字和帧的长度 6. 设置该段动画的关键帧间帧的插值方式,这里使用线性 7. 使用animation创建为每个要驱动的node创建一个track, 比如这里我们只想让一个结点(node,比如它上面挂着摄像机)运动,就只为他创建一个track就行了,第一个参数是这个track的编号 8. 对于每个track创建它的每个关键帧 9. 设置该帧的时间点 10. 设置该帧处这个结点的位置和其他几何状态 11.设置动画运动状态 1

11、2.在项目解决方案资源管理器中,找到MFCOgre1 13.右击MFCOgre1,在弹出的界面中,选择添加类 14.选择MFC类,点击添加,在类名中输入MyFrameListener 15.在MyFrameListener.h中类MyFrameListener继承FrameListener 16.在MyFrameListener.h中添加virtual bool frameStarted(const FrameEvent &evt);( 在MyFrameListener.h的第12行 ) 17.在MyFrameListener.cpp中重写frameStart()函数(在MyFrameList

12、ener.cpp第14行),代码如下:bool MyFrameListener:frameStarted(const FrameEvent &evt) if(NULL != as) as-addTime(evt.timeSinceLastFrame); return true; 18.在MFCOgre1View.cpp的构造函数中创建关联监听类对象(m_pRoot-addFrameListener(new MyFrameListener();)(在MFCOgre1View.cpp第50行) 19. 找到MFCOgre1View.cpp的onKeyDown()( MFCOgre1View.cpp

13、 的第296行)使用switch语句,判断用户按下的按键,代码如下:caseM: CreateAnimation(MyAnimation);break;三.实验结果(包括必要的截图)根据前面的实验步骤,最终得到下面的截图:1.将桌子这个实体模型导入到Ogre中,如下图所示:该截图说明mesh文件添加到场景中成功。2.将场景分别绕X轴、Y轴和Z轴旋转,如下图所示(1)绕X轴旋转:(2)绕Y轴旋转:(2)绕Z轴旋转:同样可以通过添加如下代码控制摄像机的移动:caseA: trans.x -=10; m_pCamera-moveRelative(trans); break;因此,在执行程序的时候,按

14、键“A”可以实现场景的向左移动;caseD: trans.x +=10; m_pCamera-moveRelative(trans); break;因此执行程序的时候,按键“D”可以实现场景的向右移动。四.实验体会1、思考题解答:(1)如何控制摄像机的上下移动、前后移动?解:控制摄像机的上下移动可以通过控制摄像机的Z坐标,例如要是想要向上移动,则可以使tran.z+=10,向下移动的话则可以使tran.z-=10;控制摄像机的前后移动则需要改变摄像机的Y坐标,例如要是想要向前移动,则可以使tran.y+=10,向后移动的话则可以使tran.y-=10。(2)如何控制摄像机的旋转?(函数 voi

15、d pitch(const Radian& angle); /绕X轴旋转 函数 void yaw(const Radian& angle); /绕Y轴旋转 函数 void roll(const Radian& angle); /绕Z轴旋转)解:控制摄像机的旋转已经在程序中实现,如上面的截图所示,通过函数 void pitch(const Radian& angle),使得摄像机绕轴X旋转,具体每次旋转的角度可以在函数的参数中进行设置;通过函数 void yaw(const Radian& angle),使得摄像机绕轴Y旋转;通过函数 void roll(const Radian& angle)

16、,使得摄像机绕轴Z旋转。(3)按下M键,实体球可以沿着直线运动,通过键盘控制实体球,实体球是否可以沿着曲线运动?解:通过键盘控制实体球,实体球是可以沿着曲线运动的,只需要在相应的控制按键的开关语句中调用一个能够让实体球沿着曲线运动的函数,该实体球的运动曲线可以设置为BS曲线等等。2、实验感想 通过本次实验,我初步认识和了解了Ogre这款软件,该软件能够创建三维场景,所以被用于游戏等等场合中。本次实验,我自己按照实验指导书一步步的从用3Dmax创建三维实体模型,然后生成mesh文件,将mesh文件导入到Ogre场景中,给实体模型添加材质,并且通过添加相应的代码使得实体球能够运动起来,添加相应的代

17、码使得场景左右移动、上下移动、前后移动和绕轴旋转等等,这些所有的内容虽然做的不是很漂亮,但是让自己尝试了在Ogre中如何完整的创建简单的三维模型。 实验二 一.实验名称PathFinder疏散仿真实验二.实验过程或实验程序(增加的代码及代码注解)1、Create Geometry1. On the View menu, click Units and select EN to display measurements using the English system.To specify snap grid spacing:1. On the View menu, click Edit Sna

18、p Grid.2. In the Specify snap grid spacing menu, type 2.0. By default, length units will be in feet, however, you can type a value followed by a unit (e.g.: in or m) and the length will be converted to feet.3. Click OK.To define the default floor height:1. In the Floor Height box(on the above Toolba

19、r), type 12.0.To create the room:1. In the View toolbar, click Top View ( ).2. In the Tools toolbar, click Add a Rectangular Room ( ).3. In the Z Plane box, type 0.0.4. In the coordinate boxes enter the following values: X1: 0.0, Y1: 0.0, X2: 60.0, Y2: 40.0. 5. Click Create.Replicate the room to cre

20、ate three floors.1. In the View toolbar, click the Selection Tool icon . 2. Select the room.3. In the Tools toolbar, click the Move Objects icon .4. Select Copy Mode. 5. In the Copies box type 2.6. In the Move Z box, type 12.0.7. Click Copy/Move.8. Click the Zoom Fit icon to rescale the view.Your mo

21、del should now look like Figure 1. Figure 1: The floors in the modelTo define the landings:1. Create the first landing at Z=6.0 ft. In the View toolbar, click Top View ( ). In the Tools toolbar, click Add a Rectangular Room ( ). In the Z Plane box, type 6.0. In the coordinate boxes enter the followi

22、ng values: X1: -13.5, Y1: 16.0, X2: -9.5, Y2: 24.0. Click Create.2. Replicate the landing. In the View toolbar, click the Selection Tool icon . Select the landing. In the Tools toolbar, click the Move Objects icon . Select Copy Mode. In the Copies box type 1.In the Move Z box, type 12.0. Click Copy/

23、Move.3. Repeat for the landing on the opposite side. In the View toolbar, click Top View ( ). In the Tools toolbar, click Add a Rectangular Room ( ). In the Z Plane box, type 6.0. In the coordinate boxes enter the following values: X1: 69.5, Y1: 16.0, X2: 73.5, Y2: 24.0. Click Create.4. Replicate th

24、e landing. In the View toolbar, click the Selection Tool icon . Select the landing. In the Tools toolbar, click the Move Objects icon . Select Copy Mode. In the Copies box type 1. In the Move Z box, type 12.0. Click Copy/Move.Your model should now look like Figure 2. Figure 2:The floors and landings

25、 in the modelTo add the first stairway on the left side of the building:1. In the Tools toolbar, click Create Stairs between two edges ( ).2. In the Stair Width box, type 44.0 in. In the Door 1 Width box and the Door 2 Width box, type 32.0 in. 3. Click on the lower landing and position the stair tow

26、ards the front side of the landing. Click on the lower floor to create the stairs from the landing to the lower floor, Figure 3.4. Use the Move Objects tool to make 1 copies of the stair, separated by 12 ft in the Z direction.5. Add the stairs that go up from the landing. Click on the lower landing

27、and position the stair opposite the first stairs. Click on the second floor to create the stairs from the landing to the second floor.6. Use the Move Objects tool to make a copy of the stair, separated by 12 ft in the Z direction.7. Repeat on the other side of the model. This time, position the firs

28、t stairs on the back side of the landing. Figure 3 : First stairs on left side of buildingAdd the exit doors:1. Select the door tool ( ) and in the Max Width box, type 120.0 in.2. Place a door adjacent to both stairs on the lowest floor. These doors are wide enough that exit from the first floor doe

29、s not affect the egress time. 3. Name the doors Right Exit and Left Exit to aid in later plotting of the exit rates through each door, Figure 4. Figure 4: The left ExitAdd OccupantsTo add occupants:1. Select the first (lowest) floor. On the Model menu click Add Occupants. For Occupant Count select B

30、y Number and type 100. Click OK.2. Repeat for each floor, selecting the corresponding profile for each floor. When finished, your model should look like Figure 5Figure 5: Pathfinder model with occupants三实验结果(包括必要的截图)1、实验最终结果截图显示:2、仿真截图显示:3、人群疏散仿真模拟截图显示:四实验体会本次实验主要就是熟悉Pathfinder软件的使用,在本次实验的过程中,我觉得这款软

31、件的功能还是很强大的,也很有趣,我们可以在这个平台上来进行人群疏散的仿真。该平台能够很好的将模型疏散和人群疏散显示出来。但是我觉得这款软件有一个缺点,那就是楼梯的边缘检测做的不够细致,直接导致人群疏散的时候下楼的人们的脚可以被看见。 实验三 一实验名称基于OGRE的Boids算法实验二实验过程或实验程序(增加的代码及代码注解)3.1基于OGRE的Boids算法实现1.拷贝MyBoids.h,MyBoids.cpp到E:MFCOgre1MFCOgre1(对应的项目位置)2.添加MyBoids.h、MyBoids.cpp到工程中3.在MFCOgre1View.h中引入头文件MyBoids.h(#include MyBoids.h)4.在MFCOgre1View.cpp的OnInitialUpdate()函数(OnInitialUpdate()在MFCOgre1View的第115行)中,添加函数AllInit();5.打开MFC

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1