3es  0.7
tes::MeshResource Class Referenceabstract

Represents a mesh part or object. More...

#include <3esmeshresource.h>

Inheritance diagram for tes::MeshResource:
tes::Resource tes::MeshPlaceholder tes::PointCloud tes::SimpleMesh

Public Member Functions

virtual ~MeshResource ()
 Virtual destructor.
 
uint16_t typeId () const override
 Returns MtMesh.
 
virtual Matrix4f transform () const =0
 
virtual uint32_t tint () const =0
 
virtual uint8_t drawType (int stream=0) const =0
 Returns the DrawType of the mesh. More...
 
virtual unsigned vertexCount (int stream=0) const =0
 Returns the number of vertices in the mesh. More...
 
virtual unsigned indexCount (int stream=0) const =0
 Returns the number of indices in the mesh. More...
 
virtual const float * vertices (unsigned &stride, int stream=0) const =0
 Returns a pointer to the vertex stream. More...
 
virtual const uint8_t * indices (unsigned &stride, unsigned &width, int stream=0) const =0
 Returns a pointer to the index stream. More...
 
virtual const float * normals (unsigned &stride, int stream=0) const =0
 Returns a pointer to the normal stream. More...
 
virtual const float * uvs (unsigned &stride, int stream=0) const =0
 Returns a pointer to the UV stream. More...
 
virtual const uint32_t * colours (unsigned &stride, int stream=0) const =0
 Returns a pointer to the colour stream. More...
 
int create (PacketWriter &packet) const override
 Populate a mesh creation packet. More...
 
int destroy (PacketWriter &packet) const override
 Populate a mesh destroy packet. More...
 
int transfer (PacketWriter &packet, int byteLimit, TransferProgress &progress) const override
 Populate the next mesh data packet. More...
 
*tes::PacketWriter packet ()
 Compose a mesh index component message in packet. More...
 
while (offset< mesh->indexCount()) *
 
- Public Member Functions inherited from tes::Resource
virtual ~Resource ()
 Virtual destructor (empty).
 
virtual uint32_t id () const =0
 The resource ID. More...
 
uint64_t uniqueKey () const
 Returns a unique key for this resource, based on the typeId() and id().
 
virtual Resourceclone () const =0
 Clone the resource. More...
 

Static Public Member Functions

static int estimateTransferCount (size_t elementSize, unsigned byteLimit, int overhead=0)
 Estimate the number of elements which can be transferred at the given byteLimit. More...
 
*</code > **param packet Packet to write to *param meshId The mesh to which the data belong *param offset An index count offset to start writing from See remarks *param byteLimit A hard limit on the number of bytes to write *param dataSource Base pointer for the index data *param dataStride Number of bytes between indices *param indexByteWidth The byte size of a single index Generally equal to p dataStride *param componentCount The total number of indices *return The number of indices written *static unsigned writeIndices (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, unsigned indexByteWidth, uint32_t componentCount)
 
*</code > **param packet Packet to write to *param meshId The mesh to which the data belong *param offset An vertex count offset to start writing from See remarks *param byteLimit A hard limit on the number of bytes to write *param dataSource Base pointer for the vertex data *param dataStride Number of bytes between indices *param componentCount The total number of indices *return The number of indices written *static unsigned writeVectors3 (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, uint32_t componentCount)
 
static unsigned writeVectors2 (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, uint32_t componentCount)
 Compose a mesh float vector 2 component message in packet. More...
 
static unsigned writeColours (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, uint32_t componentCount)
 Compose a mesh component message for writing colour data in packet. More...
 

Public Attributes

*const tes::MeshResourcemesh =
 
*uint32_t offset = 0
 
*unsigned dataStride
 
*unsigned indexByteWidth
 
*const uint8_t * indicesPtr = reinterpret_cast<const uint8_t *>(indices(dataStride, indexByteWidth))
 
offset
 Compose a mesh float vector 3 component message in packet. More...
 

Protected Member Functions

virtual void nextPhase (TransferProgress &progress) const
 

