Rectangle mesh texture bounds can now be changed.
This commit is contained in:
parent
4b1e57ac72
commit
75f691133a
@ -11,6 +11,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
|||||||
private bool changed;
|
private bool changed;
|
||||||
private Vector3 rotation;
|
private Vector3 rotation;
|
||||||
private Vector2 origin, dimensions;
|
private Vector2 origin, dimensions;
|
||||||
|
private RectangleF textureBounds;
|
||||||
private ValueTuple<Vector3, Vector2>[] vertices;
|
private ValueTuple<Vector3, Vector2>[] vertices;
|
||||||
private uint[] indices;
|
private uint[] indices;
|
||||||
|
|
||||||
@ -90,6 +91,30 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RectangleF TextureBounds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return textureBounds;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.vertices[0].Item2.X = value.X;
|
||||||
|
this.vertices[0].Item2.Y = value.Y;
|
||||||
|
|
||||||
|
this.vertices[1].Item2.X = value.X + value.Width;
|
||||||
|
this.vertices[1].Item2.Y = value.Y;
|
||||||
|
|
||||||
|
this.vertices[2].Item2.X = value.X + value.Width;
|
||||||
|
this.vertices[2].Item2.Y = value.Y + value.Height;
|
||||||
|
|
||||||
|
this.vertices[3].Item2.X = value.X;
|
||||||
|
this.vertices[3].Item2.Y = value.Y + value.Height;
|
||||||
|
|
||||||
|
this.textureBounds = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public uint[] Elements { get {return indices; } }
|
public uint[] Elements { get {return indices; } }
|
||||||
|
|
||||||
public Vector3 Rotation
|
public Vector3 Rotation
|
||||||
@ -111,8 +136,8 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
|||||||
|
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
|
|
||||||
public RectangleMesh(RectangleF textureRegion, ITexture texture, Color color)
|
|
||||||
{
|
public RectangleMesh(RectangleF meshBounds, ITexture texture, Color color) {
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
this.rotation = Vector3.Zero;
|
this.rotation = Vector3.Zero;
|
||||||
this.origin = Vector2.Zero;
|
this.origin = Vector2.Zero;
|
||||||
@ -121,32 +146,21 @@ namespace SlatedGameToolkit.Framework.Graphics.Render
|
|||||||
this.Color = color;
|
this.Color = color;
|
||||||
this.indices = new uint[] {0, 1, 3, 1, 2, 3};
|
this.indices = new uint[] {0, 1, 3, 1, 2, 3};
|
||||||
vertices = new ValueTuple<Vector3, Vector2>[4];
|
vertices = new ValueTuple<Vector3, Vector2>[4];
|
||||||
|
this.textureBounds = new RectangleF(0, 0, 1, 1);
|
||||||
this.vertices[0].Item2.X = textureRegion.X;
|
|
||||||
this.vertices[0].Item2.Y = textureRegion.Y;
|
|
||||||
|
|
||||||
this.vertices[1].Item2.X = textureRegion.X + textureRegion.Width;
|
|
||||||
this.vertices[1].Item2.Y = textureRegion.Y;
|
|
||||||
|
|
||||||
this.vertices[2].Item2.X = textureRegion.X + textureRegion.Width;
|
|
||||||
this.vertices[2].Item2.Y = textureRegion.Y + textureRegion.Height;
|
|
||||||
|
|
||||||
this.vertices[3].Item2.X = textureRegion.X;
|
|
||||||
this.vertices[3].Item2.Y = textureRegion.Y + textureRegion.Height;
|
|
||||||
|
|
||||||
this.matRot = Matrix4x4.Identity;
|
this.matRot = Matrix4x4.Identity;
|
||||||
|
|
||||||
|
this.TextureBounds = textureBounds;
|
||||||
}
|
|
||||||
|
|
||||||
public RectangleMesh(RectangleF meshBounds, RectangleF textureRegion, ITexture texture, Color color) : this(textureRegion, texture, color) {
|
|
||||||
this.Bounds = meshBounds;
|
this.Bounds = meshBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RectangleMesh(ITexture texture, Color color) : this(new Rectangle(0, 0, 1, 1), texture, color) {
|
public RectangleMesh(ITexture texture, Color color) : this(new RectangleF(0,0,0,0), texture, color)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RectangleMesh(RectangleF meshBounds, RectangleF textureRegion, ITexture texture, Color color) : this(meshBounds, texture, color) {
|
||||||
|
this.TextureBounds = textureRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void CalculateVertices() {
|
private void CalculateVertices() {
|
||||||
|
Loading…
Reference in New Issue
Block a user