// Just getting it working, will clean up when it works public void SetFrame(int frame, int nextFrame, float delta) { if (mesh != null) { renderVerts = mesh.vertices; } int index = 0; for (int i = 0; i < header.triCount; i++) { for (int v = 0; v < 3; v++) { MDLVert thisVert = frames[frame].verts[triangles[i].vertexIndexes[v]]; MDLVert nextVert = frames[nextFrame].verts[triangles[i].vertexIndexes[v]]; renderVerts[index].x = header.scale.x * (thisVert.v[0] + delta * (nextVert.v[0] - thisVert.v[0])) + header.translate[0]; renderVerts[index].y = header.scale.y * (thisVert.v[1] + delta * (nextVert.v[1] - thisVert.v[1])) + header.translate[1]; renderVerts[index].z = header.scale.z * (thisVert.v[2] + delta * (nextVert.v[2] - thisVert.v[2])) + header.translate[2]; float s = texCoords[triangles[i].vertexIndexes[v]].s; float t = texCoords[triangles[i].vertexIndexes[v]].t; if (triangles[i].facesFront != 1 && texCoords[triangles[i].vertexIndexes[v]].onSeam != 0) { s += (float)header.skinWidth * 0.5f; } s = (s + 0.5f) / (float)header.skinWidth; t = (t + 0.5f) / (float)header.skinHeight; renderUVs[index].x = s; renderUVs[index].y = t; index++; } renderTris[i * 3] = index - 3; renderTris[i * 3 + 1] = index - 2; renderTris[i * 3 + 2] = index - 1; } if (mesh != null) { mesh.vertices = renderVerts; } }
public MDLFrame(BinaryReader mdlFile, MDLHeader header) { verts = new List <MDLVert>(); type = mdlFile.ReadInt32(); boundingBoxMin = new MDLVert(mdlFile); boundingBoxMax = new MDLVert(mdlFile); byte [] result = mdlFile.ReadBytes(16); name = System.Text.Encoding.Default.GetString(result); for (int i = 0; i < header.vertCount; i++) { verts.Add(new MDLVert(mdlFile)); } }