예제 #1
0
        public void Load(string Path, ClientType myClientType)
        {
            this.path       = Path;
            this.clientType = myClientType;
            BinaryReader binaryReader = new BinaryReader(File.Open(this.path, FileMode.Open));
            string       text         = RoseFile.ReadFString(ref binaryReader, 7);

            if (text == "ZMD0003")
            {
                this.version = 3;
            }
            else
            {
                if (!(text == "ZMD0002"))
                {
                    throw new Exception("Wrong file header " + text + " on " + this.path);
                }
                this.version = 2;
            }
            int num = binaryReader.ReadInt32();

            for (int i = 0; i < num; i++)
            {
                ZMD.Bone bone = new ZMD.Bone();
                bone.Dummy     = false;
                bone.parentid  = binaryReader.ReadInt32();
                bone.name      = RoseFile.ReadZString(ref binaryReader);
                bone.position  = RoseFile.ReadVector3(ref binaryReader);
                bone.position /= 100f;
                bone.rotation  = RoseFile.ReadVector4(ref binaryReader);
                bone.matrix    = Matrix.CreateFromQuaternion(new Quaternion(bone.rotation.X, bone.rotation.Y, bone.rotation.Z, bone.rotation.W));
                bone.matrix   *= Matrix.CreateTranslation(bone.position);
                this.listBone.Add(bone);
            }
            int num2 = binaryReader.ReadInt32();

            this.DummyOffset = num;
            for (int i = 0; i < num2; i++)
            {
                ZMD.Bone bone2 = new ZMD.Bone();
                bone2.Dummy     = true;
                bone2.name      = RoseFile.ReadZString(ref binaryReader);
                bone2.parentid  = binaryReader.ReadInt32();
                bone2.position  = RoseFile.ReadVector3(ref binaryReader);
                bone2.position /= 100f;
                bone2.matrix    = Matrix.Identity;
                if (this.version == 3)
                {
                    bone2.rotation = RoseFile.ReadVector4(ref binaryReader);
                    bone2.matrix   = Matrix.CreateFromQuaternion(new Quaternion(bone2.rotation.X, bone2.rotation.Y, bone2.rotation.Z, bone2.rotation.W));
                }
                bone2.matrix *= Matrix.CreateTranslation(bone2.position);
                this.listBone.Add(bone2);
            }
            binaryReader.Close();
            this.TransformChildren(0);
        }
예제 #2
0
        public void Load(string filePath, ClientType clientType)
        {
            this.Path       = filePath;
            this.clientType = clientType;
            BinaryReader binaryReader = new BinaryReader(File.Open(filePath, FileMode.Open));
            short        num          = binaryReader.ReadInt16();

            this.listDDS = new List <TSI.DDS>((int)num);
            for (int i = 0; i < (int)num; i++)
            {
                TSI.DDS dDS = new TSI.DDS();
                dDS.Path      = RoseFile.ReadSString(ref binaryReader);
                dDS.ColourKey = binaryReader.ReadInt32();
                this.listDDS.Add(dDS);
            }
            short num2 = binaryReader.ReadInt16();

            for (int i = 0; i < (int)num; i++)
            {
                short num3 = binaryReader.ReadInt16();
                this.listDDS[i].ListDDS_element = new List <TSI.DDS.DDSElement>((int)num3);
                for (int j = 0; j < (int)num3; j++)
                {
                    TSI.DDS.DDSElement dDSElement = new TSI.DDS.DDSElement();
                    dDSElement.OwnerId = binaryReader.ReadInt16();
                    dDSElement.X       = binaryReader.ReadInt32();
                    dDSElement.Y       = binaryReader.ReadInt32();
                    dDSElement.Width   = binaryReader.ReadInt32() - dDSElement.X;
                    dDSElement.Height  = binaryReader.ReadInt32() - dDSElement.Y;
                    dDSElement.Color   = binaryReader.ReadInt32();
                    dDSElement.Name    = RoseFile.ReadFString(ref binaryReader, 32);
                    this.listDDS[i].ListDDS_element.Add(dDSElement);
                }
            }
            binaryReader.Close();
        }
예제 #3
0
        public void Load(string mypath, ClientType myclientType)
        {
            this.path = mypath;
            BinaryReader binaryReader = new BinaryReader(File.Open(mypath, FileMode.Open));
            string       text         = RoseFile.ReadFString(ref binaryReader, 8);

            if (!text.Equals("ZMO0002\0"))
            {
                throw new Exception("wrong file header");
            }
            this.FPS          = binaryReader.ReadInt32();
            this.frameCount   = binaryReader.ReadInt32();
            this.channelCount = binaryReader.ReadInt32();
            for (int i = 0; i < this.channelCount; i++)
            {
                ZMO.Channel channel = new ZMO.Channel();
                channel.trackType = (ZMO.TrackType)binaryReader.ReadInt32();
                channel.trackID   = binaryReader.ReadInt32();
                if (channel.trackType == ZMO.TrackType.TRACK_TYPE_NORMAL)
                {
                    channel.normal = new List <Vector3>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_ROTATION)
                {
                    channel.rotation = new List <Vector4>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_POSITION)
                {
                    channel.position = new List <Vector3>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_ALPHA)
                {
                    channel.alpha = new List <float>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_UV1)
                {
                    channel.uv1 = new List <Vector2>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_UV2)
                {
                    channel.uv2 = new List <Vector2>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_UV3)
                {
                    channel.uv3 = new List <Vector2>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_UV4)
                {
                    channel.uv4 = new List <Vector2>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_TEXTUREANIM)
                {
                    channel.textureAnim = new List <float>();
                }
                else if (channel.trackType == ZMO.TrackType.TRACK_TYPE_SCALE)
                {
                    channel.scale = new List <float>();
                }
                this.listChannel.Add(channel);
            }
            for (int i = 0; i < this.frameCount; i++)
            {
                for (int j = 0; j < this.channelCount; j++)
                {
                    if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_NORMAL)
                    {
                        this.listChannel[j].normal[i] = RoseFile.ReadVector3(ref binaryReader);
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_ROTATION)
                    {
                        this.listChannel[j].rotation[i] = RoseFile.ReadVector4(ref binaryReader);
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_POSITION)
                    {
                        this.listChannel[j].position.Add(RoseFile.ReadVector3(ref binaryReader));
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_ALPHA)
                    {
                        this.listChannel[j].alpha[i] = binaryReader.ReadSingle();
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_UV1)
                    {
                        this.listChannel[j].uv1[i] = RoseFile.ReadVector2(ref binaryReader);
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_UV2)
                    {
                        this.listChannel[j].uv2[i] = RoseFile.ReadVector2(ref binaryReader);
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_UV3)
                    {
                        this.listChannel[j].uv3[i] = RoseFile.ReadVector2(ref binaryReader);
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_UV4)
                    {
                        this.listChannel[j].uv4[i] = RoseFile.ReadVector2(ref binaryReader);
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_TEXTUREANIM)
                    {
                        this.listChannel[j].textureAnim[i] = binaryReader.ReadSingle();
                    }
                    else if (this.listChannel[j].trackType == ZMO.TrackType.TRACK_TYPE_SCALE)
                    {
                        this.listChannel[j].scale[i] = binaryReader.ReadSingle();
                    }
                }
            }
            binaryReader.Close();
        }