当前位置: 首页>>代码示例>>C#>>正文


C# GuiRenderer.AddLine方法代码示例

本文整理汇总了C#中GuiRenderer.AddLine方法的典型用法代码示例。如果您正苦于以下问题:C# GuiRenderer.AddLine方法的具体用法?C# GuiRenderer.AddLine怎么用?C# GuiRenderer.AddLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GuiRenderer的用法示例。


在下文中一共展示了GuiRenderer.AddLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Minimap_RenderUI

        //Draw minimap
        void Minimap_RenderUI( EControl sender, GuiRenderer renderer )
        {
            Rect screenMapRect = sender.GetScreenRectangle();

            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect( initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2() );

            Vec2 mapSizeInv = new Vec2( 1, 1 ) / mapRect.Size;

            //draw units
            Vec2 screenPixel = new Vec2( 1, 1 ) / new Vec2( EngineApp.Instance.VideoMode.Size.ToVec2() );

            foreach( Entity entity in Map.Instance.Children )
            {
                RTSUnit unit = entity as RTSUnit;
                if( unit == null )
                    continue;

                Rect rect = new Rect( unit.MapBounds.Minimum.ToVec2(), unit.MapBounds.Maximum.ToVec2() );

                rect -= mapRect.Minimum;
                rect.Minimum *= mapSizeInv;
                rect.Maximum *= mapSizeInv;
                rect.Minimum = new Vec2( rect.Minimum.X, 1.0f - rect.Minimum.Y );
                rect.Maximum = new Vec2( rect.Maximum.X, 1.0f - rect.Maximum.Y );
                rect.Minimum *= screenMapRect.Size;
                rect.Maximum *= screenMapRect.Size;
                rect += screenMapRect.Minimum;

                //increase 1 pixel
                rect.Maximum += new Vec2( screenPixel.X, -screenPixel.Y );

                ColorValue color;

                if( playerFaction == null || unit.Intellect == null || unit.Intellect.Faction == null )
                    color = new ColorValue( 1, 1, 0 );
                else if( playerFaction == unit.Intellect.Faction )
                    color = new ColorValue( 0, 1, 0 );
                else
                    color = new ColorValue( 1, 0, 0 );

                renderer.AddQuad( rect, color );
            }

            //Draw camera borders
            {
                Camera camera = RendererWorld.Instance.DefaultCamera;

                if( camera.Position.Z > 0 )
                {

                    Plane groundPlane = new Plane( 0, 0, 1, 0 );

                    Vec2[] points = new Vec2[ 4 ];

                    for( int n = 0; n < 4; n++ )
                    {
                        Vec2 p = Vec2.Zero;

                        switch( n )
                        {
                        case 0: p = new Vec2( 0, 0 ); break;
                        case 1: p = new Vec2( 1, 0 ); break;
                        case 2: p = new Vec2( 1, 1 ); break;
                        case 3: p = new Vec2( 0, 1 ); break;
                        }

                        Ray ray = camera.GetCameraToViewportRay( p );

                        float scale;
                        groundPlane.RayIntersection( ray, out scale );

                        Vec3 pos = ray.GetPointOnRay( scale );
                        if( ray.Direction.Z > 0 )
                            pos = ray.Origin + ray.Direction.GetNormalize() * 10000;

                        Vec2 point = pos.ToVec2();

                        point -= mapRect.Minimum;
                        point *= mapSizeInv;
                        point = new Vec2( point.X, 1.0f - point.Y );
                        point *= screenMapRect.Size;
                        point += screenMapRect.Minimum;

                        points[ n ] = point;
                    }

                    for( int n = 0; n < 4; n++ )
                        renderer.AddLine( points[ n ], points[ ( n + 1 ) % 4 ], new ColorValue( 1, 1, 1 ),
                            screenMapRect );
                }
            }
        }
开发者ID:huytd,项目名称:fosproject,代码行数:94,代码来源:RTSGameWindow.cs

