private void Line2D3D(Line2D3DCommand command, FlatBufferBuilder builder, List <Offset <RenderMessage> > messages) { //FlatBuffer doesn't like nesting "create" commands within each other so declare them early instead (vectors are immune for some reason) var color = command.Color.ToFlatBuffer(builder); RenderMessage.StartRenderMessage(builder); RenderMessage.AddRenderType(builder, RenderType.DrawLine2D_3D); RenderMessage.AddColor(builder, color); RenderMessage.AddStart(builder, command.Start.ToFlatBuffer(builder)); RenderMessage.AddEnd(builder, command.End.ToFlatBuffer(builder)); messages.Add(RenderMessage.EndRenderMessage(builder)); }
/// <summary> /// Draws a line in screen space. /// </summary> /// <param name="color">The color of the line.</param> /// <param name="start">The start point of the line.</param> /// <param name="end">The end point of the line.</param> public void DrawLine2D(Color color, Vector2 start, Vector2 end) { var colorOffset = color.ToOffsetColor(Builder); RenderMessage.StartRenderMessage(Builder); RenderMessage.AddRenderType(Builder, RenderType.DrawLine2D); RenderMessage.AddColor(Builder, colorOffset); RenderMessage.AddStart(Builder, start.ToOffsetVector(Builder)); RenderMessage.AddEnd(Builder, end.ToOffsetVector(Builder)); var finalOffset = RenderMessage.EndRenderMessage(Builder); _renderMessageOffsets.Add(finalOffset); }
private void Rectangle3D(Rectangle3DCommand command, FlatBufferBuilder builder, List <Offset <RenderMessage> > messages) { //FlatBuffer doesn't like nesting "create" commands within each other so declare them early instead (vectors are immune for some reason) var color = command.Color.ToFlatBuffer(builder); RenderMessage.StartRenderMessage(builder); RenderMessage.AddRenderType(builder, command.Centered ? RenderType.DrawCenteredRect3D : RenderType.DrawRect3D); RenderMessage.AddColor(builder, color); RenderMessage.AddStart(builder, command.Position.ToFlatBuffer(builder)); RenderMessage.AddScaleX(builder, command.Width); RenderMessage.AddScaleY(builder, command.Height); RenderMessage.AddIsFilled(builder, command.Filled); messages.Add(RenderMessage.EndRenderMessage(builder)); }
private void DrawRect3D(Color color, Vector3 position, int width, int height, bool filled, bool centered) { var colorOffset = color.ToOffsetColor(Builder); RenderMessage.StartRenderMessage(Builder); RenderMessage.AddRenderType(Builder, centered ? RenderType.DrawCenteredRect3D : RenderType.DrawRect3D); RenderMessage.AddColor(Builder, colorOffset); RenderMessage.AddStart(Builder, position.ToOffsetVector(Builder)); RenderMessage.AddScaleX(Builder, width); RenderMessage.AddScaleY(Builder, height); RenderMessage.AddIsFilled(Builder, filled); var finalOffset = RenderMessage.EndRenderMessage(Builder); _renderMessageOffsets.Add(finalOffset); }
/// <summary> /// Draws a 2D rectangle in screen space. /// </summary> /// <param name="color">The color of the rectangle.</param> /// <param name="upperLeft">The upper left corner of the rectangle.</param> /// <param name="width">The width in pixels.</param> /// <param name="height">The height in pixels</param> /// <param name="filled">Flag indicating whether the rectangle should be filled in</param> public void DrawRectangle2D(Color color, Vector2 upperLeft, int width, int height, bool filled) { var colorOffset = color.ToOffsetColor(Builder); RenderMessage.StartRenderMessage(Builder); RenderMessage.AddRenderType(Builder, RenderType.DrawRect2D); RenderMessage.AddColor(Builder, colorOffset); RenderMessage.AddStart(Builder, upperLeft.ToOffsetVector(Builder)); RenderMessage.AddScaleX(Builder, width); RenderMessage.AddScaleY(Builder, height); RenderMessage.AddIsFilled(Builder, filled); var finalOffset = RenderMessage.EndRenderMessage(Builder); _renderMessageOffsets.Add(finalOffset); }
private void String3D(String3DCommand command, FlatBufferBuilder builder, List <Offset <RenderMessage> > messages) { //FlatBuffer doesn't like nesting "create" commands within each other so declare them early instead (vectors are immune for some reason) var color = command.Color.ToFlatBuffer(builder); var text = builder.CreateString(command.Text); RenderMessage.StartRenderMessage(builder); RenderMessage.AddRenderType(builder, RenderType.DrawString3D); RenderMessage.AddColor(builder, color); RenderMessage.AddStart(builder, command.UpperLeft.ToFlatBuffer(builder)); RenderMessage.AddScaleX(builder, command.ScaleX); RenderMessage.AddScaleY(builder, command.ScaleY); RenderMessage.AddText(builder, text); messages.Add(RenderMessage.EndRenderMessage(builder)); }
/// <summary> /// Draws text in 2D, but the upper-left corner is at a 3D-tracked position in world space. /// </summary> /// <param name="text">The text to draw.</param> /// <param name="color">The color of the string.</param> /// <param name="upperLeft">The location of the upper left corner of the text.</param> /// <param name="scaleX">The multiplier for the width of the text.</param> /// <param name="scaleY">The multiplier for the height of the text</param> public void DrawString3D(String text, Color color, Vector3 upperLeft, int scaleX, int scaleY) { var colorOffset = color.ToOffsetColor(Builder); var textOffset = Builder.CreateString(text); RenderMessage.StartRenderMessage(Builder); RenderMessage.AddRenderType(Builder, RenderType.DrawString3D); RenderMessage.AddColor(Builder, colorOffset); RenderMessage.AddStart(Builder, upperLeft.ToOffsetVector(Builder)); RenderMessage.AddScaleX(Builder, scaleX); RenderMessage.AddScaleY(Builder, scaleY); RenderMessage.AddText(Builder, textOffset); var finalOffset = RenderMessage.EndRenderMessage(Builder); _renderMessageOffsets.Add(finalOffset); }
private void PolyLine3D(PolyLine3DCommand command, FlatBufferBuilder builder, List <Offset <RenderMessage> > messages) { //FlatBuffer doesn't like nesting "create" commands within each other so declare them early instead (vectors are immune for some reason) var color = command.Color.ToFlatBuffer(builder); var vectors = command.Vectors.ToArray(); for (int i = 0, l = command.Vectors.Count() - 1; i < l; i++) { RenderMessage.StartRenderMessage(builder); RenderMessage.AddRenderType(builder, RenderType.DrawLine3D); RenderMessage.AddColor(builder, color); RenderMessage.AddStart(builder, vectors[i].ToFlatBuffer(builder)); RenderMessage.AddEnd(builder, vectors[i + 1].ToFlatBuffer(builder)); messages.Add(RenderMessage.EndRenderMessage(builder)); } }
/// <summary> /// Draws a line joined by several points in world space. /// </summary> /// <param name="color">The color of the line.</param> /// <param name="vectors">The vectors of the line.</param> public void DrawPolyLine3D(Color color, Vector3[] vectors) { if (vectors.Length < 2) { throw new ArgumentException("DrawPolyLine3D: vectors array must contain at least 2 vectors!"); } var colorOffset = color.ToOffsetColor(Builder); for (int i = 0; i < vectors.Length - 1; i++) { RenderMessage.StartRenderMessage(Builder); RenderMessage.AddRenderType(Builder, RenderType.DrawLine3D); RenderMessage.AddColor(Builder, colorOffset); RenderMessage.AddStart(Builder, vectors[i].ToOffsetVector(Builder)); RenderMessage.AddEnd(Builder, vectors[i + 1].ToOffsetVector(Builder)); var finalOffset = RenderMessage.EndRenderMessage(Builder); _renderMessageOffsets.Add(finalOffset); } }