3es  0.7
tes::Shape Class Reference

A base class for encapsulating a shape which is to be represented remotely. More...

#include <3esshape.h>

Inheritance diagram for tes::Shape:
tes::Arrow tes::Box tes::Capsule tes::Cone tes::Cylinder tes::MeshSet tes::MeshShape tes::Plane tes::PointCloudShape tes::Sphere tes::Star tes::Text2D tes::Text3D

Public Member Functions

 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...
 
virtual bool writeCreate (PacketWriter &stream) const
 Writes the create message to stream. More...
 
virtual int writeData (PacketWriter &stream, unsigned &progressMarker) const
 Called only for complex shapes to write additional creation data. More...
 
bool writeUpdate (PacketWriter &stream) const
 
bool writeDestroy (PacketWriter &stream) const
 
virtual bool isComplex () const
 Is this a complex shape? Complex shapes have writeData() called. More...
 
virtual int enumerateResources (const Resource **resources, int capacity, int fetchOffset=0) const
 Enumerate the resources used by this shape. More...
 
virtual Shapeclone () const
 Deep copy clone. More...
 

Protected Member Functions

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

uint16_t _routingId
 
CreateMessage _data
 

Detailed Description

A base class for encapsulating a shape which is to be represented remotely.

Simple shapes only need a writeCreate() call to be fully represented, after which writeUpdate() may move the object. Complex shapes required additional data to be fully represented and the writeCreate() packet stream may not be large enough to hold all the data. Such complex shapes will have writeData() called, with a changing progress marker. Complex shapes return true from isComplex().

Note that a shape which is not complex may override the writeCreate() method and add additional data. Complex shapes are only required when this is not sufficient and the additional data may overflow the packet buffer.

Constructor & Destructor Documentation

◆ Shape()

tes::Shape::Shape ( uint16_t  routingId,
uint32_t  id,
uint16_t  category 
)
inline

Construct a box object.

Parameters
idThe shape ID, unique among Arrow objects, or zero for a transient shape.
categoryThe category grouping for the shape used for filtering.

References tes::CreateMessage::attributes, tes::CreateMessage::category, tes::ObjectAttributes::colour, flags(), tes::CreateMessage::flags, tes::CreateMessage::id, tes::ObjectAttributes::position, tes::CreateMessage::reserved, tes::ObjectAttributes::rotation, and tes::ObjectAttributes::scale.

Member Function Documentation

◆ clone()

virtual Shape* tes::Shape::clone ( ) const
virtual

Deep copy clone.

Returns
A deep copy.

Reimplemented in tes::MeshShape, tes::PointCloudShape, tes::MeshSet, tes::Text3D, and tes::Text2D.

◆ enumerateResources()

virtual int tes::Shape::enumerateResources ( const Resource **  resources,
int  capacity,
int  fetchOffset = 0 
) const
virtual

Enumerate the resources used by this shape.

Resources are most commonly used by mesh shapes to expose the mesh data, where the shape simply positions the mesh.

The function is called to fetch the shape's resources into resources, up to the given capacity. Repeated calls may be used to fetch all resources into a smaller array by using the fetchOffset parameter as a marker indicating how many items have already been fetched. Regardless, data are always written to resources starting at index zero.

This function may also be called with a nullptr for resources and/or a zero capacity. In this case the return value indicates the number of resources used by the shape.

Parameters
resourcesThe array to populate with this shape's resources.
capacityThe element count capacity of resources.
fetchOffsetAn offset used to fetch resources into an array too small to hold all available resources. It is essentially the running sum of resources fetched so far.
Returns
The number of items added to resources when resources and capacity are non zero. When resources is null or capacity zero, the return value indicates the total number of resources used by the shape.

Reimplemented in tes::PointCloudShape, and tes::MeshSet.

◆ flags()

uint16_t tes::Shape::flags ( ) const
inline

◆ isComplex()

virtual bool tes::Shape::isComplex ( ) const
inlinevirtual

Is this a complex shape? Complex shapes have writeData() called.

Returns
True if complex, false if simple.

Reimplemented in tes::MeshShape, and tes::PointCloudShape.

◆ isTransparent()

bool tes::Shape::isTransparent ( ) const
inline

Returns true if the transparent flag is set.

Returns
True if transparent flag is set.

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

◆ isTwoSided()

bool tes::Shape::isTwoSided ( ) const
inline

Returns true if the two sided shader flag is set.

Returns
True if two sided flag is set.

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

◆ isWireframe()

bool tes::Shape::isWireframe ( ) const
inline

Returns true if the wireframe flag is set.

Returns
True if wireframe flag is set.

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

◆ onClone()

void tes::Shape::onClone ( Shape copy) const
protected

Called when copy is created from this object to copy appropriate attributes to copy.

The general use case is for a subclass to override clone(), creating the correct concrete type, then call onClone() to copy data. The advantage is that onClone() can recursively call up the class hierarchy.

Parameters
copyThe newly cloned object to copy data to. Must not be null.

◆ setFlags()

Shape & tes::Shape::setFlags ( uint16_t  flags)
inline

Set the full set of ObjectFlag values.

This affects attributes such as isTwoSided() and isWireframe().

Parameters
flagsNew flag values to write.
Returns
*this.

References flags(), and tes::CreateMessage::flags.

◆ setTransparent()

Shape & tes::Shape::setTransparent ( bool  transparent)
inline

Sets the transparent flag value for this shape.

Only before sending create. Not all shapes will respect the flag.

Returns
*this.

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

◆ setTwoSided()

Shape & tes::Shape::setTwoSided ( bool  twoSided)
inline

Sets the two sided shader flag value for this shape.

Only before sending create. Not all shapes will respect the flag.

Returns
*this.

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

◆ setWireframe()

Shape & tes::Shape::setWireframe ( bool  wire)
inline

Sets the wireframe flag value for this shape.

Only before sending create. Not all shapes will respect the flag.

Returns
*this.

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

◆ updateFrom()

virtual void tes::Shape::updateFrom ( const Shape other)
virtual

Update the attributes of this shape to match other.

Used in maintaining cached copies of shapes. The shapes should already represent the same object.

Not all attributes need to be updated. Only attributes which may be updated via an UpdateMessage for this shape need be copied.

The default implementation copies only the ObjectAttributes.

Parameters
otherThe shape to update data from.

◆ writeCreate()

virtual bool tes::Shape::writeCreate ( PacketWriter stream) const
virtual

Writes the create message to stream.

Simple shapes will write all data in the create message. More complex shapes may have additional data which is required to create object (e.g., point clouds). In the latter case, only enough data to initialise the object need be written.

Reimplemented in tes::MeshShape, tes::PointCloudShape, tes::Text3D, tes::MeshSet, and tes::Text2D.

◆ writeData()

virtual int tes::Shape::writeData ( PacketWriter stream,
unsigned &  progressMarker 
) const
inlinevirtual

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 in tes::MeshShape, and tes::PointCloudShape.


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