4 #ifndef _3ESMESHSHAPE_H_ 5 #define _3ESMESHSHAPE_H_ 9 #include "3esmeshmessages.h" 40 MeshShape(
DrawType drawType,
const float *vertices,
unsigned vertexCount,
size_t vertexByteSize,
52 MeshShape(
DrawType drawType,
const float *vertices,
unsigned vertexCount,
size_t vertexByteSize,
53 const unsigned *indices,
unsigned indexCount,
66 MeshShape(
DrawType drawType,
const float *vertices,
unsigned vertexCount,
size_t vertexByteSize,
80 MeshShape(
DrawType drawType,
const float *vertices,
unsigned vertexCount,
size_t vertexByteSize,
81 const unsigned *indices,
unsigned indexCount, uint32_t
id,
95 MeshShape(
DrawType drawType,
const float *vertices,
unsigned vertexCount,
size_t vertexByteSize,
96 uint32_t
id, uint16_t category,
110 MeshShape(
DrawType drawType,
const float *vertices,
unsigned vertexCount,
size_t vertexByteSize,
111 const unsigned *indices,
unsigned indexCount,
112 uint32_t
id, uint16_t category,
124 bool calculateNormals()
const;
127 MeshShape &setCalculateNormals(
bool calculate);
140 MeshShape &setNormals(
const float *normals,
size_t normalByteSize);
159 inline unsigned vertexCount()
const {
return _vertexCount; }
160 inline const float *vertices()
const {
return _vertices; }
163 inline size_t vertexByteStride()
const {
return _vertexStride *
sizeof(float); }
164 inline const float *normals()
const {
return _normals; }
165 inline size_t normalsStride()
const {
return _normalsStride; }
166 inline size_t normalsByteStride()
const {
return _normalsStride *
sizeof(float); }
167 inline size_t normalsCount()
const {
return _normalsCount; }
168 inline DrawType drawType()
const {
return _drawType; }
178 int writeData(
PacketWriter &stream,
unsigned &progressMarker)
const override;
182 Shape *clone()
const override;
187 float *allocateVertices(
unsigned count);
188 void freeVertices(
const float *&vertices);
190 unsigned *allocateIndices(
unsigned count);
191 void freeIndices(
const unsigned *&indices);
199 const unsigned *_indices;
210 :
Shape(SIdMeshShape)
219 , _drawType(DtTriangles)
220 , _ownPointers(false)
227 const V3Arg &position,
230 :
Shape(SIdMeshShape)
243 setPosition(position);
244 setRotation(rotation);
250 const unsigned *indices,
unsigned indexCount,
251 const V3Arg &position,
254 :
Shape(SIdMeshShape)
267 setPosition(position);
268 setRotation(rotation);
275 const V3Arg &position,
278 :
Shape(SIdMeshShape, id)
291 setPosition(position);
292 setRotation(rotation);
298 const unsigned *indices,
unsigned indexCount,
300 const V3Arg &position,
303 :
Shape(SIdMeshShape, id)
316 setPosition(position);
317 setRotation(rotation);
323 uint32_t
id, uint16_t category,
324 const V3Arg &position,
327 :
Shape(SIdMeshShape, id, category)
340 setPosition(position);
341 setRotation(rotation);
347 const unsigned *indices,
unsigned indexCount,
348 uint32_t
id, uint16_t category,
349 const V3Arg &position,
352 :
Shape(SIdMeshShape, id, category)
365 setPosition(position);
366 setRotation(rotation);
399 #endif // _3ESMESHSHAPE_H_ A base class for encapsulating a shape which is to be represented remotely.
Definition: 3esshape.h:39
const float * _vertices
Mesh vertices.
Definition: 3esmeshshape.h:193
~MeshShape()
Destructor.
Definition: 3esmeshshape.h:371
DrawType
Defines the primitives for a mesh.
Definition: 3esmeshmessages.h:135
MeshShape & setCalculateNormals(bool calculate)
Should normals be calculated for the mesh by the viewer?
Definition: 3esmeshshape.h:391
bool calculateNormals() const
Calculate vertex normals in the viewer?
Definition: 3esmeshshape.h:385
A Shape which uses vertices and indices to render.
Definition: 3esmeshshape.h:16
Definition: 3esbounds.h:13
const unsigned * _indices
Optional triangle indices.
Definition: 3esmeshshape.h:201
const float * _normals
Normals array, one per vertex.
Definition: 3esmeshshape.h:196
bool _ownPointers
Does this instance own its vertices and indices?
Definition: 3esmeshshape.h:204
DrawType _drawType
The primitive to render.
Definition: 3esmeshshape.h:203
Represents a vector in R3.
Definition: 3esvector3.h:14
A helper structure used to convert from float or double pointers to Vector3f arguments.
Definition: 3esv3arg.h:14
size_t vertexStride() const
Vertex stride in float elements.
Definition: 3esmeshshape.h:162
MeshShape()
Constructor for cloning.
Definition: 3esmeshshape.h:209
uint16_t flags
Flags controlling the appearance and creation of the object.
Definition: 3esmessages.h:406
bool _ownNormals
Does this instance own its normals? Always true if _ownPointers is true.
Definition: 3esmeshshape.h:205
unsigned _normalsCount
Number of _normals.
Definition: 3esmeshshape.h:198
bool isComplex() const override
Mark as complex to ensure writeData() is called.
Definition: 3esmeshshape.h:121
A helper structure used to convert from float or double pointers to Quaternionf arguments.
Definition: 3esquaternionarg.h:14
unsigned _normalsStride
Stride into _normals in float elements, not bytes.
Definition: 3esmeshshape.h:197
unsigned _vertexCount
Number of _vertices.
Definition: 3esmeshshape.h:195
unsigned _indexCount
Number of indices. Divide by 3 for the triangle count.
Definition: 3esmeshshape.h:202
A utility class for writing payload data to a PacketHeader.
Definition: 3espacketwriter.h:34
Calculate normals and rendering with lighting.
Definition: 3esmessages.h:132
SendDataType
Codes for writeData(). Note: normals must be sent before completing vertices and indices. Best done first.
Definition: 3esmeshshape.h:24
unsigned _vertexStride
Stride into _vertices in float elements, not bytes.
Definition: 3esmeshshape.h:194