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


C# GuiRenderer.AddTriangles方法代码示例

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


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

示例1: RotateGuiControl

        void RotateGuiControl(EControl sender, float alpha, Texture guiTexture, GuiRenderer renderer)
        {
            Rect controlRect = sender.GetScreenRectangle();
            Rect screenMapRect = sender.GetScreenRectangle();
            Vec2 size = controlRect.GetSize();
            float angle = MathFunctions.DegToRad(alpha);
            float smallRadius = 0.03f;
            float bigRadius = 0.8f;
            float width = 0.15f;

            Vec2 U = new Vec2(+(float)Math.Cos(angle), +(float)Math.Sin(angle));
            Vec2 V = new Vec2(-(float)Math.Sin(angle), +(float)Math.Cos(angle));
            Vec2 P1 = bigRadius * U + V * width / 2;
            Vec2 P2 = bigRadius * U - V * width / 2;
            Vec2 P3 = smallRadius * U + V * width / 2;
            Vec2 P4 = smallRadius * U - V * width / 2;

            float X1 = Vec2.Dot(P1, Vec2.XAxis);
            float Y1 = Vec2.Dot(P1, Vec2.YAxis);
            float X2 = Vec2.Dot(P2, Vec2.XAxis);
            float Y2 = Vec2.Dot(P2, Vec2.YAxis);
            float X3 = Vec2.Dot(P3, Vec2.XAxis);
            float Y3 = Vec2.Dot(P3, Vec2.YAxis);
            float X4 = Vec2.Dot(P4, Vec2.XAxis);
            float Y4 = Vec2.Dot(P4, Vec2.YAxis);

            X1 = controlRect.Left + (X1 + 1) / 2 * size.X ;
            Y1 = controlRect.Top + (Y1 + 1) / 2 * size.Y ;
            X2 = controlRect.Left + (X2 + 1) / 2 * size.X;
            Y2 = controlRect.Top + (Y2 + 1) / 2 * size.Y ;
            X3 = controlRect.Left + (X3 + 1) / 2 * size.X;
            Y3 = controlRect.Top + (Y3 + 1) / 2 * size.Y ;
            X4 = controlRect.Left + (X4 + 1) / 2 * size.X;
            Y4 = controlRect.Top + (Y4 + 1) / 2 * size.Y ;

            List<GuiRenderer.TriangleVertex> vert = new List<GuiRenderer.TriangleVertex>(6);
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X1, Y1), new ColorValue(1, 1, 1, 1), new Vec2(0, 0)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X2, Y2), new ColorValue(1, 1, 1, 1), new Vec2(1, 0)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X4, Y4), new ColorValue(1, 1, 1, 1), new Vec2(0, 1)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X3, Y3), new ColorValue(1, 1, 1, 1), new Vec2(1, 1)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X4, Y4), new ColorValue(1, 1, 1, 1), new Vec2(0, 1)));
            vert.Add(new GuiRenderer.TriangleVertex(new Vec2(X2, Y2), new ColorValue(1, 1, 1, 1), new Vec2(1, 0)));
            renderer.AddTriangles(vert, guiTexture, false);
        }
开发者ID:huytd,项目名称:fosproject,代码行数:44,代码来源:VHFOSGameWindows.cs

示例2: DrawArea_RenderUI

        private void DrawArea_RenderUI(Control sender, GuiRenderer renderer)
        {
            Rect rectangle = sender.GetScreenRectangle();
            bool clipRectangle = true;
            ColorValue[] colors = new ColorValue[]{
				new ColorValue( 1 ,0, 0 ),
				new ColorValue( 0, 1, 0 ),
				new ColorValue( 0, 0, 1 ),
				new ColorValue( 1, 1, 0 ),
				new ColorValue( 1, 1, 1 )};

            if (clipRectangle)
                renderer.PushClipRectangle(rectangle);

            //draw triangles
            if (GetDrawAreaMode() == DrawAreaModes.Triangles)
            {
                float distance = rectangle.GetSize().X / 2;

                List<GuiRenderer.TriangleVertex> triangles = new List<GuiRenderer.TriangleVertex>(256);

                Radian angle = -EngineApp.Instance.Time;

                const int steps = 30;
                Vec2 lastPosition = Vec2.Zero;
                for (int step = 0; step < steps + 1; step++)
                {
                    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];
                        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)
//.........这里部分代码省略.........
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:101,代码来源:GUISamples1Window.cs

示例3: DrawArea_RenderUI

        void DrawArea_RenderUI( Control sender, GuiRenderer renderer )
        {
            Rect rectangle = sender.GetScreenRectangle();
            bool clipRectangle = true;
            ColorValue[] colors = new ColorValue[]{
                new ColorValue( 1 ,0, 0 ),
                new ColorValue( 0, 1, 0 ),
                new ColorValue( 0, 0, 1 ),
                new ColorValue( 1, 1, 0 ),
                new ColorValue( 1, 1, 1 )};

            if( clipRectangle )
                renderer.PushClipRectangle( rectangle );

            //draw triangles
            if( GetDrawAreaMode() == DrawAreaModes.Triangles )
            {
                float distance = rectangle.GetSize().X / 2;

                List<GuiRenderer.TriangleVertex> triangles = new List<GuiRenderer.TriangleVertex>( 256 );

                Radian angle = -EngineApp.Instance.Time;

                const int steps = 30;
                Vec2 lastPosition = Vec2.Zero;
                for( int step = 0; step < steps + 1; step++ )
                {
                    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 ];
                        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 )
//.........这里部分代码省略.........
开发者ID:Eneth,项目名称:GAO,代码行数:101,代码来源:GuiTestWindow.cs

示例4: OnRenderUI

		protected override void OnRenderUI(GuiRenderer renderer)
		{
			Rect r = new Rect();
			var pos = this.GetScreenPosition();
			var sz = this.GetScreenSize();
			r.Left = pos.X;
			r.Right = r.Left + sz.X;
			r.Top = pos.Y;
			r.Bottom = r.Top + sz.Y;
			if (mBorderRadius.Value != Vec2.Zero)
			{
#if DebugDraw
				ColorValue debugColor = new ColorValue(0f, 1f, 0f, .5f);
				ColorValue debugColor2 = new ColorValue(0f, 0f, 1f, .5f);
#endif

				Vec2 screenRelRad = this.ScreenFromValue(mBorderRadius);

				// By using clipping and a set of 3 rectangles, we ensure that each point
				// on the screen is only drawn once, thus allowing the alpha value to be
				// used in the color without it looking weird.

				// Top-Left
#if DebugDraw
				renderer.AddCircle(r.LeftTop + screenRelRad, debugColor, screenRelRad, (float)Math.PI, (float)(Math.PI * 1.5f));
#else
				renderer.AddCircle(r.LeftTop + screenRelRad, mColor, screenRelRad, (float)Math.PI, (float)(Math.PI * 1.5f));
#endif

				// Top-Right
#if DebugDraw
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Top + screenRelRad.Y), debugColor, screenRelRad, (float)(Math.PI * 1.5f));
#else
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Top + screenRelRad.Y), mColor, screenRelRad, (float)(Math.PI * 1.5f));
#endif

				// Bottom-Right
