Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
 }