Loading logic moved to Asset classes

This commit is contained in:
Dynamitos
2020-06-08 01:44:47 +02:00
parent 356e6058fe
commit ab4a3b5e23
50 changed files with 966 additions and 558 deletions
+42 -3
View File
@@ -3,15 +3,54 @@
namespace Seele
{
#define MAX_TEX_CHANNELS 4
enum class VertexAttribute
{
POSITION,
TEXCOORD,
NORMAL,
TANGENT,
BITANGENT
};
struct MeshDescription
{
Array<VertexAttribute> layout;
Gfx::PVertexDeclaration declaration;
uint32 getStride() const
{
return getNumFloats() * sizeof(float);
}
uint32 getNumFloats() const
{
uint32 vertexSize = 0;
for(auto a : layout)
{
switch (a)
{
case VertexAttribute::POSITION:
case VertexAttribute::NORMAL:
case VertexAttribute::TANGENT:
case VertexAttribute::BITANGENT:
vertexSize += 3;
break;
case VertexAttribute::TEXCOORD:
vertexSize += 2;
break;
}
}
return vertexSize;
}
};
DECLARE_REF(MaterialAsset);
class Mesh
{
public:
Mesh(Gfx::PVertexBuffer vertexBuffer, Gfx::PIndexBuffer indexBuffer);
Mesh(MeshDescription description, Gfx::PIndexBuffer indexBuffer);
~Mesh();
private:
Gfx::PVertexBuffer vertexBuffer;
Gfx::PIndexBuffer indexBuffer;
MeshDescription description;
PMaterialAsset referencedMaterial;
};
DEFINE_REF(Mesh);
} // namespace Seele