Compartilhar via


Processing Vertex Transformations (Windows CE 5.0)

Send Feedback

The IDirect3DMobileDevice::ProcessVertices method provides the ability to transform and light vertices from a particular source buffer and output the resulting vertices to a destination vertex buffer. IDirect3DMobileDevice::ProcessVertices allows an application to transform, and optionally light, the vertices once and use the resulting vertex buffer one or more times as a source in multi-pass rendering operations, see Lighting.

While the IDirect3DMobileDevice::ProcessVertices method is more commonly associated with transformation and lighting operations, there are other applications for the method as well, including:

  • Transforming a polygonal model's bounding box.
  • Reading the results of a clipping test to determine if a mesh would be inside or outside the viewing frustum.
  • A front end to a sort-by-Z test for drawing alpha blending polygons in a back-to-front order.

Lighting

The ability to process lighting as part of a call to the IDirect3DMobileDevice::ProcessVertices method is dependent on the lighting characteristics of the associated render states and stream sources. If lighting is not enabled then a call to IDirect3DMobileDevice::ProcessVertices will only perform transformations on the vertex buffers.

Lighting in IDirect3DMobileDevice::ProcessVertices supports both diffuse and specular calculations. For diffuse lighting, the destination flexible vertex format (FVF) must contain the D3DMFVF_DIFFUSE flag (see D3DMFVF Values) if either of the following statements is true.

  • Lighting is enabled, meaning that the D3DMRS_LIGHTING render sate (see D3DMRENDERSTATETYPE) is set to TRUE.
  • The current stream source vertex buffer FVF contains the D3DMFVF_DIFFUSE flag and the dwFlags parameter of IDirect3DMobileDevice::ProcessVertices does not have the D3DMPV_DONOTCOPYDATA bit (see D3DMPV Values) set.

For a call to IDirect3DMobileDevice::ProcessVertices to process specular lighting the destination FVF must contain the D3DMFVF_SPECULAR flag if any of the following statements is true.

  • Specular lighting is enabled, meaning that D3DMFVF_LIGHTING flag and D3DMFVF_SPECULAR are both set to TRUE.
  • Vertex fog is enabled, meaning that the D3DMRS_FOGVERTEXMODE render state is set to a value other than D3DMFOG_NONE.
  • The current stream source vertex buffer FVF contains the D3DMFVF_SPECULAR flag and the dwFlags parameter of IDirect3DMobileDevice::ProcessVertices does not have the D3DMPV_DONOTCOPYDATA bit set.

Texture Coordinate Processing

The IDirect3DMobileDevice::ProcessVertices requirements for texture coordinates are more complex than those for destination vertex buffers and those for lighting. The texture coordinate characteristics of the destination vertex buffer--such as the number of texture coordinate sets, the number of texture coordinate dimensions, and the required coordinate number format--are dependant upon a number of current texture values including the current render states, texture stage states, and source vertex buffer format.

Texture Transformations

Texture transformations are one of the basic texture operations performed by IDirect3DMobileDevice::ProcessVertices. Using this method, the texture transformation matrix is a 4x4 matrix and the texture coordinate set can contain 1, 2, or 3 elements. Any texture coordinate set containing N elements will be extended to a vector containing four elements, with the N+1 element set to 1.0 and the remaining elements set to 0.0.

Texture Projective Division

The texture projective division operation may be performed in either the rasterizer or the transformation pipeline. When the operation is performed by the rasterizer, the projective division occurs on a per-pixel basis. When the operation is performed in the transformation pipeline, the projective division occurs on a per-vertex basis. IDirect3DMobileDevice::ProcessVertices follows the behavior of the transformation pipeline, performing projective division operations on a per-vertex basis.

The divisor used in the projective division operation is the last coordinate of the texture coordinate set. When the texture stage's D3DMTEXTURETRANSFORMFLAGS state has one of the D3DMTTFF_COUNTn flags set, then the divisor used is the n component of the coordinate set.

Number Format Conversion

There are certain instances where the source and destination number formats for vertex position and texture coordinates won't match. For example, the source texture coordinate data may be in floating point while the destination texture coordinate data may be in fixed point. Under such circumstances, it is the responsibility of the driver to perform the appropriate conversion from floating point to fixed point, or vice versa.

Active Texture Stages

Microsoft® Direct3D® Mobile supports up to four texture stages. When a texture stage is active it has a direct affect on texture processing and by extension IDirect3DMobileDevice::ProcessVertices itself. The following list shows the conditions that will make a texture stage inactive.

  • The value associated with D3DMTSS_COLOROP (see D3DMTEXTURESTAGESTATETYPE), for the texture stage is set to the D3DMTEXTUREOP value D3DMTOP_DISABLE.
  • The texture stage state color argument, D3DMTSS_COLORARG1, is set to the same value as D3DMTA_TEXTURE (see D3DMTA Values) and there is currently no texture bound to the texture stage.

If any of the texture stages are inactive for the reasons listed above, all following texture stages are also assumed to be inactive.

Non-transformed, Non-generated Texture Coordinates

The rules in the following list apply when IDirect3DMobileDevice::ProcessVertices writes texture coordinates to the destination vertex buffer and none of the active texture stages specify texture coordinate generation or texture transformation.

  • If dwFlags is not set to D3DMPV_DONOTCOPYDATA, then the number of texture coordinates and the number of dimensions per coordinate for must match those of the source vertex buffer. In the case of fixed-to-float or float-to-fixed number format conversions, this will be performed by IDirect3DMobileDevice::ProcessVertices.
  • If dwFlags is set to D3DMPV_DONOTCOPYDATA, then the number of texture coordinates and their dimensionality in the destination vertex buffer are ignored.

The above case of non-transformed, non-generated texture coordinates in IDirect3DMobileDevice::ProcessVertices will be the predominant case for most Direct3D Mobile applications so driver writers may optimize this path in their implementations.

See Also

Transformation

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.