基于OPENGL的陨石爆炸视景仿真系统开发外文翻译资料

 2022-09-23 17:06:10

What Is OpenGL?

OpenGL is a software interface to graphics hardware. This interface consists of about 150 distinct commands that you use to specify the objects and operations needed to produce interactive three-dimensional applications.

OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many different hardware platforms. To achieve these qualities, no commands for performing windowing tasks or obtaining user input are included in OpenGL; instead, you must work through whatever windowing system controls the particular hardware youre using. Similarly, OpenGL doesnt provide high-level commands for describing models of three-dimensional objects. Such commands might allow you to specify relatively complicated shapes such as automobiles, parts of the body, airplanes, or molecules. With OpenGL, you must build up your desired model from a small set of geometric primitives - points, lines, and polygons.

A sophisticated library that provides these features could certainly be built on top of OpenGL. The OpenGL Utility Library (GLU) provides many of the modeling features, such as quadric surfaces and NURBS curves and surfaces. GLU is a standard part of every OpenGL implementation. Also, there is a higher-level, object-oriented toolkit, Open Inventor, which is built atop OpenGL, and is available separately for many implementations of OpenGL. (See 'OpenGL-Related Libraries' for more information about Open Inventor.)

Now that you know what OpenGL doesnt do, heres what it does do. Take a look at the color plates - they illustrate typical uses of OpenGL. They show the scene on the cover of this book, rendered (which is to say, drawn) by a computer using OpenGL in successively more complicated ways. The following list describes in general terms how these pictures were made.

  • 'Plate 1' shows the entire scene displayed as a wireframe model - that is, as if all the objects in the scene were made of wire. Each line of wire corresponds to an edge of a primitive (typically a polygon). For example, the surface of the table is constructed from triangular polygons that are positioned like slices of pie.

