+ AxisHelper
~ Transformation can now set to be ignored. (Sending a Identity, when requested) ~ Changed how Meshes store Attributes
This commit is contained in:
parent
0895c600cf
commit
2e7051d800
14 changed files with 146 additions and 30 deletions
|
|
@ -13,16 +13,17 @@ namespace SM.OGL.Mesh
|
|||
/// </summary>
|
||||
public abstract class GenericMesh : GLObject
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Generates the AttribDataIndex
|
||||
/// </summary>
|
||||
protected GenericMesh()
|
||||
{
|
||||
AttribDataIndex = new Dictionary<int, VBO>
|
||||
Attributes = new MeshAttributeList()
|
||||
{
|
||||
{0, Vertex},
|
||||
{1, UVs},
|
||||
{2, Normals}
|
||||
{0, "vertex", Vertex},
|
||||
{1, "uv", UVs},
|
||||
{2, "normal", Normals}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +62,7 @@ namespace SM.OGL.Mesh
|
|||
/// <summary>
|
||||
/// Connects the different buffer objects with ids.
|
||||
/// </summary>
|
||||
public Dictionary<int, VBO> AttribDataIndex { get; }
|
||||
public MeshAttributeList Attributes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores indices for a more performance friendly method to draw objects.
|
||||
|
|
@ -74,9 +75,9 @@ namespace SM.OGL.Mesh
|
|||
_id = GL.GenVertexArray();
|
||||
GL.BindVertexArray(_id);
|
||||
|
||||
if (AttribDataIndex == null) throw new Exception("[Critical] The model requires a attribute data index.");
|
||||
if (Attributes == null) throw new Exception("[Critical] The model requires attributes.");
|
||||
|
||||
foreach (var kvp in AttribDataIndex) kvp.Value?.BindBuffer(kvp.Key);
|
||||
foreach (var kvp in Attributes) kvp.ConnectedVBO?.BindBuffer(kvp.Index);
|
||||
|
||||
GL.BindVertexArray(0);
|
||||
}
|
||||
|
|
|
|||
16
SMCode/SM.OGL/Mesh/MeshAttribute.cs
Normal file
16
SMCode/SM.OGL/Mesh/MeshAttribute.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
namespace SM.OGL.Mesh
|
||||
{
|
||||
public struct MeshAttribute
|
||||
{
|
||||
public int Index;
|
||||
public string Name;
|
||||
public VBO ConnectedVBO;
|
||||
|
||||
public MeshAttribute(int index, string name, VBO buffer)
|
||||
{
|
||||
Index = index;
|
||||
Name = name;
|
||||
ConnectedVBO = buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
SMCode/SM.OGL/Mesh/MeshAttributeList.cs
Normal file
31
SMCode/SM.OGL/Mesh/MeshAttributeList.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SM.OGL.Mesh
|
||||
{
|
||||
public class MeshAttributeList : List<MeshAttribute>
|
||||
{
|
||||
public VBO this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (this[i].Name == name)
|
||||
{
|
||||
return this[i].ConnectedVBO;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(int id, string name, VBO vbo)
|
||||
{
|
||||
if (vbo == null) return;
|
||||
Add(new MeshAttribute(id, name, vbo));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue