Ejemplo n.º 1
0
        /// <summary>
        /// Function to update a point in the triangle.
        /// </summary>
        /// <param name="pointIndex">Index of the point.</param>
        /// <param name="point">Point information.</param>
        /// <remarks>The <paramref name="pointIndex"/> must be between 0 and 2 (inclusive) or an exception will be raised.</remarks>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the pointIndex parameter is less than 0 or greater than 2.</exception>
        public void SetPoint(int pointIndex, GorgonPolygonPoint point)
        {
            if ((pointIndex < 0) ||
                (pointIndex > 2))
            {
                throw new ArgumentOutOfRangeException("pointIndex");
            }

            _points[pointIndex] = point;
            NeedsTextureUpdate  = true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Function to draw an unfilled triangle.
 /// </summary>
 /// <param name="position">Position of the triangle.</param>
 /// <param name="point1">First point in the triangle.</param>
 /// <param name="point2">Second point in the triangle.</param>
 /// <param name="point3">Third point in the triangle.</param>
 /// <param name="thickness">Line thickness.</param>
 /// <param name="texture">Texture to apply to the triangle.</param>
 public void DrawTriangle(Vector2 position, GorgonPolygonPoint point1, GorgonPolygonPoint point2, GorgonPolygonPoint point3, Vector2 thickness, GorgonTexture2D texture)
 {
     SetStates(_triangle);
     _triangle.IsFilled = false;
     _triangle.Position = position;
     _triangle.SetPoint(0, point1);
     _triangle.SetPoint(1, point2);
     _triangle.SetPoint(2, point3);
     _triangle.Texture       = texture;
     _triangle.LineThickness = thickness;
     _triangle.Draw();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Function to draw a filled triangle.
 /// </summary>
 /// <param name="position">Position of the triangle.</param>
 /// <param name="point1">First point in the triangle.</param>
 /// <param name="point2">Second point in the triangle.</param>
 /// <param name="point3">Third point in the triangle.</param>
 /// <param name="texture">Texture to apply to the triangle.</param>
 public void FilledTriangle(Vector2 position, GorgonPolygonPoint point1, GorgonPolygonPoint point2, GorgonPolygonPoint point3, GorgonTexture2D texture)
 {
     SetStates(_triangle);
     _triangle.IsFilled = true;
     _triangle.Position = position;
     _triangle.SetPoint(0, point1);
     _triangle.SetPoint(1, point2);
     _triangle.SetPoint(2, point3);
     _triangle.Texture       = texture;
     _triangle.LineThickness = new Vector2(1.0f);
     _triangle.Draw();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Function to create a new triangle object.
        /// </summary>
        /// <param name="name">Name of the triangle.</param>
        /// <param name="point1">First point in the triangle.</param>
        /// <param name="point2">Second point in the triangle.</param>
        /// <param name="point3">Third point in the triangle.</param>
        /// <param name="filled">TRUE to create a filled triangle, FALSE to create an unfilled triangle.</param>
        /// <returns>A new triangle primitive object.</returns>
        /// <remarks>The points defined in the triangle use relative coordinates, and are offset from an origin that is defined by the <see cref="P:GorgonLibrary.Renderers.GorgonTriangle.Anchor">Anchor</see> property.</remarks>
        /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="name"/> parameter is NULL (Nothing in VB.Net).</exception>
        /// <exception cref="System.ArgumentException">Thrown when the name parameter is an empty string.</exception>
        public GorgonTriangle CreateTriangle(string name, GorgonPolygonPoint point1, GorgonPolygonPoint point2, GorgonPolygonPoint point3, bool filled)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(Resources.GOR2D_PARAMETER_MUST_NOT_BE_EMPTY, "name");
            }

            var result = new GorgonTriangle(_gorgon2D, name)
            {
                IsFilled = filled
            };

            result.SetPoint(0, point1);
            result.SetPoint(1, point2);
            result.SetPoint(2, point3);

            return(result);
        }