3es  0.7
tes::MeshShape Class Reference

A Shape which uses vertices and indices to render. More...

#include <3esmeshshape.h>

Inheritance diagram for tes::MeshShape:
tes::Shape

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?
 
MeshShapesetCalculateNormals (bool calculate)
 Should normals be calculated for the mesh by the viewer? More...
 
MeshShapesetNormals (const float *normals, size_t normalByteSize)
 Set (optional) mesh normals. More...
 
MeshShapesetUniformNormal (const Vector3f &normal)
 Sets a single normal to be shared by all vertices in the mesh. More...
 
MeshShapeexpandVertices ()
 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...
 
Shapeclone () const override
 Deep copy clone. More...
 
- Public Member Functions inherited from tes::Shape
 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
 
ShapesetId (uint32_t id)
 
uint16_t category () const
 
ShapesetCategory (uint16_t category)
 
ShapesetWireframe (bool wire)
 Sets the wireframe flag value for this shape. More...
 
bool isWireframe () const
 Returns true if the wireframe flag is set. More...
 
ShapesetTransparent (bool transparent)
 Sets the transparent flag value for this shape. More...
 
bool isTransparent () const
 Returns true if the transparent flag is set. More...
 
ShapesetTwoSided (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...
 
ShapesetFlags (uint16_t flags)
 Set the full set of ObjectFlag values. More...
 
uint16_t flags () const
 Retrieve the full set of ObjectFlag values. More...
 
ShapesetPosition (const V3Arg &pos)
 
Vector3f position () const
 
ShapesetPosX (float p)
 
ShapesetPosY (float p)
 
ShapesetPosZ (float p)
 
ShapesetRotation (const QuaternionArg &rot)
 
Quaternionf rotation () const
 
ShapesetScale (const V3Arg &scale)
 
Vector3f scale () const
 
ShapesetColour (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)
 
- Protected Member Functions inherited from tes::Shape
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.
 
- Protected Attributes inherited from tes::Shape
uint16_t _routingId
 
CreateMessage _data
 

Detailed Description

A Shape which uses vertices and indices to render.

Use MeshSet for large data sets.

Member Enumeration Documentation

◆ SendDataType

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).

Constructor & Destructor Documentation

◆ MeshShape() [1/6]

tes::MeshShape::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) 
)
inline

Transient triangle set constructor accepting an iterator and optional positioning.

Parameters
verticesPointer to the vertex array. Must be at least 3 elements per vertex.
vertexCountThe number of vertices in vertices.
vertexByteSizeThe size of a single vertex in vertices. Must be at least three floats (12).
positionLocal to world positioning of the triangles. Defaults to the origin.
rotationLocal to world rotation of the triangles. Defaults to identity.
scaleScaling for the triangles. Defaults to one.

◆ MeshShape() [2/6]

tes::MeshShape::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) 
)
inline

Transient triangle set constructor accepting vertex and index iterators and optional positioning.

Parameters
verticesPointer to the vertex array. Must be at least 3 elements per vertex.
vertexCountThe number of vertices in vertices.
vertexByteSizeThe size of a single vertex in vertices. Must be at least three floats (12).
positionLocal to world positioning of the triangles. Defaults to the origin.
rotationLocal to world rotation of the triangles. Defaults to identity.
scaleScaling for the triangles. Defaults to one.

◆ MeshShape() [3/6]

tes::MeshShape::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) 
)
inline

Persistent triangle constructor accepting an iterator and optional positioning.

Parameters
verticesPointer to the vertex array. Must be at least 3 elements per vertex.
vertexCountThe number of vertices in vertices.
vertexByteSizeThe size of a single vertex in vertices. Must be at least three floats (12).
idUnique ID for the triangles. Must be non-zero to be persistent.
positionLocal to world positioning of the triangles. Defaults to the origin.
rotationLocal to world rotation of the triangles. Defaults to identity.
scaleScaling for the triangles. Defaults to one.

