/// <summary> /// Creates a <see cref="VertexNormalColorTexture"/> with the specified position, normal, color and texture coordinates. /// </summary> public VertexNormalColorTexture(Vector3 position, Vector3 normal, Color4b color, Vector2 texCoords) { Position = position; Normal = normal; Color = color; TexCoords = texCoords; }
/// <summary> /// Calculates and sets all the values in this <see cref="TextureBatchItem"/> except for <see cref="SortValue"/>. /// </summary> public void SetValue(Texture2D texture, Vector2 position, Rectangle?source, Color4b color, Vector2 scale, float rotation, Vector2 origin, float depth) { Texture = texture; Rectangle sourceRect = source ?? new Rectangle(0, 0, (int)texture.Width, (int)texture.Height); Vector2 tl = -origin * scale; Vector2 tr = new Vector2(tl.X + sourceRect.Width * scale.X, tl.Y); Vector2 bl = new Vector2(tl.X, tl.Y + sourceRect.Height * scale.Y); Vector2 br = new Vector2(tr.X, bl.Y); float sin = MathF.Sin(rotation); float cos = MathF.Cos(rotation); VertexTL.Position = new Vector3(cos * tl.X - sin * tl.Y + position.X, sin * tl.X + cos * tl.Y + position.Y, depth); VertexTR.Position = new Vector3(cos * tr.X - sin * tr.Y + position.X, sin * tr.X + cos * tr.Y + position.Y, depth); VertexBL.Position = new Vector3(cos * bl.X - sin * bl.Y + position.X, sin * bl.X + cos * bl.Y + position.Y, depth); VertexBR.Position = new Vector3(cos * br.X - sin * br.Y + position.X, sin * br.X + cos * br.Y + position.Y, depth); VertexTL.TexCoords = new Vector2(sourceRect.X / (float)texture.Width, sourceRect.Y / (float)texture.Height); VertexBR.TexCoords = new Vector2(sourceRect.Right / (float)texture.Width, sourceRect.Bottom / (float)texture.Height); VertexTR.TexCoords = new Vector2(VertexBR.TexCoords.X, VertexTL.TexCoords.Y); VertexBL.TexCoords = new Vector2(VertexTL.TexCoords.X, VertexBR.TexCoords.Y); VertexTL.Color = color; VertexTR.Color = color; VertexBL.Color = color; VertexBR.Color = color; }
/// <summary> /// Calculates and sets all the values on this <see cref="TextureBatchItem"/> except for <see cref="SortValue"/> /// without calculating rotation nor scale. /// </summary> public void SetValue(Texture2D texture, Vector2 position, Rectangle source, Color4b color, float depth) { Texture = texture; VertexTL.Position = new Vector3(position, depth); VertexTR.Position = new Vector3(position.X + source.Width, position.Y, depth); VertexBL.Position = new Vector3(position.X, position.Y + source.Height, depth); VertexBR.Position = new Vector3(position + new Vector2(source.Width, source.Height), depth); VertexTL.TexCoords = new Vector2(source.X / (float)texture.Width, source.Y / (float)texture.Height); VertexBR.TexCoords = new Vector2(source.Right / (float)texture.Width, source.Bottom / (float)texture.Height); VertexTR.TexCoords = new Vector2(VertexBR.TexCoords.X, VertexTL.TexCoords.Y); VertexBL.TexCoords = new Vector2(VertexTL.TexCoords.X, VertexBR.TexCoords.Y); VertexTL.Color = color; VertexTR.Color = color; VertexBL.Color = color; VertexBR.Color = color; }
/// <summary> /// Calculates and sets all the values in this <see cref="TextureBatchItem"/> except for <see cref="SortValue"/>. /// </summary> public void SetValue(Texture2D texture, Vector2 position, Rectangle source, Color4b color, Vector2 scale, float sin, float cos, float depth) { Texture = texture; Vector2 size = new Vector2(source.Width, source.Height) * scale; VertexTL.Position = new Vector3(position.X, position.Y, depth); VertexTR.Position = new Vector3(cos * size.X + position.X, sin * size.X + position.Y, depth); VertexBL.Position = new Vector3(-sin * size.Y + position.X, cos * size.Y + position.Y, depth); VertexBR.Position = new Vector3(cos * size.X - sin * size.Y + position.X, sin * size.X + cos * size.Y + position.Y, depth); VertexTL.TexCoords = new Vector2(source.X / (float)texture.Width, source.Y / (float)texture.Height); VertexBR.TexCoords = new Vector2(source.Right / (float)texture.Width, source.Bottom / (float)texture.Height); VertexTR.TexCoords = new Vector2(VertexBR.TexCoords.X, VertexTL.TexCoords.Y); VertexBL.TexCoords = new Vector2(VertexTL.TexCoords.X, VertexBR.TexCoords.Y); VertexTL.Color = color; VertexTR.Color = color; VertexBL.Color = color; VertexBR.Color = color; }
/// <summary> /// Calculates and sets all the values in this <see cref="TextureBatchItem"/> except for <see cref="SortValue"/> /// without calculating rotation. /// </summary> public void SetValue(Texture2D texture, Vector2 position, Rectangle?source, Color4b color, Vector2 scale, Vector2 origin, float depth) { Texture = texture; Rectangle sourceRect = source ?? new Rectangle(0, 0, (int)texture.Width, (int)texture.Height); Vector2 tl = position - origin * scale; Vector2 br = tl + new Vector2(sourceRect.Width, sourceRect.Height) * scale; VertexTL.Position = new Vector3(tl, depth); VertexTR.Position = new Vector3(br.X, tl.Y, depth); VertexBL.Position = new Vector3(tl.X, br.Y, depth); VertexBR.Position = new Vector3(br, depth); VertexTL.TexCoords = new Vector2(sourceRect.X / (float)texture.Width, sourceRect.Y / (float)texture.Height); VertexBR.TexCoords = new Vector2(sourceRect.Right / (float)texture.Width, sourceRect.Bottom / (float)texture.Height); VertexTR.TexCoords = new Vector2(VertexBR.TexCoords.X, VertexTL.TexCoords.Y); VertexBL.TexCoords = new Vector2(VertexTL.TexCoords.X, VertexBR.TexCoords.Y); VertexTL.Color = color; VertexTR.Color = color; VertexBL.Color = color; VertexBR.Color = color; }
/// <summary> /// Creates a <see cref="VertexNormalColor"/> with the specified position, normal and color. /// </summary> public VertexNormalColor(Vector3 position, Vector3 normal, Color4b color) { Position = position; Normal = normal; Color = color; }
/// <summary> /// Creates a <see cref="VertexColorTexture"/> with the specified position and texture coordinates, and white color. /// </summary> public VertexColorTexture(Vector3 position, Vector2 texCoords) { Position = position; Color = new Color4b(255, 255, 255, 255); TexCoords = texCoords; }
/// <summary> /// Creates a <see cref="VertexColorTexture"/> with the specified position, color and texture coordinates. /// </summary> public VertexColorTexture(Vector3 position, Color4b color, Vector2 texCoords) { Position = position; Color = color; TexCoords = texCoords; }
/// <summary> /// Creates a <see cref="VertexColor"/> with the specified position and white color. /// </summary> public VertexColor(Vector3 position) { Position = position; Color = new Color4b(255, 255, 255, 255); }
/// <summary> /// Creates a <see cref="VertexColor"/> with the specified position and color. /// </summary> public VertexColor(Vector3 position, Color4b color) { Position = position; Color = color; }