void DrawTrianglesAndLines(GuiRenderer renderer) { List <GuiRenderer.TriangleVertex> vertices = new List <GuiRenderer.TriangleVertex>(32); Vec2 center = new Vec2(.7f, .4f); float radius = .1f; float step = MathFunctions.PI * 2 / 16; Vec2 lastPoint = Vec2.Zero; for (float angle = 0; angle <= MathFunctions.PI * 2 + step * .5f; angle += step) { Vec2 point = center + new Vec2( MathFunctions.Cos(angle) * radius / renderer.AspectRatio, MathFunctions.Sin(angle) * radius); if (angle != 0) { vertices.Add(new GuiRenderer.TriangleVertex(center, new ColorValue(1, 0, 0))); vertices.Add(new GuiRenderer.TriangleVertex(lastPoint, new ColorValue(0, 1, 0))); vertices.Add(new GuiRenderer.TriangleVertex(point, new ColorValue(0, 1, 0))); } lastPoint = point; } renderer.AddTriangles(vertices); Rect rect = new Rect( center.X - radius / renderer.AspectRatio, center.Y - radius, center.X + radius / renderer.AspectRatio, center.Y + radius); renderer.AddRectangle(rect, new ColorValue(1, 1, 0)); }
void Draw2DRectangles(GuiRenderer renderer) { Rect rect = new Rect(.01f, .9f, .25f, .99f); renderer.AddQuad(rect, new ColorValue(.5f, .5f, .5f, .5f)); Rect rect2 = rect; rect2.Expand(new Vec2(.005f / renderer.AspectRatio, .005f)); renderer.AddRectangle(rect2, new ColorValue(1, 1, 0)); AddTextWithShadow(renderer, fontMedium, "2D GUI Drawing", rect.GetCenter(), HorizontalAlign.Center, VerticalAlign.Center, new ColorValue(1, 1, 1)); }
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)); } } }
void Draw2DRectangles( GuiRenderer renderer ) { Rect rect = new Rect( .01f, .9f, .25f, .99f ); renderer.AddQuad( rect, new ColorValue( .5f, .5f, .5f, .5f ) ); Rect rect2 = rect; rect2.Expand( new Vec2( .005f / renderer.AspectRatio, .005f ) ); renderer.AddRectangle( rect2, new ColorValue( 1, 1, 0 ) ); AddTextWithShadow( renderer, fontMedium, "2D GUI Drawing", rect.GetCenter(), HorizontalAlign.Center, VerticalAlign.Center, new ColorValue( 1, 1, 1 ) ); }
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)); } } }
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)); }