Ejemplo n.º 1
0
        public static H3D OpenAsH3D(Stream Input, GFPackage.Header Header)
        {
            H3D Output;

            //Model
            Input.Seek(Header.Entries[0].Address, SeekOrigin.Begin);

            GFModelPack MdlPack = new GFModelPack(Input);

            Output = MdlPack.ToH3D();

            //Animations
            Input.Seek(Header.Entries[1].Address, SeekOrigin.Begin);

            GFMotionPack MotPack = new GFMotionPack(Input);

            Output.Merge(MotPack.ToH3D(MdlPack.Models[0].Skeleton));

            //Texture
            if (Header.Entries.Length > 3 && Header.Entries[3].Length >= 4)
            {
                Input.Seek(Header.Entries[3].Address, SeekOrigin.Begin);

                BinaryReader Reader = new BinaryReader(Input);

                uint MagicNum = Reader.ReadUInt32();

                if (MagicNum == 0x15041213)
                {
                    Input.Seek(-4, SeekOrigin.Current);

                    GFTexture Tex = new GFTexture(Reader);

                    Output.Textures.Add(Tex.ToH3DTexture());
                }
            }

            return(Output);
        }
Ejemplo n.º 2
0
        public static H3D OpenAsH3D(Stream Input, GFPackage.Header Header)
        {
            H3D Output;

            //Model
            Input.Seek(Header.Entries[0].Address, SeekOrigin.Begin);

            GFModelPack MdlPack = new GFModelPack(Input);

            Output = MdlPack.ToH3D();

            //Animations
            Input.Seek(Header.Entries[1].Address, SeekOrigin.Begin);

            GFMotionPack MotPack = new GFMotionPack(Input);

            foreach (GFMotion Mot in MotPack)
            {
                H3DAnimation    SklAnim = Mot.ToH3DSkeletalAnimation(MdlPack.Models[0].Skeleton);
                H3DMaterialAnim MatAnim = Mot.ToH3DMaterialAnimation();
                H3DAnimation    VisAnim = Mot.ToH3DVisibilityAnimation();

                if (SklAnim != null)
                {
                    SklAnim.Name = $"Motion_{Mot.Index}";

                    Output.SkeletalAnimations.Add(SklAnim);
                }

                if (MatAnim != null)
                {
                    MatAnim.Name = $"Motion_{Mot.Index}";

                    Output.MaterialAnimations.Add(MatAnim);
                }

                if (VisAnim != null)
                {
                    VisAnim.Name = $"Motion_{Mot.Index}";

                    Output.VisibilityAnimations.Add(VisAnim);
                }
            }

            //Texture
            if (Header.Entries.Length > 3 && Header.Entries[3].Length >= 4)
            {
                Input.Seek(Header.Entries[3].Address, SeekOrigin.Begin);

                BinaryReader Reader = new BinaryReader(Input);

                uint MagicNum = Reader.ReadUInt32();

                if (MagicNum == 0x15041213)
                {
                    Input.Seek(-4, SeekOrigin.Current);

                    GFTexture Tex = new GFTexture(Reader);

                    Output.Textures.Add(Tex.ToH3DTexture());
                }
            }

            return(Output);
        }
Ejemplo n.º 3
0
        public static H3D OpenAsH3D(Stream input, GFPackage.Header header)
        {
            var output = default(H3D);

            //Model
            input.Seek(header.Entries[0].Address, SeekOrigin.Begin);

            var mdlPack = new GFModelPack(input);

            output = mdlPack.ToH3D();

            //Animations
            input.Seek(header.Entries[1].Address, SeekOrigin.Begin);

            var motPack = new GFMotionPack(input);

            foreach (var mot in motPack)
            {
                var sklAnim = mot.ToH3DSkeletalAnimation(mdlPack.Models[0].Skeleton);
                var matAnim = mot.ToH3DMaterialAnimation();
                var visAnim = mot.ToH3DVisibilityAnimation();

                if (sklAnim != null)
                {
                    sklAnim.Name = $"Motion_{mot.Index}";

                    output.SkeletalAnimations.Add(sklAnim);
                }

                if (matAnim != null)
                {
                    matAnim.Name = $"Motion_{mot.Index}";

                    output.MaterialAnimations.Add(matAnim);
                }

                if (visAnim != null)
                {
                    visAnim.Name = $"Motion_{mot.Index}";

                    output.VisibilityAnimations.Add(visAnim);
                }
            }

            //Texture
            if (header.Entries.Length > 3 && header.Entries[3].Length >= 4)
            {
                input.Seek(header.Entries[3].Address, SeekOrigin.Begin);

                var reader = new BinaryReader(input);

                var magicNum = reader.ReadUInt32();

                if (magicNum == 0x15041213)
                {
                    input.Seek(-4, SeekOrigin.Current);

                    var tex = new GFTexture(reader);

                    output.Textures.Add(tex.ToH3DTexture());
                }
            }

            return(output);
        }