Game Development Reference
In-Depth Information
.
.
.
D3DMATERIAL9 InitMtrl(D3DXCOLOR a, D3DXCOLOR d,
D3DXCOLOR s, D3DXCOLOR e, float p);
const D3DMATERIAL9 WHITE_MTRL = InitMtrl(WHITE, WHITE,
WHITE, BLACK, 8.0f);
const D3DMATERIAL9 RED_MTRL
= InitMtrl(RED, RED,
RED, BLACK, 8.0f);
const D3DMATERIAL9 GREEN_MTRL = InitMtrl(GREEN, GREEN,
GREEN, BLACK, 8.0f);
const D3DMATERIAL9 BLUE_MTRL
= InitMtrl(BLUE, BLUE,
BLUE, BLACK, 8.0f);
const D3DMATERIAL9 YELLOW_MTRL = InitMtrl(YELLOW, YELLOW,
YELLOW, BLACK, 8.0f);
}
Note: An excellent paper on color theory, lighting, and how the
human eye perceives color is available at http://www.adobe.com/
support/techguides/color/colortheory/main.html.
A vertex structure does not have a material property; rather, a current
material must be set. To set the current material, we use the
IDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9*
pMaterial ) method.
Suppose that we want to render several objects with different
materials; we would write the following:
D3DMATERIAL9 blueMaterial, redMaterial;
...// set up material structures
Device->SetMaterial(&blueMaterial);
drawSphere(); // blue sphere
Device->SetMaterial(&redMaterial);
drawSphere(); // red sphere
5.3 Vertex Normals
A face normal is a vector that describes the direction a polygon is facing
(see Figure 5.1).
Figure 5.1: The face normal of a surface
Search WWH ::




Custom Search