Hi,
I hope I could ask you something about Models/Meshes and SubMeshes. I am kinda confused by these 3 terms. From my understanding right now it works like this.
struct SubMesh
{
VertexBuffer m_VB;
IndexBuffer m_IB;
MaterialPtr m_Material;
Transform m_LocalPos;
Transform m_WorldPos;
}
struct Mesh
{
std::vector<SubMeshes> m_SubMeshes;
AnimationData m_AnimData;
}
struct Model
{
std::vector<Mesh> m_Meshes;
Transform m_WorldPos;
} I am kinda confused about this:
- What is the point of SubMeshes? You could just create more Meshes inside model?
- If each SubMesh has its own VBO and IBO(I use dx11 for now, but easy naming), drawing takes more time. You could have only 1 VBO in mesh and use that I guess? My VertexBuffer class saves the format that I specify when I create it.
- What part should be cached? The Model? The Mesh? The SubMesh? I guess the later 2 make most sense.
My Vertexbuffer class looks now like this : It is not done yet, because I am not sure yet about my Mode/Mesh/SubMesh design. Besides that, I guess a lot of info is missing for now, but it's just a start.
enum class VertexAttributeType
{
Position,
Color,
Reflectance,
TexCords,
Normal,
Tangent
};
struct VertexAttribute
{
VertexAttributeType Type;
std::size_t Arity; // Since it's always a float, but it could be float4, float 3 etcetc
VertexAttribute(VertexAttributeType Type, std::size_t Arity) :
Type(Type),
Arity(Arity)
{
}
};
struct BufferFormat
{
bool Interleaved; // If false, it only has 1 Attribute, this is when I want to update the Buffer.
std::vector<VertexAttribute> Attributes;
};
struct SetupBuffer
{
BufferFormat Format;
std::vector<float> Data; //It's always a float I guess
};
class IVertexBuffer : public IBuffer
{
public:
virtual PResult Setup(SetupBuffer SetupInfo);
protected:
IVertexBuffer();
virtual void CreateRaw() = 0; // Call to d3d11, but it makes it easier to add GL if I ever want to.
BufferFormat m_Format;
}; I guess since a VB know it's format, I could play around the Mesh/SubMesh more, to make them use 1 VB, but the code becomes messier and messier that way.