diff options
author | Treeki <treeki@gmail.com> | 2011-03-05 05:25:14 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-05 05:25:14 +0100 |
commit | e962fd89af865d6e01522e9752f5fbd855ce128a (patch) | |
tree | 0fb19e74a2d87b2ece48152fee2b2f4ed963828c /NW4RTools/VertexSettings.cs | |
parent | a5b6dc1789f2e06a26fe6a0510aee04aeccdc70b (diff) | |
download | nw4rtools-e962fd89af865d6e01522e9752f5fbd855ce128a.tar.gz nw4rtools-e962fd89af865d6e01522e9752f5fbd855ce128a.zip |
partially working obj importer. still untested in-game
Diffstat (limited to '')
-rw-r--r-- | NW4RTools/VertexSettings.cs | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/NW4RTools/VertexSettings.cs b/NW4RTools/VertexSettings.cs index 2a0d3ac..4f05fd7 100644 --- a/NW4RTools/VertexSettings.cs +++ b/NW4RTools/VertexSettings.cs @@ -179,6 +179,23 @@ namespace NW4RTools { } + public void GetDesc(out UInt32 val1, out UInt32 val2) { + val1 = 0; + val1 |= (uint)(PNMatrixIndexExists ? 1 : 0); + + for (int i = 0; i < 8; i++) + val1 |= (TexCoordMatrixIndexExists[i] ? (uint)(2 << i) : 0); + + val1 |= ((uint)PositionDesc) << 9; + val1 |= ((uint)NormalDesc) << 11; + val1 |= ((uint)ColorDesc[0]) << 13; + val1 |= ((uint)ColorDesc[1]) << 15; + + val2 = 0; + for (int i = 0; i < 8; i++) + val2 |= ((uint)TexCoordDesc[i]) << (i * 2); + } + public void SetDesc(UInt32 val1, UInt32 val2) { PNMatrixIndexExists = ((val1 & 1) != 0); @@ -194,9 +211,69 @@ namespace NW4RTools { TexCoordDesc[i] = (DescType)((val2 & (3 << (i * 2))) >> (i * 2)); } + public void GetAttrFmt(out UInt32 val1, out UInt32 val2, out UInt32 val3) { + val1 = 0; + val2 = 0; + val3 = 0; + + val1 |= (uint)PositionCount; + val1 |= ((uint)PositionFormat) << 1; + val1 |= ((uint)PositionFrac) << 4; + if (PositionFrac > 0) + val1 |= 0x40000000; + + val1 |= ((uint)NormalFormat) << 10; + if (NormalCount == VertexSettings.CompCount.NBT || NormalCount == VertexSettings.CompCount.NBT3) + val1 |= 0x200; + if (NormalCount == VertexSettings.CompCount.NBT3) + val1 |= 0x80000000; + + val1 |= ((uint)ColorCount[0]) << 13; + val1 |= ((uint)ColorFormat[0]) << 14; + val1 |= ((uint)ColorCount[1]) << 17; + val1 |= ((uint)ColorFormat[1]) << 18; + + for (int i = 0; i < 8; i++) { + if (TexCoordFrac[i] > 0) + val1 |= 0x40000000; + } + + val1 |= ((uint)TexCoordCount[0]) << 21; + val1 |= ((uint)TexCoordFormat[0]) << 22; + val1 |= ((uint)TexCoordFrac[0]) << 25; + + val2 |= ((uint)TexCoordCount[1]); + val2 |= ((uint)TexCoordFormat[1]) << 1; + val2 |= ((uint)TexCoordFrac[1]) << 4; + + val2 |= ((uint)TexCoordCount[2]) << 9; + val2 |= ((uint)TexCoordFormat[2]) << 10; + val2 |= ((uint)TexCoordFrac[2]) << 13; + + val2 |= ((uint)TexCoordCount[3]) << 18; + val2 |= ((uint)TexCoordFormat[3]) << 19; + val2 |= ((uint)TexCoordFrac[3]) << 22; + + val2 |= ((uint)TexCoordCount[4]) << 27; + val2 |= ((uint)TexCoordFormat[4]) << 28; + val3 |= ((uint)TexCoordFrac[4]); + + val3 |= ((uint)TexCoordCount[5]) << 5; + val3 |= ((uint)TexCoordFormat[5]) << 6; + val3 |= ((uint)TexCoordFrac[5]) << 9; + + val3 |= ((uint)TexCoordCount[6]) << 14; + val3 |= ((uint)TexCoordFormat[6]) << 15; + val3 |= ((uint)TexCoordFrac[6]) << 18; + + val3 |= ((uint)TexCoordCount[7]) << 23; + val3 |= ((uint)TexCoordFormat[7]) << 24; + val3 |= ((uint)TexCoordFrac[7]) << 27; + } + public void SetAttrFmt(UInt32 val1, UInt32 val2, UInt32 val3) { PositionCount = (CompCount)(val1 & 1); - PositionFormat = (CompType)((val1 & 0xE) >> 3); + PositionFormat = (CompType)((val1 & 0xE) >> 1); PositionFrac = (byte)((val1 & 0x1F0) >> 4); // note: this field is special |