Microsoft DirectX 8.1 (C++) |
Vertices in the camera space are computed by transforming the object vertices with the world view matrix.
V = V * wvMatrix
Vertex normals, in camera space, are computed by transforming the object normals with the inverse transpose of the world view matrix. The world view matrix may or may not be symmetrical.
N = N * (wvMatrix-1)T
The matrix inversion and matrix transpose operate on a 4×4 matrix. The multiply combines the normal with the 3×3 portion of the resulting 4×4 matrix.
If the render state, D3DRENDERSTATE_NORMALIZENORMALS is set to TRUE, vertex normal vectors are normalized after transformation to camera space as follows:
N = norm(N)
Light position in camera space is computed by transforming the light source position with the view matrix.
Lp = Lp * vMatrix
The direction to the light in camera space for a directional light is computed by multiplying the light source direction by the view matrix, normalizing, and negating the result.
Ldir = -norm(Ldir * vMatrix)
For the D3DLIGHT_POINT and D3DLIGHT_SPOT the direction to light is computed as follows:
Ldir = norm(Ldir), where the parameters are defined in the following table.
Parameter | Default value | Type | Description | Ldir | (0,0,0,0) | D3DCOLORVALUE | Direction vector from object vertex to the light |
---|---|---|---|
V | (0,0,0,0) | D3DVECTOR | Vertex position |
wvMatrix | Identity | D3DMATRIX | Composite matrix containing the world and view transforms |
N | (0,0,0,0) | D3DVECTOR | Vertex normal |
Lp | (0,0,0,0) | D3DVECTOR | Light position |
vMatrix | Identity | D3DMATRIX | Matrix containing the view transform |