Good work. A little bit crooked exporting graphics, takes all the graphics resources from the container, although the texture on the model is original.
Question.
meshStream.Position = 0x4;
int bone_count1 = meshStream.ReadValueS32();
MeshBone[] bones = new MeshBone[bone_count1];
int bone_count2 = meshStream.ReadValueS32();
int bone_Offset = meshStream.ReadValueS32();
float scaleX = meshStream.ReadValueF32();
float scaleY = meshStream.ReadValueF32();
float scaleZ = meshStream.ReadValueF32();
meshStream.Position += 0x04;
int BlokVertexCount = meshStream.ReadValueS32();
int BlokVertexOffset = meshStream.ReadValueS32();
meshStream.Position = 0x58;
int FaceOffset = meshStream.ReadValueS32();
for (int boneID = 0; boneID < bone_count1; boneID++)
{
bones[boneID] = new MeshBone(boneID);
}
int z = 0;
foreach (MeshBone bone in bones)
{
meshStream.Position = bone_Offset + z * 0x40 + 0x20;
float dx = meshStream.ReadValueF32();
float dy = meshStream.ReadValueF32();
float dz = meshStream.ReadValueF32();
meshStream.Position += 12;
int parentID = meshStream.ReadValueS32();
bone.relPosition = new MeshBone.Point(dx, dy, dz);
if (parentID >= 0)
{
bone.parent = bones[parentID];
}
z++;
}
foreach (MeshBone bone in bones)
{
bone.CalculateAbsPosition();
MeshBone parent = bone.parent;
if (parent != null)
{
parent.children.Add(bone);
}
}
meshStream.Position = BlokVertexOffset;
for (int i = 0; i < BlokVertexCount; i++)
{
float vX = meshStream.ReadValueS16() * scaleX;//point
float vY = meshStream.ReadValueS16() * scaleY;//point
float vZ = meshStream.ReadValueS16() * scaleZ;//point
float nX = meshStream.ReadValueS8() / 128.0f;//normaly
float nY = meshStream.ReadValueS8() / 128.0f;//normaly
float nZ = meshStream.ReadValueS8() / 128.0f;//normaly
meshStream.ReadValueS8();
int segment = meshStream.ReadValueS16();
float tU = BitConverter.ToSingle(BitConverter.GetBytes(meshStream.ReadValueU16() << 16), 0);//texture
float tV = BitConverter.ToSingle(BitConverter.GetBytes(meshStream.ReadValueU16() << 16), 0);//texture
long backpos = meshStream.Position;
if (segment >= bone_count1)
{
meshStream.Position = bone_Offset + segment * 0x40 + 0x38;
segment = meshStream.ReadValueS16();
}
if(segment < bone_count1)
{
var absPos = bones[segment].AbsPosition;
vX += absPos.x;
vY += absPos.y;
vZ += absPos.z;
}
meshStream.Position = backpos;
temp = string.Format("v {0:0.000000} {1:0.000000} {2:0.000000}", vX, vZ, -vY);
temp = temp.Replace(",", ".");
linev.Add(temp);
temp = string.Format("vn {0:0.000000} {1:0.000000} {2:0.000000}", nX, nY, nZ);
temp = temp.Replace(",", ".");
linevn.Add(temp);
temp = string.Format("vt {0:0.000000} {1:0.000000} 0.000000", tU, tV);
temp = temp.Replace(",", ".");
linevt.Add(temp);
}
meshStream.Position = FaceData;
var blokcount = meshStream.ReadValueS16()/3;
meshStream.Position += 2;
while (blokcount != 0)
{
int groupid = meshStream.ReadValueU8();
Indices.Add(string.Format("usemtl Texture_{0}", groupid));
meshStream.Position += 0x0B;
int nextpos = meshStream.ReadValueS32();
for (int i = 0; i < blokcount; i++)
{
ushort IndexX = meshStream.ReadValueU16();
ushort IndexY = meshStream.ReadValueU16();
ushort IndexZ = meshStream.ReadValueU16();
Indices.Add(string.Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}", IndexX + 1, IndexY + 1, IndexZ + 1));
}
meshStream.Position = nextpos;
blokcount = meshStream.ReadValueS16()/3;
meshStream.Position += 2;
}
----------