/// <summary> /// compiles the <see cref="DrawAction"/> draw and returns a meshContainer. /// The <b>progs</b> of this is a list of <see cref="Mesh"/>. /// This method is called from <see cref="Entity.Compile(OpenGlDevice)"/>. /// </summary> /// <param name="Device"><see cref="OpenGlDevice"/> in which will be drawn.</param> /// <param name="Draw">the <see cref="DrawAction"/>, which is used to produce a <see cref="MeshContainer"/></param> /// <returns></returns> public static MeshContainer Compile(OpenGlDevice Device, DrawAction Draw) { Device.PushMatrix(); MeshListCurrent = new MeshContainer(); bool Compiling = Entity.Compiling; if (Compiling) { MeshCreator.Push(); } bool SaveCompiling = Entity.Compiling; Entity.Compiling = true; RenderKind SaveRenderKind = Device.RenderKind; Device.RenderKind = RenderKind.Render; MeshIndices.Clear(); Draw(Device); Renew(); Entity.Compiling = SaveCompiling; Device.RenderKind = SaveRenderKind; Device.PopMatrix(); MeshContainer Result = MeshListCurrent; if (Compiling) { MeshCreator.Pop(); } return(Result); }
private void drawLetter(Font F, byte b, String s, xyz Start, int iD, OpenGlDevice Device) { if (F.Compiled[b] == null) { CompileChar = b; CompileFont = F; MeshCreator.Push(); bool SaveRegSnap = Selector.RegisterSnap; Selector.RegisterSnap = false; F.Compiled[b] = MeshCreator.Compile(this, Compiledraw); Selector.RegisterSnap = SaveRegSnap; MeshCreator.Pop(); } if (F.Compiled[b] == null) { throw new Exception("Compile error of " + (char)(b)); } if (RenderKind == RenderKind.SnapBuffer) { Object Handle = null; if ((RenderKind == RenderKind.SnapBuffer)) { Handle = Selector.RegisterSnapItem(new TextSnappItem(F, s, iD, Start, ModelMatrix * new xyz(0, 0, 0))); if (F.GlyphInfo[b].BlackBoxY < 0.1) // blank { drawBox(new xyz(0, 0, 0), new xyz(F.GlyphInfo[b].Deltax, 1, 1)); } else { drawBox(new xyz(0, 0, 0), new xyz(F.GlyphInfo[b].Deltax, F.GlyphInfo[b].BlackBoxY, 1)); } if ((RenderKind == RenderKind.SnapBuffer)) { Selector.UnRegisterSnapItem(Handle); } } return; } if (Entity.Compiling) { MeshContainer M = F.Compiled[b] as MeshContainer; for (int i = 0; i < M.Progs.Count; i++) { Mesh E = (M.Progs[i] as Mesh).Clone() as Mesh; E.Transform(ModelMatrix); MeshCreator.MeshListCurrent.Progs.Add(E); } return; } F.Compiled[b].Paint(this); }
/// <summary> /// is the main method of this object. See also <see cref="Entity.CompileDraw(OpenGlDevice)"/>. /// </summary> /// <param name="Device">Device in which it willl be compiled.</param> /// <param name="Draw">a event, which holds the drawings.</param> public static MeshContainer CreateMeshes(OpenGlDevice Device, DrawAction Draw) { // sollte nur von compilesnapbuffer aufgerufen werden !!!! und erstellt die triangles bool Compiling = Entity.Compiling; if (Compiling) { MeshCreator.Push(); } bool SaveCompiling = Entity.Compiling; // Entity.Compiling = true; // Checken braucht es wegen line snap if (Selector.StoredSnapItems.Count == 0) { Selector.StoredSnapItems.Add(null); // braucht es nicht } MeshListCurrent = new MeshContainer(); // braucht es nicht MeshIndices.Clear(); // braucht es wahrscheinlich nicht RenderKind R = Device.RenderKind;// wieder heraus Draw(Device); Renew(); Device.RenderKind = R; Entity.Compiling = SaveCompiling; MeshContainer Result = MeshListCurrent; // MeshListCurrent.MySnapItem = new MeshSnapItem(MeshListCurrent); Device.RenderKind = RenderKind.SnapBuffer; TriangleList TL = new TriangleList(); for (int i = 0; i < MeshListCurrent.Progs.Count; i++) { if (MeshListCurrent.Progs[i] is Mesh) { Mesh M = MeshListCurrent.Progs[i] as Mesh; M.getTriangles(TL); } } TriangleArrays TA = TL.ToArrays(); Device.RenderKind = R; if (Compiling) { MeshCreator.Pop(); } return(Result); }