Example #1
0
 public ccV3F_C4B_T2F()
 {
     this.vertices  = new ccVertex3F();
     this.colors    = new ccColor4B();
     this.texCoords = new ccTex2F();
 }
Example #2
0
 public ccV2F_C4F_T2F()
 {
     vertices = new ccVertex2F();
     colors = new ccColor4F();
     texCoords = new ccTex2F();
 }
Example #3
0
        public ccVertex3F vertices; // 12 bytes

        #endregion Fields

        #region Constructors

        public ccV3F_C4B_T2F()
        {
            vertices = new ccVertex3F();
            colors = new ccColor4B();
            texCoords = new ccTex2F();
        }
Example #4
0
        public override void update(float delta)
        {
            if (!m_bStartingPositionInitialized)
            {
                return;
            }

            if (m_pVerticesPCT == null)
            {
                m_pVerticesPCT = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
            }
            if (m_uNuPoints * 2 > m_pVerticesPCT.Length)
            {
                VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
                m_pVerticesPCT.CopyTo(tmp, 0);
                m_pVerticesPCT = tmp;
            }
            delta *= m_fFadeDelta;

            int newIdx, newIdx2, i, i2;
            int mov = 0;

            // Update current points
            for (i = 0; i < m_uNuPoints; i++)
            {
                if (m_pVerticesPCT[i] == null)
                {
                    m_pVerticesPCT[i] = new VertexPositionColorTexture(m_pVertices[i].ToVector3(), m_pColor[i].XNAColor, m_pTexCoords[i].ToVector2());
                }
                if (m_pVerticesPCT[i * 2] == null)
                {
                    m_pVerticesPCT[i * 2] = new VertexPositionColorTexture(m_pVerticesPCT[i].Position, m_pVerticesPCT[i].Color, m_pVerticesPCT[i].TextureCoordinate);
                }
                m_pPointState[i] -= delta;

                if (m_pPointState[i] <= 0)
                {
                    mov++;
                }
                else
                {
                    newIdx = i - mov;

                    if (mov > 0)
                    {
                        // Move data
                        m_pPointState[newIdx] = m_pPointState[i];

                        // Move point
                        m_pPointVertexes[newIdx] = new CCPoint(m_pPointVertexes[i]);

                        // Move vertices
                        i2      = i * 2;
                        newIdx2 = newIdx * 2;
                        m_pVertices[newIdx2]     = new ccVertex2F(m_pVertices[i2]);
                        m_pVertices[newIdx2 + 1] = new ccVertex2F(m_pVertices[i2 + 1]);
                        // Move color
                        m_pColor[newIdx2]     = new ccColor4B(m_pColor[i2]);
                        m_pColor[newIdx2 + 1] = new ccColor4B(m_pColor[i2 + 1]);
                        // Move the GL vertex data
                        m_pVerticesPCT[newIdx2]     = m_pVerticesPCT[i2];
                        m_pVerticesPCT[newIdx2 + 1] = m_pVerticesPCT[i2 + 1];
                    }
                    else
                    {
                        newIdx2 = newIdx * 2;
                    }
                    byte op = (byte)(m_pPointState[newIdx] * 255.0f);
                    m_pColor[newIdx2].a     = op;
                    m_pColor[newIdx2 + 1].a = op;
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[newIdx2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2].ToVector3(), m_pColor[newIdx2].XNAColor, m_pTexCoords[newIdx2].ToVector2());
                        m_pVerticesPCT[newIdx2] = vpc;
                    }
                    if (m_pVertices[newIdx2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2 + 1].ToVector3(), m_pColor[newIdx2 + 1].XNAColor, m_pTexCoords[newIdx2 + 1].ToVector2());
                        m_pVerticesPCT[newIdx2 + 1] = vpc;
                    }
                }
            }
            m_uNuPoints -= mov;

            // Append new point
            bool appendNewPoint = true;

            if (m_uNuPoints >= m_uMaxPoints)
            {
                appendNewPoint = false;
            }

            else if (m_uNuPoints > 0)
            {
                bool a1 = (m_pPointVertexes[m_uNuPoints - 1].DistanceSQ(m_tPositionR) < m_fMinSeg);
                bool a2 = (m_uNuPoints == 1) ? false : (m_pPointVertexes[m_uNuPoints - 2].DistanceSQ(m_tPositionR) < (m_fMinSeg * 2.0f));
                if (a1 || a2)
                {
                    appendNewPoint = false;
                }
            }

            if (appendNewPoint)
            {
                m_pPointVertexes[m_uNuPoints] = new CCPoint(m_tPositionR);
                m_pPointState[m_uNuPoints]    = 1.0f;

                // Color asignment
                int offset = m_uNuPoints * 2;
                m_pColor[offset]     = new ccColor4B(m_tColor);
                m_pColor[offset + 1] = new ccColor4B(m_tColor);

                // Opacity
                m_pColor[offset].a     = 255;
                m_pColor[offset + 1].a = 255;

                // Generate polygon
                if (m_uNuPoints > 0 && m_bFastMode)
                {
                    if (m_uNuPoints > 1)
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_uNuPoints, 1);
                    }
                    else
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, 2);
                    }
                }

                m_uNuPoints++;
            }

            if (!m_bFastMode)
            {
                CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints);
            }

            // Updated Tex Coords only if they are different than previous step
            if (m_uPreviousNuPoints != m_uNuPoints)
            {
                if (m_uNuPoints > m_uPreviousNuPoints)
                {
                    int count = (m_uNuPoints + 1) * 2;
                    if (count < m_pVerticesPCT.Length)
                    {
                        count = m_pVerticesPCT.Length;
                    }
                    VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[count];
                    m_pVerticesPCT.CopyTo(tmp, 0);
                    m_pVerticesPCT = tmp;
                }
                float texDelta = 1.0f / m_uNuPoints;
                for (i = 0; i < m_uNuPoints; i++)
                {
                    m_pTexCoords[i * 2]     = new ccTex2F(0, texDelta * i);
                    m_pTexCoords[i * 2 + 1] = new ccTex2F(1, texDelta * i);
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[i * 2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2].ToVector3(), m_pColor[i * 2].XNAColor, m_pTexCoords[i * 2].ToVector2());
                        m_pVerticesPCT[i * 2] = vpc;
                    }
                    if (m_pVertices[i * 2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2 + 1].ToVector3(), m_pColor[i * 2 + 1].XNAColor, m_pTexCoords[i * 2 + 1].ToVector2());
                        m_pVerticesPCT[i * 2 + 1] = vpc;
                    }
                }

                m_uPreviousNuPoints = m_uNuPoints;
            }
        }
