3es  0.7
3esmeshset.h
1 //
2 // author: Kazys Stepanas
3 //
4 #ifndef _3ESMESH_H_
5 #define _3ESMESH_H_
6 
7 #include "3es-core.h"
8 #include "3esshape.h"
9 
10 #include <3esmatrix4.h>
11 
12 #include <cstdint>
13 
14 namespace tes
15 {
16  class MeshResource;
17 
20  class _3es_coreAPI MeshSet : public Shape
21  {
22  public:
27  MeshSet(uint32_t id = 0u, uint16_t category = 0u, int partCount = 0);
32  MeshSet(const MeshResource *part, uint32_t id = 0u, uint16_t category = 0u);
33 
35  ~MeshSet();
36 
39  int partCount() const;
45  void setPart(int index, const MeshResource *part, const Matrix4f &transform);
49  const MeshResource *partAt(int index) const;
53  const Matrix4f &partTransform(int index) const;
54 
56  bool writeCreate(PacketWriter &stream) const override;
57 
60  int enumerateResources(const Resource **resources, int capacity, int fetchOffset = 0) const override;
61 
64  Shape *clone() const override;
65 
66  protected:
67  void onClone(MeshSet *copy) const;
68 
69  private:
70  const MeshResource **_parts;
71  Matrix4f *_transforms;
72  int _partCount;
73  };
74 
75  inline int MeshSet::partCount() const { return _partCount; }
76 
77  inline void MeshSet::setPart(int index, const MeshResource *part, const Matrix4f &transform)
78  {
79  _parts[index] = part;
80  _transforms[index] = transform;
81  }
82 
83  inline const MeshResource *MeshSet::partAt(int index) const { return _parts[index]; }
84 
85  inline const Matrix4f &MeshSet::partTransform(int index) const { return _transforms[index]; }
86 }
87 
88 #endif // _3ESMESH_H_
void setPart(int index, const MeshResource *part, const Matrix4f &transform)
Set the part at the given index.
Definition: 3esmeshset.h:77
A base class for encapsulating a shape which is to be represented remotely.
Definition: 3esshape.h:39
A row major 4x4 transformation matrix.
Definition: 3esmatrix4.h:27
Definition: 3esbounds.h:13
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
const MeshResource * partAt(int index) const
Fetch the part at the given index.
Definition: 3esmeshset.h:83
Represents a mesh shape.
Definition: 3esmeshset.h:20
int partCount() const
Get the number of parts to this shape.
Definition: 3esmeshset.h:75
const Matrix4f & partTransform(int index) const
Fetch the transform for the part at the given index.
Definition: 3esmeshset.h:85
A utility class for writing payload data to a PacketHeader.
Definition: 3espacketwriter.h:34