示例2: RenderScreenUI

        public void RenderScreenUI(GuiRenderer renderer)
        {
            for (int viewIndex = 0; viewIndex < views.Count; viewIndex++)
            {
                View view = views[viewIndex];

                //draw view on screen
                if (view.Opacity > 0)
                {
                    renderer.PushTextureFilteringMode(GuiRenderer.TextureFilteringModes.Point);
                    renderer.AddQuad(view.Rectangle, new Rect(0, 0, 1, 1), view.Texture,
                        new ColorValue(1, 1, 1, view.Opacity), true);
                    renderer.PopTextureFilteringMode();
                }

                //draw debug info
                if (drawDebugInfo)
                {
                    Viewport screenViewport = renderer.ViewportForScreenGuiRenderer;
                    Vec2 pixelOffset = 1.0f / screenViewport.DimensionsInPixels.Size.ToVec2();
                    ColorValue color = new ColorValue(1, 1, 0);
                    renderer.AddRectangle(new Rect(
                        view.Rectangle.LeftTop + pixelOffset,
                        view.Rectangle.RightBottom - pixelOffset * 2),
                        color);
                    renderer.AddLine(view.Rectangle.LeftTop, view.Rectangle.RightBottom, color);
                    renderer.AddLine(view.Rectangle.RightTop, view.Rectangle.LeftBottom, color);

                    if (debugFont == null)
                        debugFont = FontManager.Instance.LoadFont("Default", .03f);

                    string sizeString = "";
                    if (view.Texture != null)
                        sizeString = string.Format("{0}x{1}", view.Texture.Size.X, view.Texture.Size.Y);
                    string text = string.Format("View {0}, {1}", viewIndex, sizeString);
                    Vec2 position = new Vec2(view.Rectangle.Right - pixelOffset.X * 5, view.Rectangle.Top);
                    AddTextWithShadow(renderer, debugFont, text, position, HorizontalAlign.Right,
                        VerticalAlign.Top, new ColorValue(1, 1, 1));
                }
            }
        }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:41,代码来源:MultiViewRenderingManager.cs

示例3: DrawArea_RenderUI


//.........这里部分代码省略.........
                    if( step != 0 )
                    {
                        ColorValue color = colors[ step % colors.Length ];
                        ColorValue color2 = color;
                        color2.Alpha = 0;
                        triangles.Add( new GuiRenderer.TriangleVertex( rectangle.GetCenter(), color ) );
                        triangles.Add( new GuiRenderer.TriangleVertex( lastPosition, color2 ) );
                        triangles.Add( new GuiRenderer.TriangleVertex( pos, color2 ) );
                    }

                    angle += ( MathFunctions.PI * 2 ) / steps;
                    lastPosition = pos;
                }

                renderer.AddTriangles( triangles );
            }

            //draw quads
            if( GetDrawAreaMode() == DrawAreaModes.Quads )
            {
                //draw background
                {
                    Texture texture = TextureManager.Instance.Load( "Gui\\Various\\Logo.png" );
                    renderer.AddQuad( rectangle, new Rect( 0, -.3f, 1, 1.4f ), texture,
                        new ColorValue( 1, 1, 1 ), true );
                }

                //draw bars
                {
                    float time = EngineApp.Instance.Time;

                    EngineRandom random = new EngineRandom( 0 );

                    int count = 15;
                    float stepOffset = rectangle.GetSize().X / count;
                    float size = stepOffset * .9f;
                    for( int n = 0; n < count; n++ )
                    {
                        float v = MathFunctions.Cos( time * random.NextFloat() );
                        float v2 = ( v + 1 ) / 2;

                        ColorValue color = colors[ n % colors.Length ];
                        Rect rect = new Rect(
                            rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y * v2,
                            rectangle.Left + stepOffset * n + size, rectangle.Bottom );
                        renderer.AddQuad( rect, color );
                    }
                }
            }

            //draw lines
            if( GetDrawAreaMode() == DrawAreaModes.Lines )
            {
                float maxDistance;
                {
                    Vec2 s = rectangle.GetSize() / 2;
                    maxDistance = MathFunctions.Sqrt( s.X * s.X + s.Y * s.Y );
                }

                int step = 0;
                float distance = 0;
                Radian angle = -EngineApp.Instance.Time;
                Vec2 lastPosition = Vec2.Zero;

                while( distance < maxDistance )
                {
                    Vec2 localPos = new Vec2( MathFunctions.Cos( angle ), MathFunctions.Sin( angle ) ) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2( localPos.X, localPos.Y * renderer.AspectRatio );

                    if( step != 0 )
                    {
                        ColorValue color = colors[ step % colors.Length ];
                        renderer.AddLine( lastPosition, pos, color );
                    }

                    step++;
                    angle += MathFunctions.PI / 10;
                    distance += .001f;
                    lastPosition = pos;
                }
            }

            //draw text
            if( GetDrawAreaMode() == DrawAreaModes.Text )
            {
                //draw text with specified font.
                renderer.AddText( drawAreaBigFont, "Big Font Sample", rectangle.LeftTop, HorizontalAlign.Left,
                    VerticalAlign.Top, new ColorValue( 1, 1, 1 ) );

                //draw text with word wrap.
                string text = "Test Test Test.\n\nThe expandable user interface system is a unified system " +
                    "for the creation of end-user controls, menus, dialogues, windows and HUD screens. " +
                    "With the help of this system the end-user exercises control over the application.";
                renderer.AddTextWordWrap( text, rectangle, HorizontalAlign.Right, false, VerticalAlign.Bottom, 0,
                    new ColorValue( 1, 1, 0 ) );
            }

            if( clipRectangle )
                renderer.PopClipRectangle();
        }
