Added Summeries
This commit is contained in:
parent
71a22df8bd
commit
8296d9b8a9
47 changed files with 812 additions and 177 deletions
|
|
@ -5,15 +5,36 @@ using SM.OGL.Mesh;
|
|||
|
||||
namespace SM2D.Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows different type of lines.
|
||||
/// </summary>
|
||||
public enum PolyLineType
|
||||
{
|
||||
/// <summary>
|
||||
/// Those lines are not connected to each other.
|
||||
/// <para>Every two points starts a new line.</para>
|
||||
/// </summary>
|
||||
NotConnected = 1,
|
||||
/// <summary>
|
||||
/// Those lines are connected with each other, but don't connect the start and the end.
|
||||
/// </summary>
|
||||
Connected = 3,
|
||||
/// <summary>
|
||||
/// Those lines are connected and they connect start and end.
|
||||
/// </summary>
|
||||
ConnectedLoop = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new poly line.
|
||||
/// </summary>
|
||||
public class PolyLine : Polygon, ILineMesh
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new polyline by using <see cref="Vector2"/>.
|
||||
/// </summary>
|
||||
/// <param name="vertices"></param>
|
||||
/// <param name="lineType"></param>
|
||||
public PolyLine(ICollection<Vector2> vertices, PolyLineType lineType = PolyLineType.NotConnected) : base(vertices)
|
||||
{
|
||||
UVs.Active = false;
|
||||
|
|
@ -21,6 +42,11 @@ namespace SM2D.Object
|
|||
PrimitiveType = (PrimitiveType)lineType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new polyline by using <see cref="PolygonVertex"/>.
|
||||
/// </summary>
|
||||
/// <param name="vertices"></param>
|
||||
/// <param name="lineType"></param>
|
||||
public PolyLine(ICollection<PolygonVertex> vertices, PolyLineType lineType = PolyLineType.NotConnected) : base(vertices)
|
||||
{
|
||||
UVs.Active = false;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,27 @@ using SM.OGL.Mesh;
|
|||
|
||||
namespace SM2D.Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a polygon.
|
||||
/// </summary>
|
||||
public class Polygon : Mesh
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override VBO Vertex { get; protected set; } = new VBO();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO UVs { get; protected set; } = new VBO(pointerSize: 2);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO Color { get; protected set; } = new VBO(pointerSize: 4);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override PrimitiveType PrimitiveType { get; protected set; } = PrimitiveType.TriangleFan;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a polygon with <see cref="Vector2"/>s.
|
||||
/// </summary>
|
||||
/// <param name="vertices"></param>
|
||||
public Polygon(ICollection<Vector2> vertices) : base(PrimitiveType.TriangleFan)
|
||||
{
|
||||
Color.Active = false;
|
||||
|
|
@ -27,25 +46,23 @@ namespace SM2D.Object
|
|||
if (UVs.Active) foreach (var vertex in vertices) AddUV(vertex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a polygon with <see cref="PolygonVertex"/>, what allows colors hard coded.
|
||||
/// </summary>
|
||||
/// <param name="vertices"></param>
|
||||
public Polygon(ICollection<PolygonVertex> vertices) : base(PrimitiveType.TriangleFan)
|
||||
{
|
||||
foreach (var polygonVertex in vertices)
|
||||
{
|
||||
Color.Add(polygonVertex.Color);
|
||||
Vertex.Add(polygonVertex.Vertex, 0);
|
||||
Vertex.Add(polygonVertex.Position, 0);
|
||||
}
|
||||
|
||||
UpdateBoundingBox();
|
||||
|
||||
if (UVs.Active) foreach (var vertex in vertices) AddUV(vertex.Vertex);
|
||||
if (UVs.Active) foreach (var vertex in vertices) AddUV(vertex.Position);
|
||||
}
|
||||
|
||||
public override VBO Vertex { get; protected set; } = new VBO();
|
||||
public override VBO UVs { get; protected set; } = new VBO(pointerSize: 2);
|
||||
public override VBO Color { get; protected set; } = new VBO(pointerSize: 4);
|
||||
|
||||
public override PrimitiveType PrimitiveType { get; protected set; } = PrimitiveType.TriangleFan;
|
||||
|
||||
private void AddUV(Vector2 vertex)
|
||||
{
|
||||
var uv = Vector2.Divide(vertex - BoundingBox.Min.Xy, BoundingBox.Max.Xy - BoundingBox.Min.Xy);
|
||||
|
|
@ -53,6 +70,11 @@ namespace SM2D.Object
|
|||
UVs.Add(uv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a circle.
|
||||
/// </summary>
|
||||
/// <param name="secments"></param>
|
||||
/// <returns></returns>
|
||||
public static Polygon GenerateCircle(int secments = 32)
|
||||
{
|
||||
var vertices = new List<Vector2> {Vector2.Zero};
|
||||
|
|
|
|||
|
|
@ -7,17 +7,36 @@ using OpenTK.Graphics;
|
|||
|
||||
namespace SM2D.Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows storing more information inside a vertex.
|
||||
/// </summary>
|
||||
public struct PolygonVertex
|
||||
{
|
||||
public Vector2 Vertex;
|
||||
/// <summary>
|
||||
/// The position in the polygon.
|
||||
/// </summary>
|
||||
public Vector2 Position;
|
||||
/// <summary>
|
||||
/// The color of the vertex.
|
||||
/// </summary>
|
||||
public Color4 Color;
|
||||
|
||||
public PolygonVertex(Vector2 vertex = default, Color4 color = default)
|
||||
/// <summary>
|
||||
/// Creates a polygon vertex.
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="color"></param>
|
||||
public PolygonVertex(Vector2 position = default, Color4 color = default)
|
||||
{
|
||||
Vertex = vertex;
|
||||
Position = position;
|
||||
Color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automaticly translates Vector2s to PolygonVertex
|
||||
/// </summary>
|
||||
/// <param name="vec"></param>
|
||||
/// <returns></returns>
|
||||
public static implicit operator PolygonVertex(Vector2 vec) => new PolygonVertex(vec, Color4.White);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue