public BSPCollision(Meta meta)
{
BinaryReader BR = new BinaryReader(meta.MS);
if (meta.Map.HaloVersion == HaloVersionEnum.Halo2)
{
BR.BaseStream.Position = 36;
int tempc = BR.ReadInt32();
int tempr = BR.ReadInt32() - meta.magic - meta.offset;
BR.BaseStream.Position = tempr + 40;
SurfaceReflexiveCount = BR.ReadInt32();
SurfaceReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
// planes
PlaneReflexiveOffset = tempr + 8;
BR.BaseStream.Position = PlaneReflexiveOffset;
PlaneReflexiveCount = BR.ReadInt32();
PlaneReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
Planes = new Vector4[PlaneReflexiveCount];
for (int x = 0; x < FaceReflexiveCount; x++)
{
Planes[x].X = BR.ReadSingle();
Planes[x].Y = BR.ReadSingle();
Planes[x].Z = BR.ReadSingle();
Planes[x].W = BR.ReadSingle();
}
// faces
FaceReflexiveOffset = tempr + 48;
BR.BaseStream.Position = FaceReflexiveOffset;
FaceReflexiveCount = BR.ReadInt32();
FaceReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
Faces = new ushort[FaceReflexiveCount * 3];
for (int x = 0; x < FaceReflexiveCount; x++)
{
BR.BaseStream.Position = FaceReflexiveTranslation + (x * 12);
Faces[x * 3] = BR.ReadUInt16();
Faces[(x * 3) + 1] = BR.ReadUInt16();
Faces[(x * 3) + 2] = Faces[(x * 3) + 1];
}
// vertices
VerticeReflexiveOffset = tempr + 56;
BR.BaseStream.Position = VerticeReflexiveOffset;
VerticeReflexiveCount = BR.ReadInt32();
VerticeReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
Vertices = new Vector3[VerticeReflexiveCount];
for (int x = 0; x < VerticeReflexiveCount; x++)
{
BR.BaseStream.Position = VerticeReflexiveTranslation + (x * 16);
Vertices[x].X = BR.ReadSingle();
Vertices[x].Y = BR.ReadSingle();
Vertices[x].Z = BR.ReadSingle();
}
}
else
{
BR.BaseStream.Position = 200;
int tempc = BR.ReadInt32();
int tempr = BR.ReadInt32() - meta.magic - meta.offset;
BR.BaseStream.Position = tempr + 40;
SurfaceReflexiveCount = BR.ReadInt32();
SurfaceReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
// planes
PlaneReflexiveOffset = tempr + 12;
BR.BaseStream.Position = PlaneReflexiveOffset;
PlaneReflexiveCount = BR.ReadInt32();
PlaneReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
Planes = new Vector4[PlaneReflexiveCount];
for (int x = 0; x < FaceReflexiveCount; x++)
{
Planes[x].X = BR.ReadSingle();
Planes[x].Y = BR.ReadSingle();
Planes[x].Z = BR.ReadSingle();
Planes[x].W = BR.ReadSingle();
}
// faces
FaceReflexiveOffset = tempr + 72;
BR.BaseStream.Position = FaceReflexiveOffset;
FaceReflexiveCount = BR.ReadInt32();
FaceReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
Faces = new ushort[FaceReflexiveCount * 3];
for (int x = 0; x < FaceReflexiveCount; x++)
{
BR.BaseStream.Position = FaceReflexiveTranslation + (x * 24);
Faces[x * 3] = (ushort)BR.ReadInt32();
Faces[(x * 3) + 1] = (ushort)BR.ReadInt32();
Faces[(x * 3) + 2] = Faces[(x * 3) + 1];
}
// vertices
VerticeReflexiveOffset = tempr + 84;
BR.BaseStream.Position = VerticeReflexiveOffset;
VerticeReflexiveCount = BR.ReadInt32();
VerticeReflexiveTranslation = BR.ReadInt32() - meta.magic - meta.offset;
Vertices = new Vector3[VerticeReflexiveCount];
for (int x = 0; x < VerticeReflexiveCount; x++)
{
BR.BaseStream.Position = VerticeReflexiveTranslation + (x * 16);
Vertices[x].X = BR.ReadSingle();
Vertices[x].Y = BR.ReadSingle();
Vertices[x].Z = BR.ReadSingle();
}
}
}