private void ParseSkinSet(BinaryParser parser, AnimSkin skin) { var name = parser.ConsumeUInt32(); var numVerts = parser.ConsumeUInt32(); var numBones = parser.ConsumeByte(); parser.Expect(1); var boneIds = parser.ConsumeByteArray(numBones); var vertIds = parser.ConsumeUInt16Array((int)numVerts); var preMultipliedPositions = parser.ConsumeVector3Array((int)numVerts * numBones); var weights = parser.ConsumeFloatArray((int)numVerts * numBones); for (int index = 0; index < vertIds.Length; index++) { var id = vertIds[index]; skin.Weights.EnsureAt(id); var vertexWeights = new VertexWeights { }; if (numBones > 0) { vertexWeights.Bone0 = new VertexWeight { BoneIndex = boneIds[0], Weight = weights[0 + index * numBones] }; } if (numBones > 1) { vertexWeights.Bone1 = new VertexWeight { BoneIndex = boneIds[1], Weight = weights[1 + index * numBones] }; } if (numBones > 2) { vertexWeights.Bone2 = new VertexWeight { BoneIndex = boneIds[2], Weight = weights[2 + index * numBones] }; } if (numBones > 3) { vertexWeights.Bone3 = new VertexWeight { BoneIndex = boneIds[3], Weight = weights[3 + index * numBones] }; } skin.Weights[id] = vertexWeights; } }
private void ParseModelExtSelSetFace(BinaryParser parser, Model model, uint name, uint flags) { var m_Flags = parser.ConsumeByte(); var m_FlagsSW = parser.ConsumeByte(); var m_FlagsHW = parser.ConsumeByte(); var m_OTZOfsSW = parser.ConsumeSByte(); var m_NumFaces = parser.ConsumeUInt32(); var m_FaceIDs = parser.ConsumeUInt16Array((int)m_NumFaces); //bool m_WorldSet; /** True if this set is a world file only set */ }
private void ParseModelBlockGLTriList( BinaryParser parser, Model model, uint name, uint size, uint numItems, ushort flags) { var streamMesh = (model.Meshes[0]); var streamSubmesh = this.context.Resolve<ModelBlockGLTriList>(); streamSubmesh.Mesh = streamMesh; streamMesh.Surfaces.Add(streamSubmesh); streamSubmesh.Material.HashReference = parser.ConsumeUInt32(); var indices = parser.ConsumeUInt16Array((int)numItems); for (int i = 0; i < indices.Length;) { UInt16 a = indices[i++]; UInt16 b = indices[i++]; UInt16 c = indices[i++]; streamSubmesh.Indices.Add(a); streamSubmesh.Indices.Add(b); streamSubmesh.Indices.Add(c); } //if (serialise.IsReading()) //{ // this.m_TupleIDs = new ushort[this.m_NumTupleIDs]; // this.prims = new _IwModelPrim[this.numItems]; //} //serialise.Serialise(ref this.m_TupleIDs); //for (int i = 0; i < this.numItems; ++i) //{ // this.prims[i].Serialise(serialise); //} }