17#include "aeongames/ProtoBufHelpers.hpp"
19#pragma warning( push )
20#pragma warning( disable : PROTOBUF_WARNINGS )
26#include "aeongames/Mesh.hpp"
27#include "aeongames/Renderer.hpp"
28#include "aeongames/AeonEngine.hpp"
75 switch ( std::get<Mesh::AttributeType> ( aAttributeTuple ) )
79 return std::get<1> ( aAttributeTuple );
84 return 2 * std::get<1> ( aAttributeTuple );
90 return 4 * std::get<1> ( aAttributeTuple );
92 return 8 * std::get<1> ( aAttributeTuple );
101 for (
const auto& i : mAttributes )
118 aMeshMsg.center().x(),
119 aMeshMsg.center().y(),
120 aMeshMsg.center().z()
123 aMeshMsg.radii().x(),
124 aMeshMsg.radii().y(),
129 mVertexCount = aMeshMsg.vertexcount();
130 mIndexCount = aMeshMsg.indexcount();
131 mIndexSize = aMeshMsg.indexsize();
132 mAttributes.reserve ( aMeshMsg.attribute().size() );
133 for (
const auto& i : aMeshMsg.attribute() )
135 mAttributes.emplace_back (
143 mVertexBuffer.clear();
144 mVertexBuffer.reserve ( aMeshMsg.vertexbuffer().size() );
145 std::copy ( aMeshMsg.vertexbuffer().begin(), aMeshMsg.vertexbuffer().end(), std::back_inserter ( mVertexBuffer ) );
147 mIndexBuffer.clear();
148 mIndexBuffer.reserve ( aMeshMsg.indexbuffer().size() );
149 std::copy ( aMeshMsg.indexbuffer().begin(), aMeshMsg.indexbuffer().end(), std::back_inserter ( mIndexBuffer ) );
160 mVertexBuffer.clear();
161 mIndexBuffer.clear();
Provides the DLL_PROTOBUF export/import macro for protobuf wrapper classes.
Axis Aligned Bounding Box class.
DLL void LoadFromMemory(const void *aBuffer, size_t aBufferSize) final
Load mesh data from a raw memory buffer.
DLL void Unload() final
Unload mesh data and release resources.
DLL size_t GetStride() const
Get the stride (bytes per vertex) for the vertex buffer.
AttributeSemantic
Semantic meaning of a vertex attribute, identified by CRC32 of its name.
DLL uint32_t GetIndexSize() const
Get the size in bytes of a single index.
DLL ~Mesh() final
Destructor.
DLL void LoadFromPBMsg(const MeshMsg &aMeshMsg)
Load mesh data from a protobuf message.
AttributeType
Data type of a vertex attribute component.
@ UNSIGNED_SHORT
Unsigned 16-bit integer.
@ HALF_FLOAT
16-bit floating point.
@ BYTE
Signed 8-bit integer.
@ DOUBLE
64-bit floating point.
@ SHORT
Signed 16-bit integer.
@ UNSIGNED_BYTE
Unsigned 8-bit integer.
@ FLOAT
32-bit floating point.
@ INT
Signed 32-bit integer.
@ UNSIGNED_INT
Unsigned 32-bit integer.
uint8_t AttributeSize
Type alias for the number of components in a vertex attribute.
std::tuple< AttributeSemantic, AttributeSize, AttributeType, AttributeFlags > AttributeTuple
Tuple describing a single vertex attribute (semantic, component count, type, flags).
DLL const AABB & GetAABB() const
Get the axis-aligned bounding box of the mesh.
DLL uint32_t GetIndexCount() const
Get the total number of indices.
uint8_t AttributeFlags
Type alias for vertex attribute flag bits.
DLL const std::vector< uint8_t > & GetIndexBuffer() const
Get the raw index data buffer.
DLL const std::vector< uint8_t > & GetVertexBuffer() const
Get the raw vertex data buffer.
DLL const std::vector< AttributeTuple > & GetAttributes() const
Get the list of vertex attributes.
DLL uint32_t GetVertexCount() const
Get the total number of vertices.
DLL Mesh()
Default constructor.
<- This is here just for the literals
void LoadFromProtoBufObject(T &aTarget, const void *aBuffer, size_t aBufferSize)
Loads a Protocol Buffer message from a buffer and populates a target object.
DLL size_t GetAttributeTotalSize(const Mesh::AttributeTuple &aAttributeTuple)
Compute the total byte size of a single vertex attribute.