• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# dfRenderData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中dfRenderData的典型用法代码示例。如果您正苦于以下问题:C# dfRenderData类的具体用法?C# dfRenderData怎么用?C# dfRenderData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



dfRenderData类属于命名空间,在下文中一共展示了dfRenderData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Add

    public void Add( dfRenderData buffer )
    {
        if( Material == null && buffer.Material != null )
            Material = buffer.Material;

        buffers.Add( buffer );
    }
开发者ID:BjarkeHou,项目名称:ProjectGuard,代码行数:7,代码来源:dfRenderBatch.cs


示例2: Clip

 public static void Clip(IList<Plane> planes, dfRenderData source, dfRenderData dest)
 {
     dest.EnsureCapacity(dest.Vertices.Count + source.Vertices.Count);
     for (int i = 0; i < source.Triangles.Count; i = i + 3)
     {
         for (int j = 0; j < 3; j++)
         {
             int item = source.Triangles[i + j];
             Matrix4x4 transform = source.Transform;
             dfClippingUtil.clipSource[0].corner[j] = transform.MultiplyPoint(source.Vertices[item]);
             dfClippingUtil.clipSource[0].uv[j] = source.UV[item];
             dfClippingUtil.clipSource[0].color[j] = source.Colors[item];
         }
         int plane = 1;
         for (int k = 0; k < planes.Count; k++)
         {
             plane = dfClippingUtil.clipToPlane(planes[k], dfClippingUtil.clipSource, dfClippingUtil.clipDest, plane);
             dfClippingUtil.ClipTriangle[] clipTriangleArray = dfClippingUtil.clipSource;
             dfClippingUtil.clipSource = dfClippingUtil.clipDest;
             dfClippingUtil.clipDest = clipTriangleArray;
         }
         for (int l = 0; l < plane; l++)
         {
             dfClippingUtil.clipSource[l].CopyTo(dest);
         }
     }
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:27,代码来源:dfClippingUtil.cs


示例3: renderSprite

    internal static new void renderSprite( dfRenderData renderData, RenderOptions options )
    {
        #if UNITY_EDITOR

        var atlas = options.atlas;
        if( atlas == null )
            throw new NullReferenceException( "The Texture Atlas cannot be null" );

        if( atlas.Texture == null )
            throw new NullReferenceException( "The Texture Altas has no texture assigned or the texture was deleted" );

        if( options.spriteInfo == null )
            throw new ArgumentNullException( "The Sprite cannot be null" );

        #endif

        options.baseIndex = renderData.Vertices.Count;

        rebuildTriangles( renderData, options );
        rebuildVertices( renderData, options );
        rebuildUV( renderData, options );
        rebuildColors( renderData, options );

        if( options.fillAmount < 1f )
        {
            doFill( renderData, options );
        }
    }
开发者ID:haozi000005,项目名称:happy2d,代码行数:28,代码来源:dfSlicedSprite.cs


示例4: renderSprite

 internal static new void renderSprite(dfRenderData renderData, dfSprite.RenderOptions options)
 {
     options.baseIndex = renderData.Vertices.Count;
     dfSlicedSprite.rebuildTriangles(renderData, options);
     dfSlicedSprite.rebuildVertices(renderData, options);
     dfSlicedSprite.rebuildUV(renderData, options);
     dfSlicedSprite.rebuildColors(renderData, options);
     if (options.fillAmount < 1f)
     {
         dfSlicedSprite.doFill(renderData, options);
     }
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:12,代码来源:dfSlicedSprite.cs


示例5: Clip

	/// <summary>
	/// Clips a <see cref="dfRenderData"/> instance containing control rendering data
	/// against a list of <see cref="Plane"/> objects defined by the current clipping 
	/// region, and outputs the clipped data into <paramref name="dest"/>
	/// </summary>
	/// <param name="planes">The list of planes to clip against</param>
	/// <param name="source">The control rendering data to be clipped</param>
	/// <param name="dest">The output buffer that will hold the resulting clipped data</param>
	public static void Clip( IList<Plane> planes, dfRenderData source, dfRenderData dest )
	{

		dest.EnsureCapacity( dest.Vertices.Count + source.Vertices.Count );

		var triangleCount = source.Triangles.Count;
		var vertices = source.Vertices.Items;
		var triangles = source.Triangles.Items;
		var uvs = source.UV.Items;
		var colors = source.Colors.Items;
		var transform = source.Transform;

		var planeCount = planes.Count;

		for( int sourceIndex = 0; sourceIndex < triangleCount; sourceIndex += 3 )
		{

			for( int i = 0; i < 3; i++ )
			{

				var index = triangles[ sourceIndex + i ];

				clipSource[ 0 ].corner[ i ] = transform.MultiplyPoint( vertices[ index ] );
				clipSource[ 0 ].uv[ i ] = uvs[ index ];
				clipSource[ 0 ].color[ i ] = colors[ index ];

			}

			var count = 1;
			for( int planeIndex = 0; planeIndex < planeCount; planeIndex++ )
			{

				var clipPlane = planes[ planeIndex ];
				count = clipToPlane( ref clipPlane, clipSource, clipDest, count );

				var temp = clipSource;
				clipSource = clipDest;
				clipDest = temp;

			}

			for( int i = 0; i < count; i++ )
			{
				clipSource[ i ].CopyTo( dest );
			}

		}

	}
开发者ID:Elringus,项目名称:StarcorPreAlpha,代码行数:57,代码来源:dfClippingUtil.cs


示例6: renderText

    private void renderText( dfRenderData textBuffer )
    {
        var p2u = PixelsToUnits();
        var maxSize = new Vector2( size.x - padding.horizontal, this.size.y - padding.vertical );

        var pivotOffset = pivot.TransformToUpperLeft( Size );
        var origin = new Vector3(
            pivotOffset.x + padding.left,
            pivotOffset.y - padding.top,
            0
        ) * p2u;

        var displayText = IsPasswordField && !string.IsNullOrEmpty( this.passwordChar ) ? passwordDisplayText() : this.text;

        var renderColor = IsEnabled ? TextColor : DisabledColor;

        var scaleMultiplier = getTextScaleMultiplier();

        using( var textRenderer = font.ObtainRenderer() )
        {

            textRenderer.WordWrap = false;
            textRenderer.MaxSize = maxSize;
            textRenderer.PixelRatio = p2u;
            textRenderer.TextScale = TextScale * scaleMultiplier;
            textRenderer.VectorOffset = origin;
            textRenderer.MultiLine = false;
            textRenderer.TextAlign = TextAlignment.Left;
            textRenderer.ProcessMarkup = false;
            textRenderer.DefaultColor = renderColor;
            textRenderer.BottomColor = renderColor;
            textRenderer.OverrideMarkupColors = false;
            textRenderer.Opacity = this.CalculateOpacity();
            textRenderer.Shadow = this.Shadow;
            textRenderer.ShadowColor = this.ShadowColor;
            textRenderer.ShadowOffset = this.ShadowOffset;

            #region Manage the scroll position - Keep cursor in view at all times

            cursorIndex = Mathf.Min( cursorIndex, displayText.Length );
            scrollIndex = Mathf.Min( Mathf.Min( scrollIndex, cursorIndex ), displayText.Length );

            charWidths = textRenderer.GetCharacterWidths( displayText );
            var maxRenderSize = maxSize * p2u;

            leftOffset = 0f;
            if( textAlign == TextAlignment.Left )
            {

                // Measure everything from the current scroll position up to the cursor
                var renderedWidth = 0f;
                for( int i = scrollIndex; i < cursorIndex; i++ )
                {
                    renderedWidth += charWidths[ i ];
                }

                // Make sure that the cursor can still be viewed
                while( renderedWidth >= maxRenderSize.x && scrollIndex < cursorIndex )
                {
                    renderedWidth -= charWidths[ scrollIndex++ ];
                }

            }
            else
            {

                scrollIndex = Mathf.Max( 0, Mathf.Min( cursorIndex, displayText.Length - 1 ) );

                var renderedWidth = 0f;
                var slop = font.FontSize * 1.25f * p2u;
                while( scrollIndex > 0 && renderedWidth < maxRenderSize.x - slop )
                {
                    renderedWidth += charWidths[ scrollIndex-- ];
                }

                var textSize = ( displayText.Length > 0 ) ? textRenderer.GetCharacterWidths( displayText.Substring( scrollIndex ) ).Sum() : 0;

                switch( textAlign )
                {
                    case TextAlignment.Center:
                        leftOffset = Mathf.Max( 0, ( maxRenderSize.x - textSize ) * 0.5f );
                        break;
                    case TextAlignment.Right:
                        leftOffset = Mathf.Max( 0, maxRenderSize.x - textSize );
                        break;
                }

                origin.x += leftOffset;
                textRenderer.VectorOffset = origin;

            }

            #endregion

            if( selectionEnd != selectionStart )
            {
                renderSelection( scrollIndex, charWidths, leftOffset );
            }
            else if( cursorShown )
            {
//.........这里部分代码省略.........
开发者ID:BjarkeHou,项目名称:ProjectGuard,代码行数:101,代码来源:dfTextbox.cs


示例7: clipToViewport

    private void clipToViewport( dfRenderData renderData )
    {
        //@Profiler.BeginSample( "Clip markup box to viewport" );

        var planes = getViewportClippingPlanes();

        var material = renderData.Material;
        var matrix = renderData.Transform;

        clipBuffer.Clear();
        dfClippingUtil.Clip( planes, renderData, clipBuffer );

        renderData.Clear();
        renderData.Merge( clipBuffer, false );
        renderData.Material = material;
        renderData.Transform = matrix;

        Profiler.EndSample();
    }
开发者ID:kvelury,项目名称:apocalyptia,代码行数:19,代码来源:dfRichTextLabel.cs


示例8: renderSprite

		private void renderSprite( dfMarkupToken token, Color32 color, Vector3 position, dfRenderData destination )
		{

			try
			{

				//@Profiler.BeginSample( "Render embedded sprite" );

				var spriteName = token.GetAttribute( 0 ).Value.Value;
				var spriteInfo = SpriteAtlas[ spriteName ];
				if( spriteInfo == null )
					return;

				var options = new dfSprite.RenderOptions()
				{
					atlas = SpriteAtlas,
					color = color,
					fillAmount = 1,
					flip = dfSpriteFlip.None,
					offset = position,
					pixelsToUnits = PixelRatio,
					size = new Vector2( token.Width, token.Height ),
					spriteInfo = spriteInfo
				};

				dfSprite.renderSprite( SpriteBuffer, options );

			}
			finally
			{
				//@Profiler.EndSample();
			}

		}
开发者ID:kidaa,项目名称:ProjectUniverse,代码行数:34,代码来源:dfDynamicFont.cs


示例9: renderLine

		/// <summary>
		/// Renders a single line of text
		/// </summary>
		private void renderLine( LineRenderInfo line, Stack<Color32> colors, Vector3 position, dfRenderData destination )
		{

			position.x += calculateLineAlignment( line );

			for( int i = line.startOffset; i <= line.endOffset; i++ )
			{

				var token = tokens[ i ];
				var type = token.TokenType;

				if( type == dfMarkupTokenType.Text )
				{
					renderText( token, colors.Peek(), position, destination );
				}
				else if( type == dfMarkupTokenType.StartTag )
				{
					if( token.Matches( "sprite" ) && SpriteAtlas != null && SpriteBuffer != null )
					{
						renderSprite( token, colors.Peek(), position, SpriteBuffer );
					}
					else if( token.Matches( "color" ) )
					{
						colors.Push( parseColor( token ) );
					}
				}
				else if( type == dfMarkupTokenType.EndTag )
				{
					if( token.Matches( "color" ) && colors.Count > 1 )
					{
						colors.Pop();
					}
				}

				position.x += token.Width;

			}

		}
开发者ID:kidaa,项目名称:ProjectUniverse,代码行数:42,代码来源:dfDynamicFont.cs


示例10: clipBottom

		private void clipBottom( dfRenderData destination, int startIndex )
		{

			if( destination == null )
				return;

			var limit = VectorOffset.y - MaxSize.y * PixelRatio;

			var verts = destination.Vertices;
			var uv = destination.UV;
			var colors = destination.Colors;

			for( int i = startIndex; i < verts.Count; i += 4 )
			{

				var ul = verts[ i + 0 ];
				var ur = verts[ i + 1 ];
				var br = verts[ i + 2 ];
				var bl = verts[ i + 3 ];

				var h = ul.y - bl.y;

				if( bl.y <= limit )
				{

					var clip = 1f - ( Mathf.Abs( -limit + ul.y ) / h );

					verts[ i + 0 ] = ul = new Vector3( ul.x, Mathf.Max( ul.y, limit ), ur.z );
					verts[ i + 1 ] = ur = new Vector3( ur.x, Mathf.Max( ur.y, limit ), ur.z );
					verts[ i + 2 ] = br = new Vector3( br.x, Mathf.Max( br.y, limit ), br.z );
					verts[ i + 3 ] = bl = new Vector3( bl.x, Mathf.Max( bl.y, limit ), bl.z );

					uv[ i + 3 ] = Vector2.Lerp( uv[ i + 3 ], uv[ i + 0 ], clip );
					uv[ i + 2 ] = Vector2.Lerp( uv[ i + 2 ], uv[ i + 1 ], clip );

					var color = Color.Lerp( colors[ i + 3 ], colors[ i ], clip );
					colors[ i + 3 ] = color;
					colors[ i + 2 ] = color;

				}

			}

		}
开发者ID:kidaa,项目名称:ProjectUniverse,代码行数:44,代码来源:dfDynamicFont.cs


示例11: Merge

    /// <summary>
    /// Merges another <see cref="dfRenderData"/> instance with this instance
    /// </summary>
    /// <param name="buffer">The render data to be appended to this instance</param>
    /// <param name="transformVertices">If set to TRUE, the render data in 
    /// <paramref name="buffer"/> will be transformed by its <see cref="Transform"/> 
    /// before being merged with this instance. If set to FALSE, the data will be 
    /// merged without tranforming.</param>
    public void Merge( dfRenderData buffer, bool transformVertices )
    {
        // We need the current currentIndex of vertices before adding any more so that
        // we have a proper base index for our triangle indices
        var baseIndex = Vertices.Count;

        #region Merge vertices

        Vertices.AddRange( buffer.Vertices );
        if( transformVertices )
        {

            var rawVerts = Vertices.Items;
            var count = buffer.Vertices.Count;
            var transform = buffer.Transform;

            for( int i = baseIndex; i < baseIndex + count; i++ )
            {
                rawVerts[ i ] = transform.MultiplyPoint( rawVerts[ i ] );
            }

        }

        #endregion

        #region Merge triangles

        var triangleBaseIndex = Triangles.Count;

        Triangles.AddRange( buffer.Triangles );

        var bufferTriangleCount = buffer.Triangles.Count;
        var rawTriangles = Triangles.Items;
        for( int i = triangleBaseIndex; i < triangleBaseIndex + bufferTriangleCount; i++ )
        {
            rawTriangles[ i ] += baseIndex;
        }

        #endregion

        UV.AddRange( buffer.UV );
        Colors.AddRange( buffer.Colors );
        Normals.AddRange( buffer.Normals );
        Tangents.AddRange( buffer.Tangents );
    }
开发者ID:CoryBerg,项目名称:drexelNeonatal,代码行数:53,代码来源:dfRenderData.cs


示例12: RenderMultiple

    public dfList<dfRenderData> RenderMultiple()
    {
        if( Atlas == null || Font == null )
            return null;

        if( !isVisible )
        {
            return null;
        }

        // Initialize render buffers if needed
        if( renderData == null )
        {

            renderData = dfRenderData.Obtain();
            textRenderData = dfRenderData.Obtain();

            isControlInvalidated = true;

        }

        // If control is not dirty, update the transforms on the
        // render buffers (in case control moved) and return
        // pre-rendered data
        if( !isControlInvalidated )
        {
            for( int i = 0; i < buffers.Count; i++ )
            {
                buffers[ i ].Transform = transform.localToWorldMatrix;
            }
            return buffers;
        }

        #region Prepare render buffers

        buffers.Clear();

        renderData.Clear();
        renderData.Material = Atlas.Material;
        renderData.Transform = this.transform.localToWorldMatrix;
        buffers.Add( renderData );

        textRenderData.Clear();
        textRenderData.Material = Atlas.Material;
        textRenderData.Transform = this.transform.localToWorldMatrix;
        buffers.Add( textRenderData );

        #endregion

        // Render background before anything else, since we're going to
        // want to keep track of where the background data ends and any
        // other data begins
        renderBackground();

        // We want to start clipping *after* the background is rendered, so
        // grab the current number of vertices before rendering other elements
        var spriteClipStart = renderData.Vertices.Count;

        // Render other sprites
        renderHover();
        renderSelection();

        // Render text items
        renderItems( textRenderData );

        // Perform clipping
        clipQuads( renderData, spriteClipStart );
        clipQuads( textRenderData, 0 );

        // Control is no longer in need of rendering
        isControlInvalidated = false;

        // Make sure that the collider size always matches the control
        updateCollider();

        return buffers;
    }
开发者ID:CoryBerg,项目名称:drexelNeonatal,代码行数:77,代码来源:dfListbox.cs


示例13: clipToViewport

    private void clipToViewport( dfRenderData renderData )
    {
        var planes = getViewportClippingPlanes();

        var material = renderData.Material;
        var matrix = renderData.Transform;

        clipBuffer.Clear();
        dfClippingUtil.Clip( planes, renderData, clipBuffer );

        renderData.Clear();
        renderData.Merge( clipBuffer, false );
        renderData.Material = material;
        renderData.Transform = matrix;
    }
开发者ID:zc1415926,项目名称:Unity-SelectCharacter-Scene,代码行数:15,代码来源:dfRichTextLabel.cs


示例14: rebuildVertices

    private static void rebuildVertices( dfRenderData renderData, RenderOptions options )
    {
        float meshLeft = 0;
        float meshTop = 0;
        float meshRight = Mathf.Ceil( options.size.x );
        float meshBottom = Mathf.Ceil( -options.size.y );

        #region Borders

        var spriteInfo = options.spriteInfo;
        float borderLeft = spriteInfo.border.left;
        float borderTop = spriteInfo.border.top;
        float borderRight = spriteInfo.border.right;
        float borderBottom = spriteInfo.border.bottom;

        if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) )
        {
            float temp = borderRight;
            borderRight = borderLeft;
            borderLeft = temp;
        }

        if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) )
        {
            float temp = borderBottom;
            borderBottom = borderTop;
            borderTop = temp;
        }

        #endregion

        // Top left corner
        verts[ 0 ] = new Vector3( meshLeft, meshTop, 0 ) + options.offset;
        verts[ 1 ] = verts[ 0 ] + new Vector3( borderLeft, 0, 0 );
        verts[ 2 ] = verts[ 0 ] + new Vector3( borderLeft, -borderTop, 0 );
        verts[ 3 ] = verts[ 0 ] + new Vector3( 0, -borderTop, 0 );

        // Top right corner
        verts[ 4 ] = new Vector3( meshRight - borderRight, meshTop, 0 ) + options.offset;
        verts[ 5 ] = verts[ 4 ] + new Vector3( borderRight, 0, 0 );
        verts[ 6 ] = verts[ 4 ] + new Vector3( borderRight, -borderTop, 0 );
        verts[ 7 ] = verts[ 4 ] + new Vector3( 0, -borderTop, 0 );

        // Bottom left corner
        verts[ 8 ] = new Vector3( meshLeft, meshBottom + borderBottom, 0 ) + options.offset;
        verts[ 9 ] = verts[ 8 ] + new Vector3( borderLeft, 0, 0 );
        verts[ 10 ] = verts[ 8 ] + new Vector3( borderLeft, -borderBottom, 0 );
        verts[ 11 ] = verts[ 8 ] + new Vector3( 0, -borderBottom, 0 );

        // Bottom right corner
        verts[ 12 ] = new Vector3( meshRight - borderRight, meshBottom + borderBottom, 0 ) + options.offset;
        verts[ 13 ] = verts[ 12 ] + new Vector3( borderRight, 0, 0 );
        verts[ 14 ] = verts[ 12 ] + new Vector3( borderRight, -borderBottom, 0 );
        verts[ 15 ] = verts[ 12 ] + new Vector3( 0, -borderBottom, 0 );

        for( int i = 0; i < verts.Length; i++ )
        {
            renderData.Vertices.Add( ( verts[ i ] * options.pixelsToUnits ).Quantize( options.pixelsToUnits ) );
        }
    }
开发者ID:haozi000005,项目名称:happy2d,代码行数:60,代码来源:dfSlicedSprite.cs


示例15: rebuildUV

    private static void rebuildUV( dfRenderData renderData, RenderOptions options )
    {
        var atlas = options.atlas;
        var textureSize = new Vector2( atlas.Texture.width, atlas.Texture.height );

        var spriteInfo = options.spriteInfo;
        float offsetTop = spriteInfo.border.top / textureSize.y;
        float offsetBottom = spriteInfo.border.bottom / textureSize.y;
        float offsetLeft = spriteInfo.border.left / textureSize.x;
        float offsetRight = spriteInfo.border.right / textureSize.x;

        var rect = spriteInfo.region;

        // Top left corner
        uv[ 0 ] = new Vector2( rect.x, rect.yMax );
        uv[ 1 ] = new Vector2( rect.x + offsetLeft, rect.yMax );
        uv[ 2 ] = new Vector2( rect.x + offsetLeft, rect.yMax - offsetTop );
        uv[ 3 ] = new Vector2( rect.x, rect.yMax - offsetTop );

        // Top right corner
        uv[ 4 ] = new Vector2( rect.xMax - offsetRight, rect.yMax );
        uv[ 5 ] = new Vector2( rect.xMax, rect.yMax );
        uv[ 6 ] = new Vector2( rect.xMax, rect.yMax - offsetTop );
        uv[ 7 ] = new Vector2( rect.xMax - offsetRight, rect.yMax - offsetTop );

        // Bottom left corner
        uv[ 8 ] = new Vector2( rect.x, rect.y + offsetBottom );
        uv[ 9 ] = new Vector2( rect.x + offsetLeft, rect.y + offsetBottom );
        uv[ 10 ] = new Vector2( rect.x + offsetLeft, rect.y );
        uv[ 11 ] = new Vector2( rect.x, rect.y );

        // Bottom right corner
        uv[ 12 ] = new Vector2( rect.xMax - offsetRight, rect.y + offsetBottom );
        uv[ 13 ] = new Vector2( rect.xMax, rect.y + offsetBottom );
        uv[ 14 ] = new Vector2( rect.xMax, rect.y );
        uv[ 15 ] = new Vector2( rect.xMax - offsetRight, rect.y );

        #region Flip UV if requested

        if( options.flip != dfSpriteFlip.None )
        {

            for( int i = 0; i < uv.Length; i += 4 )
            {

                Vector2 temp = Vector2.zero;

                if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) )
                {
                    temp = uv[ i + 0 ]; uv[ i + 0 ] = uv[ i + 1 ]; uv[ i + 1 ] = temp;
                    temp = uv[ i + 2 ]; uv[ i + 2 ] = uv[ i + 3 ]; uv[ i + 3 ] = temp;
                }

                if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) )
                {
                    temp = uv[ i + 0 ]; uv[ i + 0 ] = uv[ i + 3 ]; uv[ i + 3 ] = temp;
                    temp = uv[ i + 1 ]; uv[ i + 1 ] = uv[ i + 2 ]; uv[ i + 2 ] = temp;
                }

            }

            if( options.flip.IsSet( dfSpriteFlip.FlipHorizontal ) )
            {

                var th = new Vector2[ uv.Length ];
                Array.Copy( uv, th, uv.Length );

                // Swap top-left and top-right corners
                Array.Copy( uv, 0, uv, 4, 4 );
                Array.Copy( th, 4, uv, 0, 4 );

                // Swap bottom-left and bottom-right corners
                Array.Copy( uv, 8, uv, 12, 4 );
                Array.Copy( th, 12, uv, 8, 4 );

            }

            if( options.flip.IsSet( dfSpriteFlip.FlipVertical ) )
            {

                var tv = new Vector2[ uv.Length ];
                Array.Copy( uv, tv, uv.Length );

                // Swap top-left and bottom-left corners
                Array.Copy( uv, 0, uv, 8, 4 );
                Array.Copy( tv, 8, uv, 0, 4 );

                // Swap top-right and bottom-right corners
                Array.Copy( uv, 4, uv, 12, 4 );
                Array.Copy( tv, 12, uv, 4, 4 );

            }

        }

        #endregion

        for( int i = 0; i < uv.Length; i++ )
        {
            renderData.UV.Add( uv[ i ] );
//.........这里部分代码省略.........
开发者ID:haozi000005,项目名称:happy2d,代码行数:101,代码来源:dfSlicedSprite.cs


示例16: renderControl

    private void renderControl( ref dfRenderData buffer, dfControl control, uint checksum, float opacity )
    {
        // Don't render controls that are not currently active
        if( !control.enabled || !control.gameObject.activeSelf )
            return;

        // Don't render controls that are invisible. Keeping a running
        // accumulator for opacity allows us to know a control's final
        // calculated opacity
        var effectiveOpacity = opacity * control.Opacity;
        if( effectiveOpacity <= 0.001f )
        {
            return;
        }

        // If this control has a dfRenderGroup component on it, then pass off all
        // responsibility for rendering that control to the component.
        var renderGroup = GetRenderGroupForControl( control, true );
        if( renderGroup != null && renderGroup != this && renderGroup.enabled )
        {
            renderGroups.Add( renderGroup );
            renderGroup.Render( renderCamera, control, groupOccluders, groupControls, checksum, effectiveOpacity );
            return;
        }

        // Don't render controls that have the IsVisible flag set to FALSE. Note that this is tested
        // *after* checking for the presence of a dfRenderGroup component, since that component (if
        // present) will need to update its own internal state if the control's IsVisible property
        // has changed.
        if( !control.GetIsVisibleRaw() )
            return;

        // Grab the current clip region information off the stack
        var clipInfo = clipStack.Peek();

        // Update the checksum to include the current control
        checksum = dfChecksumUtil.Calculate( checksum, control.Version );

        // Retrieve the control's bounds, which will be used in intersection testing
        // and triangle clipping.
        var bounds = control.GetBounds();
        var screenRect = control.GetScreenRect();
        var occluder = getControlOccluder( ref screenRect, control );

        // Indicates whether the control was not rendered because it fell outside
        // of the currently-active clipping region
        var wasClipped = false;

        if( !( control is IDFMultiRender ) )
        {

            // Ask the control to render itself and return a buffer of the
            // information needed to render it as a Mesh
            var controlData = control.Render();
            if( controlData != null )
            {
                processRenderData( ref buffer, controlData, ref bounds, ref screenRect, checksum, clipInfo, ref wasClipped );
            }

        }
        else
        {

            // Ask the control to render itself and return as many dfRenderData buffers
            // as needed to render all elements of the control as a Mesh
            var childBuffers = ( (IDFMultiRender)control ).RenderMultiple();

            if( childBuffers != null )
            {

                var buffers = childBuffers.Items;
                var bufferCount = childBuffers.Count;

                for( int i = 0; i < bufferCount; i++ )
                {

                    var childBuffer = buffers[ i ];
                    if( childBuffer != null )
                    {
                        processRenderData( ref buffer, childBuffer, ref bounds, ref screenRect, checksum, clipInfo, ref wasClipped );
                    }

                }

            }

        }

        // Allow control to keep track of its clipping state
        control.setClippingState( wasClipped );

        // Keep track of which controls are rendered, and where they appear on-screen
        groupOccluders.Add( occluder );
        groupControls.Add( control );

        // If the control has the "Clip child controls" option set, push
        // its clip region information onto the stack so that all controls
        // lower in the hierarchy are clipped against that region.
        if( control.ClipChildren )
        {
//.........这里部分代码省略.........
开发者ID:zc1415926,项目名称:Unity-SelectCharacter-Scene,代码行数:101,代码来源:dfRenderGroup.cs


示例17: clipQuads

    private void clipQuads( dfRenderData buffer, int startIndex )
    {
        // Performs a simplified version of triangle clipping, "clipping" vertices
        // to the vertical limits of the target render area. Simplified clipping
        // does not split triangles, it simply moves vertices to the corresponding
        // edge of the clip area and adjusts the UV coordinates to match, which
        // means that it is faster than regular triangle clipping and does not
        // allocate any additional memory.

        var verts = buffer.Vertices;
        var uv = buffer.UV;

        var p2u = PixelsToUnits();
        var maxY = ( Pivot.TransformToUpperLeft( Size ).y - listPadding.top ) * p2u;
        var minY = maxY - ( size.y - listPadding.vertical ) * p2u;

        for( int i = startIndex; i < verts.Count; i += 4 )
        {

            var ul = verts[ i + 0 ];
            var ur = verts[ i + 1 ];
            var br = verts[ i + 2 ];
            var bl = verts[ i + 3 ];

            var h = ul.y - bl.y;

            // Bottom of clip rect
            if( bl.y < minY )
            {

                var clip = 1f - ( Mathf.Abs( -minY + ul.y ) / h );

                verts[ i + 0 ] = ul = new Vector3( ul.x, Mathf.Max( ul.y, minY ), ur.z );
                verts[ i + 1 ] = ur = new Vector3( ur.x, Mathf.Max( ur.y, minY ), ur.z );
                verts[ i + 2 ] = br = new Vector3( br.x, Mathf.Max( br.y, minY ), br.z );
                verts[ i + 3 ] = bl = new Vector3( bl.x, Mathf.Max( bl.y, minY ), bl.z );

                var uvy = Mathf.Lerp( uv[ i + 3 ].y, uv[ i ].y, clip );
                uv[ i + 3 ] = new Vector2( uv[ i + 3 ].x, uvy );
                uv[ i + 2 ] = new Vector2( uv[ i + 2 ].x, uvy );

                h = Mathf.Abs( bl.y - ul.y );

            }

            // Top of clip rect
            if( ul.y > maxY )
            {

                var clip = Mathf.Abs( maxY - ul.y ) / h;

                verts[ i + 0 ] = new Vector3( ul.x, Mathf.Min( maxY, ul.y ), ul.z );
                verts[ i + 1 ] = new Vector3( ur.x, Mathf.Min( maxY, ur.y ), ur.z );
                verts[ i + 2 ] = new Vector3( br.x, Mathf.Min( maxY, br.y ), br.z );
                verts[ i + 3 ] = new Vector3( bl.x, Mathf.Min( maxY, bl.y ), bl.z );

                var uvy = Mathf.Lerp( uv[ i ].y, uv[ i + 3 ].y, clip );
                uv[ i ] = new Vector2( uv[ i ].x, uvy );
                uv[ i + 1 ] = new Vector2( uv[ i + 1 ].x, uvy );

            }

        }
    }
开发者ID:CoryBerg,项目名称:drexelNeonatal,代码行数:64,代码来源:dfListbox.cs


示例18: clipRight

		private void clipRight( dfRenderData destination, int startIndex )
		{

			if( destination == null )
				return;

			var limit = VectorOffset.x + MaxSize.x * PixelRatio;

			var verts = destination.Vertices;
			var uv = destination.UV;

			for( int i = startIndex; i < verts.Count; i += 4 )
			{

				var ul = verts[ i + 0 ];
				var ur = verts[ i + 1 ];
				var br = verts[ i + 2 ];
				var bl = verts[ i + 3 ];

				var w = ur.x - ul.x;

				if( ur.x > limit )
				{

					var clip = 1f - ( ( limit - ur.x + w ) / w );

					verts[ i + 0 ] = ul = new Vector3( Mathf.Min( ul.x, limit ), ul.y, ul.z );
					verts[ i + 1 ] = ur = new Vector3( Mathf.Min( ur.x, limit ), ur.y, ur.z );
					verts[ i + 2 ] = br = new Vector3( Mathf.Min( br.x, limit ), br.y, br.z );
					verts[ i + 3 ] = bl = new Vector3( Mathf.Min( bl.x, limit ), bl.y, bl.z );

					var uvx = Mathf.Lerp( uv[ i + 1 ].x, uv[ i ].x, clip );
					uv[ i + 1 ] = new Vector2( uvx, uv[ i + 1 ].y );
					uv[ i + 2 ] = new Vector2( uvx, uv[ i + 2 ].y );

					w = ur.x - ul.x;

				}

			}

		}
开发者ID:kidaa,项目名称:ProjectUniverse,代码行数:42,代码来源:dfDynamicFont.cs


示例19: renderItems

    private void renderItems( dfRenderData buffer )
    {
        if( font == null || items == null || items.Length == 0 )
            return;

        var p2u = PixelsToUnits();
        var maxSize = new Vector2( this.size.x - itemPadding.horizontal - listPadding.horizontal, itemHeight - itemPadding.vertical );

        var pivotOffset = pivot.TransformToUpperLeft( Size );
        var origin = new Vector3(
            pivotOffset.x + itemPadding.left + listPadding.left,
            pivotOffset.y - itemPadding.top - listPadding.top,
            0
        ) * p2u;

        origin.y += scrollPosition * p2u;

        var renderColor = IsEnabled ? ItemTextColor : DisabledColor;

        // TODO: Figure out why the text renderer cannot be re-used for each list item

        var top = pivotOffset.y * p2u;
        var bottom = top - size.y * p2u;
        for( int i = 0; i < items.Length; i++ )
        {

            using( var textRenderer = font.ObtainRenderer() )
            {

                textRenderer.WordWrap = false;
                textRenderer.MaxSize = maxSize;
                textRenderer.PixelRatio = p2u;
                textRenderer.TextScale = ItemTextScale * getTextScaleMultiplier();
                textRenderer.VectorOffset = origin;
                textRenderer.MultiLine = false;
                textRenderer.TextAlign = this.ItemAlignment;
                textRenderer.ProcessMarkup = true;
                textRenderer.DefaultColor = renderColor;
                textRenderer.OverrideMarkupColors = false;
                textRenderer.Opacity = this.CalculateOpacity();
                textRenderer.Shadow = this.Shadow;
                textRenderer.ShadowColor = this.ShadowColor;
                textRenderer.ShadowOffset = this.ShadowOffset;

                var dynamicFontRenderer = textRenderer as dfDynamicFont.DynamicFontRenderer;
                if( dynamicFontRenderer != null )
                {
                    dynamicFontRenderer.SpriteAtlas = this.Atlas;
                    dynamicFontRenderer.SpriteBuffer = renderData;
                }

                if( origin.y - itemHeight * p2u <= top )
                {
                    textRenderer.Render( items[ i ], buffer );
                }

                origin.y -= itemHeight * p2u;
                textRenderer.VectorOffset = origin;

                if( origin.y < bottom )
                    break;

            }

        }
    }
开发者ID:CoryBerg,项目名称:drexelNeonatal,代码行数:66,代码来源:dfListbox.cs


示例20: Render

		/// <summary>
		/// Render the given text as mesh data to the given destination buffer
		/// </summary>
		/// <param name="text">The text to be rendered</param>
		/// <param name="destination">The dfRenderData buffer that will hold the 
		/// text mesh information</param>
		public override void Render( string text, dfRenderData destination )
		{

			//@Profiler.BeginSample( "Render dynamic font text" );

			textColors.Clear();
			textColors.Push( Color.white );

			// Ensure that the required characters can be found in the dynamic font's
			// character data.
			var font = (dfDynamicFont)Font;
			var fontSize = Mathf.CeilToInt( font.FontSize * TextScale );
			font.RequestCharacters( text, fontSize, FontStyle.Normal );

			tokenize( text );
			var lines = calculateLinebreaks();

			destination.EnsureCapacity( getAnticipatedVertCount( tokens ) );

			var maxWidth = 0;
			var maxHeight = 0;

			var position = ( VectorOffset / PixelRatio ).CeilToInt();

			for( int i = 0; i < lines.Count; i++ )
			{

				var line = lines[ i ];
				var lineStartIndex = destination.Vertices.Count;
				var spriteStartIndex = ( SpriteBuffer != null ) ? SpriteBuffer.Vertices.Count : 0;

				renderLine( lines[ i ], textColors, position, destination );

				position.y -= line.lineHeight;

				maxWidth = Mathf.Max( (int)line.lineWidth, maxWidth );
				maxHeight += Mathf.CeilToInt( line.lineHeight );

				if( line.lineWidth > MaxSize.x )
				{
					clipRight( destination, lineStartIndex );
					clipRight( SpriteBuffer, spriteStartIndex );
				}

				clipBottom( destination, lineStartIndex );
				clipBottom( SpriteBuffer, spriteStartIndex );

			}

			this.RenderedSize = new Vector2(
				Mathf.Min( MaxSize.x, maxWidth ),
				Mathf.Min( MaxSize.y, maxHeight )
			) * TextScale;

			this.tokens.Release();
			this.tokens = null;

			//@Profiler.EndSample();

		}
开发者ID:kidaa,项目名称:ProjectUniverse,代码行数:66,代码来源:dfDynamicFont.cs



注:本文中的dfRenderData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# direction类代码示例发布时间:2022-05-24
下一篇:
C# dfMouseEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap