3es  0.7
3esmeshresource.h
1 //
2 // author: Kazys Stepanas
3 //
4 #ifndef _3ESMESHRESOURCE_H_
5 #define _3ESMESHRESOURCE_H_
6 
7 #include "3es-core.h"
8 #include "3esresource.h"
9 
10 #include "3esmatrix4.h"
11 
12 namespace tes
13 {
16  class _3es_coreAPI MeshResource : public Resource
17  {
18  public:
20  virtual ~MeshResource() {}
21 
27  static int estimateTransferCount(size_t elementSize, unsigned byteLimit, int overhead = 0);
28 
30  uint16_t typeId() const override;
31 
32  virtual Matrix4f transform() const = 0;
33  virtual uint32_t tint() const = 0;
34 
37  virtual uint8_t drawType(int stream = 0) const = 0;
38 
42  virtual unsigned vertexCount(int stream = 0) const = 0;
43 
47  virtual unsigned indexCount(int stream = 0) const = 0;
48 
55  virtual const float *vertices(unsigned &stride, int stream = 0) const = 0;
56 
64  virtual const uint8_t *indices(unsigned &stride, unsigned &width, int stream = 0) const = 0;
65 
73  virtual const float *normals(unsigned &stride, int stream = 0) const = 0;
74 
82  virtual const float *uvs(unsigned &stride, int stream = 0) const = 0;
83 
92  virtual const uint32_t *colours(unsigned &stride, int stream = 0) const = 0;
93 
97  int create(PacketWriter &packet) const override;
98 
102  int destroy(PacketWriter &packet) const override;
103 
115  int transfer(PacketWriter &packet, int byteLimit, TransferProgress &progress) const override;
116 
165  static unsigned writeIndices(PacketWriter &packet, uint32_t meshId,
166  uint32_t offset, unsigned byteLimit,
167  const uint8_t *dataSource, unsigned dataStride,
168  unsigned indexByteWidth, uint32_t componentCount);
169 
194  static unsigned writeVectors3(PacketWriter &packet, uint32_t meshId,
195  uint32_t offset, unsigned byteLimit,
196  const uint8_t *dataSource, unsigned dataStride,
197  uint32_t componentCount);
198 
211  static unsigned writeVectors2(PacketWriter &packet, uint32_t meshId,
212  uint32_t offset, unsigned byteLimit,
213  const uint8_t *dataSource, unsigned dataStride,
214  uint32_t componentCount);
215 
235  static unsigned writeColours(PacketWriter &packet, uint32_t meshId,
236  uint32_t offset, unsigned byteLimit,
237  const uint8_t *dataSource, unsigned dataStride,
238  uint32_t componentCount);
239 
240  protected:
241  virtual void nextPhase(TransferProgress &progress) const;
242  };
243 }
244 
245 #endif // _3ESMESHRESOURCE_H_
virtual ~MeshResource()
Virtual destructor.
Definition: 3esmeshresource.h:20
A row major 4x4 transformation matrix.
Definition: 3esmatrix4.h:27
Definition: 3esbounds.h:13
A structure tracking progress of a data transfer.
Definition: 3estransferprogress.h:18
The Resource base class defines an interface for any resource used by Shape objects such as MeshSet...
Definition: 3esresource.h:34
Represents a mesh part or object.
Definition: 3esmeshresource.h:16
A utility class for writing payload data to a PacketHeader.
Definition: 3espacketwriter.h:34