예제 #1
0
        internal void PreSave()
        {
            Version = SaveVersion();

            for (int i = 0; i < Models.Count; i++)
            {
                for (int s = 0; s < Models[i].Shapes.Count; s++)
                {
                    Models[i].Shapes[s].VertexBuffer = Models[i].VertexBuffers[Models[i].Shapes[s].VertexBufferIndex];

                    //Link texture sections for wii u texture refs
                    if (Textures != null)
                    {
                        foreach (var texRef in Models[i].Materials[Models[i].Shapes[s].MaterialIndex].TextureRefs)
                        {
                            if (Textures.ContainsKey(texRef.Name))
                            {
                                texRef.Texture = Textures[texRef.Name];
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < SkeletalAnims.Count; i++)
            {
                int curveIndex = 0;
                for (int s = 0; s < SkeletalAnims[i].BoneAnims.Count; s++)
                {
                    SkeletalAnims[i].BoneAnims[s].BeginCurve = curveIndex;
                    curveIndex += SkeletalAnims[i].BoneAnims[s].Curves.Count;
                }
            }

            // Update ShapeAnim instances.
            foreach (ShapeAnim anim in ShapeAnims.Values)
            {
                int curveIndex = 0;
                int infoIndex  = 0;
                foreach (VertexShapeAnim subAnim in anim.VertexShapeAnims)
                {
                    subAnim.BeginCurve        = curveIndex;
                    subAnim.BeginKeyShapeAnim = infoIndex;
                    curveIndex += subAnim.Curves.Count;
                    infoIndex  += subAnim.KeyShapeAnimInfos.Count;
                }
            }

            foreach (var anim in TexPatternAnims.Values)
            {
                int curveIndex = 0;
                int infoIndex  = 0;
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.TexturePatternCurveIndex = curveIndex;
                    }
                    subAnim.InfoIndex = infoIndex;
                    curveIndex       += subAnim.Curves.Count;
                    infoIndex        += subAnim.PatternAnimInfos.Count;
                }
            }

            foreach (var anim in ShaderParamAnims.Values)
            {
                int curveIndex = 0;
                int infoIndex  = 0;
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.ShaderParamCurveIndex = curveIndex;
                    }
                    subAnim.InfoIndex = infoIndex;
                    curveIndex       += subAnim.Curves.Count;
                    infoIndex        += subAnim.ParamAnimInfos.Count;
                }
            }

            foreach (var anim in MatVisibilityAnims.Values)
            {
                int curveIndex = 0;
                int infoIndex  = 0;
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.VisalCurveIndex = curveIndex;
                    }
                    curveIndex += subAnim.Curves.Count;
                }
            }

            if (IsPlatformSwitch)
            {
                MaterialAnims.Clear();
                foreach (var anim in TexPatternAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in ShaderParamAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in TexSrtAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in ColorAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in MatVisibilityAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                for (int i = 0; i < MaterialAnims.Count; i++)
                {
                    MaterialAnims[i].signature = "FMAA";
                    foreach (var subAnim in MaterialAnims[i].MaterialAnimDataList)
                    {
                        if (subAnim.TexturePatternCount == 0)
                        {
                            subAnim.VisualConstantIndex = 0;
                        }
                        else
                        {
                            subAnim.VisualConstantIndex = -1;
                        }
                    }
                }
            }
        }
