Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// gets the triangles of the mesh.
        /// </summary>
        /// <param name="TrList">is the list in which the triangles are posed.</param>
        public void getTriangles(TriangleList TrList)
        {
            TriangleArrays T = new TriangleArrays(Indices, Position, Normals, Colors, TextureCoords);

            TrList.AddToList(T);
        }