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