예제 #1
0
        private void AddVertex(ref LinePointInfo info, ref Vector3 thicknessDirection, float uCoord, int vertexIndex, VertexPositionColorTextureAxis[] vertices, float thicknessFactor = 1)
        {
            vertices[vertexIndex].Color    = info.Color;
            vertices[vertexIndex].TexCoord = new Vector2(uCoord, 1) * this.textureTiling;

            vertices[vertexIndex + 1].Color    = info.Color;
            vertices[vertexIndex + 1].TexCoord = new Vector2(uCoord, 0) * this.textureTiling;

            float halfThickness = info.Thickness * 0.5f;

            halfThickness *= this.is2DMode ? -thicknessFactor : thicknessFactor;

            if (this.IsCameraAligned)
            {
                vertices[vertexIndex].Position     = info.Position;
                vertices[vertexIndex + 1].Position = info.Position;
                vertices[vertexIndex].AxisSize     = new Vector4(thicknessDirection, halfThickness);
                vertices[vertexIndex + 1].AxisSize = new Vector4(thicknessDirection, -halfThickness);
            }
            else
            {
                var axisThickness = thicknessDirection * halfThickness;
                vertices[vertexIndex].Position     = info.Position + axisThickness;
                vertices[vertexIndex + 1].Position = info.Position - axisThickness;
            }

            var halfThicknessAbs = Math.Abs(halfThickness);
            var thicknessVector  = new Vector3(halfThicknessAbs, halfThicknessAbs, 0);

            this.boundingBox.Max = Vector3.Max(info.Position + thicknessVector, this.boundingBox.Max);
            this.boundingBox.Min = Vector3.Min(info.Position - thicknessVector, this.boundingBox.Min);
        }
예제 #2
0
        /// <inheritdoc/>
        protected override void RefreshMeshes()
        {
            if (this.bezierLinePoints == null || this.bezierLinePoints.Count < 2)
            {
                return;
            }

            this.linePoints.Clear();

            var firstPoint = this.bezierLinePoints[0];

            for (int i = 1; i < this.bezierLinePoints.Count; i++)
            {
                var secondPoint = this.bezierLinePoints[i];

                int r = i > 1 ? 1 : 0;
                for (; r <= this.resolution; r++)
                {
                    var t = (float)r / this.resolution;

                    var point = new LinePointInfo()
                    {
                        Color     = Color.Lerp(ref firstPoint.Color, ref secondPoint.Color, t),
                        Thickness = MathHelper.Lerp(firstPoint.Thickness, secondPoint.Thickness, t)
                    };

                    if (this.bezierType == BezierTypes.Quadratic)
                    {
                        var p1 = secondPoint.Position + secondPoint.InboundHandle;
                        point.Position = this.CalculateQuadraticPoint(t, ref firstPoint.Position, ref p1, ref secondPoint.Position);
                    }
                    else if (this.bezierType == BezierTypes.Cubic)
                    {
                        var p1 = firstPoint.Position + firstPoint.OutboundHandle;
                        var p2 = secondPoint.Position + secondPoint.InboundHandle;
                        point.Position = this.CalculateCubicPoint(t, ref firstPoint.Position, ref p1, ref p2, ref secondPoint.Position);
                    }

                    this.linePoints.Add(point);
                }

                firstPoint = secondPoint;
            }

            base.RefreshMeshes();
        }
예제 #3
0
        /// <summary>
        /// Updates last point added with the previous point
        /// </summary>
        /// <param name="point">Last point added to the list</param>
        public void CloneLastPoint(LinePointInfo point)
        {
            if (this.linePoints.Count == 1)
            {
                var prev = this.linePoints.ElementAt(0);
                point.Color     = Color.White;
                point.Thickness = 1;
            }
            else
            {
                var prev = this.linePoints.ElementAt(this.linePoints.Count - 2);
                point.Color     = prev.Color;
                point.Position  = prev.Position;
                point.Thickness = prev.Thickness;
            }

            this.RefreshMeshes();
        }
예제 #4
0
 /// <summary>
 /// Refresh mesh when a value from the list has changed
 /// </summary>
 /// <param name="point">point</param>
 public void Refresh(LinePointInfo point)
 {
     this.RefreshMeshes();
 }