//  Copy triangles to array of vertexes and return count of triangles to draw
        public int CopyDecalsToVertices(MyVertexFormatDecal[] vertices)
        {
            CheckIfBufferIsFull();

            float fadingOutAlpha = 1;

            if ((m_status == MyDecalsBufferState.FADING_OUT_ONLY_BEGINNING) || (m_status == MyDecalsBufferState.FADING_OUT_ALL))
            {
                fadingOutAlpha = 1 - MathHelper.Clamp((float)(MyRender.RenderTimeInMS - m_fadingOutStartTime) / (float)MyDecalsConstants.DECALS_FADE_OUT_INTERVAL_MILISECONDS, 0, 1);
            }

            int i = 0;

            foreach (MyDecalTriangle decalTriangle in m_trianglesQueue)
            {
                float alpha = 1;

                //  If fading-out, we blend first 'm_fadingOutRealTriangleCount' triangles
                if (m_status == MyDecalsBufferState.FADING_OUT_ALL)
                {
                    alpha = fadingOutAlpha;
                }
                else if ((m_status == MyDecalsBufferState.FADING_OUT_ONLY_BEGINNING) && (i < m_fadingOutRealTriangleCount))
                {
                    alpha = fadingOutAlpha;
                }

                int vertexIndexStart = i * MyDecalsConstants.VERTEXES_PER_DECAL;

                vertices[vertexIndexStart + 0].Position = decalTriangle.Position0;
                vertices[vertexIndexStart + 1].Position = decalTriangle.Position1;
                vertices[vertexIndexStart + 2].Position = decalTriangle.Position2;

                vertices[vertexIndexStart + 0].TexCoord = decalTriangle.TexCoord0;
                vertices[vertexIndexStart + 1].TexCoord = decalTriangle.TexCoord1;
                vertices[vertexIndexStart + 2].TexCoord = decalTriangle.TexCoord2;

                Vector4 color0 = decalTriangle.Color0;
                Vector4 color1 = decalTriangle.Color1;
                Vector4 color2 = decalTriangle.Color2;

                color0.W *= alpha;
                color1.W *= alpha;
                color2.W *= alpha;

                vertices[vertexIndexStart + 0].Color = color0;
                vertices[vertexIndexStart + 1].Color = color1;
                vertices[vertexIndexStart + 2].Color = color2;

                vertices[vertexIndexStart + 0].Normal = decalTriangle.Normal0;
                vertices[vertexIndexStart + 1].Normal = decalTriangle.Normal1;
                vertices[vertexIndexStart + 2].Normal = decalTriangle.Normal2;

                /*
                 * vertices[vertexIndexStart + 0].Tangent = decalTriangle.Tangent0;
                 * vertices[vertexIndexStart + 1].Tangent = decalTriangle.Tangent1;
                 * vertices[vertexIndexStart + 2].Tangent = decalTriangle.Tangent2;
                 */
                float emisivity = MyDecals.UpdateDecalEmissivity(decalTriangle, alpha, RenderObject);

                vertices[vertexIndexStart + 0].EmissiveRatio = emisivity;
                vertices[vertexIndexStart + 1].EmissiveRatio = emisivity;
                vertices[vertexIndexStart + 2].EmissiveRatio = emisivity;

                i++;
            }

            return(i);
        }