开发者ID:Eneth,项目名称:GAO,代码行数:101,代码来源:GuiTestWindow.cs

示例4: DrawVector

        void DrawVector(GuiRenderer g, Vec2 start, Vec2 end, ColorValue color)
        {
            Vec2 vAngle = end - start;
            vAngle.Normalize();
            float angle = MathFunctions.ATan(vAngle.Y, vAngle.X);

            //g.AddLine(start, end, color);

            float tipLength = 0.01f;
            Vec2 endArrow1 = end + new Vec2(MathFunctions.Cos(angle + MathFunctions.DegToRad(180 - 20)) * tipLength, MathFunctions.Sin(angle + MathFunctions.DegToRad(180 - 20)) * tipLength);
            Vec2 endArrow2 = end + new Vec2(MathFunctions.Cos(angle + MathFunctions.DegToRad(180 + 20)) * tipLength, MathFunctions.Sin(angle + MathFunctions.DegToRad(180 + 20)) * tipLength);

            g.AddLine(start, end, color);
            g.AddLine(end, endArrow1, color);
            g.AddLine(end, endArrow2, color);
        }
开发者ID:CITS4242B2010,项目名称:project2010,代码行数:16,代码来源:Aerofoil.cs

示例5: DrawDebug

        public void DrawDebug(Rect r, GuiRenderer g)
        {
            float windScale = 0.1f;
            float forceScale = 0.2f;
            float positionScale = 5.0f;

            // Box around
            g.AddRectangle(r, new ColorValue(0.416f, 0.133f, 0.494f));

            // Aerofoil
            float controlAngle = MathFunctions.DegToRad(debugControl);
            g.AddLine(
                Utils.TR(r, new Vec2(0.5f - MathFunctions.Cos(controlAngle) * 0.25f, 0.5f - MathFunctions.Sin(controlAngle) * 0.25f)),
                Utils.TR(r, new Vec2(0.5f + MathFunctions.Cos(controlAngle) * 0.25f, 0.5f + MathFunctions.Sin(controlAngle) * 0.25f)),
                new ColorValue(0.416f, 0.553f, 0.576f)
            );

            // Wind
            Vec2 windStart = Utils.TR(r, new Vec2(0.5f - debugWind.Y * windScale, 0.5f - debugWind.Z * windScale));
            Vec2 windEnd = Utils.TR(r, new Vec2(0.5f, 0.5f));
            DrawVector(g, windStart, windEnd, new ColorValue(0.196f, 0.384f, 0.337f));

            // Lift
            Vec2 liftStart = Utils.TR(r, new Vec2(0.5f + debugLinearPosition * positionScale, 0.5f));
            Vec2 liftEnd = liftStart + new Vec2(0, -debugLift.Z * forceScale);
            DrawVector(g, liftStart, liftEnd, new ColorValue(0.333f, 0.973f, 0.969f));

            // Drag
            Vec2 dragStart = Utils.TR(r, new Vec2(0.5f + debugLinearPosition * positionScale, 0.5f + 0.01f));
            Vec2 dragEnd = dragStart + new Vec2(-debugDrag.Y * forceScale, 0);
            DrawVector(g, dragStart, dragEnd, new ColorValue(0.486f, 0.184f, 0.184f));

            // Pitch
            Vec2 pitchStart = Utils.TR(r, new Vec2(0.5f, 0.5f - debugPitchPosition * positionScale));
            Vec2 pitchEnd = pitchStart + new Vec2(0, -debugPitchForce.Z * forceScale);
            DrawVector(g, pitchStart, pitchEnd, new ColorValue(0.388f, 0.769f, 0.373f));
        }
