Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
voxel.h
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 
5 #include "property/property.h"
6 
7 #include "display/rendering/visuals.h"
8 
9 
10 class VoxelCluster;
11 class VoxelTreeNode;
12 class WorldObject;
13 class Sphere;
14 
15 class Voxel {
16 public:
17  Voxel(const glm::ivec3& gridCell, uint32_t color = 0xFFFFFF, float mass = defaultMass(), float hp = defaultHp(), float emissiveness = 0);
18  Voxel(const Voxel& other);
19  virtual ~Voxel();
20 
21  const glm::ivec3 &gridCell() const;
22 
23  glm::vec3 position() const;
24 
25  VoxelTreeNode *voxelTreeNode();
26  void setVoxelTreeNode(VoxelTreeNode* voxelTreeNode);
27 
28  virtual void addToCluster(VoxelCluster *cluster);
29  virtual void addToObject(WorldObject *object);
30 
31  virtual Visuals visuals() const;
32 
33  float hp() const;
34  void applyDamage(float deltaHp);
35  virtual float damageForwardingDestructionDamage();
36 
37  float normalizedMass() const;
38 
39  // These hooks apply only for WorldObjects and do not need to be called by pure VoxelClusters
40  virtual void onRemoval();
41  virtual void onDestruction();
42 
43 
44 
45 protected:
46  glm::ivec3 m_gridCell;
47  VoxelTreeNode *m_voxelTreeNode;
48  Visuals m_visuals;
49  float m_hp;
50  float m_normalizedMass;
51 
52  static Property<float>* s_defaultMass;
53  static Property<float>* s_defaultHp;
54 
55  static float defaultMass();
56  static float defaultHp();
57 };
58 
Definition: worldobject.h:43
Definition: voxelcluster.h:21
Definition: voxeltreenode.h:15
Definition: voxel.h:15
Definition: visuals.h:11
Definition: sphere.h:11