Detailed Description

Represents a mesh part or object.

These are visualised via MeshSet, which may contain several MeshResource parts.

Member Function Documentation

◆ colours()

virtual const uint32_t* tes::MeshResource::colours ( unsigned &  stride,
int  stream = 0 
) const
pure virtual

Returns a pointer to the colour stream.

Each element is taken 32-bit integer. Expects vertexCount(stream) elements or null if no vertex colours.

Parameters
[out]strideThe stride between colour elements (bytes). This would be 4 for a contiguous array of uint32_t colours.
streamReserved for future use.
Returns
A pointer to the first colour value or null.

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ create()

int tes::MeshResource::create ( PacketWriter packet) const
overridevirtual

Populate a mesh creation packet.

Parameters
packetA packet to populate and send.
Returns
Zero on success, an error code otherwise.

Implements tes::Resource.

◆ destroy()

int tes::MeshResource::destroy ( PacketWriter packet) const
overridevirtual

Populate a mesh destroy packet.

Parameters
packetA packet to populate and send.
Returns
Zero on success, an error code otherwise.

Implements tes::Resource.

◆ drawType()

virtual uint8_t tes::MeshResource::drawType ( int  stream = 0) const
pure virtual

Returns the DrawType of the mesh.

Parameters
streamReserved for future use.

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ estimateTransferCount()

static int tes::MeshResource::estimateTransferCount ( size_t  elementSize,
unsigned  byteLimit,
int  overhead = 0 
)
static

Estimate the number of elements which can be transferred at the given byteLimit.

Parameters
elementSizeThe byte size of each element.
byteLimitThe maximum number of bytes to transfer. Note: a hard limit of 0xffff, packet header size and CRC is enforced. Zero indices use of the hard limit.
Additionalbyte overhead to account for.

◆ indexCount()

virtual unsigned tes::MeshResource::indexCount ( int  stream = 0) const
pure virtual

Returns the number of indices in the mesh.

Parameters
streamReserved for future use.
Returns
The number of indices.

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ indices()

virtual const uint8_t* tes::MeshResource::indices ( unsigned &  stride,
unsigned &  width,
int  stream = 0 
) const
pure virtual

Returns a pointer to the index stream.

Supports different index widths. Expects indexCount(stream) elements or null if no indices.

Parameters
[out]strideSpecifies the stride between index elements (bytes). This would be 4 for a contiguous array of uint32_t indices.
[out]Specifiesthe index byte width. Supports [1, 2, 4].
streamReserved for future use.
Returns
A pointer to the first index.

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ normals()

virtual const float* tes::MeshResource::normals ( unsigned &  stride,
int  stream = 0 
) const
pure virtual

Returns a pointer to the normal stream.

Each element is taken as a triple of single precision floats: (x, y, z). Expects vertexColour(stream) elements or null if no normals.

Parameters
[out]strideThe stride between normal elements (bytes). This would be 12 for a contiguous array of float triples.
streamReserved for future use.
Returns
A pointer to the first normal or null

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ packet()

* tes::PacketWriter tes::MeshResource::packet ( )

Compose a mesh index component message in packet.

This method composes a MeshComponentMessage for writing index data to packet. The packet must be reset before calling this method and finalised after calling.

The number of indices written is limited by three factors:

  1. The available packet buffer space.
  2. The byteLimit
  3. The remaining indices to write from offset. All present hard limits to the number of indices written to packet. The number of indices written is reported in the return value.

The index source address starts at dataSource plus dataStride times offset. The dataStride identifies the space between indices while indexByteWidth identifies the number of bytes in each integer index.

A complete index set can be written by repeated calls, using the following code: tes::Server server = / server pointer

◆ transfer()

int tes::MeshResource::transfer ( PacketWriter packet,
int  byteLimit,
TransferProgress progress 
) const
overridevirtual

Populate the next mesh data packet.

The progress.phase is used to track which data array currently being transfered, from the various MeshMessageType values matching components (e.g., vertices, indices). The progress.progress value is used to track how many have been transfered.

