iMSTK
Interactive Medical Simulation Toolkit
imstkRenderParticles.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkGeometry.h"
10 #include "imstkMath.h"
11 #include "imstkMacros.h"
12 
13 #ifdef WIN32
14 #pragma warning( push )
15 #pragma warning( disable : 4201 )
16 #endif
17 
18 #ifdef WIN32
19 #pragma warning( pop )
20 #endif
21 
22 namespace imstk
23 {
30 {
31  Vec3f m_position = Vec3f(0, 0, 0);
32  Vec3f m_velocity = Vec3f(0, 0, 0);
33  Vec3f m_acceleration = Vec3f(0, 0, 0);
34  Vec4d m_color = Vec4d(1., 1., 1., 1.);
35  float m_age = 0;
36  bool m_created = false;
37  float m_scale = 1.0f;
38  float m_rotation = 0;
39  float m_rotationalVelocity = 0;
40  float m_rotationalAcceleration = 0;
41 };
42 
48 class RenderParticles : public Geometry
49 {
50 public:
57  RenderParticles(const unsigned int maxNumParticles = 128);
58  ~RenderParticles() override = default;
59 
60  IMSTK_TYPE_NAME(RenderParticles)
61 
62 
63  void setParticleSize(const float size);
68 
73  std::vector<std::unique_ptr<RenderParticle>>& getParticles();
74 
78  void reset();
79 
83  void incrementNumOfParticles();
84 
88  unsigned int getNumParticles();
89 
93  unsigned int getMaxNumParticles();
94 
99  std::unique_ptr<RenderParticles> clone()
100  {
101  return std::unique_ptr<RenderParticles>(cloneImplementation());
102  }
103 
104 protected:
105  unsigned int m_numParticles = 0;
106  unsigned int m_maxNumParticles = 128;
107  float m_particleSize = 0.1f;
108 
109  std::vector<std::unique_ptr<RenderParticle>> m_particles;
110  Vec3d m_vertexPositions[4];
111  Vec3d m_vertexNormals[4];
112  Vec3d m_vertexTangents[4];
113  Vec2d m_vertexUVs[4];
114  Vec3i m_triangles[2];
115 
116  void applyTransform(const Mat4d& m) override;
117 
118  void updatePostTransformData() const override {}
119 
120 private:
121  RenderParticles* cloneImplementation() const;
122 };
123 } // namespace imstk
std::vector< std::unique_ptr< RenderParticle > > m_particles
Particle objects.
std::unique_ptr< RenderParticles > clone()
Polymorphic clone, hides the declaration in superclass return own type.
Compound Geometry.
Particles for rendering.
Base class for any geometrical representation.
Definition: imstkGeometry.h:22