Share via


Transformed and Lit Vertices (Windows Embedded CE 6.0)

1/6/2010

If you include a D3DMFVF_XYZRHW flag in your vertex format description, you are telling the system that your application is using transformed and lit vertices. This means that Microsoft® Direct3D® Mobile does not transform your vertices with the world, view, or projection matrices, nor does it perform any lighting calculations. It assumes that your application has taken care of these steps. This fact makes transformed and lit vertices common when porting existing 3-D applications to Direct3D Mobile. In short, Direct3D Mobile does not modify transformed and lit vertices at all. It passes them directly to the driver to be rasterized.

The vertex format flags associated with untransformed vertices and lighting (D3DMFVF_XYZ and D3DMFVF_NORMAL) are not allowed if a D3DMFVF_XYZRHW flag is present. For more about flag dependencies and exclusions, see the description for each of the D3DMFVF Values.

The system requires that the vertex position you specify be already transformed. The x and y values must be in screen coordinates, and z must be the depth value of the pixel to be used in the z-buffer. Z values can range from 0.0 to 1.0, where 0.0 is the closest possible position to the user, and 1.0 is the farthest position still visible within the viewing area. Immediately following the position, transformed and lit vertices must include a reciprocal of homogeneous W (RHW) value. RHW is the reciprocal of the W coordinate from the homogeneous point (x,y,z,w) at which the vertex exists in projection space. This value often works out to be the distance from the eyepoint to the vertex, taken along the z-axis.

Other than the position and RHW requirements, this vertex format is similar to an untransformed and lit vertex. To summarize:

  • The system does not do any lighting calculations with this format, so it does not need a vertex normal.
  • You can specify a diffuse or specular color. If you do not, the system uses 0x0 for specular color and 0xFFFFFFFF for diffuse color.
  • You can use up to eight sets of texture coordinates, or none at all.

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 transformed and lit vertex, with diffuse and specular vertex colors, and one set of texture coordinates.

//
// The vertex format description for this vertex would be
// (D3DMFVF_XYZRHW | D3DMFVF_DIFFUSE |  D3DMFVF_SPECULAR | D3DMFVF_TEX1)
//
typedef struct _TRANSLITVERTEX {
    float x, y;      // screen position    
    float z;         // Z-buffer depth    
    float rhw;       // reciprocal homogeneous W    
    DWORD Diffuse;   // diffuse color    
    DWORD Specular;  // specular color    
    float tu1, tv1;  // texture coordinates
} TRANSLITVERTEX, *LPTRANSLITVERTEX; 

The vertex description for the preceding structure would be a combination of the D3DMFVF_XYZRHW, D3DMFVF_DIFFUSE, D3DMFVF_SPECULAR, and D3DMFVF_TEX1 flexible vertex format flags.

For more information, see Vertex Data Description.

See Also

Concepts

Vertex Formats