Esempio 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);
        }
        /// <summary>
        /// adds the lists to a <see cref="TriangleArrays"/> R.
        /// </summary>
        /// <param name="R">the <see cref="TriangleArrays"/></param>
        public void AddToList(TriangleArrays R)
        {
            int ct = Pointslistf.Count;

            if (R.Indices != null)
            {
                for (int i = 0; i < R.Indices.Length; i++)
                {
                    Indices.Add((IndexType)(ct + R.Indices[i]));
                }
            }
            if (R.Points != null)
            {
                for (int i = 0; i < R.Points.Length; i++)
                {
                    Pointslistf.Add(/*Device.ModelMatrix**/ R.Points[i]);
                }
            }
            if (R.Texture != null)
            {
                for (int i = 0; i < R.Texture.Length; i++)
                {
                    Texturelist.Add(R.Texture[i]);
                }
            }
            if (R.Normals != null)
            {
                for (int i = 0; i < R.Normals.Length; i++)
                {
                    Normallist.Add(/*Device.ModelMatrix.multaffin*/ (R.Normals[i]));
                }
            }
            if (R.Colors != null)
            {
                for (int i = 0; i < R.Colors.Length; i++)
                {
                    ColorList.Add(R.Colors[i]);
                }
            }
        }
Esempio n. 3
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);
        }