private void DrawTimer_Tick(object sender, EventArgs e) { orb.UpdateOrbiter(MousePosition.X, MousePosition.Y); GL_Monitor2.Invalidate(); if (moveForm) { this.SetDesktopLocation(MousePosition.X - moveOffsetX, MousePosition.Y - moveOffsetY); } }
private void ReadSelectedFile(string fileName) { STLReader stlReader = new STLReader(fileName); TriangleMesh[] meshArray = stlReader.ReadFile(); modelVAO = new Desm0nt_GL.VAO_TRIANGLES(); modelVAO.parameterArray = STLExport.Get_Mesh_Vertices(meshArray); modelVAO.normalArray = STLExport.Get_Mesh_Normals(meshArray); modelVAO.colorArray = STLExport.Get_Mesh_Colors(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 */ Desm0nt_GL.Configure(GL_Monitor2, Desm0nt_GL.Ortho_Mode.CENTER); GL_Monitor2.SwapBuffers(); } }
private void GL_Monitor_Paint(object sender, PaintEventArgs e) { if (!monitorLoaded) { return; } Desm0nt_GL.Configure(GL_Monitor2, Desm0nt_GL.Ortho_Mode.CENTER); if (modelVAO != null) { ConfigureBasicLighting(modelVAO.color); } GL.Translate(orb.PanX, orb.PanY, 0); GL.Rotate(orb.orbitStr.angle, orb.orbitStr.ox, orb.orbitStr.oy, orb.orbitStr.oz); GL.Scale(orb.scaleVal, orb.scaleVal, orb.scaleVal); GL.Translate(-minPos.x, -minPos.y, -minPos.z); GL.Translate(-(maxPos.x - minPos.x) / 2.0f, -(maxPos.y - minPos.y) / 2.0f, -(maxPos.z - minPos.z) / 2.0f); if (modelVAO != null) { modelVAO.Draw(); } GL_Monitor2.SwapBuffers(); }