#if DebugDraw
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Bottom - screenRelRad.Y), debugColor, screenRelRad, 0f, (float)(Math.PI * 0.5f));
#else
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Bottom - screenRelRad.Y), mColor, screenRelRad, 0f, (float)(Math.PI * 0.5f));
#endif

				// Bottom-Left
#if DebugDraw
				renderer.AddCircle(new Vec2(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y), debugColor, screenRelRad, (float)(Math.PI * 0.5), (float)Math.PI);
#else
				renderer.AddCircle(new Vec2(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y), mColor, screenRelRad, (float)(Math.PI * 0.5), (float)Math.PI);
#endif

				// Middle-Middle
#if DebugDraw
				renderer.AddQuad(new Rect(r.Left, r.Top + screenRelRad.Y, r.Right, r.Bottom - screenRelRad.Y), debugColor2);
#else
				renderer.AddQuad(new Rect(r.Left, r.Top + screenRelRad.Y, r.Right, r.Bottom - screenRelRad.Y), mColor);
#endif
				// Middle-Top
				renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Top, r.Right - screenRelRad.X, r.Top + screenRelRad.Y), mColor);
				// Middle-Bottom
				renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y, r.Right - screenRelRad.X, r.Bottom), mColor);


				if (mBorderWidth.Value != Vec2.Zero)
				{
					Vec2 screenRel = this.ScreenFromValue(mBorderWidth);

					float xHalfWidth = screenRel.X / 2;
					float yHalfWidth = screenRel.Y / 2;
					// Top
					renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Top + yHalfWidth, r.Right - screenRelRad.X, r.Top - yHalfWidth), mBorderColor);
					// Right
					renderer.AddQuad(new Rect(r.Right - xHalfWidth, r.Top + screenRelRad.Y, r.Right + xHalfWidth, r.Bottom - screenRelRad.Y), mBorderColor);
					// Bottom
					renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Bottom - yHalfWidth, r.Right - screenRelRad.X, r.Bottom + yHalfWidth), mBorderColor);
					// Left
					renderer.AddQuad(new Rect(r.Left - xHalfWidth, r.Top + screenRelRad.Y, r.Left + xHalfWidth, r.Bottom - screenRelRad.Y), mBorderColor);

					// Top-Left
					BezierCurve curve = new BezierCurve();
					curve.AddValue(0, new Vec3(r.Left, r.Top + screenRelRad.Y, 0f));
					curve.AddValue(1, new Vec3(r.LeftTop, 0f));
					curve.AddValue(2, new Vec3(r.Left + screenRelRad.X, r.Top, 0f));
					renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));

					// Top-Right
					curve = new BezierCurve();
					curve.AddValue(0, new Vec3(r.Right - screenRelRad.X, r.Top, 0f));
					curve.AddValue(1, new Vec3(r.RightTop, 0f));
					curve.AddValue(2, new Vec3(r.Right, r.Top + screenRelRad.Y, 0f));
					renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));

					// Bottom-Right
					curve = new BezierCurve();
					curve.AddValue(0, new Vec3(r.Right, r.Bottom - screenRelRad.Y, 0f));
					curve.AddValue(1, new Vec3(r.RightBottom, 0f));
					curve.AddValue(2, new Vec3(r.Right - screenRelRad.X, r.Bottom, 0f));
					renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));

					// Bottom-Left
					curve = new BezierCurve();
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:NeoAxis.UI,代码行数:101,代码来源:Rectangle.cs


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