예제 #1
0
        private void ImportVisualMeshToCategory(View.VisualMeshImportWindow importWindow, CategoryDOMNode category, string meshName)
        {
            List <J3DNode> meshList = category.GetChildrenOfType <J3DNode>();

            bool isBDL = true;

            J3DNode oldMeshNode = meshList.Find(x => x.Name == meshName);

            if (oldMeshNode != null)
            {
                category.Children.Remove(oldMeshNode);
                isBDL = oldMeshNode.Model.StudioType == "bdl4";
            }

            string fileExt      = Path.GetExtension(importWindow.FileName);
            string loadFilename = "";

            if (fileExt == ".bmd" || fileExt == ".bdl")
            {
                loadFilename = importWindow.FileName;
            }
            else
            {
                loadFilename = ImportVisualMesh(importWindow, isBDL);
            }

            JStudio.J3D.J3D newMesh = WResourceManager.LoadResource(loadFilename);
            newMesh.Name = meshName;
            J3DNode newNode = new J3DNode(newMesh, MainWorld, loadFilename);

            category.Children.Add(newNode);
        }
예제 #2
0
        private void ImportVisualMeshToRoom(View.VisualMeshImportWindow importWindow)
        {
            WRoom           room         = GetRoomFromDropdownIndex(importWindow.SceneNumber - 1);
            CategoryDOMNode meshCategory = room.GetChildrenOfType <CategoryDOMNode>().Find(x => x.Name == "Models");

            string newMeshName = "model";

            if (importWindow.SlotNumber > 0)
            {
                newMeshName += importWindow.SlotNumber;
            }

            ImportVisualMeshToCategory(importWindow, meshCategory, newMeshName);
        }
예제 #3
0
        public void OnRequestImportVisualMesh()
        {
            View.VisualMeshImportWindow window = new View.VisualMeshImportWindow(MainWorld.Map);
            window.FileSelector.IsFilePicker = true;

            if (window.ShowDialog() == true)
            {
                if (window.FileName == "" || !File.Exists(window.FileName))
                {
                    MessageBox.Show("Invalid filename entered!", "Mesh Import Error");
                    return;
                }

                if (window.SceneNumber == -1 || window.SceneNumber > MainWorld.Map.SceneList.Count)
                {
                    MessageBox.Show("Invalid room number entered!", "Mesh Import Error");
                    return;
                }

                try
                {
                    if (window.SceneNumber == 0)
                    {
                        ImportVisualMeshToStage(window);
                    }
                    else
                    {
                        ImportVisualMeshToRoom(window);
                    }
                }
                catch (Exception e)
                {
                    string error = "";
                    error += e.GetType().FullName + "\n";
                    error += e.Message + "\n";
                    error += e.StackTrace;
                    MessageBox.Show(error, "Mesh Import Error");
                    return;
                }
            }
        }
예제 #4
0
        private void ImportVisualMeshToStage(View.VisualMeshImportWindow importWindow)
        {
            WStage stage = GetStage();

            if (importWindow.SlotNumber == 4)
            {
                ImportVisualMeshToSkybox(importWindow, stage);
            }
            else
            {
                CategoryDOMNode meshCategory = stage.GetChildrenOfType <CategoryDOMNode>().Find(x => x.Name == "Models");
                string          meshName     = "";

                switch (importWindow.SlotNumber)
                {
                case 0:
                    meshName = "vr_sky";
                    break;

                case 4:
                    meshName = "door10";
                    break;

                case 5:
                    meshName = "door20";
                    break;

                case 6:
                    meshName = "key10";
                    break;

                case 7:
                    meshName = "stop10";
                    break;
                }

                ImportVisualMeshToCategory(importWindow, meshCategory, meshName);
            }
        }
예제 #5
0
        private string ImportVisualMesh(View.VisualMeshImportWindow importWindow, bool isBDL)
        {
            string tempFileName = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            string loadFilename = Path.Combine(Path.GetTempPath(), "Winditor", tempFileName + (isBDL ? ".bdl" : ".bmd"));

            List <string> superBMDArgs = new List <string>(new string[] { "-i", $"{ importWindow.FileName }" });

            superBMDArgs.Add("--rotate");
            if (isBDL)
            {
                superBMDArgs.Add("-b");
            }
            if (importWindow.GenerateMaterials)
            {
                superBMDArgs.Add("-glm");
            }

            SuperBMDLib.Arguments args = new SuperBMDLib.Arguments(superBMDArgs.ToArray());

            SuperBMDLib.Model newJ3D = SuperBMDLib.Model.Load(args);
            newJ3D.ExportBMD(loadFilename, isBDL);

            return(loadFilename);
        }
예제 #6
0
 private void ImportVisualMeshToSkybox(View.VisualMeshImportWindow importWindow, WStage stage)
 {
 }