forked from arookas/Demolisher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vertex.cs
62 lines (54 loc) · 1.48 KB
/
Vertex.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Arookas.Math;
using Arookas.IO.Binary;
namespace Arookas.Demolisher
{
struct Vertex
{
public short? MatrixIndex { get; private set; }
public short? PositionIndex { get; private set; }
public short? NormalIndex { get; private set; }
public short? BinormalIndex { get; private set; }
public short? TangentIndex { get; private set; }
public short?[] ColorIndex { get; private set; }
public short?[] UVIndex { get; private set; }
public Vertex(ABinaryReader binaryReader, bool useNBT, int uvCount, BatchAttributes attributes)
: this() // stupid fucking C#
{
MatrixIndex = null;
PositionIndex = null;
NormalIndex = null;
BinormalIndex = null;
TangentIndex = null;
ColorIndex = new short?[2];
UVIndex = new short?[8];
if (attributes.HasFlag(BatchAttributes.Position))
{
PositionIndex = binaryReader.ReadS16();
}
if (attributes.HasFlag(BatchAttributes.Normal))
{
NormalIndex = binaryReader.ReadS16();
if (useNBT)
{
BinormalIndex = binaryReader.ReadS16();
TangentIndex = binaryReader.ReadS16();
}
}
if (attributes.HasFlag(BatchAttributes.Color0))
{
ColorIndex[0] = binaryReader.ReadS16();
}
if (attributes.HasFlag(BatchAttributes.Color1))
{
ColorIndex[1] = binaryReader.ReadS16();
}
for (int texCoord = 0; texCoord < uvCount; texCoord++)
{
if (attributes.HasFlag((BatchAttributes)(1 << (13 + texCoord))))
{
UVIndex[texCoord] = binaryReader.ReadS16();
}
}
}
}
}