/// <inheritdoc/> public void Point(Color color, Vector vector) { var r = GetColorValue(color.R); var g = GetColorValue(color.G); var b = GetColorValue(color.B); float x = (float)vector.X, y = 200f - (float)vector.Y; _pointBuffer.Triangle(0, 1, 2); _pointBuffer.Triangle(0, 2, 3); WriteVector(_pointBuffer, x - _lineRadius, y - _lineRadius); _pointBuffer.VertexFloat(-1, -1); _pointBuffer.VertexByte(r, g, b); _pointBuffer.EndVertex(); WriteVector(_pointBuffer, x + _lineRadius, y - _lineRadius); _pointBuffer.VertexFloat(1, -1); _pointBuffer.VertexByte(r, g, b); _pointBuffer.EndVertex(); WriteVector(_pointBuffer, x + _lineRadius, y + _lineRadius); _pointBuffer.VertexFloat(1, 1); _pointBuffer.VertexByte(r, g, b); _pointBuffer.EndVertex(); WriteVector(_pointBuffer, x - _lineRadius, y + _lineRadius); _pointBuffer.VertexFloat(-1, 1); _pointBuffer.VertexByte(r, g, b); _pointBuffer.EndVertex(); }
/// <inheritdoc/> public void Line(Color color, Vector begin, Vector end) { var r = GetColorValue(color.R); var g = GetColorValue(color.G); var b = GetColorValue(color.B); float ax = (float)begin.X, ay = 200f - (float)begin.Y, bx = (float)end.X, by = 200f - (float)end.Y; var vx = bx - ax; float vy = by - ay; var vectorLength = (float)Math.Sqrt(vx * vx + vy * vy); float vf = _lineRadius / vectorLength; vx *= vf; vy *= vf; float lineLength = vectorLength / _lineRadius; _lineBuffer.Triangle(0, 1, 3); _lineBuffer.Triangle(1, 2, 3); WriteVector(_lineBuffer, ax - vx - vy, ay - vy + vx); _lineBuffer.VertexFloat(-1, 1); _lineBuffer.VertexFloat(lineLength); _lineBuffer.VertexByte(r, g, b); _lineBuffer.EndVertex(); WriteVector(_lineBuffer, ax - vx + vy, ay - vy - vx); _lineBuffer.VertexFloat(-1, -1); _lineBuffer.VertexFloat(lineLength); _lineBuffer.VertexByte(r, g, b); _lineBuffer.EndVertex(); WriteVector(_lineBuffer, bx + vx + vy, by + vy - vx); _lineBuffer.VertexFloat(lineLength + 1, -1); _lineBuffer.VertexFloat(lineLength); _lineBuffer.VertexByte(r, g, b); _lineBuffer.EndVertex(); WriteVector(_lineBuffer, bx + vx - vy, by + vy + vx); _lineBuffer.VertexFloat(lineLength + 1, 1); _lineBuffer.VertexFloat(lineLength); _lineBuffer.VertexByte(r, g, b); _lineBuffer.EndVertex(); }
private void DrawEntity(TriangleBuffer buffer, float x, float y, float z, float xRadius, float height) { var textureEntry = _textureAtlas.GetTextureEntry(0); buffer.Triangle(0, 1, 3); buffer.Triangle(3, 1, 2); buffer.VertexFloat(x - xRadius, y, z + xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y0); buffer.VertexByte(217, 217, 217, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y, z + xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y0); buffer.VertexByte(217, 217, 217, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y + height, z + xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y1); buffer.VertexByte(217, 217, 217, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y + height, z + xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y1); buffer.VertexByte(217, 217, 217, 0); buffer.EndVertex(); buffer.Triangle(0, 1, 3); buffer.Triangle(3, 1, 2); buffer.VertexFloat(x + xRadius, y, z + xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y, z - xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y + height, z - xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y + height, z + xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.Triangle(0, 1, 3); buffer.Triangle(3, 1, 2); buffer.VertexFloat(x + xRadius, y, z - xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y, z - xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y + height, z - xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y + height, z - xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.Triangle(0, 1, 3); buffer.Triangle(3, 1, 2); buffer.VertexFloat(x - xRadius, y, z - xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y, z + xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y + height, z + xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y + height, z - xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.Triangle(0, 1, 3); buffer.Triangle(3, 1, 2); buffer.VertexFloat(x - xRadius, y, z + xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y, z - xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y0); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y, z - xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y, z + xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y1); buffer.VertexByte(178, 204, 230, 0); buffer.EndVertex(); buffer.Triangle(0, 1, 3); buffer.Triangle(3, 1, 2); buffer.VertexFloat(x - xRadius, y + height, z + xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y0); buffer.VertexByte(255, 255, 255, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y + height, z + xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y0); buffer.VertexByte(255, 255, 255, 0); buffer.EndVertex(); buffer.VertexFloat(x + xRadius, y + height, z - xRadius); buffer.VertexUInt16(textureEntry.X1, textureEntry.Y1); buffer.VertexByte(255, 255, 255, 0); buffer.EndVertex(); buffer.VertexFloat(x - xRadius, y + height, z - xRadius); buffer.VertexUInt16(textureEntry.X0, textureEntry.Y1); buffer.VertexByte(255, 255, 255, 0); buffer.EndVertex(); }
public static void VertexColorBytes(this TriangleBuffer buffer, float r, float g, float b, float a) { buffer.VertexByte(GetColorByte(r), GetColorByte(g), GetColorByte(b), GetColorByte(a)); }