2020-04-15 02:03:56 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "GraphicsResources.h"
|
2020-08-06 00:54:43 +02:00
|
|
|
#include "Material/MaterialAsset.h"
|
2020-04-15 02:03:56 +02:00
|
|
|
|
|
|
|
|
namespace Seele
|
|
|
|
|
{
|
2020-08-06 00:54:43 +02:00
|
|
|
#define MAX_TEX_CHANNELS 8
|
2020-06-08 01:44:47 +02:00
|
|
|
struct MeshDescription
|
|
|
|
|
{
|
2020-08-06 00:54:43 +02:00
|
|
|
Array<Gfx::VertexAttribute> layout;
|
2020-06-08 01:44:47 +02:00
|
|
|
Gfx::PVertexDeclaration declaration;
|
|
|
|
|
uint32 getStride() const
|
|
|
|
|
{
|
|
|
|
|
return getNumFloats() * sizeof(float);
|
|
|
|
|
}
|
|
|
|
|
uint32 getNumFloats() const
|
|
|
|
|
{
|
|
|
|
|
uint32 vertexSize = 0;
|
|
|
|
|
for(auto a : layout)
|
|
|
|
|
{
|
|
|
|
|
switch (a)
|
|
|
|
|
{
|
2020-08-06 00:54:43 +02:00
|
|
|
case Gfx::VertexAttribute::POSITION:
|
|
|
|
|
case Gfx::VertexAttribute::NORMAL:
|
|
|
|
|
case Gfx::VertexAttribute::TANGENT:
|
|
|
|
|
case Gfx::VertexAttribute::BITANGENT:
|
2020-06-08 01:44:47 +02:00
|
|
|
vertexSize += 3;
|
|
|
|
|
break;
|
2020-08-06 00:54:43 +02:00
|
|
|
case Gfx::VertexAttribute::TEXCOORD:
|
2020-06-08 01:44:47 +02:00
|
|
|
vertexSize += 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return vertexSize;
|
|
|
|
|
}
|
2020-08-06 00:54:43 +02:00
|
|
|
|
|
|
|
|
friend class boost::serialization::access;
|
|
|
|
|
template<class Archive>
|
|
|
|
|
void serialize(Archive& ar, const unsigned int version)
|
|
|
|
|
{
|
|
|
|
|
ar & layout;
|
|
|
|
|
//TODO declaration
|
|
|
|
|
}
|
2020-06-08 01:44:47 +02:00
|
|
|
};
|
|
|
|
|
DECLARE_REF(MaterialAsset);
|
2020-04-15 02:03:56 +02:00
|
|
|
class Mesh
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-06-08 01:44:47 +02:00
|
|
|
Mesh(MeshDescription description, Gfx::PIndexBuffer indexBuffer);
|
2020-04-15 02:03:56 +02:00
|
|
|
~Mesh();
|
2020-05-05 01:51:13 +02:00
|
|
|
|
2020-06-02 11:46:18 +02:00
|
|
|
Gfx::PIndexBuffer indexBuffer;
|
2020-06-08 01:44:47 +02:00
|
|
|
MeshDescription description;
|
|
|
|
|
PMaterialAsset referencedMaterial;
|
2020-08-06 00:54:43 +02:00
|
|
|
private:
|
|
|
|
|
friend class boost::serialization::access;
|
|
|
|
|
template<class Archive>
|
|
|
|
|
void serialize(Archive& ar, const unsigned int version)
|
|
|
|
|
{
|
|
|
|
|
ar & description;
|
|
|
|
|
ar & referencedMaterial->getFullPath();
|
|
|
|
|
//TODO:
|
|
|
|
|
}
|
2020-04-15 02:03:56 +02:00
|
|
|
};
|
2020-06-02 11:46:18 +02:00
|
|
|
DEFINE_REF(Mesh);
|
2020-05-05 01:51:13 +02:00
|
|
|
} // namespace Seele
|