Parameters
packetA packet to populate and send.
byteLimitA nominal byte limit on how much data a single transfer() call may add.
[in,out]progressA progress marker tracking how much has already been transfered, and updated to indicate what has been added to packet.
Returns
Zero on success, an error code otherwise.

Implements tes::Resource.

◆ uvs()

virtual const float* tes::MeshResource::uvs ( unsigned &  stride,
int  stream = 0 
) const
pure virtual

Returns a pointer to the UV stream.

Each element is taken as a pair of single precision floats: (u, v). Expects vertexCount(stream) elements or null if no UVs.

Parameters
[out]strideThe stride between UV elements (bytes). This would be 8 for a contiguous array of float pairs.
streamReserved for future use.
Returns
A pointer to the first UV coordinate or null.

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ vertexCount()

virtual unsigned tes::MeshResource::vertexCount ( int  stream = 0) const
pure virtual

Returns the number of vertices in the mesh.

Parameters
streamReserved for future use.
Returns
The number of vertices.

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ vertices()

virtual const float* tes::MeshResource::vertices ( unsigned &  stride,
int  stream = 0 
) const
pure virtual

Returns a pointer to the vertex stream.

Each element is taken as a triple of single precision floats: (x, y, z).

Parameters
[out]strideThe stride between vertex elements (bytes). This would be 12 for a contiguous array of float triples.
streamReserved for future use.
Returns
A pointer to the first vertex.

Implemented in tes::SimpleMesh, tes::PointCloud, and tes::MeshPlaceholder.

◆ writeColours()

static unsigned tes::MeshResource::writeColours ( PacketWriter packet,
uint32_t  meshId,
uint32_t  offset,
unsigned  byteLimit,
const uint8_t *  dataSource,
unsigned  dataStride,
uint32_t  componentCount 
)
static

Compose a mesh component message for writing colour data in packet.

This method is very similar to writeIndices() and writeVectors3(), except that it is intended for 4-byte colour values. Example call below: packet.reset(mesh->typeId(), MmtVertexColour); offset += tes::MeshResource::writeColours( packet, mesh->id(), offset, 0xffffffffu, coloursPtr, dataStride, mesh->vertexCount());

Parameters
packetPacket to write to.
meshIdThe mesh to which the data belong.
offsetAn vertex count offset to start writing from. See remarks.
byteLimitA hard limit on the number of bytes to write.
dataSourceBase pointer for the vertex data.
dataStrideNumber of bytes between indices.
componentCountThe total number of indices.
Returns
The number of indices written.

◆ writeVectors2()

static unsigned tes::MeshResource::writeVectors2 ( PacketWriter packet,
uint32_t  meshId,
uint32_t  offset,
unsigned  byteLimit,
const uint8_t *  dataSource,
unsigned  dataStride,
uint32_t  componentCount 
)
static

Compose a mesh float vector 2 component message in packet.

This method is identical to writeVectors3(), except that it deals with vector 2 components such as UV coordinates (MmtUv).

Parameters
packetPacket to write to.
meshIdThe mesh to which the data belong.
offsetAn vertex count offset to start writing from. See remarks.
byteLimitA hard limit on the number of bytes to write.
dataSourceBase pointer for the vertex data.
dataStrideNumber of bytes between indices.
componentCountThe total number of indices.
Returns
The number of indices written.

Member Data Documentation

◆ offset

* tes::MeshResource::offset
Initial value:
= tes::MeshResource::writeVectors3(
* packet, mesh->id(), offset,
* 0xffffffffu, vectorPtr,
* dataStride, mesh->vertexCount())

Compose a mesh float vector 3 component message in packet.

This method composes a MeshComponentMessage for writing vector based data to packet. The packet must be reset before calling this method and finalised after calling.

The behaviour and calling pattern matches writeIndices(), except that the size of each vector component is assumed to be three floats (12). The code below shows the call required to replace writeIndices() in that example code: packet.reset(mesh->typeId(), /* MmtVertex or MmtNormal


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