using Robust.Shared.Maths;
namespace Robust.Client.Graphics
{
public abstract class DrawingHandleWorld : DrawingHandleBase
{
private const int Ppm = EyeManager.PixelsPerMeter;
///
/// Draws an untextured colored rectangle to the world.The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// The four vertices of the quad in object space (or world if the transform is identity.).
/// Color of the rectangle.
/// Is it filled with color, or just the border lines?
public abstract void DrawRect(Box2 rect, Color color, bool filled = true);
///
/// Draws an untextured colored rectangle to the world.The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// The four vertices of the quad in object space (or world if the transform is identity.).
/// The rotation of the rectangle is applied before the transform matrix.
/// Color of the rectangle.
/// Is it filled with color, or just the border lines?
public abstract void DrawRect(in Box2Rotated rect, Color color, bool filled = true);
///
/// Draws a sprite to the world. The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// Texture to draw.
/// The four vertices of the quad in object space (or world if the transform is identity.).
/// A color to multiply the texture by when shading.
/// The four corners of the texture sub region in px.
public abstract void DrawTextureRectRegion(Texture texture, Box2 quad,
Color? modulate = null, UIBox2? subRegion = null);
///
/// Draws a sprite to the world. The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// Texture to draw.
/// The four vertices of the quad in object space (or world if the transform is identity.).
/// The rotation of the rectangle is applied before the transform matrix.
/// A color to multiply the texture by when shading.
/// The four corners of the texture sub region in px.
public abstract void DrawTextureRectRegion(Texture texture, in Box2Rotated quad,
Color? modulate = null, UIBox2? subRegion = null);
private Box2 GetQuad(Texture texture, Vector2 position)
{
return Box2.FromDimensions(position, texture.Size / (float)Ppm);
}
///
/// Draws a full texture sprite to the world. The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// Texture to draw.
/// The coordinates of the quad in object space (or world if the transform is identity.).
/// A color to multiply the texture by when shading.
///
/// The sprite will have it's local dimensions calculated so that it has texels per meter in the world.
///
public void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
{
CheckDisposed();
DrawTextureRect(texture, GetQuad(texture, position), modulate);
}
///
/// Draws a full texture sprite to the world. The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// Texture to draw.
/// The coordinates of the quad in object space (or world if the transform is identity.).
/// The angle of the quad in object space.
/// A color to multiply the texture by when shading.
///
/// The sprite will have it's local dimensions calculated so that it has texels per meter in the world.
///
public void DrawTexture(Texture texture, Vector2 position, Angle angle, Color? modulate = null)
{
CheckDisposed();
var quad = GetQuad(texture, position);
DrawTextureRect(texture, new Box2Rotated(quad, angle, quad.Center), modulate);
}
///
/// Draws a full texture sprite to the world. The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// Texture to draw.
/// The four vertices of the quad in object space (or world if the transform is identity.).
/// A color to multiply the texture by when shading.
public void DrawTextureRect(Texture texture, Box2 quad, Color? modulate = null)
{
CheckDisposed();
DrawTextureRectRegion(texture, quad, modulate);
}
///
/// Draws a full texture sprite to the world. The coordinate system is right handed.
/// Make sure to set
/// to set the model matrix if needed.
///
/// Texture to draw.
/// The four vertices of the quad in object space (or world if the transform is identity.).
/// The rotation of the rectangle is applied before the transform matrix.
/// A color to multiply the texture by when shading.
public void DrawTextureRect(Texture texture, in Box2Rotated quad, Color? modulate = null)
{
CheckDisposed();
DrawTextureRectRegion(texture, in quad, modulate);
}
}
}