コード例 #1
0
        private void ShowCustomMeshDialog()
        {
            System.Windows.Forms.OpenFileDialog opf = new System.Windows.Forms.OpenFileDialog();
            opf.CheckFileExists = true;
            opf.CheckPathExists = true;
            opf.Filter          = "FBX & OBJ (*.fbx;*.obj)|*.fbx;*.obj";
            opf.Multiselect     = false;
            if (opf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string path = opf.FileName;

                RSMI.Importer importer = new RSMI.Importer();
                List <Mesh>   meshes   = importer.Parse(path);

                if (meshes != null && meshes.Count > 0)
                {
                    customMesh = meshes[0];

                    if (custom != null)
                    {
                        custom.Release();
                        custom = null;
                    }

                    custom = new MeshRenderer(customMesh);
                }
            }
        }
コード例 #2
0
        void LoadMeshes()
        {
            LoadDefaultTextures();

            try
            {
                string        pcube                = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "cube.obj");
                RSMI.Importer importer             = new RSMI.Importer();
                List <RSMI.Containers.Mesh> meshes = importer.Parse(pcube);

                if (mat == null)
                {
                    mat = new Material.PBRMaterial
                    {
                        Metallic  = defaultBlack,
                        Albedo    = defaultDarkGray,
                        Occlusion = defaultWhite,
                        Roughness = defaultBlack,
                        Height    = defaultWhite,
                        Thickness = defaultBlack,
                        Emission  = defaultBlack
                    };
                }

                if (tessMat == null)
                {
                    tessMat = new Material.PBRTess
                    {
                        Metallic  = defaultBlack,
                        Albedo    = defaultDarkGray,
                        Occlusion = defaultWhite,
                        Roughness = defaultBlack,
                        Height    = defaultBlack,
                        Thickness = defaultBlack,
                        Emission  = defaultBlack
                    };
                }

                if (meshes.Count > 0)
                {
                    cubeMesh = meshes[0];
                    cube     = new MeshRenderer(meshes[0]);
                    cube.Mat = mat;

                    if (UIPreviewPane.Instance != null)
                    {
                        UIPreviewPane.Instance.SetMesh(cube);
                    }
                }

                string psphere = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "sphere.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(psphere);

                if (meshes.Count > 0)
                {
                    sphereMesh    = meshes[0];
                    sphere        = new MeshRenderer(meshes[0]);
                    sphere.Mat    = mat;
                    lightMesh     = new MeshRenderer(meshes[0]);
                    lightMesh.Mat = lightMat;
                }

                string prounded = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "cube-rounded.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(prounded);

                if (meshes.Count > 0)
                {
                    cubeRoundedMesh = meshes[0];
                    cubeRounded     = new MeshRenderer(meshes[0]);
                    cubeRounded.Mat = mat;
                }

                //NOTE TO SELF: Recreate the cylnder 3D object with better UV
                string pcyl = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "cylinder.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(pcyl);

                if (meshes.Count > 0)
                {
                    cylinderMesh = meshes[0];
                    cylinder     = new MeshRenderer(meshes[0]);
                    cylinder.Mat = mat;
                }

                string pplane = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "plane.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(pplane);

                if (meshes.Count > 0)
                {
                    planeMesh = meshes[0];
                    plane     = new MeshRenderer(meshes[0]);
                    plane.Mat = mat;
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #3
0
        void LoadMeshes()
        {
            LoadDefaultTextures();

            try
            {
                string        pcube                = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "cube.obj");
                RSMI.Importer importer             = new RSMI.Importer();
                List <RSMI.Containers.Mesh> meshes = importer.Parse(pcube);

                if (mat == null)
                {
                    mat = new Material.PBRMaterial
                    {
                        Metallic  = defaultBlack,
                        Albedo    = defaultDarkGray,
                        Occlusion = defaultWhite,
                        Roughness = defaultBlack,
                        Height    = defaultWhite
                    };
                }

                if (meshes.Count > 0)
                {
                    cubeMesh = meshes[0];
                    cube     = new MeshRenderer(meshes[0]);
                    cube.Mat = mat;

                    if (UIPreviewPane.Instance != null)
                    {
                        UIPreviewPane.Instance.SetMesh(cube);
                    }
                }

                string psphere = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "sphere.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(psphere);

                if (meshes.Count > 0)
                {
                    sphereMesh = meshes[0];
                    sphere     = new MeshRenderer(meshes[0]);
                    sphere.Mat = mat;
                }

                string prounded = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "cube-rounded.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(prounded);

                if (meshes.Count > 0)
                {
                    cubeRoundedMesh = meshes[0];
                    cubeRounded     = new MeshRenderer(meshes[0]);
                    cubeRounded.Mat = mat;
                }

                string pcyl = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "cylinder.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(pcyl);

                if (meshes.Count > 0)
                {
                    cylinderMesh = meshes[0];
                    cylinder     = new MeshRenderer(meshes[0]);
                    cylinder.Mat = mat;
                }

                string pplane = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Geometry", "plane.obj");
                importer = new RSMI.Importer();
                meshes   = importer.Parse(pplane);

                if (meshes.Count > 0)
                {
                    planeMesh = meshes[0];
                    plane     = new MeshRenderer(meshes[0]);
                    plane.Mat = mat;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }