6 #ifndef MATERIALX_MESH_H
7 #define MATERIALX_MESH_H
41 static const unsigned int STRIDE_2D = 2;
42 static const unsigned int STRIDE_3D = 3;
43 static const unsigned int STRIDE_4D = 4;
44 static const unsigned int DEFAULT_STRIDE = STRIDE_3D;
51 _stride(DEFAULT_STRIDE)
65 _data.reserve(elementCount * (
size_t) _stride);
71 _data.resize(elementCount * (
size_t) _stride);
107 return reinterpret_cast<T*
>(getData().data())[index];
113 return reinterpret_cast<const T*
>(getData().data())[index];
131 return _data.size() / _stride;
163 return std::make_shared<MeshPartition>();
169 _indices.resize(indexCount);
188 _sourceNames.insert(val);
236 using MeshMap = std::unordered_map<string, MeshPtr>;
249 return std::make_shared<Mesh>(
name);
261 _sourceUri = sourceUri;
267 return !_sourceUri.empty();
281 for (
const auto&
stream : _streams)
297 for (
const auto&
stream : _streams)
299 if (
stream->getType() == type &&
311 _streams.push_back(stream);
318 if (it != _streams.end())
339 _minimumBounds =
val;
345 return _minimumBounds;
357 return _maximumBounds;
369 return _sphereCenter;
381 return _sphereRadius;
387 return _partitions.size();
393 _partitions.push_back(partition);
399 return _partitions[partIndex];
427 void mergePartitions();
444 vector<MeshPartitionPtr> _partitions;
shared_ptr< class Mesh > MeshPtr
Shared pointer to a mesh.
void addSourceName(const string &val)
void resize(size_t elementCount)
Resize data to an given number of elements.
void setVertexCount(size_t val)
Set vertex count.
MeshFloatBuffer & getData()
Return the raw float vector.
void removeStream(MeshStreamPtr stream)
Remove a mesh stream.
shared_ptr< class MeshStream > MeshStreamPtr
Shared pointer to a mesh stream.
vector< float > MeshFloatBuffer
Float geometry buffer.
void partition(I begin, I middle, I end, const Pred &pred, I *out_eqbeg, I *out_eqend)
const string & getSourceUri() const
Return the mesh's source URI.
#define MATERIALX_NAMESPACE_BEGIN
size_t getSize() const
Get the number of elements.
shared_ptr< class MeshPartition > MeshPartitionPtr
Shared pointer to a mesh partition.
static MeshPartitionPtr create()
Create a new mesh partition.
const Vector3 & getSphereCenter() const
Return center of the bounding sphere.
const StringSet & getSourceNames() const
unsigned int getStride() const
Get stride between elements.
static MeshStreamPtr create(const string &name, const string &type, unsigned int index=0)
Create a new mesh stream.
std::unordered_map< string, MeshPtr > MeshMap
Map from names to meshes.
MeshStream(const string &name, const string &type, unsigned int index)
const MeshFloatBuffer & getData() const
Return the raw float vector.
static const string GEOMETRY_PROPERTY_ATTRIBUTE
static MeshPtr create(const string &name)
Create a new mesh.
float getSphereRadius() const
Return radius of the bounding sphere.
void setFaceCount(size_t val)
Set face count.
const MeshIndexBuffer & getIndices() const
Return indexing.
bool hasSourceUri() const
Return true if this mesh has a source URI.
T & getElement(size_t index)
static const string NORMAL_ATTRIBUTE
static const string TANGENT_ATTRIBUTE
vector< uint32_t > MeshIndexBuffer
Geometry index buffer.
void addPartition(MeshPartitionPtr partition)
Add a partition.
void setName(const string &val)
Set the name of this partition.
const Vector3 & getMaximumBounds() const
Return the minimum bounds for the geometry.
const T & getElement(size_t index) const
void setStride(unsigned int stride)
Set stride between elements.
GLint GLenum GLboolean GLsizei stride
void addStream(MeshStreamPtr stream)
Add a mesh stream.
static const string COLOR_ATTRIBUTE
const string & getName() const
Return the name of this partition.
const Vector3 & getMinimumBounds() const
Return the minimum bounds for the geometry.
size_t getFaceCount() const
Return number of faces.
GLuint const GLchar * name
GA_API const UT_StringHolder transform
void setSourceUri(const string &sourceUri)
Set the mesh's source URI.
vector< MeshStreamPtr > MeshStreamList
List of mesh streams.
void setMinimumBounds(const Vector3 &val)
Set the minimum bounds for the geometry.
void setSphereCenter(const Vector3 &val)
Set center of the bounding sphere.
static const string TEXCOORD_ATTRIBUTE
static const string BITANGENT_ATTRIBUTE
void setMaximumBounds(const Vector3 &v)
Set the minimum bounds for the geometry.
size_t getVertexCount() const
Get vertex count.
unsigned int getIndex() const
Get stream index.
const string & getType() const
Get stream attribute name.
const string & getName() const
Get stream name.
MeshIndexBuffer & getIndices()
Return indexing.
MeshStreamPtr getStream(const string &name) const
const string & getName() const
Return the name of this mesh.
std::set< string > StringSet
A set of strings.
MeshStreamPtr getStream(const string &type, unsigned int index) const
void resize(size_t indexCount)
Resize data to the given number of indices.
#define MATERIALX_NAMESPACE_END
vector< MeshPtr > MeshList
List of meshes.
MeshPartitionPtr getPartition(size_t partIndex) const
Return a reference to a mesh partition.
static const string POSITION_ATTRIBUTE
void setSphereRadius(float val)
Set radius of the bounding sphere.
void reserve(size_t elementCount)
Reserve memory for a given number of elements.
size_t getPartitionCount() const
Return the number of mesh partitions.
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool