Added Summeries
This commit is contained in:
parent
71a22df8bd
commit
8296d9b8a9
47 changed files with 812 additions and 177 deletions
|
|
@ -49,21 +49,59 @@ namespace SM.OGL.Mesh
|
|||
/// <returns></returns>
|
||||
public Vector3 this[bool x, bool y, bool z] => Get(x,y,z);
|
||||
|
||||
/// <summary>
|
||||
/// Equivalent to <see cref="this"/>.
|
||||
/// <para>Returns specific configurations of corners</para>
|
||||
/// </summary>
|
||||
/// <param name="x">If true, it takes the X-value of maximum, otherwise the minimum.</param>
|
||||
/// <param name="y">If true, it takes the Y-value of maximum, otherwise the minimum.</param>
|
||||
/// <param name="z">If true, it takes the Z-value of maximum, otherwise the minimum.</param>
|
||||
/// <returns></returns>
|
||||
public Vector3 Get(bool x, bool y, bool z)
|
||||
{
|
||||
return new Vector3(x ? Max.X : Min.X, y ? Max.Y : Min.Y, z ? Max.Z : Min.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the configuration of the two furthest away corners.
|
||||
/// </summary>
|
||||
/// <param name="xyz">If true, it will take the maximum, otherwise the minimum.</param>
|
||||
/// <returns></returns>
|
||||
public Vector3 Get(bool xyz) => Get(xyz, xyz, xyz);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the configuration of one corner and applies a transformation to it.
|
||||
/// <para>If the transformation causes the points to shift to no being in the right location is NOT checked!</para>
|
||||
/// <para>For that use <see cref="GetBounds"/></para>
|
||||
/// </summary>
|
||||
/// <param name="transformation">The transformation</param>
|
||||
/// <param name="x">If true, it takes the X-value of maximum, otherwise the minimum.</param>
|
||||
/// <param name="y">If true, it takes the Y-value of maximum, otherwise the minimum.</param>
|
||||
/// <param name="z">If true, it takes the Z-value of maximum, otherwise the minimum.</param>
|
||||
/// <returns></returns>
|
||||
public Vector3 Get(Matrix4 transformation, bool x, bool y, bool z)
|
||||
{
|
||||
Vector3 get = Get(x, y, z);
|
||||
return (new Vector4(get, 1) * transformation).Xyz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the configuration of the two furthest away corners.
|
||||
/// <para>If the transformation causes the points to shift to no being in the right location is NOT checked!</para>
|
||||
/// <para>For that use <see cref="GetBounds"/></para>
|
||||
/// </summary>
|
||||
/// <param name="transformation">The transformation</param>
|
||||
/// <param name="xyz">If true, it will take the maximum, otherwise the minimum.</param>
|
||||
/// <returns></returns>
|
||||
public Vector3 Get(Matrix4 transformation, bool xyz) => Get(transformation, xyz, xyz, xyz);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the bounds of the bounding box while applying a transformation.
|
||||
/// <para>This takes care of min and max locations.</para>
|
||||
/// </summary>
|
||||
/// <param name="transformation"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
public void GetBounds(Matrix4 transformation, out Vector3 min, out Vector3 max)
|
||||
{
|
||||
min = Get(transformation, false);
|
||||
|
|
@ -79,6 +117,10 @@ namespace SM.OGL.Mesh
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the bounding box to the mesh provided.
|
||||
/// </summary>
|
||||
/// <param name="mesh"></param>
|
||||
public void Update(GenericMesh mesh)
|
||||
{
|
||||
int pos = 0;
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ namespace SM.OGL.Mesh
|
|||
public abstract class GenericMesh : GLObject
|
||||
{
|
||||
private bool _boundingBoxUpdated = false;
|
||||
|
||||
public static int LastID { get; internal set; } = -1;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool AutoCompile { get; set; } = true;
|
||||
|
||||
|
|
@ -71,12 +69,18 @@ namespace SM.OGL.Mesh
|
|||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the object bounding box.
|
||||
/// </summary>
|
||||
public void UpdateBoundingBox()
|
||||
{
|
||||
BoundingBox.Update(this);
|
||||
_boundingBoxUpdated = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Activates the object to be rendered.
|
||||
/// </summary>
|
||||
public void Activate()
|
||||
{
|
||||
GL.BindVertexArray(ID);
|
||||
|
|
@ -99,6 +103,7 @@ namespace SM.OGL.Mesh
|
|||
GL.BindVertexArray(0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
GL.DeleteVertexArray(_id);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@
|
|||
/// </summary>
|
||||
public VBO ConnectedVBO;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a attribute for a mesh.
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="buffer"></param>
|
||||
public MeshAttribute(int index, string name, VBO buffer)
|
||||
{
|
||||
Index = index;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,11 @@ namespace SM.OGL.Mesh
|
|||
Add(new MeshAttribute(id, name, vbo));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the attribute list has the attribute name.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public bool Has(string name)
|
||||
{
|
||||
VBO attribute = this[name];
|
||||
|
|
|
|||
|
|
@ -139,6 +139,10 @@ namespace SM.OGL.Mesh
|
|||
Add(vector.X, vector.Y, z, w);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a array of vector2s.
|
||||
/// </summary>
|
||||
/// <param name="vectors"></param>
|
||||
public void Add(params Vector2[] vectors)
|
||||
{
|
||||
foreach (Vector2 vector in vectors)
|
||||
|
|
@ -163,6 +167,10 @@ namespace SM.OGL.Mesh
|
|||
Add(vector.X, vector.Y, vector.Z, w);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a array of Vector3s.
|
||||
/// </summary>
|
||||
/// <param name="vectors"></param>
|
||||
public void Add(params Vector3[] vectors)
|
||||
{
|
||||
foreach (Vector3 vector in vectors)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue