public ctl3DView() { InitializeComponent(); //Visible = false; //SetupSceneTree(); m_modelAnimTmr = null; m_camera = new GLCamera(); m_axisCam = new GLCamera(); ResetCameraView(); m_isectnormal = new Engine3D.Vector3d(); mainViewSplitContainer.Panel1Collapsed = true; UVDLPApp.Instance().m_undoer.AsociateUndoButton(buttUndo); UVDLPApp.Instance().m_undoer.AsociateRedoButton(buttRedo); //glControl1. = new GraphicsMode(GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, 8); gr2d = UVDLPApp.Instance().m_2d_graphics; ctlBgndList = new List<ctlBgnd>(); guiconf = UVDLPApp.Instance().m_gui_config; // set from the main program GUIConfig guiconf.TopLevelControl = mainViewSplitContainer.Panel2; UpdateButtonList(); RearrangeGui(); // once the GUIConfig is loaded from the plugins and from the main GUIConfig, the screen is re-arranged // toplevel controls must point to this glControl1.PaintCallback += new ctlGL.delPaint(DisplayFunc); m_sliceTex = -1; RegisterCallbacks(); UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv); UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel); }
public ctl3DView() { InitializeComponent(); //Visible = false; //SetupSceneTree(); m_modelAnimTmr = null; m_camera = new GLCamera(); m_axisCam = new GLCamera(); ResetCameraView(); m_isectnormal = new Engine3D.Vector3d(); mainViewSplitContainer.Panel1Collapsed = true; UVDLPApp.Instance().m_undoer.AsociateUndoButton(buttUndo); UVDLPApp.Instance().m_undoer.AsociateRedoButton(buttRedo); //glControl1. = new GraphicsMode(GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, 8); gr2d = UVDLPApp.Instance().m_2d_graphics; ctlBgndList = new List<ctlBgnd>(); guiconf = UVDLPApp.Instance().m_gui_config; guiconf.TopLevelControl = mainViewSplitContainer.Panel2; UpdateButtonList(); //guiconf.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig); RearrangeGui(); // toplevel controls must point to this glControl1.PaintCallback += new ctlGL.delPaint(DisplayFunc); m_sliceTex = -1; RegisterCallbacks(); UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv); UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel); }
public ctl3DView() { InitializeComponent(); //SetupSceneTree(); m_modelAnimTmr = null; m_camera = new GLCamera(); ResetCameraView(); m_isectnormal = new Engine3D.Vector3d(); ctlViewOptions.TreeViewHolder = mainViewSplitContainer; ctlViewOptions.LayerNumberScroll = numLayer; ctlViewOptions.ObjectInfoPanel = objectInfoPanel; ctlViewOptions.SceneControl = ctlScene1; mainViewSplitContainer.Panel1Collapsed = true; UVDLPApp.Instance().m_undoer.AsociateUndoButton(buttUndo); UVDLPApp.Instance().m_undoer.AsociateRedoButton(buttRedo); //glControl1. = new GraphicsMode(GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, 8); gr2d = UVDLPApp.Instance().m_2d_graphics; ctlBgndList = new List<ctlBgnd>(); guiconf = UVDLPApp.Instance().m_gui_config; guiconf.TopLevelControl = mainViewSplitContainer.Panel2; UpdateButtonList(); guiconf.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig); RearrangeGui(); ctlObjScale.c3d = this; ctlObjRotate.c3d = this; ctlObjMove.c3d = this; ctlSupport.c3d = this; objectInfoPanel.c3d = this; ctlViewOptions.c3d = this; ctlMeshTools1.c3d = this; ctlScene1.c3d = this; /*ctlImageButton imbtn = new ctlImageButton(); imbtn.BackColor = System.Drawing.Color.Navy; imbtn.CheckImage = null; imbtn.Image = global::UV_DLP_3D_Printer.Properties.Resources.homeButt; imbtn.Location = new System.Drawing.Point(200, 200); imbtn.Name = "buttGlHome"; imbtn.Size = new System.Drawing.Size(48, 48); imbtn.TabIndex = 16; imbtn.Visible = true; mainViewSplitContainer.Panel2.Controls.Add(imbtn); imbtn.BringToFront();*/ //buttGlHome.GLVisible = true; //buttGlHome.BackColor = Color.Transparent; //buttGlHome.FixStyle(); //buttGlHome.BackColor = Color.FromArgb(60,0,0,0); m_sliceTex = -1; }
public frmMain() { // following 2 lines removed from designer - SHS to eliminate autoscale //this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); //this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; InitializeComponent(); UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel); UVDLPApp.Instance().Engine3D.UpdateGrid(); //UVDLPApp.Instance().Engine3D.AddPlatCube(); UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv); UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus); UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer); DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent); UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent); UVDLPApp.Instance().m_supportgenerator.SupportEvent += new SupportGeneratorEvent(SupEvent); ctl3DView1.SetMessagePanelHolder(splitContainerMainWindow); ctl3DView1.Enable3dView(true); #if (DEBUG) ShowLogPanel(true); #else ShowLogPanel(false); findHolesInMeshToolStripMenuItem.Visible = false; splashToolStripMenuItem.Visible = false; pluginTesterToolStripMenuItem.Visible = false; stalactite3DToolStripMenuItem.Visible = false; testToolStripMenuItem.Visible = false; #endif splitContainerTop.Panel1Collapsed = true; m_frmdlp.HideDLPScreen(); m_frmSliceView.SliceView.DlpForm = m_frmdlp; //arcball = new ArcBall(); m_camera = new GLCamera(); ResetCameraView(); lblTime.Text = ctl3DView1.TimeMessage = ""; lblMainMessage.Text = ctl3DView1.MainMessage = ""; SetButtonStatuses(); //PopulateBuildProfilesMenu(); RegisterCallbacks(); Refresh(); }
//Slice m_curslice = null; // for previewing only //float ipx = 0.0f, ipy = 0.0f, ipz = 2.0f; public frmMain() { // following 2 lines removed from designer - SHS to eliminate autoscale //this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); //this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; InitializeComponent(); UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel); UVDLPApp.Instance().Engine3D.UpdateGrid(); //UVDLPApp.Instance().Engine3D.AddPlatCube(); UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv); UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus); UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer); DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent); UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent); UVDLPApp.Instance().m_supportgenerator.SupportEvent += new SupportGeneratorEvent(SupEvent); ctl3DView1.SetMessagePanelHolder(splitContainerMainWindow); ctl3DView1.Dock = DockStyle.Fill; ctl3DView1.Enable3dView(true); tabMain.Dock = DockStyle.Fill; tabMain.Visible = false; m_frmdlp.HideDLPScreen(); ctlSliceView1.Visible = false; ctlSliceView1.Dock = DockStyle.Fill; ctlSliceView1.DlpForm = m_frmdlp; ctlGcodeView1.Visible = false; ctlGcodeView1.Dock = DockStyle.Fill; //arcball = new ArcBall(); m_camera = new GLCamera(); ResetCameraView(); lblTime.Text = ""; lblMainMessage.Text = ""; SetButtonStatuses(); //PopulateBuildProfilesMenu(); Refresh(); }
public ctl3DView() { InitializeComponent(); SetupSceneTree(); m_modelAnimTmr = null; m_camera = new GLCamera(); ResetCameraView(); ctlViewOptions.TreeViewHolder = mainViewSplitContainer; ctlViewOptions.LayerNumberScroll = numLayer; ctlViewOptions.ObjectInfoPanel = objectInfoPanel; mainViewSplitContainer.Panel1Collapsed = true; UVDLPApp.Instance().m_undoer.AsociateUndoButton(buttUndo); UVDLPApp.Instance().m_undoer.AsociateRedoButton(buttRedo); //glControl1. = new GraphicsMode(GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, 8); }
public ctl3DView() { InitializeComponent(); //SetupSceneTree(); m_modelAnimTmr = null; m_camera = new GLCamera(); ResetCameraView(); ctlViewOptions.TreeViewHolder = mainViewSplitContainer; ctlViewOptions.LayerNumberScroll = numLayer; ctlViewOptions.ObjectInfoPanel = objectInfoPanel; ctlViewOptions.SceneControl = ctlScene1; mainViewSplitContainer.Panel1Collapsed = true; UVDLPApp.Instance().m_undoer.AsociateUndoButton(buttUndo); UVDLPApp.Instance().m_undoer.AsociateRedoButton(buttRedo); //glControl1. = new GraphicsMode(GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, 8); gr2d = new C2DGraphics(); ctlBgndList = new List<ctlBgnd>(); guiconf = new GuiConfig(); UpdateButtonList(); guiconf.LoadConfiguration(global::UV_DLP_3D_Printer.Properties.Resources.GuiConfig); guiconf.LayoutGui(Width, Height); ctlObjScale.c3d = this; ctlObjRotate.c3d = this; ctlObjMove.c3d = this; ctlSupport.c3d = this; objectInfoPanel.c3d = this; ctlViewOptions.c3d = this; ctlMeshTools1.c3d = this; ctlScene1.c3d = this; m_sliceTex = -1; }
//float ipx = 0.0f, ipy = 0.0f, ipz = 2.0f; public frmMain() { InitializeComponent(); UVDLPApp.Instance().AppEvent += new AppEventDelegate(AppEventDel); UVDLPApp.Instance().Engine3D.UpdateGrid(); //UVDLPApp.Instance().Engine3D.AddPlatCube(); UVDLPApp.Instance().m_slicer.Slice_Event += new Slicer.SliceEvent(SliceEv); UVDLPApp.Instance().m_buildmgr.BuildStatus += new delBuildStatus(BuildStatus); UVDLPApp.Instance().m_buildmgr.PrintLayer += new delPrinterLayer(PrintLayer); DebugLogger.Instance().LoggerStatusEvent += new LoggerStatusHandler(LoggerStatusEvent); UVDLPApp.Instance().m_deviceinterface.StatusEvent += new DeviceInterface.DeviceInterfaceStatus(DeviceStatusEvent); UVDLPApp.Instance().m_supportgenerator.SupportEvent += new SupportGeneratorEvent(SupEvent); arcball = new ArcBall(); m_quat = new Quaternion(); m_camera = new GLCamera(); m_camera.ResetView(0, -200, 0, 20, 20); SetButtonStatuses(); //PopulateBuildProfilesMenu(); SetupSceneTree(); Refresh(); }
/// <summary> /// This function will take an object, move the camera a distance away and generate the preview /// </summary> /// <param name="xsize"></param> /// <param name="ysize"></param> /// <param name="obj"></param> /// <returns></returns> public Bitmap GeneratePreview(int xsize, int ysize, List<Object3d> objs) { if (ViewAngle == ePreview.None) return null; try { // taken from http://www.opentk.com/doc/graphics/frame-buffer-objects // more good examples here: http://www.opentk.com/node/1642?page=1 // find scene extents Point3d minext = new Point3d(999999,999999,999999); Point3d maxext = new Point3d(-999999,-999999,-999999); foreach (Object3d obj in objs) { minext.x = Math.Min(obj.m_min.x, minext.x); minext.y = Math.Min(obj.m_min.y, minext.y); minext.z = Math.Min(obj.m_min.z, minext.z); maxext.x = Math.Max(obj.m_max.x, maxext.x); maxext.y = Math.Max(obj.m_max.y, maxext.y); maxext.z = Math.Max(obj.m_max.z, maxext.z); } int FboWidth = xsize; int FboHeight = ysize; uint FboHandle; uint ColorTexture; uint DepthRenderbuffer; GLCamera previewcamera = new GLCamera(); //OpenTK.Matrix4 projection = OpenTK.Matrix4.CreatePerspectiveFieldOfView(0.55f, (float)xsize / (float)ysize, 1, 2000); // Create Color Texture GL.GenTextures(1, out ColorTexture); GL.BindTexture(TextureTarget.Texture2D, ColorTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, FboWidth, FboHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero); // test for GL Error here (might be unsupported format) GL.BindTexture(TextureTarget.Texture2D, 0); // prevent feedback, reading and writing to the same image is a bad idea // Create Depth Renderbuffer GL.Ext.GenRenderbuffers(1, out DepthRenderbuffer); GL.Ext.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, DepthRenderbuffer); GL.Ext.RenderbufferStorage(RenderbufferTarget.RenderbufferExt, (RenderbufferStorage)All.DepthComponent32, FboWidth, FboHeight); // test for GL Error here (might be unsupported format) // Create a FBO and attach the textures GL.Ext.GenFramebuffers(1, out FboHandle); GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, FboHandle); GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, ColorTexture, 0); GL.Ext.FramebufferRenderbuffer(FramebufferTarget.FramebufferExt, FramebufferAttachment.DepthAttachmentExt, RenderbufferTarget.RenderbufferExt, DepthRenderbuffer); // now GL.Ext.CheckFramebufferStatus( FramebufferTarget.FramebufferExt ) can be called, check the end of this page for a snippet. // since there's only 1 Color buffer attached this is not explicitly required GL.DrawBuffer((DrawBufferMode)FramebufferAttachment.ColorAttachment0Ext); GL.PushAttrib(AttribMask.ViewportBit); // stores GL.Viewport() parameters GL.Viewport(0, 0, FboWidth, FboHeight); // render whatever your heart desires, when done ... // clear buffer //GL.ClearColor(Color.White); // clear the screen, to make it very obvious what the clear affected. only the FBO, not the real framebuffer GL.ClearColor(BackColor); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //set up camera for the specified view float bmpaspect = (float)xsize / (float)ysize; switch (ViewAngle) { case ePreview.Front: SetProjection(bmpaspect, minext.x, maxext.x, minext.z, maxext.z); previewcamera.ResetView(0, -50, 0, 0, 0); break; case ePreview.Back: SetProjection(bmpaspect, -maxext.x, -minext.x, minext.z, maxext.z); previewcamera.ResetView(0, 50, 0, 0, 0); break; case ePreview.Top: SetProjection(bmpaspect, minext.x, maxext.x, minext.y, maxext.y); previewcamera.ResetView(0, -50, 0, 90, 0); break; case ePreview.Bottom: SetProjection(bmpaspect, minext.x, maxext.x, -maxext.y, -minext.y); previewcamera.ResetView(0, -50, 0, -90, 0); break; case ePreview.Right: SetProjection(bmpaspect, minext.y, maxext.y, minext.z, maxext.z); previewcamera.ResetView(50, 0, 0, 0, 0); break; case ePreview.Left: SetProjection(bmpaspect, -maxext.y, -minext.y, minext.z, maxext.z); previewcamera.ResetView(-50,0 , 0, 0, 0); break; case ePreview.Isometric: float oldscale = Scale; Scale = ((Scale +1f) * 1.4f) - 1f; SetProjection(bmpaspect, minext.x, maxext.x, minext.z, maxext.z); Scale = oldscale; previewcamera.ResetView(50, -50, 0, 30, 0); break; } //previewcamera.ResetView(0, -200, 0, 20, 20); //previewcamera.ResetView(0, -200, obj.m_radius/2, 0, 00); // setup projection matrix GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref projection); GL.MatrixMode(MatrixMode.Modelview); previewcamera.SetViewGL(); //render scene foreach (Object3d obj in objs) { obj.InvalidateList(); obj.RenderGL(false, false, false, SceneColor); obj.InvalidateList(); } //copy the framebuffer to a bitmap Bitmap bmppreview = GetBitmap(xsize, ysize); GL.PopAttrib(); // restores GL.Viewport() parameters GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); // return to visible framebuffer GL.DrawBuffer(DrawBufferMode.Back); return bmppreview; } catch (Exception ex) { DebugLogger.Instance().LogError(ex); return null; } }