Exemplo n.º 1
0
        private void fileSelectBt_Click(object sender, EventArgs e)
        {
            OpenFileDialog stldosyaSec = new OpenFileDialog();

            stldosyaSec.Filter = "STL Files|*.stl;*.txt;";

            if (stldosyaSec.ShowDialog() == DialogResult.OK)
            {
                dosyaSecTxb.Text = stldosyaSec.SafeFileName;

                STLReader      stlReader = new STLReader(stldosyaSec.FileName);
                TriangleMesh[] meshArray = stlReader.ReadFile();
                modelVAO = new Batu_GL.VAO_TRIANGLES();

                STLExport stlExporter = new STLExport();

                modelVAO.parameterArray = stlExporter.Get_Mesh_Vertices(meshArray);
                modelVAO.normalArray    = stlExporter.Get_Mesh_Normals(meshArray);
                modelVAO.color          = Color.CadetBlue;

                if (!stlReader.Get_Process_Error())
                {
                    rotation               = 0;
                    drawTimer.Enabled      = true;
                    fileSelectBt.BackColor = Color.DeepSkyBlue;
                }
                else
                {
                    drawTimer.Enabled      = false;
                    fileSelectBt.BackColor = Color.Tomato;

                    /* if there is an error, deinitialize the gl monitor to clear the screen */
                    glController.glInit(monitor, Batu_GL.Ortho_Mode.CENTER);
                    monitor.SwapBuffers();
                }
            }
            else
            {
                // intentionally left blank
            }
        }
Exemplo n.º 2
0
        private void ReadSelectedFile(string fileName)
        {
            STLReader stlReader = new STLReader(fileName);

            TriangleMesh[] meshArray = stlReader.ReadFile();
            modelVAO = new Batu_GL.VAO_TRIANGLES();
            modelVAO.parameterArray = STLExport.Get_Mesh_Vertices(meshArray);
            modelVAO.normalArray    = STLExport.Get_Mesh_Normals(meshArray);
            modelVAO.color          = Color.Crimson;
            minPos = stlReader.GetMinMeshPosition(meshArray);
            maxPos = stlReader.GetMaxMeshPosition(meshArray);
            orb.Reset_Orientation();
            orb.Reset_Pan();
            orb.Reset_Scale();
            if (stlReader.Get_Process_Error())
            {
                modelVAO = null;
                /* if there is an error, deinitialize the gl monitor to clear the screen */
                Batu_GL.Configure(GL_Monitor, Batu_GL.Ortho_Mode.CENTER);
                GL_Monitor.SwapBuffers();
            }
        }