3es  0.7
3espointcloud.h
1 //
2 // author: Kazys Stepanas
3 //
4 #ifndef _3ESPOINTCLOUD_H_
5 #define _3ESPOINTCLOUD_H_
6 
7 #include "3es-core.h"
8 
9 #include "3escolour.h"
10 #include "3esmeshresource.h"
11 
12 namespace tes
13 {
14  struct PointCloudImp;
15 
19  class _3es_coreAPI PointCloud : public MeshResource
20  {
21  protected:
24  PointCloud(const PointCloud &other);
25 
26  public:
29  PointCloud(uint32_t id);
31  ~PointCloud();
32 
34  uint32_t id() const override;
35 
42  PointCloud *clone() const override;
43 
46  Matrix4f transform() const override;
47 
50  uint32_t tint() const override;
51 
54  uint8_t drawType(int stream = 0) const override;
55 
58  void reserve(unsigned size);
59 
62  void resize(unsigned count);
63 
65  void squeeze();
66 
69  unsigned capacity() const;
70 
72  unsigned vertexCount(int stream = 0) const override;
74  const float *vertices(unsigned &stride, int stream = 0) const override;
77  const Vector3f *vertices() const;
78 
81  unsigned indexCount(int stream = 0) const override;
82 
85  const uint8_t *indices(unsigned &stride, unsigned &width, int stream = 0) const override;
86 
88  const float *normals(unsigned &stride, int stream = 0) const override;
91  const Vector3f *normals() const;
92 
94  const uint32_t *colours(unsigned &stride, int stream = 0) const override;
97  const Colour *colours() const;
98 
101  const float *uvs(unsigned &, int) const override;
102 
106  void addPoint(const Vector3f &point);
111  void addPoint(const Vector3f &point, const Vector3f &normal);
116  void addPoint(const Vector3f &point, const Vector3f &normal, const Colour &colour);
117 
122  void addPoints(const Vector3f *points, unsigned count);
128  void addPoints(const Vector3f *points, const Vector3f *normals, unsigned count);
134  void addPoints(const Vector3f *points, const Vector3f *normals, const Colour *colours, unsigned count);
135 
140  void setPoint(unsigned index, const Vector3f &point);
146  void setPoint(unsigned index, const Vector3f &point, const Vector3f &normal);
153  void setPoint(unsigned index, const Vector3f &point, const Vector3f &normal, const Colour &colour);
154 
159  void setNormal(unsigned index, const Vector3f &normal);
164  void setColour(unsigned index, const Colour &colour);
165 
173  void setPoints(unsigned index, const Vector3f *points, unsigned count);
182  void setPoints(unsigned index, const Vector3f *points, const Vector3f *normals, unsigned count);
191  void setPoints(unsigned index, const Vector3f *points, const Vector3f *normals, const Colour *colours, unsigned count);
192 
193  private:
196  void setCapacity(unsigned capacity);
197 
199  void copyOnWrite();
200 
201  PointCloudImp *_imp;
202  };
203 
204 
205  inline void PointCloud::addPoint(const Vector3f &point)
206  {
207  addPoints(&point, 1);
208  }
209 
210 
211  inline void PointCloud::addPoint(const Vector3f &point, const Vector3f &normal)
212  {
213  addPoints(&point, &normal, 1);
214  }
215 
216 
217  inline void PointCloud::addPoint(const Vector3f &point, const Vector3f &normal, const Colour &colour)
218  {
219  addPoints(&point, &normal, &colour, 1);
220  }
221 
222 
223 
224  inline void PointCloud::setPoint(unsigned index, const Vector3f &point)
225  {
226  setPoints(index, &point, 1);
227  }
228 
229 
230  inline void PointCloud::setPoint(unsigned index, const Vector3f &point, const Vector3f &normal)
231  {
232  setPoints(index, &point, &normal, 1);
233  }
234 
235 
236  inline void PointCloud::setPoint(unsigned index, const Vector3f &point, const Vector3f &normals, const Colour &colours)
237  {
238  setPoints(index, &point, &normals, &colours, 1);
239  }
240 }
241 
242 #endif // _3ESPOINTCLOUD_H_
A 32-bit integer colour class.
Definition: 3escolour.h:19
A row major 4x4 transformation matrix.
Definition: 3esmatrix4.h:27
Definition: 3esbounds.h:13
void setPoint(unsigned index, const Vector3f &point)
Replace an existing point.
Definition: 3espointcloud.h:224
A MeshResource which defines a point cloud by its contained vertices.
Definition: 3espointcloud.h:19
Represents a mesh part or object.
Definition: 3esmeshresource.h:16
void addPoint(const Vector3f &point)
Add a single point to the cloud.
Definition: 3espointcloud.h:205
Represents a vector in R3.
Definition: 3esvector3.h:14