Exemple #1
0
        public PreviewChara(CharaModelData modelData)
            : base()
        {
            maxNumModels = (int)ModelPart.NumModelParts;
            this.models  = new Model[maxNumModels];

            this.modelData = modelData;
            this.textures  = new List <List <TextureSection> > [maxNumModels];

            for (var i = 0; i < (int)ModelPart.NumModelParts; i++)
            {
                if (this.modelData.Models[i] == null)
                {
                    continue;
                }

                var modelContainer = this.modelData.Models[i].FindChild <ModelContainerChunk>();
                var model          = new Model(modelContainer);
                this.models[i] = model;
                this.renderList.Add(model);

                var textureList = this.modelData.Textures[i];

                this.textures[i] = new List <List <TextureSection> >();
                for (var j = 0; j < textureList.Count; j++)
                {
                    var texSections = this.modelData.Textures[i][j].FindAllChildren <TextureSection>();
                    this.textures[i].Add(texSections);
                }
            }
        }
Exemple #2
0
        public PreviewAnimatedChara(CharaModelData modelData)
            : base()
        {
            maxNumModels = (int)ModelPart.NumModelParts;
            this.models  = new Model[maxNumModels];

            this.modelData = modelData;
            this.textures  = new List <List <DatDigger.Sections.Texture.TextureSection> > [maxNumModels];

            for (var i = 0; i < (int)ModelPart.NumModelParts; i++)
            {
                if (this.modelData.Models[i] == null)
                {
                    continue;
                }

                var modelContainer = this.modelData.Models[i].FindChild <ModelContainerChunk>();
                var model          = new Model(modelContainer);
                this.models[i] = model;
                this.renderList.Add(model);

                var textureList = this.modelData.Textures[i];

                this.textures[i] = new List <List <DatDigger.Sections.Texture.TextureSection> >();
                for (var j = 0; j < textureList.Count; j++)
                {
                    var texSections = this.modelData.Textures[i][j].FindAllChildren <DatDigger.Sections.Texture.TextureSection>();
                    this.textures[i].Add(texSections);
                }
            }

            string skeletonFilePath = modelData.SkeletonFile;

            skeletonFilePath = System.IO.Path.GetDirectoryName(skeletonFilePath);
            skeletonFilePath = skeletonFilePath.Substring(0, skeletonFilePath.LastIndexOfAny(new char[] { '\\', '/' }));

            string animationFilePath = System.IO.Path.Combine(skeletonFilePath, "act/emp_emp/bid/base/0000");

            if (!System.IO.File.Exists(animationFilePath))
            {
                throw new System.InvalidOperationException("File " + animationFilePath + " does not exist");
            }

            var animFile = DatDigger.Sections.SectionLoader.OpenFile(animationFilePath);

            mtbSection = animFile.FindChild <MtbSection>(x => x.ResourceId == "cbnm_id0");
            if (mtbSection == null)
            {
                throw new System.InvalidOperationException("Cannot find cbnm_id0");
            }
        }