次の方法で共有


Untransformed and Unlit Vertices (Windows Embedded CE 6.0)

1/6/2010

The presence of the D3DMFVF_XYZ and D3DMFVF_NORMAL flags in the vertex description that you pass to rendering methods identifies the untransformed and unlit vertex type, see D3DMFVF Values. By using untransformed and unlit vertices, your application effectively requests that Microsoft® Direct3D® Mobile perform all transformation and lighting operations using its internal algorithms. You can disable the Direct3D Mobile lighting engine for the primitives being rendered by setting the D3DMRS_LIGHTING render state (see D3DMRENDERSTATETYPE) to FALSE.

Many applications use this vertex type, as it frees them from implementing their own transformation and lighting engines. However, because the system is making calculations for you, it requires that you provide a certain amount of information with each vertex.

You are required to specify vertices in untransformed model coordinates. The system then applies world, view, and projection transformations to the model coordinates to position them in your scene and determine their final locations on the screen.

You can include a vertex normal for more realistic lighting effects. Vertices lit by the system that do not include a vertex normal will use a dot product of 0 in all lighting calculations. These vertices are assumed to receive no incident light. The system uses the vertex normal, along with the current material, in its lighting calculations. For details, Lights, Materials, and Lighting Equations.

Other than these requirements, you have the flexibility to use or disregard the other vertex components. For example, you can include a diffuse or specular color with your untransformed vertices. Including individual colors for each vertex makes it possible to achieve shading effects that are more subtle and flexible than lighting calculations that use only the material color. Keep in mind that you must enable per-vertex color through the D3DRS_COLORVERTEX render state. Untransformed, unlit vertices can also include up to eight sets of texture coordinates.

When you define your own vertex format, remember which vertex components your application needs, and make sure they appear in the required order by declaring a properly ordered structure. The following code example declares a valid vertex format structure that includes a position, a vertex normal, a diffuse color, and two sets of texture coordinates.

//
// The vertex format description for this vertex would be:
// (D3DMFVF_XYZ_FLOAT | D3DMFVF_NORMAL_FLOAT |  D3DMFVF_DIFFUSE
// | D3DMFVF_TEX2)
//
typedef struct _UNLITVERTEX
{
    float x, y, z;     // position
    float nx, ny, nz;  // normal
    DWORD Diffuse;     // diffuse color
    float tu1, tv1;    // texture coordinates
    float tu2, tv2;
  tv2;
} UNLITVERTEX, *LPUNLITVERTEX; 

The vertex description for the preceding structure is a combination of the D3DMFVF_XYZ_FLOAT, D3DMFVF_NORMAL_FLOAT, D3DMFVF_DIFFUSE, and D3DMFVF_TEX2 flexible vertex format flags.

For more information, see Vertex Data Description.

See Also

Concepts

Vertex Formats