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 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); } }