Beispiel #1
0
        /// <summary>
        /// builds the intialial ribbon segments
        /// </summary>
        void initializeVertices()
        {
            var radiusVec = new Vector3(0, -ribbonRadius, 0);

            _vertices = new VertexPositionColor[_ribbonLength * 2 + 3];

            // head of ribbon
            _vertices[0].Position = new Vector3(entity.transform.position, 0f) + radiusVec;
            _vertices[0].Color    = Color.Red;
            _vertices[1].Position = new Vector3(entity.transform.position, 0f) + radiusVec;
            _vertices[1].Color    = Color.Yellow;
            _vertices[2].Position = new Vector3(entity.transform.position, 0f) + radiusVec;
            _vertices[2].Color    = Color.Green;

            var pos = entity.transform.position;

            for (var i = 0; i < _ribbonLength; i++)
            {
                var distanceRatio = 1 - (1 / (float)_ribbonLength * (i + 1));
                var segRadius     = distanceRatio * ribbonRadius; // the radius size of this current segment
                var seg           = new RibbonSegment(pos, segRadius);
                _segments.AddLast(seg);
            }

            calculateVertices();
        }
Beispiel #2
0
		/// <summary>
		/// builds the intialial ribbon segments
		/// </summary>
		void initializeVertices()
		{
			var radiusVec = new Vector3( 0, -ribbonRadius, 0 );
			_vertices = new VertexPositionColor[_ribbonLength * 2 + 3];

			// head of ribbon
			_vertices[0].Position = new Vector3( entity.transform.position, 0f ) + radiusVec;
			_vertices[0].Color = Color.Red;
			_vertices[1].Position = new Vector3( entity.transform.position, 0f ) + radiusVec;
			_vertices[1].Color = Color.Yellow;
			_vertices[2].Position = new Vector3( entity.transform.position, 0f ) + radiusVec;
			_vertices[2].Color = Color.Green;

			var pos = entity.transform.position;
			for( var i = 0; i < _ribbonLength; i++ )
			{
				var distanceRatio = 1 - ( 1 / (float)_ribbonLength * ( i + 1 ) );
				var segRadius = distanceRatio * ribbonRadius; // the radius size of this current segment
				var seg = new RibbonSegment( pos, segRadius );
				_segments.AddLast( seg );

			}
			calculateVertices();
		}