Inheritance: SectionBase
        public AnimatedSkeleton(ISkeleton baseFrame, MtbSection mtbSection)
        {
            if (baseFrame == null) { throw new ArgumentNullException("baseFrame"); }

            this.baseFrame = baseFrame;
            this.IsLoaded = false;
            this.Bones = null;
            this.mtbSection = mtbSection;

            this.Fps = mtbSection.Header.Float1;
            this.TotalFrames = mtbSection.Header.AnimationLength;
            this.AnimationLength = this.TotalFrames / this.Fps;
        }
Example #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");
            }
        }
        public PreviewAnimatedSkeleton(SkeletonSection skeleton)
            : base()
        {
            this.skeleton = skeleton;

            string skeletonFilePath = skeleton.GetParent<DatDigger.Sections.PwibSection>().FilePath;
            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);
            animationData = animFile.FindChild<MtbSection>(x => x.ResourceId == "cbnm_id0");
            if (animationData == null)
            {
                throw new System.InvalidOperationException("Cannot find cbnm_id0");
            }
        }