public virtual void AddObject(LinkedList <DrawingContainer> a_objects, LinkedList <Renderer> a_renderers) { if (m_material == null) { return; } // Finds the material linked to the Renderer object and adds it to the materials render list foreach (DrawingContainer container in a_objects) { if (container.Material == m_material) { container.Renderers.AddLast(new DrawingContainer.RenderingContainer() { Renderer = this }); return; } } // The material was not found so add the material to the list and add the renderer to the materials list DrawingContainer cont = new DrawingContainer(m_material); cont.Renderers.AddLast(new DrawingContainer.RenderingContainer() { Renderer = this }); a_objects.AddLast(cont); }
public void ScreenShotToClipboard() { var graphics = new Graphics3DImage(this.Size); try { double angleHorizRad = AngleHoriz * Math.PI / 180.0; double angleVertRad = AngleVert * Math.PI / 180.0; double cameraDistance = 100000.0; graphics.CameraPosition = new Vector3D( cameraDistance * Math.Cos(angleHorizRad) * Math.Cos(angleVertRad) , cameraDistance * Math.Sin(angleHorizRad) * Math.Cos(angleVertRad) , cameraDistance * Math.Sin(angleVertRad)); // set camera target graphics.Target = Vector3D.Zero; // set viewport (not actually needed) graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f); // show images graphics.ShowTextures = true; graphics.ShowDimensions = ShowDimensions; graphics.FontSizeRatio = 10.0f / (float)Size.Height; if (null != DrawingContainer) { try { DrawingContainer.Draw(this, graphics); } catch (Exception ex) { _log.Error(ex.ToString()); } } else if (null != Viewer) { try { Viewer.Draw(graphics, Transform3D.Identity); } catch (Exception ex) { graphics.Graphics.DrawString(ex.Message , new Font("Arial", 12) , new SolidBrush(Color.Red) , new Point(0, 0) , StringFormat.GenericDefault); _log.Error(ex.Message); } } graphics.Flush(); } catch (Exception ex) { _log.Error(ex.ToString()); } Clipboard.SetImage(BitmapHelpers.Crop(graphics.Bitmap)); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); try { Graphics3DForm graphics = new Graphics3DForm(this, e.Graphics); double angleHorizRad = AngleHoriz * Math.PI / 180.0; double angleVertRad = AngleVert * Math.PI / 180.0; double cameraDistance = 100000.0; graphics.CameraPosition = new Vector3D( cameraDistance * Math.Cos(angleHorizRad) * Math.Cos(angleVertRad) , cameraDistance * Math.Sin(angleHorizRad) * Math.Cos(angleVertRad) , cameraDistance * Math.Sin(angleVertRad)); // set camera target graphics.Target = Vector3D.Zero; // set viewport (not actually needed) graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f); // show images graphics.ShowTextures = true; graphics.ShowDimensions = ShowDimensions; graphics.FontSizeRatio = 10.0f / (float)Size.Height; if (null != DrawingContainer) { try { DrawingContainer.Draw(this, graphics); } catch (Exception ex) { e.Graphics.DrawString(ex.ToString() , new Font("Arial", 12) , new SolidBrush(Color.Red) , new Point(0, 0) , StringFormat.GenericDefault); _log.Error(ex.ToString()); } } if (null != Viewer) { try { Viewer.Draw(graphics, Transform3D.Identity); } catch (Exception ex) { e.Graphics.DrawString(ex.Message , new Font("Arial", 12) , new SolidBrush(Color.Red) , new Point(0, 0) , StringFormat.GenericDefault); _log.Error(ex.Message); } } graphics.Flush(); if (null != Viewer) { Viewer.CurrentTransformation = graphics.GetCurrentTransformation(); Viewer.ViewDir = graphics.ViewDirection; } // draw toolbar if (ShowToolBar) { DrawToolBar(e.Graphics); } } catch (Exception ex) { _log.Error(ex.ToString()); } }