8 #include "vertexattribute.h"
13 #include <utility/dllexport.h>
14 #include <rtti/object.h>
15 #include <rtti/objectptr.h>
16 #include <nap/numeric.h>
17 #include <rtti/factory.h>
18 #include <nap/numeric.h>
88 void reserveIndices(
size_t numIndices);
96 void setIndices(
uint32* indices,
int numIndices);
101 const std::vector<uint32>&
getIndices()
const {
return mIndices; }
115 void addIndices(
uint32* indices,
int numIndices);
156 template<
typename VERTEX_ATTRIBUTE_PTR>
270 void reserveVertices(
size_t numVertices);
380 std::unique_ptr<GPUMesh> mGPUMesh;
381 bool mInitialized =
false;
474 std::unique_ptr<MeshInstance> mMeshInstance;
486 for (
auto& attribute : mProperties.mAttributes)
487 if (attribute->mAttributeID ==
id)
488 return rtti_cast<VertexAttribute<T>>(attribute.get());
495 for (
auto& attribute : mProperties.mAttributes)
497 if (attribute->mAttributeID ==
id)
510 assert(attribute !=
nullptr);
518 assert(attribute !=
nullptr);
525 for (
auto& attribute : mProperties.mAttributes)
527 if (attribute->mAttributeID ==
id)
530 assert(result !=
nullptr);
535 std::unique_ptr<VertexAttribute<T>> new_attribute = std::make_unique<VertexAttribute<T>>();
538 mProperties.mAttributes.emplace_back(std::move(new_attribute));
546 for (
auto& attribute : mProperties.mAttributes)
547 if (attribute->mAttributeID ==
id)
558 assert(attribute !=
nullptr);
std::vector< uint32 > & getIndices()
Definition: mesh.h:106
const VertexAttribute< T > & GetAttribute(const std::string &id) const
Definition: mesh.h:555
VertexAttribute< T > * findAttribute(const std::string &id)
EDrawMode getDrawMode() const
Definition: mesh.h:297
@ TriangleFan
Interpret the vertex data as a fan of triangles.
Definition: polyline.h:172
void clearIndices()
Definition: mesh.h:82
const std::vector< uint32 > & getIndices() const
Definition: mesh.h:101
MeshShape & getShape(int index)
Definition: mesh.h:327
virtual MeshInstance & getMeshInstance()=0
VertexAttribute< T > & getOrCreateAttribute(const std::string &id)
void addIndex(uint32 index)
Definition: mesh.h:122
Definition: vertexattribute.h:65
@ Static
Buffer data is uploaded only once from the CPU to the GPU.
EPolygonMode
Definition: mesh.h:55
@ Front
Cull front facing triangles.
Definition: vertexattribute.h:20
@ TriangleStrip
Interpret the vertex data as a strip of triangles.
ECullMode
Definition: mesh.h:43
EMemoryUsage
Definition: gpubuffer.h:41
int getNumIndices() const
Definition: mesh.h:76
VertexAttributeList mAttributes
Property: 'Attributes' vertex attributes.
Definition: mesh.h:166
const MeshShape & getShape(int index) const
Definition: mesh.h:334
Definition: errorstate.h:19
std::string mAttributeID
Name/ID of the attribute.
Definition: vertexattribute.h:52
void setDrawMode(EDrawMode mode)
Definition: mesh.h:292
@ Points
Interpret the vertex data as single points.
int getNumShapes() const
Definition: mesh.h:287
@ Unknown
Invalid vertex interpretation.
RTTIMeshProperties mProperties
Property: 'Properties' RTTI mesh CPU data.
Definition: mesh.h:471
std::vector< rtti::ObjectPtr< BaseVertexAttribute > > VertexAttributeList
Definition: mesh.h:159
uint32_t uint32
Definition: numeric.h:20
const uint32 & operator[](std::size_t index) const
Definition: mesh.h:136
ECullMode getCullMode() const
Definition: mesh.h:307
Definition: renderservice.h:275
VertexAttribute< T > & getAttribute(const std::string &id)
const VertexAttribute< T > * FindAttribute(const std::string &id) const
Definition: mesh.h:544
EPolygonMode getPolygonMode() const
Definition: mesh.h:320
EPolygonMode mPolygonMode
Property: 'PolygonMode' The polygon mode to use, fill is always available and should be the default.
Definition: mesh.h:165
@ Back
Cull back facing triangles.
@ FrontAndBack
Cull front and back facing triangles.
@ Fill
Polygons are interpreted and rendered using the specified 'EDrawMode'.
@ Lines
Interpret the vertex data as individual lines.
void setNumVertices(int numVertices)
Definition: mesh.h:277
std::vector< uint32 > mIndices
Property: 'Indices' into the mesh's vertex data.
Definition: mesh.h:138
@ Triangles
Interpret the vertex data as a set of triangles.
Definition: templateapp.h:17
EMemoryUsage getUsage() const
Definition: mesh.h:351
void setUsage(EMemoryUsage inUsage)
Definition: mesh.h:346
int getNumVertices() const
Definition: mesh.h:282
virtual MeshInstance & getMeshInstance() override
uint32 & operator[](std::size_t index)
Definition: mesh.h:129
virtual bool init(utility::ErrorState &errorState) override
Definition: resource.h:19
void setCullMode(ECullMode mode)
Definition: mesh.h:302
EMemoryUsage mUsage
Property: 'Usage' GPU memory usage.
Definition: mesh.h:162
int mNumVertices
Property: 'NumVertices' number of mesh vertices.
Definition: mesh.h:161
ECullMode mCullMode
Property: 'CullMode' The triangle cull mode to use.
Definition: mesh.h:164
@ LineStrip
Interpret the vertex data as a single connected line.
std::vector< MeshShape > mShapes
Property: 'Shapes' list of managed shapes.
Definition: mesh.h:167
@ Point
Polygon vertices are drawn as points.
EDrawMode
Definition: mesh.h:28
int32_t int32
Definition: numeric.h:19
EDrawMode mDrawMode
Property: 'DrawMode' The draw mode that should be used to draw the shapes.
Definition: mesh.h:163