[2197] | 1 | #include "dxstdafx.h"
|
---|
| 2 | #include ".\flexvertex.h"
|
---|
| 3 |
|
---|
| 4 | unsigned int FlexVertex::posByteOffset(0);
|
---|
| 5 | unsigned int FlexVertex::normalByteOffset(12);
|
---|
| 6 | unsigned int FlexVertex::diffuseByteOffset(24);
|
---|
| 7 | unsigned int FlexVertex::specularByteOffset(28);
|
---|
| 8 | unsigned int FlexVertex::texByteOffset[16] = { 32, 40, 48, 56, 64, 72, 80, 88,
|
---|
| 9 | 96, 104, 112, 120, 128, 136, 144, 152};
|
---|
| 10 | unsigned int FlexVertex::nTex = 2;
|
---|
| 11 |
|
---|
| 12 | void FlexVertex::setFormat(D3DVERTEXELEMENT9* decl)
|
---|
| 13 | {
|
---|
| 14 | int i=0;
|
---|
| 15 | nTex = 0;
|
---|
| 16 | while(decl[i].Type != D3DDECLTYPE_UNUSED)
|
---|
| 17 | {
|
---|
| 18 | if(decl[i].Usage == D3DDECLUSAGE_POSITION)
|
---|
| 19 | posByteOffset = decl[i].Offset;
|
---|
| 20 | if(decl[i].Usage == D3DDECLUSAGE_NORMAL)
|
---|
| 21 | normalByteOffset = decl[i].Offset;
|
---|
| 22 | if(decl[i].Usage == D3DDECLUSAGE_COLOR)
|
---|
| 23 | {
|
---|
| 24 | if(decl[i].UsageIndex == 0)
|
---|
| 25 | diffuseByteOffset = decl[i].Offset;
|
---|
| 26 | if(decl[i].UsageIndex == 1)
|
---|
| 27 | specularByteOffset = decl[i].Offset;
|
---|
| 28 | }
|
---|
| 29 | if(decl[i].Usage == D3DDECLUSAGE_TEXCOORD)
|
---|
| 30 | {
|
---|
| 31 | texByteOffset[decl[i].UsageIndex] = decl[i].Offset;
|
---|
| 32 | if(decl[i].UsageIndex >= nTex)
|
---|
| 33 | nTex = decl[i].UsageIndex+1;
|
---|
| 34 | }
|
---|
| 35 | i++;
|
---|
| 36 | }
|
---|
| 37 | } |
---|