Platform SDK: DirectX |
In C++, the D3DTSS_TEXCOORDINDEX texture-stage state (from the D3DTEXTURESTAGESTATETYPE enumerated type) controls how the system generates texture coordinates.
In Visual Basic, the D3DTSS_TEXCOORDINDEX texture-stage state (from the CONST_D3DTEXTURESTAGESTATETYPE enumeration) controls how the system generates texture coordinates.
Normally, this state instructs the system to use a particular set of texture coordinates encoded in the vertex format. When you include the D3DTSS_TCI_CAMERASPACENORMAL, D3DTSS_TCI_CAMERASPACEPOSITION, or D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR flags in the value you assign to this state, the system's behavior is quite different. If any of these flags are present, the texture stage ignores the texture coordinates within the vertex format in favor of coordinates that the system generates. The meanings for each flag are as follows:
The preceding flags are mutually exclusive, so they cannot be combined. If you include one of these flags, you can still specify an index value, which the system uses to determine the texture wrapping mode.
The following code fragment shows how these flags are used in C++.
// For this example, the lpd3dDevice variable is a valid // pointer to an IDirect3DDevice7 interface. // Use the vertex position (camera-space) as the input // texture coordinates for this texture stage, and to use the // wrap mode set in the D3DRENDERSTATE_WRAP1 render state lpd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION | 1 );
The following code fragment shows how these flags are used in Visual Basic.
' For this example, the d3dDevice variable is a valid ' reference to a Direct3DDevice7 object. ' Use the vertex position (camera-space) as the input ' texture coordinates for this texture stage, and the ' wrap mode set in the D3DRENDERSTATE_WRAP1 render state Call d3dDevice.SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, _ D3DTSS_TCI_CAMERASPACEPOSITION Or 1)
Note Automatically-generated texture coordinates are most useful as input values for a texture coordinate transformation, or to eliminate the need for your application to compute 3-element vectors for cubic-environment maps.
Texture Coordinate Transformations, Cubic Environment Mapping