tailieunhanh - Advanced 3D Game Programming with DirectX - phần 7

Nếu có một ngọn núi dốc đứng tách nó từ mục tiêu của nó, con đường hợp lý nhất sẽ được đi bộ xung quanh núi, thay vì whipping thiết bị leo núi. Một định nghĩa chính xác hơn một chút của một con đường hợp lý là con đường của ít nhất là kháng chiến. Kháng có thể được định nghĩa là một trong một triệu điều có thể, từ một hố nham thạch để một kẻ thù mạnh mẽ để một | struct mtVertex points m loc points m norm ulong m diff ulong m spec texCoord2 m texl texCoord3 m tex2 Position Normal Color Diffuse Color Specular static ulong m fvfFlags ulong mtVertex m fvfFlags D3DFVF_XYZ D3DFVF_NORMAL D3DFVF_DIFFUSE D3DFVF_SPECULAR D3DFVF_TEXCOORDSIZE2 0 set 0 is 2-dimensional D3DFVF_TEXCOORDSIZE3 1 set 1 is 3-dimensional Primitive Types When drawing primitives using the D3D device you need to inform the device what type of primitive you would like it to draw. Currently Direct3D can draw three types of primitives points lines and triangles. D3DPT_POINTLIST The data being handed to the driver is a list of points. The Direct3D device draws one pixel for each vertex handed to it. D3DPT_LINELIST The data being handed to the driver is a list of lines. The number of vertices provided to the device must be even. If n vertices are passed in n 2 lines are drawn. For example the third line D3D draws is from the fourth to the fifth vertex. 427 D3DPTLINESTRIP Direct3D draws a continuous strip of lines. Each vertex besides the first becomes the endpoint of a line with a beginning of the vertex before it. D3DPT _TRIANGLELIST Direct3D draws a list of distinct triangles. Each three vertices are rendered as a triangle. Of course the number of vertices supplied to the DrawPrim functions must be a multiple of three. D3DPT _TRIANGLESTRIP Direct3D draws a triangle strip each vertex after the first two defining the third point of a triangle. See Chapter 5 for a discussion of triangle strips. D3DPT _TRIANGLEFAN Direct3D draws a triangle fan each vertex after the first two defining the third point of a triangle. See Chapter 5 for a discussion of triangle fans. The DrawPrimitive Functions There are four total functions to draw primitives for us. They are all very similar and once you ve mastered one you ve pretty much mastered them all. Let s take a look at each of them. DrawPrimitive DrawPrimitive is the most basic primitive drawing function. It simply takes the .