Note that you can see portions of objects that would be obscured if the objects were solid rather than wireframe. For example, you can see the entire model of the hills outside the window even though most of this model is normally hidden by the wall of the room. The globe appears to be nearly solid because its composed of hundreds of colored blocks, and you see the wireframe lines for all the edges of all the blocks, even those forming the back side of the globe. The way the globe is constructed gives you an idea of how complex objects can be created by assembling lower-level objects.

  • 'Plate 2' shows a depth-cued version of the same wireframe scene. Note that the lines farther from the eye are dimmer, just as they would be in real life, thereby giving a visual cue of depth. OpenGL uses atmospheric effects (collectively referred to as fog) to achieve depth cueing.
  • 'Plate 3' shows an antialiased version of the wireframe scene. Antialiasing is a technique for reducing the jagged edges (also known as jaggies) created when approximating smooth edges using pixels - short for picture elements - which are confined to a rectangular grid. Such jaggies are usually the most visible with near-horizontal or near-vertical lines.
  • 'Plate 4' shows a flat-shaded, unlit version of the scene. The objects in the scene are now shown as solid. They appear 'flat' in the sense that only one color is used to render each polygon, so they dont appear smoothly rounded. There are no effects from any light sources.
  • 'Plate 5' shows a lit, smooth-shaded version of the scene. Note how the scene looks much more realistic and three-dimensional when the objects are shaded to respond to the light sources in the room as if the objects were smoothly rounded.
  • 'Plate 6' adds shadows and textures to the previous version of the scene. Shadows arent an explicitly defined feature of OpenGL (there is no 'shadow command'), but you can create them yourself using the techniques described in Chapter 14. Texture mapping allows you to apply a two-dimensional image onto a three-dimensional object. In this scene, the top on the table surface is the most vibrant example of texture mapping. The wood grain on the floor and table surface are all texture mapped, as well as the wallpaper and the toy top (on the table).
  • 'Plate 7' shows a motion-blurred object in the scene. The sphinx (or dog, depending on your Rorschach tendencies) appears to be captured moving forward, leaving a blurred trace of its path of motion.
  • 'Plate 8' shows the scene as its drawn for the cover of the book from a different viewpoint. This plate illustrates that the image really is a snapshot of models of three-dimensional objects.
  • 'Plate 9' brings back the use of fog, which was seen in bull;呈现三维对象,坐标系统,远近的剪切表面;

    bull;应用三维对象的转化,旋转、尺度变换以及复合转换;

    bull;应用透视投影,建立远近剪切面位置,视角位置,参考点位置,向上向量参数;

    bull;友好的交互能力的界面控件;

    bull;呈现区域和文本区域副窗口最大化演示;

    bull;设置多种光照和材料组件,包括全局环绕光、背景光,漫射光和反射光;

    bull;自定义编码文本演示内容和演示的颜色。

    主要的编码实现简要描述如下:

    bull;主窗口控制

    主窗口使用GLUT和GLUI库函数,相关的代码段如下:

    //创建主窗口

    glutCreateWindow('DEMONSTRATE SYSTEM OF3D GRAPHICS');

    //显示注册回调函数

    glutDisplayFunc(MainDisplay);

    //重塑注册回调函数

    GLUI_Master.set_glutReshapeFunc(MainReshape);

    //ASCII键盘注册回调函数

    GLUI_Master.set_glutKeyboardFunc(MainKeyboard);

    //注册非ASCLL键盘回调函数

    GLUI_Master.set_glutSpecialFunc(MainSpecialKeyboard);

    //注册鼠标回调函数

    GLUI_Master.set_glutMouseFunc(MainMouse);

    //注册GLUI闲置的回调函数

    GLUI_Master.set_glutIdleFunc(MainGlutIdle);

    //注册运动并回调函数

    glutMotionFunc(MainMotion);

    //显示主窗口的位置

    GLUI_Master.auto_set_viewport();

    /*子窗口创建和显示*/

    hellip;

    //激活显示窗口

    glutMainLoop();

    bull;子窗口控制

    三维对象场景和文本窗口使用GLUT库函数实现,三个维对象场景控制函数声明如下:

    void WorldDisplay(void);//显示窗口

    void WorldReshape(int, int);// 绘制窗口

    // 键盘控制

    void WorldKeyboard(unsigned char, int, int);

    void WorldSpecialKeyboard(int, int , int);//Specialkey控制

    void WorldMouse(int, int, int, int);// 鼠标控制

    void WorldMotion(int, int); // 运动控制

    WorldDisplay函数使用常见的GL库函数渲染窗口图形对象。WorldMouse函数可监听鼠标左键双击事件和最大化当前窗口。查看港区和编码描述区域控制函数与空间对象场景函数是一样的。

    交互式控制区域使用GLUI库中的GLUI_Button,GLUI_Rollout,GLUI_Panel,GLUI_Rotation,GLUI_Translation,GLUI_Spinner,GLUI_RadioGroup和GLUI_RadioButton类。当每个控制值改变时,系统可以调用pre-definition全局变量值和MainGLUI回调函数响应交互事件。

    bull;三维物体呈现

    该演示系统定义Model3D类用于保持三维对象属性, 如平移、旋转、尺度参数。Model3D类提供了两个public方法:Update和Render。当每个控件值发生变化时,系统就可以自动调用MainGLUI回调函数,那么MainGLUI函数将继续调用Model3D Update方法更新三维对象的属性。同时,三维对象渲染区域和浏览港区演示窗口可以调用Model3D Render方法重绘三维对象。系统中使用GL和GLUT库函数实现三维对象渲染。

    bull;光照

    该系统使用两个外部光源分别控制对象场景渲染区域和对象查看港区。为了保证演示效果的一致性,两个外部光源均使用相同的光源参数和材料参数。系统可以设置光照位置,全局光的组成颜色,环境光的组成颜色,漫射光的组成颜色,镜面光的组成颜色以及相应的材料颜色参数。

    OpenGL的编码文字描述区子窗口使用GLUT函数来实现右键菜单功能,并支持选择文本内容和文本颜色。该系统首先使用glColor3f功能设置文本颜色,然后使用标准的C fstream来阅读文件中预定的文本内容,最后用glutBitmapCharacter功能来呈现这些文本。

    1. 演示结果

    该系统可灵活生动地显示三维对象的建模,查看和投影变换。图4显示的图形对象和文本当任何控制值的变化时,文本显示效果内容和颜色由右键菜单中的动态设置。图5显示鼠标左键双击这个区域后场景对象区域的最大化显示。如图6所示,各个光源组件由复选框控件表示以便可以观察任何的照明效果,这对理解海防光照模型非常有用。

    1. 结论

    这个演示系统使用OpenGL来实现一个交互式图形界面,通过与系统交互,所有的三维变换都可被灵活生动的展示出来,以便加深用户对图形概念的理解。另外,用户可以通过查询这个系统的OpenGL编码文本,独立进行OpenGL编程练习。因此,该系统具有较高示范价值。目前,一些电脑图形教学和实验材料应用OpenGL代码段来解释图形理论,显然,这个演示系统给他们提供了一个有益的补充。该系统的另一个优点是,因为只有GL,GLU,GLUT和GLUT库函数支持编程的开发进行,所以该系统具有良好的平台独立性。基于我们的系统,很容易进一步实现三维图形高级渲染的演示如质地,以及更多的键盘和鼠标控件。

    写一个OpenGL应用程序

    第一步是选择你的语言。对OpenGL绑定在许多语言中存在,从C#和Java到Python和Lua。有些语言拥有多套的OpenGL绑定的,他们都不是官方的。所有这些最终都是基于C/C 绑定。

    如果你不使用C/C ,你必须下载并安装一个软件包或库包含了OpenGL绑定你选择的语言。一些预装,但其他人有单独的下载。

    如果您正在使用C/C ,那么你必须首先建立一个构建环境(Visual Studio项目,GNU的makefile,CMake的文件等),可以链接到的OpenGL。在Windows下,你需要静态链接到一个名为OpenGL32.lib库(请注意,您还链接到OpenGL32.lib如果你正在建设一个64位可执行文件。在“32”的部分是没有意义的)。Visual Studio中,大多数Windows编译器,并配备了这个库。

    在Linux上,你需要链接到libGL函数。这是与“-lGL”的命令行参数完成。

    初始化

    之前,实际上你可以在程序中使用OpenGL,必须先对其进行初始化。因为OpenGL是平台无关的,没有初始化的OpenGL标准方法;每个平台处理不同的看法。非C/C 语言绑定也可以不同的方式处理这些。

    有OpenGL的初始化的两个阶段。第一个阶段是一个OpenGL上下文的建立;第二阶段是加载所有必要的功能,使用OpenGL。一些非C/C 语言绑定合并这些为一体。

    OpenGL上下文创建

    一个OpenGL上下文代表所有的OpenGL。制作一个非常特定于平台的,以及语言结合特异性。

    如果您使用的是C/C 语言的OpenGL绑定,那么我们强烈建议你使用一个窗口工具箱来管理这个任务。这些库创建一个窗口,附加一个OpenGL上下文这个窗口,该窗口管理基本输入。一旦你熟悉OpenGL的,你就可以开始学习如何手动执行此操作。

    大多数非C/C 语言绑定将为您提供用于创建上下文特定于语言的机制。

    获取功能

    如果您在使用非C/C 语言绑定,那么该维护者结合已经将处理这个作为创作背景的一部分。如果您正在使用C/C ,请继续阅读。

    为了使用OpenGL,你必须得到OpenGL的API函数。对于你所熟悉的大多数图书馆,你只是#包括一个头文件,确保一库被链接到您的项目或makefile文件,而这一切的作品。 OpenGL的不工作的方式。

    对于最终都是这里的问题无关的原因,你必须手动通过特定于平台的API调用加载函数。这个样板的工作与各种OpenGL的库加载完成的;这些使这个过程顺利。我们强烈建议您使用一个。

    如果你想要做手工然而,有一个指导用户手动加载功能。你还是应该使用延长加载器。

    利用OpenGL

    OpenGL是一个渲染库。什么OpenGL的不就是保留有关一个“对象”的信息。所有的OpenGL看到的是三角形的一个球和状态,用以使它们的袋子。它不记得你在一个位置,而在另一个球划了一道线。

    正因为如此,使用OpenGL的一般方式是吸引你需要绘制的一切,然后显示与平台相关的缓冲区交换命令这个形象。如果你需要更新的形象,你再画的一切,即使你只需要更新图像的一部分。如果你想动画在屏幕上移动对象,则需要一个循环,不断清除并重绘屏幕。

    有只更新屏幕的一部分的技术。您还可以使用OpenGL使用这些技术。但是OpenGL的本身并不做内部;你必须记住,你画的一切。你必须弄清楚什么需要更新和清晰的画面只是一部分。等等。

    有可用于学习如何使用Op

    剩余内容已隐藏,支付完成后下载完整资料


    资料编号:[148065],资料为PDF文档或Word文档,PDF文档可免费转换为Word

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。