◆ MeshShape() [4/6]

tes::MeshShape::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) 
)
inline

Persistent triangle constructor accepting vertex and triangle iterators and optional positioning.

Parameters
verticesPointer to the vertex array. Must be at least 3 elements per vertex.
vertexCountThe number of vertices in vertices.
vertexByteSizeThe size of a single vertex in vertices. Must be at least three floats (12).
idUnique ID for the triangles. Must be non-zero to be persistent.
positionLocal to world positioning of the triangles. Defaults to the origin.
rotationLocal to world rotation of the triangles. Defaults to identity.
scaleScaling for the triangles. Defaults to one.

◆ MeshShape() [5/6]

tes::MeshShape::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) 
)
inline

Persistent triangle constructor accepting an iterator and optional positioning.

Parameters
verticesPointer to the vertex array. Must be at least 3 elements per vertex.
vertexCountThe number of vertices in vertices.
vertexByteSizeThe size of a single vertex in vertices. Must be at least three floats (12).
idUnique ID for the triangles. Must be non-zero to be persistent.
categoryCategorisation of the triangles. For filtering.
positionLocal to world positioning of the triangles. Defaults to the origin.
rotationLocal to world rotation of the triangles. Defaults to identity.
scaleScaling for the triangles. Defaults to one.

◆ MeshShape() [6/6]

tes::MeshShape::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) 
)
inline

Persistent triangle constructor accepting and triangle iterators and optional positioning.

Parameters
verticesPointer to the vertex array. Must be at least 3 elements per vertex.
vertexCountThe number of vertices in vertices.
vertexByteSizeThe size of a single vertex in vertices. Must be at least three floats (12).
idUnique ID for the triangles. Must be non-zero to be persistent.
categoryCategorisation of the triangles. For filtering.
positionLocal to world positioning of the triangles. Defaults to the origin.
rotationLocal to world rotation of the triangles. Defaults to identity.
scaleScaling for the triangles. Defaults to one.

Member Function Documentation

◆ clone()

Shape* tes::MeshShape::clone ( ) const
overridevirtual

Deep copy clone.

Returns
A deep copy.

Reimplemented from tes::Shape.

◆ expandVertices()

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.

Returns
this

◆ setCalculateNormals()

MeshShape & tes::MeshShape::setCalculateNormals ( bool  calculate)
inline

Should normals be calculated for the mesh by the viewer?

Parameters
calculateTrue to calculate vertex normals in the viewer.

References tes::CreateMessage::flags, and tes::MeshShapeCalculateNormals.

◆ setNormals()

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.

Parameters
normalsThe normals array.
normalByteSizethe number of bytes between each element of normals.
Returns
this

◆ setUniformNormal()

MeshShape& tes::MeshShape::setUniformNormal ( const Vector3f normal)

Sets a single normal to be shared by all vertices in the mesh.

Sets calculateNormals() to false.

Parameters
normalThe shared normal to set.
Returns
this

◆ writeCreate()

bool tes::MeshShape::writeCreate ( PacketWriter stream) const
overridevirtual

Writes the standard create message and appends mesh data.

  • Vertex count : uint32
  • Index count : uint32
  • Draw type : uint8
    Parameters
    streamThe stream to write to.
    Returns
    True on success.

Reimplemented from tes::Shape.

◆ writeData()

int tes::MeshShape::writeData ( PacketWriter stream,
unsigned &  progressMarker 
) const
overridevirtual

Called only for complex shapes to write additional creation data.

Parameters
streamThe data stream to write to.
[in,out]progressMarkerIndicates data transfer progress. Initially zero, the Shape manages its own semantics.
Returns
Indicates completion progress. 0 indicates completion, 1 indicates more data are available and more calls should be made. -1 indicates an error. No more calls should be made.

Reimplemented from tes::Shape.

Member Data Documentation

◆ _normalsCount

unsigned tes::MeshShape::_normalsCount
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.


The documentation for this class was generated from the following file: