private Vertices ReadVertices(Stream input, int vertexCount) { float scale = Scale; int verticesLength = vertexCount << 1; Vertices vertices = new Vertices(); if (!ReadBoolean(input)) { vertices.vertices = ReadFloatArray(input, verticesLength, scale); return(vertices); } var weights = new ExposedList <float>(verticesLength * 3 * 3); var bonesArray = new ExposedList <int>(verticesLength * 3); for (int i = 0; i < vertexCount; i++) { int boneCount = ReadVarint(input, true); bonesArray.Add(boneCount); for (int ii = 0; ii < boneCount; ii++) { bonesArray.Add(ReadVarint(input, true)); weights.Add(ReadFloat(input) * scale); weights.Add(ReadFloat(input) * scale); weights.Add(ReadFloat(input)); } } vertices.vertices = weights.ToArray(); vertices.bones = bonesArray.ToArray(); return(vertices); }
private void ReadVertices(Dictionary <String, Object> map, VertexAttachment attachment, int verticesLength) { attachment.WorldVerticesLength = verticesLength; float[] vertices = GetFloatArray(map, "vertices", 1); float scale = Scale; if (verticesLength == vertices.Length) { if (scale != 1) { for (int i = 0; i < vertices.Length; i++) { vertices[i] *= scale; } } attachment.vertices = vertices; return; } ExposedList <float> weights = new ExposedList <float>(verticesLength * 3 * 3); ExposedList <int> bones = new ExposedList <int>(verticesLength * 3); for (int i = 0, n = vertices.Length; i < n;) { int boneCount = (int)vertices[i++]; bones.Add(boneCount); for (int nn = i + boneCount * 4; i < nn; i += 4) { bones.Add((int)vertices[i]); weights.Add(vertices[i + 1] * this.Scale); weights.Add(vertices[i + 2] * this.Scale); weights.Add(vertices[i + 3]); } } attachment.bones = bones.ToArray(); attachment.vertices = weights.ToArray(); }