AFai

AFai
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年12月27日

摘要: 本文是整个系列文章的最后一篇,将创建一个完整的虚拟office应用程序(如图所示)来做为ending.1,在CCY457OpenGLView类中加入下述变量,用来保存office内各个物体的显示列表//DisplayListNamesGLuintm_SceneList;GLuintm_ComputerList;GLuintm_ChairList;GLuintm_BlindsList;GLuintm_MonitorList;GLuintm_BooksList;GLuintm_PhoneList;GLuintm_DoorList;2,创建房间内部场景//CreatetheDisplayListfo 阅读全文

posted @ 2011-12-27 09:33 阿Fai 阅读(359) 评论(0) 推荐(0) 编辑

摘要: 本文将介绍如何从Obj文件格式中创建3D对象,我们使用的是Nate Miller的obj格式加载类。This would be very useful to create large Virtual Reality applications as we could make use of the readily available 3D model files or make use of modeling tools to create these models and load them instead of creating them programatically. The .obj 阅读全文

posted @ 2011-12-27 09:32 阿Fai 阅读(358) 评论(0) 推荐(0) 编辑

摘要: ReflectionsAdding reflections to a program too can improve its realism to a great extent. Here we'll look at a simple method to create reflection where we simply redraw the object with an appropriate transformation and make the surface in between translucent. This creates an effective illusion o 阅读全文

posted @ 2011-12-27 09:31 阿Fai 阅读(305) 评论(0) 推荐(0) 编辑

摘要: ShadowsConceptually drawing a shadow is quite simple. A shadow is produced when an object keeps light from a source from striking some object or surface behind the object, casting the shadow. The area on the shadowed object's surface outlined by the object casting the shadow appears dark. We can 阅读全文

posted @ 2011-12-27 09:31 阿Fai 阅读(252) 评论(0) 推荐(0) 编辑

摘要: 本文在第11篇文章的基础上,为其加入显示各种二次曲面的代码;QuadricsEvery quadric has a few settings associated with it. We have to create a quadric first and then customize its settings to render the shape we want. ThegluNewQuadricfunction creates a state variable that describes the current drawing style, orientation, lighting 阅读全文

posted @ 2011-12-27 09:30 阿Fai 阅读(208) 评论(0) 推荐(0) 编辑

摘要: SelectionSelectionis a powerful feature of OpenGL that allows you click at some position of the OpenGL window using the mouse and determine which of your objects lie beneath it. The act of selecting a specific object is calledPicking. With OpenGL's selection feature, we can specify a viewing vol 阅读全文

posted @ 2011-12-27 09:30 阿Fai 阅读(291) 评论(0) 推荐(0) 编辑

摘要: 本文对第11篇文章进行修改,使用显示列表来存储渲染命令。显示列表OpenGL provides a facility to create a preprocessed set of OpenGL commands called a display list. Creating a display list is a straight forward process. We just have to delimit the display list code with glNewList and glEndList. The display list is named by an integer 阅读全文

posted @ 2011-12-27 09:29 阿Fai 阅读(189) 评论(0) 推荐(0) 编辑

摘要: wglUseFontBitmaps函数The wglUseFontBitmaps() function creates a set of bitmap display lists based on the glyphs in the currently selected font in the current DC for use in the current OpenGL RC. It basically creates a series of sequential display lists which can be executed using the function glCallLi 阅读全文

posted @ 2011-12-27 09:29 阿Fai 阅读(302) 评论(0) 推荐(0) 编辑

摘要: Blending and TransparencyBlending in OpenGL provides pixel-level control of RGBA color storage in the color buffer. To enable blending we must first callglEnable(GL_BLEND). We have to set up the blending functionglBlendFuncwith two arguments: the source and the destination colors. By default these a 阅读全文

posted @ 2011-12-27 09:26 阿Fai 阅读(215) 评论(0) 推荐(0) 编辑

摘要: 本文在第9篇文章的基础上,为立方体加入纹理映射的功能。Texture MappingTexture Mapping in OpenGL is a fairly straightforward concept. Every texture is nothing but an image of some sort. Texture mapping is basically applying a texture to a surface. Textures can be 1D, 2D or even 3D. A 1D texture is an image with either a width o 阅读全文

posted @ 2011-12-27 09:25 阿Fai 阅读(236) 评论(0) 推荐(0) 编辑

