OSG场景漫游实验四.doc

OSG场景漫游实验四

天津理工大学 计算机科学与技术学院 实验报告 2015 至 2016 学年 第 二 学期 课程名称 计算机图形学 学号 学生姓名 年级 专业 课程号 实验地点 实验时间 主讲教师 辅导教师 实验( 四 ) 实验名称 场景漫游 软件环境 Visual Studio 2010 OSG-3.1.0 Windows 7 硬件环境 2G内存 显卡GT610 CPU奔腾双核 硬盘320G 实验目的 掌握透视投影与平行投影的基本原理。 掌握投影变换的操作方法。 实验内容(应包括实验题目、实验要求、实验任务等) 实验题目: 构建地形场景。 构建人物模型 交互式方式浏览场景各部分 交互式人的运动操作 设计视点运动轨迹 实验要求: 采用OpenSceneGraph创建图形窗口和实现人机交互功能,采用方向键控制对场景的浏览。 要求漫游操作方便,视点运动自然流畅。 提交电子版实验报告及工程代码,试验报告模板可参考计算机学院统一模板 提交的工程代码必须删除其中的Debug或Release文件夹 实验过程与实验结果(可包括实验实施的步骤、算法描述、流程、结论等) 节点模型: 实验步骤: 用Node节点去放置加载的地形数据,并加载之前设定的机器人,将其放入同一个场景之中; 建立类并使其继承osgGA::CameraManipulator,处理鼠标键盘事件,对各种操作进行处理,实现场景漫游,对不同的按键处理不同的操作,主要为机器人前进、后退,转身,以及通过方向键控制漫游,实现相机视点的旋转,通过w/s/a/d键实现视点的前进后踢,通过i/k/j/l键实现机器人的运动; 通过单机F键实现窗口视图和全屏视图; 将程序各模块接入主程序,实现场景的自由漫步。 实验效果: 附录(可包括源程序清单或其它说明) 源程序: #include osgViewer/Viewer #include osg/LineSegment #include osg/Point #include osg/Geometry #include osgGA/CameraManipulator #include osgUtil/IntersectVisitor #include vector #include iostream #include osg/Node #include osg/Geode #include osg/Group #include osgDB/ReadFile #include osgDB/WriteFile #include osgUtil/Optimizer #include osg/MatrixTransform #include osgViewer/ViewerEventHandlers #include osgGA/StateSetManipulator #include osg/ShapeDrawable #include osgViewer/ViewerEventHandlers #include osgUtil/LineSegmentIntersector #include osgGA/GUIEventHandler #include osg/Matrixd #include osg/MatrixTransform using namespace std; osg::ref_ptrosg::MatrixTransform root_Tr = new osg::MatrixTransform; osg::ref_ptrosg::MatrixTransform head_Tr = new osg::MatrixTransform; osg::ref_ptrosg::MatrixTransform body_Tr = new osg::MatrixTransform; osg::ref_ptrosg::MatrixTransform left_arm_Tr =new osg::MatrixTransform; osg::ref_ptrosg::MatrixTransform right_arm_Tr =new osg::MatrixTransform; osg::ref_ptrosg::MatrixTransform left_leg_Tr =new osg::MatrixTransform; osg::ref_ptrosg::MatrixTransform righ

文档评论(0)

1亿VIP精品文档

相关文档