I used C# to render it using DirectX but I got this problem
and here is the code:
Code: Select all
CustomMesh cMesh = new CustomMesh();
using (BinaryReader br = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read)))
{
char[] cef = br.ReadChars(3);
br.Seek(99);
string modelName = br.ReadStringZeroEnded();
br.ReadBytes(133);
string position = br.ReadStringZeroEnded();
br.ReadBytes(35);
long pos = br.BaseStream.Position;
string blendWeight = br.ReadStringZeroEnded();
if (blendWeight == "BLENDWEIGHT")
return null; // todo --> followed by BLENDINDICES
else
br.Seek(pos);
// pos 296 7944 bytes 1986 floats 662 vertices
int vertSize = br.ReadUInt16();
br.ReadBytes(16);
List<Vector3> vertices = new List<Vector3>();
for (int i = 0; i < vertSize / 12; i++)
{
var x = br.ReadFloat();
var y = br.ReadFloat();
var z = br.ReadFloat();
vertices.Add(new Vector3(x, z, y));
}
cMesh.Vertices = vertices;
// pos 8326 3768 bytes 1884 ints 628 faces
br.ReadBytes(24);
string indice = br.ReadStringZeroEnded();
br.ReadBytes(37);
int indexSize = br.ReadUInt16();
br.ReadBytes(16);
int[] indices = new int[indexSize / 2];
for (int i = 0; i < indices.Length; i++)
{
indices[i] = br.ReadUInt16();
}
cMesh.Indices = indices;
br.Close();
}
return cMesh;
T.