摘要: 本文在第8篇文章的基础上,为其加入灯光效果。MaterialsOpenGL materials are description of what objects are made of. It basically specifies how much of light they reflect and this is what we would be seeing. OpenGL lighting goes a long way towards modeling real world lighting. In order achieve proper lighting effects in Op 阅读全文

posted @ 2011-12-27 09:25 阿Fai 阅读(236) 评论(0) 推荐(0) 编辑

摘要: OpenGL支持两种颜色模式:RGBA和颜色索引模式,本文关注于前者。Smooth Shading and Flat ShadingWhen Smooth Shading is specified, the color values are interpolated between vertices. If Flat Shading is specified, one vertex is selected as being representative of all the vertices, thus the entire primitive is displayed using one s 阅读全文

posted @ 2011-12-27 09:25 阿Fai 阅读(160) 评论(0) 推荐(0) 编辑

摘要: 本文中将对第5篇文章的太阳系模型进行修改,加入一些动画效果。此外还会加入显示帧速率的代码。加入动画效果最容易的方法是响应WM_TIMER消息,在其消息处理函数中改变一些参数值,比如每过多少毫秒就旋转一定的角度,并且重绘场景。Frame RateFrame rate is nothing but the number of frames that can be rendered per second. The higher this rate, the smoother the animation. In order to calculate the frame rate we retrieve 阅读全文

posted @ 2011-12-27 09:24 阿Fai 阅读(295) 评论(0) 推荐(0) 编辑

摘要: 在上一篇的基础上加入对键盘和鼠标的事件处理程序,以便用其来控制3D物体的旋转和移动。1,首先在CCY457OpenGLView类中为WM_KEYDOWN, WM_LBUTTONDOWN, WM_LBUTTONUP和WM_MOUSEMOVE四个事件加入事件处理函数。2,在CCY457OpenGLView.h中加入下列用于控制旋转和移动的变量:GLfloatm_xAngle;GLfloatm_yAngle;GLfloatm_xPos;GLfloatm_yPos;CPointm_MouseDownPoint;并在构造函数中初始化:CCY457OpenGLView::CCY457OpenGLView( 阅读全文

posted @ 2011-12-27 09:24 阿Fai 阅读(307) 评论(0) 推荐(0) 编辑

摘要: Transformations - Translation, Rotation and ScalingTranslation is nothing but moving along an arbitrary axis. Rotation is spinning about an arbitrary axis. Scaling is increase or decrease in size along an arbitrary axis. One important point to remember is that OpenGL uses a right hand coordinate sys 阅读全文

posted @ 2011-12-27 09:23 阿Fai 阅读(238) 评论(0) 推荐(0) 编辑

摘要: 视见体Viewing Volume is nothing but the region of 3D Cartesian space in that will occupy the window. It is nothing but the minimum and maximum x, y and z values that are inside the window. So if a vertex is outside this range of x, y and z values then they are clipped by OpenGL before rendering can occ 阅读全文

posted @ 2011-12-27 09:23 阿Fai 阅读(317) 评论(0) 推荐(0) 编辑

摘要: 剪裁区域In OpenGL when you create a window to draw in we must specify the coordinate system we want to use and how to map the specified coordinates into physical screen coordinates. We would be using the 2D Cartesian coordinate system with the origin 0,0 at the centre of the screen. Before we can start 阅读全文

posted @ 2011-12-27 09:22 阿Fai 阅读(306) 评论(0) 推荐(0) 编辑

摘要: WGL – Windows的OpenGL扩展层The WGL extension consists of a set of functions (wglCreateContext, wglDeleteContext etc.) and structures (such as PIXELFORMATDESCRIPTOR, GLYPHMETRICSFLOAT) etc. Thus every OpenGL implementation has a platform-specific portion which has to be set up and used according to the p 阅读全文

posted @ 2011-12-27 09:21 阿Fai 阅读(528) 评论(0) 推荐(1) 编辑

摘要: 3D图形学基本概念PerspectivePerspective refers to the angles between the lines that lend the illusion of three dimensions.Colors and ShadingMoving beyond line drawing, we need to add color to create a solid object. Shading refers to the way the color is applied to the polygon. Shading can be of two types in 阅读全文

posted @ 2011-12-27 09:21 阿Fai 阅读(390) 评论(0) 推荐(0) 编辑