예제 #2
0
        internal void PreSave()
        {
            Version = SaveVersion();
            bool calculateBakeSizes = true;

            if (MatVisibilityAnims == null)
            {
                MatVisibilityAnims = new ResDict <MaterialAnim>();
            }

            for (int i = 0; i < Models.Count; i++)
            {
                for (int s = 0; s < Models[i].Shapes.Count; s++)
                {
                    Models[i].Shapes[s].VertexBuffer = Models[i].VertexBuffers[Models[i].Shapes[s].VertexBufferIndex];

                    //Link texture sections for wii u texture refs
                    if (Textures != null)
                    {
                        foreach (var texRef in Models[i].Materials[Models[i].Shapes[s].MaterialIndex].TextureRefs)
                        {
                            if (Textures.ContainsKey(texRef.Name))
                            {
                                texRef.Texture = Textures[texRef.Name];
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < SkeletalAnims.Count; i++)
            {
                int curveIndex = 0;
                if (calculateBakeSizes)
                {
                    SkeletalAnims[i].BakedSize = 0;
                }
                for (int s = 0; s < SkeletalAnims[i].BoneAnims.Count; s++)
                {
                    SkeletalAnims[i].BoneAnims[s].BeginCurve = curveIndex;
                    curveIndex += SkeletalAnims[i].BoneAnims[s].Curves.Count;

                    if (calculateBakeSizes)
                    {
                        foreach (var curve in SkeletalAnims[i].BoneAnims[s].Curves)
                        {
                            SkeletalAnims[i].BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            // Update ShapeAnim instances.
            foreach (ShapeAnim anim in ShapeAnims.Values)
            {
                int curveIndex = 0;
                int infoIndex  = 0;
                if (calculateBakeSizes)
                {
                    anim.BakedSize = 0;
                }
                foreach (VertexShapeAnim subAnim in anim.VertexShapeAnims)
                {
                    subAnim.BeginCurve        = curveIndex;
                    subAnim.BeginKeyShapeAnim = infoIndex;
                    curveIndex += subAnim.Curves.Count;
                    infoIndex  += subAnim.KeyShapeAnimInfos.Count;

                    if (calculateBakeSizes)
                    {
                        foreach (var curve in subAnim.Curves)
                        {
                            anim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            foreach (var anim in TexPatternAnims.Values)
            {
                anim.signature = IsPlatformSwitch ? "FMAA" : "FTXP";
                int curveIndex = 0;
                int infoIndex  = 0;
                if (calculateBakeSizes)
                {
                    anim.BakedSize = 0;
                }
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.TexturePatternCurveIndex = curveIndex;
                    }
                    subAnim.InfoIndex = infoIndex;
                    curveIndex       += subAnim.Curves.Count;
                    infoIndex        += subAnim.PatternAnimInfos.Count;

                    if (calculateBakeSizes)
                    {
                        foreach (var curve in subAnim.Curves)
                        {
                            anim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            foreach (var anim in TexSrtAnims.Values)
            {
                anim.signature = IsPlatformSwitch ? "FMAA" : "FSHU";
                int curveIndex = 0;
                int infoIndex  = 0;
                if (calculateBakeSizes)
                {
                    anim.BakedSize = 0;
                }
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.TexturePatternCurveIndex = curveIndex;
                    }
                    subAnim.InfoIndex = infoIndex;
                    curveIndex       += subAnim.Curves.Count;
                    infoIndex        += subAnim.PatternAnimInfos.Count;

                    if (calculateBakeSizes)
                    {
                        foreach (var curve in subAnim.Curves)
                        {
                            anim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            foreach (var anim in ColorAnims.Values)
            {
                anim.signature = IsPlatformSwitch ? "FMAA" : "FSHU";
                int curveIndex = 0;
                int infoIndex  = 0;
                if (calculateBakeSizes)
                {
                    anim.BakedSize = 0;
                }
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.TexturePatternCurveIndex = curveIndex;
                    }
                    subAnim.InfoIndex = infoIndex;
                    curveIndex       += subAnim.Curves.Count;
                    infoIndex        += subAnim.PatternAnimInfos.Count;

                    if (calculateBakeSizes)
                    {
                        foreach (var curve in subAnim.Curves)
                        {
                            anim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            foreach (var anim in ShaderParamAnims.Values)
            {
                anim.signature = IsPlatformSwitch ? "FMAA" : "FSHU";
                int curveIndex = 0;
                int infoIndex  = 0;
                if (calculateBakeSizes)
                {
                    anim.BakedSize = 0;
                }
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.ShaderParamCurveIndex = curveIndex;
                    }
                    subAnim.InfoIndex = infoIndex;
                    curveIndex       += subAnim.Curves.Count;
                    infoIndex        += subAnim.ParamAnimInfos.Count;

                    if (calculateBakeSizes)
                    {
                        foreach (var curve in subAnim.Curves)
                        {
                            anim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            foreach (var anim in MatVisibilityAnims.Values)
            {
                int curveIndex = 0;
                int infoIndex  = 0;
                if (calculateBakeSizes)
                {
                    anim.BakedSize = 0;
                }
                foreach (var subAnim in anim.MaterialAnimDataList)
                {
                    if (subAnim.Curves.Count > 0)
                    {
                        subAnim.VisalCurveIndex = curveIndex;
                    }
                    curveIndex += subAnim.Curves.Count;

                    if (calculateBakeSizes)
                    {
                        foreach (var curve in subAnim.Curves)
                        {
                            anim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            foreach (var anim in SceneAnims.Values)
            {
                foreach (var camAnim in anim.CameraAnims.Values)
                {
                    if (calculateBakeSizes)
                    {
                        foreach (var curve in camAnim.Curves)
                        {
                            camAnim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                        }
                    }
                }
            }

            foreach (var anim in BoneVisibilityAnims.Values)
            {
                anim.BakedSize = 0;
                foreach (var curve in anim.Curves)
                {
                    anim.BakedSize += curve.CalculateBakeSize(IsPlatformSwitch);
                }
            }

            if (IsPlatformSwitch)
            {
                MaterialAnims.Clear();
                foreach (var anim in ShaderParamAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in TexSrtAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in ColorAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in TexPatternAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                foreach (var anim in MatVisibilityAnims.Values)
                {
                    MaterialAnims.Add(anim.Name, anim);
                }

                for (int i = 0; i < MaterialAnims.Count; i++)
                {
                    MaterialAnims[i].signature = "FMAA";
                }
            }

            //Custom external file loading
            foreach (var file in ExternalFiles)
            {
                if (file.Value.LoadedFileData is Brtcamera)
                {
                    var cam = file.Value.LoadedFileData as Brtcamera;
                    cam.IsBigEndian = !IsPlatformSwitch;
                    var mem = new MemoryStream();
                    cam.Save(mem);
                    file.Value.Data = mem.ToArray();
                }
            }
        }