Example #5
0
 public static ccTex2F tex2(float u, float v)
 {
     ccTex2F t = new ccTex2F(u, v);
     return t;
 }
Example #6
0
        public static ccTex2F tex2(float u, float v)
        {
            ccTex2F t = new ccTex2F(u, v);

            return(t);
        }
Example #7
0
 public ccV3F_C4B_T2F()
 {
     vertices  = new ccVertex3F();
     colors    = new ccColor4B();
     texCoords = new ccTex2F();
 }
Example #8
0
 public ccV2F_C4F_T2F()
 {
     vertices  = new ccVertex2F();
     colors    = new ccColor4F();
     texCoords = new ccTex2F();
 }
Example #9
0
        public override void update(float delta)
        {
            if (!m_bStartingPositionInitialized)
            {
                return;
            }

            if (m_pVerticesPCT == null)
            {
                m_pVerticesPCT = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
            }
            if (m_uNuPoints * 2 > m_pVerticesPCT.Length)
            {
                VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
                m_pVerticesPCT.CopyTo(tmp, 0);
                m_pVerticesPCT = tmp;
            }
            delta *= m_fFadeDelta;

            int newIdx, newIdx2, i, i2;
            int mov = 0;

            // Update current points
            for (i = 0; i < m_uNuPoints; i++)
            {
                if (m_pVerticesPCT[i] == null)
                {
                    m_pVerticesPCT[i] = new VertexPositionColorTexture(m_pVertices[i].ToVector3(), m_pColor[i].XNAColor, m_pTexCoords[i].ToVector2());
                }
                if (m_pVerticesPCT[i * 2] == null)
                {
                    m_pVerticesPCT[i * 2] = new VertexPositionColorTexture(m_pVerticesPCT[i].Position, m_pVerticesPCT[i].Color, m_pVerticesPCT[i].TextureCoordinate);
                }
                m_pPointState[i] -= delta;

                if (m_pPointState[i] <= 0)
                    mov++;
                else
                {
                    newIdx = i - mov;

                    if (mov > 0)
                    {
                        // Move data
                        m_pPointState[newIdx] = m_pPointState[i];

                        // Move point
                        m_pPointVertexes[newIdx] = new CCPoint(m_pPointVertexes[i]);

                        // Move vertices
                        i2 = i * 2;
                        newIdx2 = newIdx * 2;
                        m_pVertices[newIdx2] = new ccVertex2F(m_pVertices[i2]);
                        m_pVertices[newIdx2 + 1] = new ccVertex2F(m_pVertices[i2 + 1]);
                        // Move color
                        m_pColor[newIdx2] = new ccColor4B(m_pColor[i2]);
                        m_pColor[newIdx2 + 1] = new ccColor4B(m_pColor[i2 + 1]);
                        // Move the GL vertex data
                        m_pVerticesPCT[newIdx2] = m_pVerticesPCT[i2];
                        m_pVerticesPCT[newIdx2 + 1] = m_pVerticesPCT[i2 + 1];
                    }
                    else
                    {
                        newIdx2 = newIdx * 2;
                    }
                    byte op = (byte)(m_pPointState[newIdx] * 255.0f);
                    m_pColor[newIdx2].a = op;
                    m_pColor[newIdx2 + 1].a = op;
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[newIdx2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2].ToVector3(), m_pColor[newIdx2].XNAColor, m_pTexCoords[newIdx2].ToVector2());
                        m_pVerticesPCT[newIdx2] = vpc;
                    }
                    if (m_pVertices[newIdx2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2 + 1].ToVector3(), m_pColor[newIdx2 + 1].XNAColor, m_pTexCoords[newIdx2 + 1].ToVector2());
                        m_pVerticesPCT[newIdx2 + 1] = vpc;
                    }
                }
            }
            m_uNuPoints -= mov;

            // Append new point
            bool appendNewPoint = true;
            if (m_uNuPoints >= m_uMaxPoints)
            {
                appendNewPoint = false;
            }

            else if (m_uNuPoints > 0)
            {
                bool a1 = (m_pPointVertexes[m_uNuPoints - 1].DistanceSQ(m_tPositionR) < m_fMinSeg);
                bool a2 = (m_uNuPoints == 1) ? false : (m_pPointVertexes[m_uNuPoints - 2].DistanceSQ(m_tPositionR) < (m_fMinSeg * 2.0f));
                if (a1 || a2)
                {
                    appendNewPoint = false;
                }
            }

            if (appendNewPoint)
            {
                m_pPointVertexes[m_uNuPoints] = new CCPoint(m_tPositionR);
                m_pPointState[m_uNuPoints] = 1.0f;

                // Color asignment
                int offset = m_uNuPoints * 2;
                m_pColor[offset] = new ccColor4B(m_tColor);
                m_pColor[offset + 1] = new ccColor4B(m_tColor);

                // Opacity
                m_pColor[offset].a = 255;
                m_pColor[offset + 1].a = 255;

                // Generate polygon
                if (m_uNuPoints > 0 && m_bFastMode)
                {
                    if (m_uNuPoints > 1)
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_uNuPoints, 1);
                    }
                    else
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, 2);
                    }
                }

                m_uNuPoints++;
            }

            if (!m_bFastMode)
            {
                CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints);
            }

            // Updated Tex Coords only if they are different than previous step
            if (m_uPreviousNuPoints != m_uNuPoints)
            {
                if (m_uNuPoints > m_uPreviousNuPoints)
                {
                    int count = (m_uNuPoints + 1) * 2;
                    if (count < m_pVerticesPCT.Length)
                    {
                        count = m_pVerticesPCT.Length;
                    }
                    VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[count];
                    m_pVerticesPCT.CopyTo(tmp, 0);
                    m_pVerticesPCT = tmp;
                }
                float texDelta = 1.0f / m_uNuPoints;
                for (i = 0; i < m_uNuPoints; i++)
                {
                    m_pTexCoords[i * 2] = new ccTex2F(0, texDelta * i);
                    m_pTexCoords[i * 2 + 1] = new ccTex2F(1, texDelta * i);
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[i * 2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2].ToVector3(), m_pColor[i * 2].XNAColor, m_pTexCoords[i * 2].ToVector2());
                        m_pVerticesPCT[i * 2] = vpc;
                    }
                    if (m_pVertices[i * 2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2 + 1].ToVector3(), m_pColor[i * 2 + 1].XNAColor, m_pTexCoords[i * 2 + 1].ToVector2());
                        m_pVerticesPCT[i * 2 + 1] = vpc;
                    }
                }

                m_uPreviousNuPoints = m_uNuPoints;
            }
        }
Example #10
0
 public ccV2F_C4F_T2F()
 {
     this.vertices  = new ccVertex2F();
     this.colors    = new ccColor4F();
     this.texCoords = new ccTex2F();
 }