天行健 君子当自强而不息

     摘要: 在创建顶点缓冲区之前,需要先定义一个表示顶点的结构类型,描述顶点保存格式的FVF和一个保存顶点的结构数组。  阅读全文
posted @ 2008-04-30 13:26 lovedday 阅读(1382) | 评论 (0)编辑 收藏
     摘要: 图元(primitives)是Direct3D中定义的基本图形表示,它是组成一个单一实体的一组顶点。最简单的图元是三维坐标系中多个点的集合,称为点列表(point list)。通常,图元是多边形(polygon),一个多边形是由至少三条边组成的封闭图形。最简单的多边形是三角形,Direct3D使用三角形来构成大多数其他多边形,这是因为三角形的三个顶点肯定是共面的,而渲染不共面的顶点效率比较低。通过组合三角形可以形成更大、更复杂的多边形和网格(mesh)。  阅读全文
posted @ 2008-04-30 12:25 lovedday 阅读(1535) | 评论 (0)编辑 收藏
D3DFVF_XYZ和D3DFVF_XYZRHW有什么区别?以前好像没有仔细思考过,只是见到Beginning DirectX9中如是说:The RHW value, which stands for Reciprocal of Homogeneous W[1], tells Direct3D that the vertices that are being used are already in screen coordinates. This value is normally used in fog and clipping calculations and should be set to 1.0.

    今天,做了个实验得知,在顶点结构体中没有RHW时,Direct3D将执行视、投影、世界等变换以及进行光线计算,之后你才能在窗口中得到你所绘制的物体。当顶点结构体中有RHW时,就像上面那段英文所述,告知Direct3D使用的顶点已经在屏幕坐标系中了,不再执行视图、投影、世界等变换和光线计算,因为D3DFVF_XYZRHW标志告诉它顶点已经经过了这些处理,并直接将顶点进行光栅操作,任何用SetTransform进行的转换都对其无效。不过这时的原点就在客户区的左上角了,其中x向右为正,y向下为正,而z的意义已经变为z-buffer的象素深度。


    值得注意的是,D3DFVF_XYZRHW和D3DFVF_XYZ、D3DFVF_NORMAL不能共存,因为后两个标志与前一个矛盾。在使用这种顶点时,系统需要顶点的位置已经经过变换了,也就是说x、y必须在屏幕坐标系中,z必须是z-buffer中的象素深度,取值范围:0.0-1.0,离观察者最近的地方为0.0,观察范围内最远可见的地方为1.0。(不过我测试的时候似乎z值不起作用。)


If you use D3DFVF_XYZ, then your vertex format needs to have 3 floats in it, for x, y and z. Those are used to define a vertex position in 3D space.If you use D3DFVF_XYZRHW, then your vertex format needs to have 4 floats in it, for x, y, z and rhw. X and Y are used to define a vertex position in 2D space, Z is ignored (I think, it may be used for fog and such, but I don't recall just now - I always set it to 0.0f), and rhw is the Reciprocal of Homogenous W - which is basically 1 / the depth of the vertex.

Usually, you use D3DFVF_XYZRHW for doing 2D, and D3DFVF_XYZ any other time. However, a lot of people just use D3DFVF_XYZ, and use an orthoganal projection matrix to make it seem 2D.

_______________________

[1] RHW表示投影空间中顶点所在的齐次点(x,y,z,w)(homogeneous point)的w坐标的倒数(reciprocal)。


posted @ 2008-04-30 10:44 lovedday 阅读(5269) | 评论 (5)编辑 收藏
     摘要: Microsoft Direct3D的一种实现方式是通过组件对象模型(Component Object Model, COM)及其接口实现的,在用C++语言和COM接口方式开发的程序中可以直接访问这些接口和对象。Direct3D对象是Direct3D程序中需要创建的第一个对象,也是需要最后一个释放的对象,这里所说的对象是指COM对象。通过Direct3D对象,可以枚举和检索Direct3D设备,这样应用程序就可以在不需要创建设备对象的前提下选择Direct3D渲染设备。  阅读全文
posted @ 2008-04-29 15:45 lovedday 阅读(1893) | 评论 (1)编辑 收藏
     摘要: 使用Direct3D绘制三维图形和使用GDI绘制二维图形的方法非常类似,Direct3D程序中的Direct3D设备对象相当于GDI程序中的 hdc(设备描述表),使用 GDI绘制图形前,通常需要先利用hdc进行相关设置,然后通过hdc进行绘图。同样在Direct3D程序中通常先通过 Direct3D设备接口进行相关的渲染设备设置,然后再渲染图形。而且所有的渲染图形操作必须在函数BeginScene()和EndScene()之间进行。  阅读全文
posted @ 2008-04-29 14:29 lovedday 阅读(1692) | 评论 (0)编辑 收藏
     摘要: Direct3D是基于Microsoft Windows的图形开发接口,它的使用必须建立在Windows窗口的基础上,这就需要创建一个窗口,而创建窗口首先需要注册一个窗口类。示例程序中注册窗口类并根据窗口类创建窗口的代码如下:  阅读全文
posted @ 2008-04-29 13:55 lovedday 阅读(1250) | 评论 (0)编辑 收藏
     摘要: Microsoft Direct3D的一种实现方式是通过组件对象模型(Component Object Model, COM)及其接口实现的,在用C++语言和COM接口方式开发的程序中可以直接访问这些接口和对象。Direct3D对象是Direct3D程序中需要创建的第一个对象,也是需要最后一个释放的对象,这里所说的对象是指COM对象。通过Direct3D对象,可以枚举和检索Direct3D设备,这样应用程序就可以在不需要创建设备对象的前提下选择Direct3D渲染设备。  阅读全文
posted @ 2008-04-29 12:57 lovedday 阅读(2763) | 评论 (2)编辑 收藏
     摘要: Directly manipulating a mesh's vertex buffers is probably the easiest way to work with morphing. For this method you'll need a third mesh that contains the final coordinates of each vertex after morphing; it's this third mesh that you'll render.

To create the third mesh, which I call the resulting morphed mesh, you can clone the source mesh and be on your way.  阅读全文
posted @ 2008-04-28 18:09 lovedday 阅读(1274) | 评论 (0)编辑 收藏
     摘要: Back in the early 90s, a revolutionary computer−graphics animation technique known as morphing hit the big league and was brought into the mainstream, thanks to a man known as Michael Jackson. No, I'm not referring to one of his plastic surgery fiascos−rather, the use of morphing in one of his music videos. Yep, the King of Pop used morphing techniques in his video for the song "Black or White" and created an animation phenomenon that continues to this day.  阅读全文
posted @ 2008-04-28 16:59 lovedday 阅读(825) | 评论 (1)编辑 收藏
     摘要: 一点P上的外力F亦在此平面内。定义力F对z轴的力图1是刚体的一个横截平面,z轴为刚体的转轴,它与横截面的交点为O。作用在刚体内矩为

M= Fd = F r sinθ  阅读全文
posted @ 2008-04-28 10:58 lovedday 阅读(1225) | 评论 (0)编辑 收藏
仅列出标题
共136页: First 10 11 12 13 14 15 16 17 18 Last 

公告

导航

统计

常用链接

随笔分类(178)

3D游戏编程相关链接

搜索

最新评论