3es
0.7
|
A Shape
which uses vertices and indices to render.
More...
#include <3esmeshshape.h>
Public Types | |
enum | SendDataType { SDT_Vertices, SDT_Indices, SDT_Normals, SDT_UniformNormal } |
Codes for writeData() . Note: normals must be sent before completing vertices and indices. Best done first. More... | |
Public Member Functions | |
MeshShape (DrawType drawType, const float *vertices, unsigned vertexCount, size_t vertexByteSize, const V3Arg &position=V3Arg(0, 0, 0), const QuaternionArg &rotation=QuaternionArg(0, 0, 0, 1), const V3Arg &scale=V3Arg(1, 1, 1)) | |
Transient triangle set constructor accepting an iterator and optional positioning. More... | |
MeshShape (DrawType drawType, const float *vertices, unsigned vertexCount, size_t vertexByteSize, const unsigned *indices, unsigned indexCount, const V3Arg &position=V3Arg(0, 0, 0), const QuaternionArg &rotation=QuaternionArg(0, 0, 0, 1), const V3Arg &scale=V3Arg(1, 1, 1)) | |
Transient triangle set constructor accepting vertex and index iterators and optional positioning. More... | |
MeshShape (DrawType drawType, const float *vertices, unsigned vertexCount, size_t vertexByteSize, uint32_t id, const V3Arg &position=V3Arg(0, 0, 0), const QuaternionArg &rotation=QuaternionArg(0, 0, 0, 1), const V3Arg &scale=V3Arg(1, 1, 1)) | |
Persistent triangle constructor accepting an iterator and optional positioning. More... | |
MeshShape (DrawType drawType, const float *vertices, unsigned vertexCount, size_t vertexByteSize, const unsigned *indices, unsigned indexCount, uint32_t id, const V3Arg &position=V3Arg(0, 0, 0), const QuaternionArg &rotation=QuaternionArg(0, 0, 0, 1), const V3Arg &scale=V3Arg(1, 1, 1)) | |
Persistent triangle constructor accepting vertex and triangle iterators and optional positioning. More... | |
MeshShape (DrawType drawType, const float *vertices, unsigned vertexCount, size_t vertexByteSize, uint32_t id, uint16_t category, const V3Arg &position=V3Arg(0, 0, 0), const QuaternionArg &rotation=QuaternionArg(0, 0, 0, 1), const V3Arg &scale=V3Arg(1, 1, 1)) | |
Persistent triangle constructor accepting an iterator and optional positioning. More... | |
MeshShape (DrawType drawType, const float *vertices, unsigned vertexCount, size_t vertexByteSize, const unsigned *indices, unsigned indexCount, uint32_t id, uint16_t category, const V3Arg &position=V3Arg(0, 0, 0), const QuaternionArg &rotation=QuaternionArg(0, 0, 0, 1), const V3Arg &scale=V3Arg(1, 1, 1)) | |
Persistent triangle constructor accepting and triangle iterators and optional positioning. More... | |
~MeshShape () | |
Destructor. | |
bool | isComplex () const override |
Mark as complex to ensure writeData() is called. | |
bool | calculateNormals () const |
Calculate vertex normals in the viewer? | |
MeshShape & | setCalculateNormals (bool calculate) |
Should normals be calculated for the mesh by the viewer? More... | |
MeshShape & | setNormals (const float *normals, size_t normalByteSize) |
Set (optional) mesh normals. More... | |
MeshShape & | setUniformNormal (const Vector3f &normal) |
Sets a single normal to be shared by all vertices in the mesh. More... | |
MeshShape & | expandVertices () |
Expand the vertex set into a new block of memory. More... | |
unsigned | vertexCount () const |
const float * | vertices () const |
size_t | vertexStride () const |
Vertex stride in float elements. | |
size_t | vertexByteStride () const |
const float * | normals () const |
size_t | normalsStride () const |
size_t | normalsByteStride () const |
size_t | normalsCount () const |
DrawType | drawType () const |
bool | writeCreate (PacketWriter &stream) const override |
Writes the standard create message and appends mesh data. More... | |
int | writeData (PacketWriter &stream, unsigned &progressMarker) const override |
Called only for complex shapes to write additional creation data. More... | |
Shape * | clone () const override |
Deep copy clone. More... | |
![]() | |
Shape (uint16_t routingId, uint32_t id=0) | |
Shape (uint16_t routingId, uint32_t id, uint16_t category) | |
Construct a box object. More... | |
uint16_t | routingId () const |
uint32_t | id () const |
Shape & | setId (uint32_t id) |
uint16_t | category () const |
Shape & | setCategory (uint16_t category) |
Shape & | setWireframe (bool wire) |
Sets the wireframe flag value for this shape. More... | |
bool | isWireframe () const |
Returns true if the wireframe flag is set. More... | |
Shape & | setTransparent (bool transparent) |
Sets the transparent flag value for this shape. More... | |
bool | isTransparent () const |
Returns true if the transparent flag is set. More... | |
Shape & | setTwoSided (bool twoSided) |
Sets the two sided shader flag value for this shape. More... | |
bool | isTwoSided () const |
Returns true if the two sided shader flag is set. More... | |
Shape & | setFlags (uint16_t flags) |
Set the full set of ObjectFlag values. More... | |
uint16_t | flags () const |
Retrieve the full set of ObjectFlag values. More... | |
Shape & | setPosition (const V3Arg &pos) |
Vector3f | position () const |
Shape & | setPosX (float p) |
Shape & | setPosY (float p) |
Shape & | setPosZ (float p) |
Shape & | setRotation (const QuaternionArg &rot) |
Quaternionf | rotation () const |
Shape & | setScale (const V3Arg &scale) |
Vector3f | scale () const |
Shape & | setColour (const Colour &colour) |
Colour | colour () const |
virtual void | updateFrom (const Shape &other) |
Update the attributes of this shape to match other . More... | |
bool | writeUpdate (PacketWriter &stream) const |
bool | writeDestroy (PacketWriter &stream) const |
virtual int | enumerateResources (const Resource **resources, int capacity, int fetchOffset=0) const |
Enumerate the resources used by this shape. More... | |
Protected Member Functions | |
MeshShape () | |
Constructor for cloning. | |
void | onClone (MeshShape *copy) const |
float * | allocateVertices (unsigned count) |
void | freeVertices (const float *&vertices) |
unsigned * | allocateIndices (unsigned count) |
void | freeIndices (const unsigned *&indices) |
![]() | |
void | onClone (Shape *copy) const |
Called when copy is created from this object to copy appropriate attributes to copy . More... | |
void | init (uint32_t id, uint16_t cat=0, uint16_t flags=0) |
Protected Attributes | |
const float * | _vertices |
Mesh vertices. | |
unsigned | _vertexStride |
Stride into _vertices in float elements, not bytes. | |
unsigned | _vertexCount |
Number of _vertices . | |
const float * | _normals |
Normals array, one per vertex. | |
unsigned | _normalsStride |
Stride into _normals in float elements, not bytes. | |
unsigned | _normalsCount |
Number of _normals . More... | |
const unsigned * | _indices |
Optional triangle indices. | |
unsigned | _indexCount |
Number of indices . Divide by 3 for the triangle count. | |
DrawType | _drawType |
The primitive to render. | |
bool | _ownPointers |
Does this instance own its vertices and indices? | |
bool | _ownNormals |
Does this instance own its normals? Always true if _ownPointers is true. | |
![]() | |
uint16_t | _routingId |
CreateMessage | _data |
Codes for writeData()
. Note: normals must be sent before completing vertices and indices. Best done first.
Enumerator | |
---|---|
SDT_UniformNormal | Sending a single normals for all vertices (voxel extents). |
|
inline |
Transient triangle set constructor accepting an iterator and optional positioning.
vertices | Pointer to the vertex array. Must be at least 3 elements per vertex. |
vertexCount | The number of vertices in vertices . |
vertexByteSize | The size of a single vertex in vertices . Must be at least three floats (12). |
position | Local to world positioning of the triangles. Defaults to the origin. |
rotation | Local to world rotation of the triangles. Defaults to identity. |
scale | Scaling for the triangles. Defaults to one. |
|
inline |
Transient triangle set constructor accepting vertex and index iterators and optional positioning.
vertices | Pointer to the vertex array. Must be at least 3 elements per vertex. |
vertexCount | The number of vertices in vertices . |
vertexByteSize | The size of a single vertex in vertices . Must be at least three floats (12). |
position | Local to world positioning of the triangles. Defaults to the origin. |
rotation | Local to world rotation of the triangles. Defaults to identity. |
scale | Scaling for the triangles. Defaults to one. |
|
inline |
Persistent triangle constructor accepting an iterator and optional positioning.
vertices | Pointer to the vertex array. Must be at least 3 elements per vertex. |
vertexCount | The number of vertices in vertices . |
vertexByteSize | The size of a single vertex in vertices . Must be at least three floats (12). |
id | Unique ID for the triangles. Must be non-zero to be persistent. |
position | Local to world positioning of the triangles. Defaults to the origin. |
rotation | Local to world rotation of the triangles. Defaults to identity. |
scale | Scaling for the triangles. Defaults to one. |
|
inline |
Persistent triangle constructor accepting vertex and triangle iterators and optional positioning.
vertices | Pointer to the vertex array. Must be at least 3 elements per vertex. |
vertexCount | The number of vertices in vertices . |
vertexByteSize | The size of a single vertex in vertices . Must be at least three floats (12). |
id | Unique ID for the triangles. Must be non-zero to be persistent. |
position | Local to world positioning of the triangles. Defaults to the origin. |
rotation | Local to world rotation of the triangles. Defaults to identity. |
scale | Scaling for the triangles. Defaults to one. |
|
inline |
Persistent triangle constructor accepting an iterator and optional positioning.
vertices | Pointer to the vertex array. Must be at least 3 elements per vertex. |
vertexCount | The number of vertices in vertices . |
vertexByteSize | The size of a single vertex in vertices . Must be at least three floats (12). |
id | Unique ID for the triangles. Must be non-zero to be persistent. |
category | Categorisation of the triangles. For filtering. |
position | Local to world positioning of the triangles. Defaults to the origin. |
rotation | Local to world rotation of the triangles. Defaults to identity. |
scale | Scaling for the triangles. Defaults to one. |
|
inline |
Persistent triangle constructor accepting and triangle iterators and optional positioning.
vertices | Pointer to the vertex array. Must be at least 3 elements per vertex. |
vertexCount | The number of vertices in vertices . |
vertexByteSize | The size of a single vertex in vertices . Must be at least three floats (12). |
id | Unique ID for the triangles. Must be non-zero to be persistent. |
category | Categorisation of the triangles. For filtering. |
position | Local to world positioning of the triangles. Defaults to the origin. |
rotation | Local to world rotation of the triangles. Defaults to identity. |
scale | Scaling for the triangles. Defaults to one. |
|
overridevirtual |
MeshShape& tes::MeshShape::expandVertices | ( | ) |
Expand the vertex set into a new block of memory.
This is useful when indexing small primitive from a large set of vertices. The method allocates a new array of vertices, explicitly copying and unpacking the vertices by traversing the index array. This ensure only the indexed subset is present.
Does nothing when the shape does not use indices.
|
inline |
Should normals be calculated for the mesh by the viewer?
calculate | True to calculate vertex normals in the viewer. |
References tes::CreateMessage::flags, and tes::MeshShapeCalculateNormals.
MeshShape& tes::MeshShape::setNormals | ( | const float * | normals, |
size_t | normalByteSize | ||
) |
Set (optional) mesh normals.
The number of normal elements in normals
must match the vertexCount
.
The normals array is copied if this object owns its vertex memory such as after calling expandVertices()
.
Sets calculateNormals()
to false.
normals | The normals array. |
normalByteSize | the number of bytes between each element of normals . |
Sets a single normal to be shared by all vertices in the mesh.
Sets calculateNormals()
to false.
normal | The shared normal to set. |
|
overridevirtual |
Writes the standard create message and appends mesh data.
stream | The stream to write to. |
Reimplemented from tes::Shape.
|
overridevirtual |
Called only for complex shapes to write additional creation data.
stream | The data stream to write to. | |
[in,out] | progressMarker | Indicates data transfer progress. Initially zero, the Shape manages its own semantics. |
Reimplemented from tes::Shape.
|
protected |
Number of _normals
.
Must be 0, 1 or _vertexCount
. 0 indicates no normals, 1 indicates a single, shared normal (for voxels), otherwise there must be one per normal.