/// <summary> /// overrides the <see cref="CustomEntity.Draw"/> method. /// </summary> /// <param name="Device"></param> protected override void OnDraw(OpenGlDevice Device) { for (int i = 0; i < Curvextruders.Count; i++) { for (int j = 0; j < Curvextruders[i].Count; j++) { Curvextruders[i][j].Paint(Device); if (Device.RenderKind == RenderKind.SnapBuffer) { SnappItem SI = Selector.StoredSnapItems[Selector.StoredSnapItems.Count - 1]; SI.OfObject = this; } } } if (ShowUpPlane) { DrawUpPlane(Device); } if (ShowDownPlane) { DrawDownPlane(Device); } base.OnDraw(Device); }
/// <summary> /// internal. /// </summary> internal static void Renew() { if (MeshIndices.Count > 0) { xyzf[] _Colors = null; if ((MeshColors != null) && (MeshColors.Count == MeshVertices.Count)) { _Colors = MeshColors.ToArray(); } xyf[] TextureCoords = null; if (MeshTextureCoords.Count > 0) { TextureCoords = MeshTextureCoords.ToArray(); } CompiledMesh M = new CompiledMesh(MeshIndices.ToArray(), MeshVertices.ToArray(), MeshNormals.ToArray(), TextureCoords, _Colors); // sollte nur im snap modus passieren M.SnapObject = Selector.StoredSnapItems.Count - 1; M.PenWidth = PenWidth; M.Mode = MeshMode; M.Material = Material; M.PenColor = Emission; M.PenStyle = PenStyle; M.Texture = Texture; MeshListCurrent.Progs.Add(M); MeshMode = PolygonMode.Fill; if (Selector.RegisterSnap) { Selector.SnapMesh.Progs.Add(M); } } PenWidth = 1; MeshVertices = new List <xyzf>(); MeshNormals = new List <xyzf>(); MeshTextureCoords = new List <xyf>(); MeshIndices = new List <IndexType>(); HasMaterial = false; _Material = Materials.Chrome; HasTexture = false; _Texture = null; HasPenWidth = false; _PenWidth = 1; HasEmission = false; _Emission = System.Drawing.Color.Black; HasPenStyle = false; _PenStyle = PenStyles.Full; SnapItem = null; MeshMode = PolygonMode.Fill; }
/// <summary> /// paints the upper plane. You can override this metod e.g to gives the uppPlane a materal. See also <see cref="DrawUpPlane(OpenGlDevice)"/> /// </summary> /// <param name="Device">the device in wich will drawn.</param> protected virtual void DrawDownPlane(OpenGlDevice Device) { Device.PushMatrix(); Device.MulMatrix(DownMatrix); Device.drawPolyPolyLine(DownLoxy); Device.PopMatrix(); if (Device.RenderKind == RenderKind.SnapBuffer) { SnappItem SI = Selector.StoredSnapItems[Selector.StoredSnapItems.Count - 1]; { SI.OfObject = this; } } }
void _drawPolyPolyCurve(Loxy L, Loca Loca, int id) { Object Handle = null; if (PolygonMode == PolygonMode.Fill) { if ((RenderKind == RenderKind.SnapBuffer)) { Handle = Selector.RegisterSnapItem(getSI(id, Loca, L, -1)); } drawFilledArray2d(this, L); if ((RenderKind == RenderKind.SnapBuffer)) { MeshCreator.Renew(); Selector.UnRegisterSnapItem(Handle); } return; } if ((RenderKind == RenderKind.SnapBuffer)) { SnappItem S = (getSI(id, Loca, L, -1)); Handle = Selector.RegisterSnapItem(S); } { for (int i = 0; i < L.Count; i++) { //IndexType[] Indices = new IndexType[L[i].Count]; //for (int k = 0;k < L[i].Count; k++) //{ // Indices[k] = k; //} //xyzf[] Points = new xyzf[L[i].Count]; //for (int k = 0; k < L[i].Count; k++) //{ // Points[k] = new xyzf((float)L[i][k].X, (float)L[i][k].y, 0f); //} //Primitives3d.drawTriangles(this,Indices, Points, null, null, null); ////if ((RenderKind == RenderKind.SnapBuffer)) //// Selector.ToSnapBuffer((uint)i); Primitives2d.drawArrayLined(this, L[i]); } } if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } }
SnappItem Inside() { SnappItem Result = null; for (int j = 0; j < Device.SnappItems.Count; j++) { if (Device.SnappItems[j].Object == this) { Result = Device.SnappItems[j]; return(Result); } } return(Result); }
/// <summary> /// paints the upper plane. You can override this metod e.g to gives the uppPlane a materal. /// <br/> /// f.e:<br/> /// class MyPolyExtruder:PolyCurveExtruder<br/> ///{<br/> ///protected override void DrawUpPlane(OpenGlDevice Device)<br/> ///{<br/> ///Material Save = Device.Material<br/> ///Device.Material = Materials.Gold;<br/> /// base.DrawUpPlane(Device);<br/> ///Device.Material = Save;<br/> ///} ///} /// </summary> /// <param name="Device">the device in wich will drawn.</param> protected virtual void DrawUpPlane(OpenGlDevice Device) { Device.PushMatrix(); Device.MulMatrix(UpMatrix); Device.drawPolyPolyLine(UpLoxy); if (Device.RenderKind == RenderKind.SnapBuffer) { if (Selector.StoredSnapItems.Count > 0) { SnappItem SI = Selector.StoredSnapItems[Selector.StoredSnapItems.Count - 1]; if (SI != null) { SI.OfObject = this; } } } Device.PopMatrix(); }
public MeshCreatorItem( List <xyzf> MeshVertices, List <xyzf> MeshNormals, List <xyf> MeshTextureCoords, List <IndexType> MeshIndices, MeshContainer MeshListCurrent, float PenWidth, SnappItem SnapItem, PolygonMode _MeshMode, List <SnappItem> StoredSnapItems) { this.MeshVertices = MeshVertices; this.MeshNormals = MeshNormals; this.MeshTextureCoords = MeshTextureCoords; this.MeshIndices = MeshIndices; this.MeshListCurrent = MeshListCurrent; this.PenWidth = PenWidth; this._MeshMode = PolygonMode.Fill; }
/// <summary> /// overrides the <see cref="CustomEntity.OnDraw(OpenGlDevice)"/> method. /// </summary> /// <param name="Device"></param> protected override void OnDraw(OpenGlDevice Device) { base.OnDraw(Device); if (Transverse == null) { return; } if (Transverse.Count == 0) { return; } for (int i = 1; i > 0; i--) { if (Trace[i].dist(Trace[i - 1]) < Utils.epsilon) { Trace.RemoveAt(i); } } if ((Trace.Count == 3) && (Trace.Closed())) { Trace.RemoveAt(2); } if (Trace.Count <= 1) { return; } // if (Trace.Count <= 1) return; xyz Basey = new xyz(0, 0, 0); if (Trace.Count == 2) { Basey = new xyz(0, 0, -1); if ((Basey & (Trace[1] - Trace[0])).length() < 0.000001) { Basey = new xyz(0, -1, 0); } } else { Basey = (((Trace[2] - Trace[1]) & (Trace[0] - Trace[1]))).normalized() * (-1); } for (int i = 0; i < Trace.Count - 1; i++) { xyz N1, N2; if (i == 0) { if (Trace.Closed()) { N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[Trace.Count - 2] - Trace[i]).normalized(); } else { N1 = (Trace[i + 1] - Trace[i]).normalized(); } if ((i + 2) == Trace.Count) { N2 = (Trace[i] - Trace[i + 1]).normalized() & Basey; } else { N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized(); } } else if (i == (Trace.Count - 2)) { N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized(); if (Trace.Closed()) { N2 = (Trace[i] - Trace[0]).normalized() - (Trace[1] - Trace[0]).normalized(); } else { N2 = (Trace[i] - Trace[Trace.Count - 1]).normalized(); } } else { N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized(); N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized(); } if (Trace.Count == 2) { N1 = Trace[1] - Trace[0]; N2 = Trace[0] - Trace[1]; } Plane P1 = new Plane(Trace[i], N1.normalized()); Plane P2 = new Plane(Trace[i + 1], N2.normalized()); if (i > 0) { Basey = Matrix.Mirror(P1) * Basey - Matrix.Mirror(P1) * new xyz(0, 0, 0); } Base B = new Base(); B.BaseO = Trace[i]; B.BaseZ = (Trace[i + 1] - Trace[i]).normalized(); B.BaseY = Basey.normalized(); B.BaseX = (B.BaseY & B.BaseZ).normalized(); B.BaseY = B.BaseZ & B.BaseX * (-1); Matrix BInvert = B.ToMatrix().invert(); Plane DownPlane = BInvert * P1; Plane UpPlane = BInvert * P2; Device.PushMatrix(); Device.MulMatrix(B.ToMatrix()); for (int m = 0; m < Transverse.Count; m++) { for (int n = 0; n < Transverse[m].Count; n++) { CurveExtruder CE = new CurveExtruder(); CE.Height = -1; CE.DownPlane = BInvert * P1; CE.UpPlane = BInvert * P2; CE.Curve = Transverse[m][n]; CE.Paint(Device); if (Device.RenderKind == RenderKind.SnapBuffer) { SnappItem SI = Selector.StoredSnapItems[Selector.StoredSnapItems.Count - 1]; if (SI != null) { SI.OfObject = this; } } } } double L = (Trace[i + 1] - Trace[i]).length(); if ((i == 0) && (CloseFirst)) { Device.drawPolyPolyCurve(Transverse); } if ((i == Trace.Count - 2) && (CloseLast)) { Device.PushMatrix(); Device.MulMatrix(Matrix.Translation(new xyz(0, 0, L))); Device.drawPolyPolyCurve(Transverse); Device.PopMatrix(); } Device.PopMatrix(); } }