Esempio n. 1
0
            private void Deserialize(BinaryReader reader)
            {
                header = reader.ReadBytes(ModelLodHeader.STRUCT_SIZE).ToStruct <ModelLodHeader>();

                Vertices = new List <Vector4>(header.nVertices);
                for (var i = 0; i < header.nVertices; i++)
                {
                    var vec = new Vector4
                    {
                        X = reader.ReadInt16(),
                        Y = reader.ReadInt16(),
                        Z = reader.ReadInt16(),
                        W = reader.ReadInt16()
                    };
                    Vertices.Add(vec);
                }

                Normals = new List <Vector4>(header.nNormals);
                for (var i = 0; i < header.nNormals; i++)
                {
                    var vec = new Vector4
                    {
                        X = reader.ReadInt16(),
                        Y = reader.ReadInt16(),
                        Z = reader.ReadInt16(),
                        W = reader.ReadInt16()
                    };
                    Normals.Add(vec);
                }

                Faces = new List <ModelFace>(header.nFaces);
                for (var i = 0; i < header.nFaces; i++)
                {
                    var face = reader.ReadBytes(ModelFace.STRUCT_SIZE).ToStruct <ModelFace>();
                    Faces.Add(face);
                }

                SubObjects = new List <ModelSubObject>(header.nSubObjects);
                for (var i = 0; i < header.nSubObjects; i++)
                {
                    var obj = reader.ReadBytes(ModelSubObject.STRUCT_SIZE).ToStruct <ModelSubObject>();
                    SubObjects.Add(obj);
                }

                for (var i = 0; i < header.nPartAnims; i++)
                {
                    var anm = reader.ReadBytes(0x0C).ToStruct <ModelBoneAnim>();
                }

                //TODO: Read ColPlanes
                reader.BaseStream.Position += 0x08 * header.nColPlanes;

                //TODO: Read ColVolumes
                reader.BaseStream.Position += 0x50 * header.nColVolumes;

                Materials = new List <ModelMaterial>(header.nMaterials);
                for (var i = 0; i < header.nMaterials; i++)
                {
                    var mat = reader.ReadBytes(ModelMaterial.STRUCT_SIZE).ToStruct <ModelMaterial>();
                    Materials.Add(mat);
                }
            }
Esempio n. 2
0
            private void Deserialize(BinaryReader reader)
            {
                header = reader.ReadBytes(ModelLodHeader.STRUCT_SIZE).ToStruct<ModelLodHeader>();

                Vertices = new List<Vector4>(header.nVertices);
                for (var i = 0; i < header.nVertices; i++)
                {
                    var vec = new Vector4
                    {
                        X = reader.ReadInt16(),
                        Y = reader.ReadInt16(),
                        Z = reader.ReadInt16(),
                        W = reader.ReadInt16()
                    };
                    Vertices.Add(vec);
                }

                Normals = new List<Vector4>(header.nNormals);
                for (var i = 0; i < header.nNormals; i++)
                {
                    var vec = new Vector4
                    {
                        X = reader.ReadInt16(),
                        Y = reader.ReadInt16(),
                        Z = reader.ReadInt16(),
                        W = reader.ReadInt16()
                    };
                    Normals.Add(vec);
                }

                Faces = new List<ModelFace>(header.nFaces);
                for (var i = 0; i < header.nFaces; i++)
                {
                    var face = reader.ReadBytes(ModelFace.STRUCT_SIZE).ToStruct<ModelFace>();
                    Faces.Add(face);
                }

                SubObjects = new List<ModelSubObject>(header.nSubObjects);
                for (var i = 0; i < header.nSubObjects; i++)
                {
                    var obj = reader.ReadBytes(ModelSubObject.STRUCT_SIZE).ToStruct<ModelSubObject>();
                    SubObjects.Add(obj);
                }

                for (var i = 0; i < header.nPartAnims; i++)
                {
                    var anm = reader.ReadBytes(0x0C).ToStruct<ModelBoneAnim>();
                }

                //TODO: Read ColPlanes
                reader.BaseStream.Position += 0x08*header.nColPlanes;

                //TODO: Read ColVolumes
                reader.BaseStream.Position += 0x50*header.nColVolumes;

                Materials = new List<ModelMaterial>(header.nMaterials);
                for (var i = 0; i < header.nMaterials; i++)
                {
                    var mat = reader.ReadBytes(ModelMaterial.STRUCT_SIZE).ToStruct<ModelMaterial>();
                    Materials.Add(mat);
                }
            }