开发者ID:CITS4242B2010,项目名称:project2010,代码行数:37,代码来源:Aerofoil.cs

示例6: DrawArea_RenderUI


//.........这里部分代码省略.........
                        ColorValue color2 = color;
                        color2.Alpha = 0;
                        triangles.Add(new GuiRenderer.TriangleVertex(rectangle.GetCenter(), color));
                        triangles.Add(new GuiRenderer.TriangleVertex(lastPosition, color2));
                        triangles.Add(new GuiRenderer.TriangleVertex(pos, color2));
                    }

                    angle += (MathFunctions.PI * 2) / steps;
                    lastPosition = pos;
                }

                renderer.AddTriangles(triangles);
            }

            //draw quads
            if (GetDrawAreaMode() == DrawAreaModes.Quads)
            {
                //draw background
                {
                    Texture texture = TextureManager.Instance.Load("GUI\\Textures\\NeoAxisLogo.png");
                    renderer.AddQuad(rectangle, new Rect(0, -.3f, 1, 1.4f), texture,
                        new ColorValue(1, 1, 1), true);
                }

                //draw bars
                {
                    float time = EngineApp.Instance.Time;

                    EngineRandom random = new EngineRandom(0);

                    int count = 15;
                    float stepOffset = rectangle.GetSize().X / count;
                    float size = stepOffset * .9f;
                    for (int n = 0; n < count; n++)
                    {
                        float v = MathFunctions.Cos(time * random.NextFloat());
                        float v2 = (v + 1) / 2;

                        ColorValue color = colors[n % colors.Length];
                        Rect rect = new Rect(
                            rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y * v2,
                            rectangle.Left + stepOffset * n + size, rectangle.Bottom);
                        renderer.AddQuad(rect, color);
                    }
                }
            }

            //draw lines
            if (GetDrawAreaMode() == DrawAreaModes.Lines)
            {
                float maxDistance;
                {
                    Vec2 s = rectangle.GetSize() / 2;
                    maxDistance = MathFunctions.Sqrt(s.X * s.X + s.Y * s.Y);
                }

                int step = 0;
                float distance = 0;
                Radian angle = -EngineApp.Instance.Time;
                Vec2 lastPosition = Vec2.Zero;

                while (distance < maxDistance)
                {
                    Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);

                    if (step != 0)
                    {
                        ColorValue color = colors[step % colors.Length];
                        renderer.AddLine(lastPosition, pos, color);
                    }

                    step++;
                    angle += MathFunctions.PI / 10;
                    distance += .001f;
                    lastPosition = pos;
                }
            }

            //draw text
            if (GetDrawAreaMode() == DrawAreaModes.Text)
            {
                string text;

                //draw text with specified font.
                text = "Map Editor is a tool to create worlds for your project. The tool is a complex editor to manage " +
                    "objects on the map.";
                renderer.AddTextWordWrap(drawAreaBigFont, text, rectangle, HorizontalAlign.Left, false, VerticalAlign.Top, 0,
                    new ColorValue(1, 1, 1));

                //draw text with word wrap.
                text = "Deployment Tool is a tool to deploy the final version of your application to specified platforms. " +
                    "This utility is useful to automate the final product's creation.";
                renderer.AddTextWordWrap(drawAreaSmallFont, text, rectangle, HorizontalAlign.Right, false, VerticalAlign.Bottom, 0,
                    new ColorValue(1, 1, 0));
            }

            if (clipRectangle)
                renderer.PopClipRectangle();
        }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:101,代码来源:GUISamples1Window.cs


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