Exemple #1
0
        private static bool LoadModel(CharaModelData modelData, TreeNode parent)
        {
            string animDir      = Path.Combine(modelData.ModelPath, "act/");
            bool   hasAnim      = Directory.Exists(animDir);
            string skeletonFile = Path.Combine(modelData.ModelPath, "skl/0001");
            string subModelDir  = Path.Combine(modelData.ModelPath, "equ/");

            var subModels = Directory.GetDirectories(subModelDir, "e???", SearchOption.TopDirectoryOnly);

            foreach (string subModel in subModels)
            {
                string dirName    = Path.GetFileName(subModel);
                int    subModelId = 0;
                if (!Int32.TryParse(dirName.Substring(1), out subModelId))
                {
                    continue;
                }

                CharaModelData charaModelData = new CharaModelData(modelData);
                charaModelData.SkeletonFile = skeletonFile;
                charaModelData.SubModelId   = subModelId;
                charaModelData.SubModelPath = subModel;
                charaModelData.HasAnimation = hasAnim;

                TreeNode node = new TreeNode(dirName);
                node.Tag = charaModelData;
                if (LoadSubModel(charaModelData, node))
                {
                    parent.Nodes.Add(node);
                }
            }

            return(true);
        }
        private void charaSelector_AfterSelect(object sender, TreeViewEventArgs e)
        {
            CharaModelData modelData = (e.Node.Tag as CharaModelData);

            if (modelData == null)
            {
                return;
            }

            btnRenderChara.Enabled    = modelData.CanRender;
            btnCharaAnimation.Enabled = modelData.HasAnimation && modelData.CanRender;
        }
Exemple #3
0
        private static bool LoadModelPart(ModelPart part, CharaModelData modelData)
        {
            if (part == ModelPart.NumModelParts)
            {
                return(false);
            }

            modelData.ModelFiles[(int)part]   = null;
            modelData.TextureFiles[(int)part] = null;

            string partFolder = modelTypes[(int)part];

            // Get Model File
            string modelDir = Path.Combine(modelData.SubModelPath, String.Format("{0}_mdl/", partFolder));
            string modelFile;

            if (Directory.Exists(modelDir))
            {
                modelFile = Path.Combine(modelDir, "0001");
            }
            else
            {
                return(false);
            }

            // Get Textures Files
            string tex1Dir = Path.Combine(modelData.SubModelPath, String.Format("{0}_tex1/", partFolder));
            string tex2Dir = Path.Combine(modelData.SubModelPath, String.Format("{0}_tex2/", partFolder));

            string texDir = null;

            if (Directory.Exists(tex2Dir))
            {
                texDir = tex2Dir;
            }
            else if (Directory.Exists(tex1Dir))
            {
                texDir = tex1Dir;
            }

            if (texDir == null)
            {
                return(false);
            }

            var textures = Directory.GetFiles(texDir);

            modelData.TextureFiles[(int)part] = new List <string>(textures);
            modelData.ModelFiles[(int)part]   = modelFile;

            return(true);
        }
Exemple #4
0
        public static void LoadCharaData(TreeNode rootNode, CharaType type)
        {
            string folder = type.GetFolder();
            string prefix = type.GetPrefix();

            string charaDir = Path.Combine(Properties.Settings.Default.GameDirectory, String.Format("client/chara/{0}/", folder));

            if (!Directory.Exists(charaDir))
            {
                rootNode.Nodes.Add(new TreeNode("!error - directory does not exist"));
                return;
            }

            string cmnDir  = Path.Combine(charaDir, "cmn");
            string cmnFile = null;

            if (Directory.Exists(cmnDir))
            {
                cmnFile = Path.Combine(cmnDir, "0001");
            }

            var subdirs = Directory.GetDirectories(charaDir, prefix + "???", SearchOption.TopDirectoryOnly);

            foreach (string subdir in subdirs)
            {
                string dirName = Path.GetFileName(subdir);
                int    modelId = 0;
                if (!Int32.TryParse(dirName.Substring(1), out modelId))
                {
                    continue;
                }

                CharaModelData charaModel = new CharaModelData();
                charaModel.CharaType       = type;
                charaModel.ModelId         = modelId;
                charaModel.ModelPath       = subdir;
                charaModel.ModelCommonFile = cmnFile;

                TreeNode node = new TreeNode(dirName);
                if (LoadModel(charaModel, node))
                {
                    rootNode.Nodes.Add(node);
                }
            }
        }
Exemple #5
0
        private static bool LoadSubModel(CharaModelData modelData, TreeNode parent)
        {
            string soundDir = Path.Combine(modelData.SubModelPath, "top_snd/");

            // Load Sounds
            if (Directory.Exists(soundDir))
            {
                modelData.HasSounds = true;
            }

            // Load Model Parts
            foreach (ModelPart part in Enum.GetValues(typeof(ModelPart)))
            {
                modelData.HasTextures |= LoadModelPart(part, modelData);
            }

            return(true);
        }
        private void charaSelector_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // For scripts
            scriptViewer_btn.Enabled = false;
            if (e.Node.Text.EndsWith(".lpb") || e.Node.Text.EndsWith(".san"))
            {
                scriptViewer_btn.Enabled = true;
            }

            CharaModelData modelData = (e.Node.Tag as CharaModelData);

            if (modelData == null)
            {
                return;
            }

            btnRenderChara.Enabled    = modelData.CanRender;
            btnCharaAnimation.Enabled = modelData.HasAnimation && modelData.CanRender;
        }
Exemple #7
0
        public CharaModelData(CharaModelData copy)
        {
            this.CharaType    = copy.CharaType;
            this.ModelId      = copy.ModelId;
            this.ModelPath    = copy.ModelPath;
            this.SubModelId   = copy.SubModelId;
            this.SubModelPath = copy.SubModelPath;
            this.TextureId    = copy.TextureId;

            this.ModelCommonFile = copy.ModelCommonFile;
            this.TextureFiles    = (List <string>[])copy.TextureFiles.Clone();
            this.ModelFiles      = (string[])copy.ModelFiles.Clone();
            this.SkeletonFile    = copy.SkeletonFile;

            this.HasAnimation = copy.HasAnimation;
            this.HasTextures  = copy.HasTextures;
            this.HasSounds    = copy.HasSounds;

            this.Models      = (INavigable[])copy.Models.Clone();
            this.Textures    = (List <INavigable>[])copy.Textures.Clone();
            this.Skeleton    = copy.Skeleton;
            this.ModelCommon = copy.ModelCommon;
        }