smrendererv3/SMCode/SM.OGL/Mesh/MeshAttributeList.cs
2021-03-19 20:59:02 +01:00

63 lines
No EOL
1.6 KiB
C#

using System.Collections.Generic;
namespace SM.OGL.Mesh
{
/// <summary>
/// List of mesh attributes.
/// </summary>
public class MeshAttributeList : List<MeshAttribute>
{
/// <summary>
/// Returns the VBO (or null) that is connected to the specified name.
/// </summary>
public VBO this[string name]
{
get
{
for (int i = 0; i < Count; i++)
{
if (this[i].Name == name)
{
return this[i].ConnectedVBO;
}
}
return null;
}
set
{
for (int i = 0; i < Count; i++)
{
if (this[i].Name == name)
{
this[i].ConnectedVBO = value;
return;
}
}
}
}
/// <summary>
/// Adds a new attribute.
/// </summary>
/// <param name="id"></param>
/// <param name="name"></param>
/// <param name="vbo"></param>
public void Add(int id, string name, VBO vbo)
{
//if (vbo == null) return;
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];
return attribute != null && attribute.Active;
}
}
}