public TransformationNode(int ID, Element3D parent) : base(ID, parent) { Rotation = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 0.0f); Scale = new M3D.Model.Utils.Vector3(1f, 1f, 1f); Translation = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 0.0f); }
private static OpenTK.Vector3 GluProject(M3D.Model.Utils.Vector3 objPos, Matrix4 matWorldViewProjection, int[] viewport) { Vector4 vec; vec.X = objPos.X; vec.Y = objPos.Y; vec.Z = objPos.Z; vec.W = 1f; var vector4 = Vector4.Transform(vec, matWorldViewProjection); if (vector4.W <= 0.0) { return(OpenTK.Vector3.Zero); } vector4.X /= vector4.W; vector4.Y /= vector4.W; vector4.Z /= vector4.W; vector4.X = (float)(vector4.X * 0.5 + 0.5); vector4.Y = (float)(-vector4.Y * 0.5 + 0.5); vector4.Z = (float)(vector4.Z * 0.5 + 0.5); vector4.X = vector4.X * viewport[2] + viewport[0]; vector4.Y = vector4.Y * viewport[3] + viewport[1]; OpenTK.Vector3 vector3; vector3.X = vector4.X; vector3.Y = viewport[3] - vector4.Y; vector3.Z = vector4.Z; return(vector3); }
private static void UpdateScreenMinMax(M3D.Model.Utils.Vector3 coord, ref M3D.Model.Utils.Vector3 screen_min, ref M3D.Model.Utils.Vector3 screen_max, Matrix4 matWorldViewProjection, int[] viewport) { OpenTK.Vector3 vector3 = ImageCapture.GluProject(coord, matWorldViewProjection, viewport); if (vector3.X < (double)screen_min.X) { screen_min.X = vector3.X; } if (vector3.Y < (double)screen_min.Y) { screen_min.Y = vector3.Y; } if (vector3.Z < (double)screen_min.Z) { screen_min.Z = vector3.Z; } if (vector3.X > (double)screen_max.X) { screen_max.X = vector3.X; } if (vector3.Y > (double)screen_max.Y) { screen_max.Y = vector3.Y; } if (vector3.Z <= (double)screen_max.Z) { return; } screen_max.Z = vector3.Z; }
private static void RenderModelGetScreenMinMax(Model3DNode model, M3D.Model.Utils.Vector3 rotation, M3D.Model.Utils.Vector3 translation, M3D.Model.Utils.Vector3 scale, out Rectangle screen_rec) { var scale1 = Matrix4.CreateScale(scale.X, scale.Y, scale.Z); Matrix4 matrix4_1 = Matrix4.CreateRotationY(rotation.Y * ((float)Math.PI / 180f)) * Matrix4.CreateRotationX(rotation.X * ((float)Math.PI / 180f)) * Matrix4.CreateRotationZ(rotation.Z * ((float)Math.PI / 180f)); var translation1 = Matrix4.CreateTranslation(translation.X, translation.Y, translation.Z); Matrix4 matrix4_2 = matrix4_1; Matrix4 mat = scale1 * matrix4_2 * translation1; GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.Rotate(-90f, new OpenTK.Vector3(1f, 0.0f, 0.0f)); GL.MultMatrix(ref mat); Color4 diffuse = model.Diffuse; var brightness = model.Brightness; var highlight = model.Highlight; if (ImageCapture.IconColor == "Standard") { model.Diffuse = new Color4(98, 181, 233, byte.MaxValue); } else if (ImageCapture.IconColor == "Random") { FilamentConstants.HexToRGB(FilamentConstants.generateHEXFromColor((FilamentConstants.ColorsEnum)(ImageCapture.internalRandomGenerator.Next(10) + 5)), out var R, out var G, out var B, out var A); model.Diffuse = new Color4(R, G, B, A); } model.Brightness = 1f; model.Highlight = false; model.Render3D(); model.Diffuse = diffuse; model.Brightness = brightness; model.Highlight = highlight; screen_rec = ImageCapture.GetScreenMinMax(model); GL.PopMatrix(); }
public Frame3DView(int ID, Element2D parent) : base(ID, parent) { viewPointPos = new M3D.Model.Utils.Vector3(0.0f, 100f, 400f); cameraLookAtPos = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 0.0f); SetCameraPerspective(45f, 100f, 1000f); }
public TransformationNode(M3D.Model.Utils.Vector3 translate, M3D.Model.Utils.Vector3 scale, M3D.Model.Utils.Vector3 rotate) : base(0, null) { Rotation = new M3D.Model.Utils.Vector3(rotate); Scale = new M3D.Model.Utils.Vector3(scale); Translation = new M3D.Model.Utils.Vector3(translate); }
public Ray UnProjectMouseCoordinates(float mouse_x, float mouse_y, Matrix4 worldMatrix) { var w1 = new Vector4(mouse_x, mouse_y, 0.0f, 0.0f); var w2 = new Vector4(mouse_x, mouse_y, 1f, 0.0f); Vector4 vector4_1 = UnProject(w1, worldMatrix); Vector4 vector4_2 = UnProject(w2, worldMatrix); var direction = new M3D.Model.Utils.Vector3(vector4_2.X - vector4_1.X, vector4_2.Y - vector4_1.Y, vector4_2.Z - vector4_1.Z); direction.Normalize(); return(new Ray(new M3D.Model.Utils.Vector3(vector4_1.X, vector4_1.Y, vector4_1.Z), direction)); }
public Transform(M3D.Model.Utils.Vector3 translation, M3D.Model.Utils.Vector3 scale, M3D.Model.Utils.Vector3 rotation) { this.translation.x = translation.X; this.translation.y = translation.Y; this.scale.x = scale.X; this.scale.y = scale.Y; this.scale.z = scale.Z; this.rotation.x = rotation.X; this.rotation.y = rotation.Y; this.rotation.z = rotation.Z; }
public void PlaceObjectOnFloor(int selected_model_index) { if (ModelList.Count <= 0 || selected_model_index < 0) { return; } ModelTransformPair model = ModelList[selected_model_index]; var vector3 = new M3D.Model.Utils.Vector3(0.0f, 0.0f, (float)(-model.modelSize.Min.Z + 1.0)); model.transformNode.Translation.Z += vector3.Z; model.CalculateExtents(); }
private static Bitmap GenerateIcon(Model3DNode model, GLControl glcontrol, Vector2 icon_size, M3D.Model.Utils.Vector3 orientation, Color4 bgColor) { ImageCapture.SetViewPoint(glcontrol); var rotation = new M3D.Model.Utils.Vector3(orientation); var translation = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 0.0f); M3D.Model.Utils.Vector3 ext = model.CalculateMinMax().Ext; var num = ext.X <= (double)ext.Z ? ext.Z <= (double)ext.Y ? 100f / ext.Y : 100f / ext.Z : ext.Y <= (double)ext.X ? 100f / ext.X : 100f / ext.Y; var scale = new M3D.Model.Utils.Vector3(num, num, num); ImageCapture.SetupForIconRender(new OpenTK.Vector3(100f, 100f, 250f), new OpenTK.Vector3(0.0f, 0.0f, 0.0f), bgColor); ImageCapture.RenderModelGetScreenMinMax(model, rotation, translation, scale, out Rectangle screen_rec); return(ImageCapture.GrabIconFromRender(glcontrol, ref screen_rec, icon_size)); }
public PrinterViewSceneGraph(GUIHost host, SettingsManager.GridUnit initialGridUnits, PrinterSizeProfile.CaseType initialCaseType) : base(123456) { RelativeX = 0.0f; RelativeY = 0.0f; RelativeWidth = 1f; RelativeHeight = 1f; ViewPointPos = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 10f); ModelList = new List <ModelTransformPair>(); CameraLookAtPos = new M3D.Model.Utils.Vector3(0.0f, -10f, 0.0f); AddChildElement3D(new LightNode(0, 0, new Vector4(0.0f, 400f, 1000f, 1f), new Color4(0.2f, 0.2f, 0.2f, 1f), new Color4(1f, 1f, 1f, 1f), new Color4(1f, 1f, 1f, 1f))); AddChildElement3D(new LightNode(1, 1, new Vector4(0.0f, 20f, -400f, 1f), new Color4(0.0f, 0.0f, 0.0f, 1f), new Color4(1f, 1f, 1f, 1f), new Color4(0.3f, 0.3f, 0.3f, 1f))); OpenGLCoordinateSystem = new TransformationNode(0, origin) { Rotation = new M3D.Model.Utils.Vector3(-90f, 0.0f, 0.0f) }; AddChildElement3D(OpenGLCoordinateSystem); PrinterTiltTransform = new TransformationNode(0, OpenGLCoordinateSystem); OpenGLCoordinateSystem.AddChildElement(PrinterTiltTransform); PrinterTransformation = new TransformationNode(0, PrinterTiltTransform); PrinterTypeAdjustments = new TransformationNode(3011, PrinterTransformation); var num = 1.1f; PrinterTypeAdjustments.Scale = new M3D.Model.Utils.Vector3(num, num, 1f); PrinterTransformation.AddChildElement(PrinterTypeAdjustments); PrinterModel = new PrinterModelNode(initialCaseType); PrinterTypeAdjustments.AddChildElement(PrinterModel); ObjectToPrinterSpace = new TransformationNode(3005, PrinterTransformation) { Translation = new M3D.Model.Utils.Vector3(0.0f, 0.0f, 0.0f) }; PrinterTransformation.AddChildElement(ObjectToPrinterSpace); GridSizeAdjustments = new TransformationNode(3012, ObjectToPrinterSpace); ObjectToPrinterSpace.AddChildElement(GridSizeAdjustments); Grid = new GridObjectNode(3003, 100f, 100f); Grid.SetUnits(initialGridUnits); Grid.Visible = false; Grid.Emission = new Color4(1f, 1f, 1f, 1f); GridSizeAdjustments.AddChildElement(Grid); var texturedFloorNode = new TexturedFloorNode(3004); var bitmap = new Bitmap(Resources.shadowtexture); var texture = 0; Element3D.CreateTexture(ref texture, bitmap); bitmap.Dispose(); texturedFloorNode.Create(new M3D.Model.Utils.Vector3(0.0f, 0.0f, -76f), 450f, 240f, texture); OpenGLCoordinateSystem.AddChildElement(texturedFloorNode); PrinterTiltTransform.AddChildElement(PrinterTransformation); }
public void Create(M3D.Model.Utils.Vector3 pos, float xWidth, float yWidth, int opengl_texture_handle) { var num1 = xWidth / 2f; var num2 = yWidth / 2f; var vector3_1 = new M3D.Model.Utils.Vector3(pos.X + num1, pos.Y + num2, pos.Z); var vector3_2 = new M3D.Model.Utils.Vector3(pos.X - num1, pos.Y - num2, pos.Z); Create(new List <VertexTNV>() { new VertexTNV(new Vector2(0.0f, 0.0f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_1.Z)), new VertexTNV(new Vector2(1f, 0.0f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_1.Z)), new VertexTNV(new Vector2(1f, 1f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_1.Z)), new VertexTNV(new Vector2(1f, 1f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_1.Z)), new VertexTNV(new Vector2(0.0f, 1f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_1.Z)), new VertexTNV(new Vector2(0.0f, 0.0f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_1.Z)) }, opengl_texture_handle); }
private bool CheckIsPositionFree(M3D.Model.Utils.Vector3 position, OpenTK.Vector2 modelsize) { var boundingBox = new BoundingBox(new Vector3D(position.X - modelsize.X / 2f, position.Y - modelsize.Y / 2f, 0.0f), new Vector3D(position.X + modelsize.X / 2f, position.Y + modelsize.Y / 2f, 0.0f)); var flag = true; foreach (ModelTransformPair model in ModelList) { var x = model.transformNode.Translation.X; var y = model.transformNode.Translation.Y; var num1 = model.modelSize.Ext.X / 2f; var num2 = model.modelSize.Ext.Y / 2f; var other = new BoundingBox(new Vector3D(x - num1 / 2f, y - num2 / 2f, 0.0f), new Vector3D(x + num1 / 2f, y + num2 / 2f, 0.0f)); if (boundingBox.OverLap(other)) { flag = false; break; } } return(flag); }
public GridObjectNode(int ID, float bedwidth, float bedheight) : base(ID, null) { texture_handles = new int[2, 2]; texture_handles[0, 0] = CreateTexture(Resources.gridinchestexture_micro1); texture_handles[0, 1] = CreateTexture(Resources.gridmmtexture_micro1); texture_handles[1, 0] = CreateTexture(Resources.gridinchestexture_pro); texture_handles[1, 1] = CreateTexture(Resources.gridmmtexture_pro); var vertex_list = new List <VertexTNV>(); var vector3_1 = new M3D.Model.Utils.Vector3(-6.6667f, -6.6667f, 0.0f); var vector3_2 = new M3D.Model.Utils.Vector3(100f, 100f, 0.0f); vertex_list.Add(new VertexTNV(new OpenTK.Vector2(0.0f, 0.0f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new OpenTK.Vector2(0.0f, 1f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new OpenTK.Vector2(1f, 0.0f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new OpenTK.Vector2(1f, 0.0f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new OpenTK.Vector2(0.0f, 1f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new OpenTK.Vector2(1f, 1f), new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_2.Z))); Create(vertex_list, texture_handles[0, 1]); CurrentCaseType = PrinterSizeProfile.CaseType.Micro1Case; CurrentUnits = SettingsManager.GridUnit.MM; }
public void SizeFromPrinterProfile(PrinterSizeProfile sizeProfile) { PrinterModelCaseType = sizeProfile.case_type; M3D.Model.Utils.Vector3 ext = PrinterModel.ShellModel.Ext; PrinterTypeAdjustments.Scale.X = sizeProfile.shell_size.x / ext.X; PrinterTypeAdjustments.Scale.Y = sizeProfile.shell_size.y / ext.Y; PrinterTypeAdjustments.Scale.Z = sizeProfile.shell_size.z / ext.X; PrinterTransformation.Translation.Z = PrinterModel.ZOffset; ObjectToPrinterSpace.Translation.X = sizeProfile.printBedSize.x / -2f; ObjectToPrinterSpace.Translation.Y = sizeProfile.printBedSize.y / -2f; ObjectToPrinterSpace.Translation.Z = (float)(sizeProfile.shell_size.z / -2.0 + sizeProfile.fluff_height * (double)PrinterTypeAdjustments.Scale.Z); GridSizeAdjustments.Scale.X = sizeProfile.printBedSize.x / 100f; GridSizeAdjustments.Scale.Y = sizeProfile.printBedSize.y / 100f; PrinterBedWidth = sizeProfile.printBedSize.x; PrinterBedLength = sizeProfile.printBedSize.y; SetPrintableExts(sizeProfile.printBedSize.x, sizeProfile.printBedSize.y, 110f); PrinterCenter = new M3D.Model.Utils.Vector3(sizeProfile.HomeLocation.x, sizeProfile.HomeLocation.y, 0.0f); var num = PrinterModel.GUICaseSize / sizeProfile.shell_size.z; PrinterTransformation.Scale = new M3D.Model.Utils.Vector3(num, num, num); PrinterBoundsConst = sizeProfile; CreateBoundsGeometry(ObjectToPrinterSpace); }
private static Rectangle GetScreenMinMax(Model3DNode model) { int[] numArray = new int[4]; double[] data1 = new double[16]; double[] data2 = new double[16]; GL.GetInteger(GetPName.Viewport, numArray); GL.GetDouble(GetPName.Modelview0MatrixExt, data1); GL.GetDouble(GetPName.ProjectionMatrix, data2); var right = new Matrix4((float)data2[0], (float)data2[1], (float)data2[2], (float)data2[3], (float)data2[4], (float)data2[5], (float)data2[6], (float)data2[7], (float)data2[8], (float)data2[9], (float)data2[10], (float)data2[11], (float)data2[12], (float)data2[13], (float)data2[14], (float)data2[15]); var left = new Matrix4((float)data1[0], (float)data1[1], (float)data1[2], (float)data1[3], (float)data1[4], (float)data1[5], (float)data1[6], (float)data1[7], (float)data1[8], (float)data1[9], (float)data1[10], (float)data1[11], (float)data1[12], (float)data1[13], (float)data1[14], (float)data1[15]); var screen_max = new M3D.Model.Utils.Vector3(float.MinValue, float.MinValue, float.MinValue); var screen_min = new M3D.Model.Utils.Vector3(float.MaxValue, float.MaxValue, float.MaxValue); ModelSize minMax = model.CalculateMinMax(); M3D.Model.Utils.Vector3 min = minMax.Min; M3D.Model.Utils.Vector3 max = minMax.Max; M3D.Model.Utils.Vector3 ext = minMax.Ext; var coord1 = new M3D.Model.Utils.Vector3(min); ImageCapture.UpdateScreenMinMax(coord1, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); coord1.X = max.X; ImageCapture.UpdateScreenMinMax(coord1, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); coord1.Z = max.Z; ImageCapture.UpdateScreenMinMax(coord1, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); coord1.X = min.X; ImageCapture.UpdateScreenMinMax(coord1, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); var coord2 = new M3D.Model.Utils.Vector3(max); ImageCapture.UpdateScreenMinMax(coord2, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); coord2.X = min.X; ImageCapture.UpdateScreenMinMax(coord2, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); coord2.Z = min.Z; ImageCapture.UpdateScreenMinMax(coord2, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); coord2.X = max.X; ImageCapture.UpdateScreenMinMax(coord2, ref screen_min, ref screen_max, Matrix4.Mult(left, right), numArray); return(new Rectangle((int)screen_min.X, (int)screen_min.Y, (int)(screen_max.X - (double)screen_min.X), (int)(screen_max.Y - (double)screen_min.Y))); }
public VertexTNV(M3D.Model.Utils.Vector3 normal, M3D.Model.Utils.Vector3 position) { Normal = new OpenTK.Vector3(normal.X, normal.Y, normal.Z); Position = new OpenTK.Vector3(position.X, position.Y, position.Z); TexCoord = new Vector2(0.0f, 0.0f); }
public static bool GenerateMultiModelPreview(List <ModelTransformPair> model_list, string icon_file, Vector2 icon_size, Color4 bgColor, GLControl glcontrol, M3D.Model.Utils.Vector3 center) { ImageCapture.SetViewPoint(glcontrol); ImageCapture.SetupForIconRender(new OpenTK.Vector3(center.X, center.Y, center.Z + 200f), new OpenTK.Vector3(center.X, center.Y, center.Z), bgColor); var minMax = new Rectangle(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue); foreach (ModelTransformPair model in model_list) { ImageCapture.RenderModelGetScreenMinMax(model.modelNode, model.transformNode.Rotation, model.transformNode.Translation, model.transformNode.Scale, out Rectangle screen_rec); if (minMax.X == int.MaxValue) { minMax = screen_rec; } else { var x1 = minMax.X; var y1 = minMax.Y; var num1 = minMax.X + minMax.Width; var num2 = minMax.Y + minMax.Height; var x2 = screen_rec.X; var y2 = screen_rec.Y; var num3 = screen_rec.X + screen_rec.Width; var num4 = screen_rec.Y + screen_rec.Height; var num5 = x1 < x2 ? x1 : x2; var num6 = y1 < y2 ? y1 : y2; var num7 = num1 > num3 ? num1 : num3; var num8 = num2 > num4 ? num2 : num4; minMax.X = num5; minMax.Y = num6; minMax.Width = num7 - num5; minMax.Height = num8 - num6; } } Bitmap image = ImageCapture.GrabIconFromRender(glcontrol, ref minMax, icon_size); if (image == null) { return(false); } ImageCapture.SaveIcon(image, icon_file); return(true); }
public M3D.Model.Utils.Vector3 FindFreePosition(OpenTK.Vector2 modelsize) { var position = new M3D.Model.Utils.Vector3(PrinterCenter); if (ModelCount < 1) { return(position); } var num1 = modelsize.X * 0.75f; var num2 = modelsize.Y * 0.75f; for (var index = 0; index < 6; ++index) { var num3 = (float)(1.0 + 0.25 * index); var num4 = (float)((PrinterBedWidth * (double)num3 - modelsize.X) / 2.0); var num5 = (float)((PrinterBedLength * (double)num3 - modelsize.Y) / 2.0); var num6 = (float)(PrinterCenter.X + (double)num4 - 2.0); var num7 = (float)(PrinterCenter.Y + (double)num5 - 2.0); var num8 = (float)(PrinterCenter.X - (double)num4 + 2.0); var num9 = (float)(PrinterCenter.Y - (double)num5 + 2.0); var num10 = 0; label_24: if (num10 < 8) { int num11; int num12; if (num10 == 0) { num11 = 1; num12 = 0; } else if (num10 == 1) { num11 = 0; num12 = 1; } else if (num10 == 2) { num11 = -1; num12 = 0; } else if (num10 == 3) { num11 = 0; num12 = -1; } else if (num10 == 4) { num11 = 2; num12 = 2; } else if (num10 == 5) { num11 = -2; num12 = 2; } else if (num10 == 6) { num11 = -2; num12 = -2; } else { num11 = 2; num12 = -2; } position.X = PrinterCenter.X; position.Y = PrinterCenter.Y; while (!CheckIsPositionFree(position, modelsize)) { position.X += num11 * num1; position.Y += num12 * num2; if (position.X >= (double)num6 || position.Y >= (double)num7 || (position.X <= (double)num8 || position.Y <= (double)num9)) { ++num10; goto label_24; } } return(position); } } return(position); }
private void SetPrintableExts(float x, float y, float z) { printableRegionExts = new M3D.Model.Utils.Vector3(x, y, z); PrinterCenter = new M3D.Model.Utils.Vector3(x / 2f, y / 2f, 0.0f); }
private void CreateBoundsGeometry(Element3D parent) { lock (exceedsBoundsSync) { if (PrinterBoundsConst.PrintableRegion == null || PrinterBoundsConst.PrintableRegion.bounds_list.Count < 1) { return; } StackedBoundingBox printableRegion = PrinterBoundsConst.PrintableRegion; if (ExceedsBoundsGeometry != null) { for (var index1 = 0; index1 < ExceedsBoundsGeometry.GetLength(0); ++index1) { for (var index2 = 0; index2 < ExceedsBoundsGeometry.GetLength(1); ++index2) { parent.RemoveChildElement(ExceedsBoundsGeometry[index1, index2]); } } } List <BoundingBox> boundsList = printableRegion.bounds_list; ExceedsBoundsGeometry = new CustomShape[boundsList.Count, 6]; var vertex_list = new List <VertexTNV>(); for (var index = 0; index < boundsList.Count; ++index) { var vector3_1 = new Model.Utils.Vector3(boundsList[index].min.x, boundsList[index].min.y, boundsList[index].min.z); var vector3_2 = new M3D.Model.Utils.Vector3(boundsList[index].max.x, boundsList[index].max.y, boundsList[index].max.z); ExceedsBoundsGeometry[index, 0] = new CustomShape(3006); vertex_list.Clear(); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_1.Z))); ExceedsBoundsGeometry[index, 0].Create(vertex_list, 0); BoundingBoxColoringHelper(ref ExceedsBoundsGeometry[index, 0]); parent.AddChildElement(ExceedsBoundsGeometry[index, 0]); ExceedsBoundsGeometry[index, 1] = new CustomShape(3007); vertex_list.Clear(); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, -1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, -1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, -1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, -1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, -1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, -1f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_1.Z))); ExceedsBoundsGeometry[index, 1].Create(vertex_list, 0); BoundingBoxColoringHelper(ref ExceedsBoundsGeometry[index, 1]); parent.AddChildElement(ExceedsBoundsGeometry[index, 1]); ExceedsBoundsGeometry[index, 2] = new CustomShape(3008); vertex_list.Clear(); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_1.Z))); ExceedsBoundsGeometry[index, 2].Create(vertex_list, 0); BoundingBoxColoringHelper(ref ExceedsBoundsGeometry[index, 2]); parent.AddChildElement(ExceedsBoundsGeometry[index, 2]); ExceedsBoundsGeometry[index, 3] = new CustomShape(3009); vertex_list.Clear(); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(-1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(-1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(-1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(-1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(-1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_1.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(-1f, 0.0f, 0.0f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_1.Z))); ExceedsBoundsGeometry[index, 3].Create(vertex_list, 0); BoundingBoxColoringHelper(ref ExceedsBoundsGeometry[index, 3]); parent.AddChildElement(ExceedsBoundsGeometry[index, 3]); if (index + 1 == boundsList.Count) { ExceedsBoundsGeometry[index, 4] = new CustomShape(3010); vertex_list.Clear(); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_1.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_2.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_2.Y, vector3_2.Z))); vertex_list.Add(new VertexTNV(new M3D.Model.Utils.Vector3(0.0f, 0.0f, 1f), new M3D.Model.Utils.Vector3(vector3_1.X, vector3_1.Y, vector3_2.Z))); ExceedsBoundsGeometry[index, 4].Create(vertex_list, 0); BoundingBoxColoringHelper(ref ExceedsBoundsGeometry[index, 4]); parent.AddChildElement(ExceedsBoundsGeometry[index, 4]); } } } }
public VertexTNV(Vector2 texCoord, M3D.Model.Utils.Vector3 normal, M3D.Model.Utils.Vector3 position) { TexCoord = texCoord; Normal = new OpenTK.Vector3(normal.X, normal.Y, normal.Z); Position = new OpenTK.Vector3(position.X, position.Y, position.Z); }
public Transform(M3D.Model.Utils.Vector3 rotation, M3D.Model.Utils.Vector3 scaling, M3D.Model.Utils.Vector3 translation) { this.rotation = new M3D.Model.Utils.Vector3(rotation); this.scaling = new M3D.Model.Utils.Vector3(scaling); this.translation = new M3D.Model.Utils.Vector3(translation); }