Game Development Reference
In-Depth Information
where
_decl
is a pointer to an
IDirect3DVertexDeclaration9
interface.
17.2
Vertex Data Usages
Consider the vertex declaration:
D3DVERTEXELEMENT9 decl[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_
POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_
NORMAL, 0},
{0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_
NORMAL, 1},
{0, 36, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_
NORMAL, 2},
D3DDECL_END()
};
We need a way to define a map from the elements of the vertex declara-
tion to the data members of the vertex shader's input structure. We
define this map in the input structure by specifying a semantic
(
: usage-type[usage-index]
) for each data member. The seman-
tic identifies an element in the vertex declaration by its usage type and
usage index. The vertex element identified by a data member's seman-
tic is the element that gets mapped to that data member. For example,
an input structure for the previous vertex declaration is:
struct VS_INPUT
{
vector position : POSITION;
vector normal : NORMAL0;
vector faceNormal1 : NORMAL1;
vector faceNormal2 : NORMAL2;
};
Note:
If we leave off the usage index, it implies usage index zero.
For example,
POSITION
is the same thing as
POSITION0
.
Here element 0 in
decl
, identified by usage
POSITION
and usage
index 0, is mapped to
position
. Element 1 in
decl
, identified by
usage
NORMAL
and usage index 0, is mapped to
normal
. Element 2 in
decl
, identified by usage
NORMAL
and usage index 1, is mapped to
faceNormal1
. Element 3 in
decl
, identified by usage
NORMAL
and
usage index 2, is mapped to
faceNormal2
.
Search WWH ::
Custom Search