Nez.Portable/ECS/Components/Renderables/TrailRibbon.cs
/// <summary>
/// transfers the data from our segments to the vertices for display
/// </summary>
transfers the data from our segments to the vertices for display
transfers the data from our segments to the vertices for display
void calculateVertices()
        {
            if (!_areVertsDirty)
                return;
            var center = new Vector3(entity.transform.position, 0f);
            var radVec = new Vector3(0, -ribbonRadius, 0);
            _vertices[0].Position = center + radVec;
            _vertices[0].Color = Color.Red;
            _vertices[1].Position = center + radVec;
            _vertices[1].Color = Color.Yellow;
            _vertices[2].Position = center + radVec;
            _vertices[2].Color = Color.Green;
            var maxX = float.MinValue;
            var minX = float.MaxValue;
            var maxY = float.MinValue;
            var minY = float.MaxValue;
            var index = 3;
            var segCount = 1;
            foreach (var seg in _segments)
            {
                var ratio = 1 - (1 / (float)_ribbonLength * segCount);
                seg.radius = ratio * ribbonRadius;
                ColorExt.lerp(ref startColor, ref endColor, out _vertices[index].Color, 1 - ratio);
                _vertices[index].Position = seg.topPoint;
                _vertices[index + 1].Position = seg.bottomPoint;
                _vertices[index + 1].Color = _vertices[index].Color;
                maxX = Mathf.maxOf(maxX, _vertices[index].Position.X, _vertices[index + 1].Position.X);
                minX = Mathf.minOf(minX, _vertices[index].Position.X, _vertices[index + 1].Position.X);
                maxY = Mathf.maxOf(maxY, _vertices[index].Position.Y, _vertices[index + 1].Position.Y);
                minY = Mathf.minOf(minY, _vertices[index].Position.Y, _vertices[index + 1].Position.Y);
                index += 2;
                segCount++;
            }
            _bounds.x = minX;
            _bounds.y = minY;
            _bounds.width = maxX - minX;
            _bounds.height = maxY - minY;
            _areVertsDirty = false;
        }
void calculateVertices ( ) { if ( ! _areVertsDirty ) return ; var center = new Vector3 ( entity . transform . position , 0f ) ; var radVec = new Vector3 ( 0 , - ribbonRadius , 0 ) ; _vertices [ 0 ] . Position = center + radVec ; _vertices [ 0 ] . Color = Color . Red ; _vertices [ 1 ] . Position = center + radVec ; _vertices [ 1 ] . Color = Color . Yellow ; _vertices [ 2 ] . Position = center + radVec ; _vertices [ 2 ] . Color = Color . Green ; var maxX = float . MinValue ; var minX = float . MaxValue ; var maxY = float . MinValue ; var minY = float . MaxValue ; var index = 3 ; var segCount = 1 ; foreach ( var seg in _segments ) { var ratio = 1 - ( 1 / ( float ) _ribbonLength * segCount ) ; seg . radius = ratio * ribbonRadius ; ColorExt . lerp ( ref startColor , ref endColor , out _vertices [ index ] . Color , 1 - ratio ) ; _vertices [ index ] . Position = seg . topPoint ; _vertices [ index + 1 ] . Position = seg . bottomPoint ; _vertices [ index + 1 ] . Color = _vertices [ index ] . Color ; maxX = Mathf . maxOf ( maxX , _vertices [ index ] . Position . X , _vertices [ index + 1 ] . Position . X ) ; minX = Mathf . minOf ( minX , _vertices [ index ] . Position . X , _vertices [ index + 1 ] . Position . X ) ; maxY = Mathf . maxOf ( maxY , _vertices [ index ] . Position . Y , _vertices [ index + 1 ] . Position . Y ) ; minY = Mathf . minOf ( minY , _vertices [ index ] . Position . Y , _vertices [ index + 1 ] . Position . Y ) ; index += 2 ; segCount ++ ; } _bounds . x = minX ; _bounds . y = minY ; _bounds . width = maxX - minX ; _bounds . height = maxY - minY ; _areVertsDirty = false ; }
transfers the data from our segments to the vertices for display
transfers the data from our segments to the vertices for display
// starting triangle, the head // update min/max for any visible verts // increment counters