UpdateMesh() public method

public UpdateMesh ( ) : void
return void
 static public int UpdateMesh(IntPtr l)
 {
     try {
         FairyGUI.NGraphics self = (FairyGUI.NGraphics)checkSelf(l);
         self.UpdateMesh();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#2
0
        public void Draw(NGraphics graphics, float alpha, bool grayed, BlendMode blendMode, ref Matrix localToWorldMatrix, IFilter filter)
        {
            if (graphics.texture == null || !graphics.enabled)
            {
                return;
            }

            graphics.UpdateMesh();

            List <Vector3> vertices  = graphics._vertices;
            int            vertCount = vertices.Count;

            if (vertCount == 0)
            {
                return;
            }

            if (_blendMode != blendMode)
            {
                Flush();

                _blendMode         = blendMode;
                _device.BlendState = BlendModeUtils.blendStates[(int)_blendMode];
            }

            grayed |= this.grayed;
            if (_grayed != grayed)
            {
                Flush();

                _grayed = grayed;
                if (_grayed)
                {
                    _grayedPass.Apply();
                }
                else
                {
                    _defaultPass.Apply();
                }
            }

            Texture2D texture = graphics.texture.nativeTexture;

            if (texture != _texture)
            {
                Flush();
                _texture = texture;
            }

            if (filter != null)
            {
                if (_vertexPtr > 0)
                {
                    Flush();
                }

                filter.Apply(this);
            }

            List <Vector2> uv         = graphics._uv0;
            List <Color>   colors     = graphics._colors;
            List <int>     triangles  = graphics._triangles;
            int            indexCount = triangles.Count;

            if (_vertexPtr + vertCount > _vertexCache.Length)
            {
                VertexPositionColorTexture[] newArray = new VertexPositionColorTexture[_vertexCache.Length + vertCount + (int)Math.Ceiling(_vertexCache.Length * 0.5f)];
                _vertexCache.CopyTo(newArray, 0);
                _vertexCache = newArray;
            }

            if (_indexPtr + indexCount > _indexCache.Length)
            {
                int[] newArray = new int[_indexCache.Length + indexCount + (int)Math.Ceiling(_indexCache.Length * 0.5f)];
                _indexCache.CopyTo(newArray, 0);
                _indexCache = newArray;
            }

            VertexPositionColorTexture vpct;

            for (int i = 0; i < indexCount; i++)
            {
                _indexCache[_indexPtr++] = triangles[i] + _vertexPtr;
            }

            for (int i = 0; i < vertCount; i++)
            {
                Vector3 pt = vertices[i];
                Vector3.Transform(ref pt, ref localToWorldMatrix, out vpct.Position);
                if (_hasRenderTarget)
                {
                    vpct.Position.X -= _renderOffset.X;
                    vpct.Position.Y -= _renderOffset.Y;
                }
                Vector2 uvpt = uv[i];
                uvpt.Y = 1 - uvpt.Y;
                vpct.TextureCoordinate     = uvpt;
                vpct.Color                 = colors[i] * this.alpha * alpha;
                _vertexCache[_vertexPtr++] = vpct;
            }

            if (filter != null)
            {
                if (_vertexPtr > 0)
                {
                    Flush();
                }

                _defaultPass.Apply();
            }
        }