Environement.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 namespace ege {
9  class Environement;
10  class ElementInteraction;
11 };
12 #include <ege/camera/Camera.hpp>
13 #include <ege/ParticuleEngine.hpp>
14 
15 #include <etk/types.hpp>
16 #include <BulletDynamics/Dynamics/btActionInterface.h>
17 class btDynamicsWorld;
18 
19 #include <vector>
20 #include <etk/math/Vector3D.hpp>
21 #include <ejson/ejson.hpp>
22 #include <exml/exml.hpp>
23 #include <ewol/object/Object.hpp>
24 #include <esignal/Signal.hpp>
25 #include <ewol/event/Time.hpp>
26 #include <eproperty/Value.hpp>
27 #include <ege/resource/Mesh.hpp>
28 #include <ege/physics/Engine.hpp>
29 
30 namespace ege {
31  class Element;
32  class Environement;
33  typedef ememory::SharedPtr<ege::Element> (*createElement_tf)(const ememory::SharedPtr<ege::Environement>& _env);
34 
35  enum gameStatus {
36  gameStart,
37  gamePause,
38  gameStop
39  };
40 
42  protected:
43  int32_t m_type;
44  public:
45  int32_t getType() {
46  return m_type;
47  };
48  protected:
49  int32_t m_groupSource;
50  public:
51  int32_t getSourceGroup() {
52  return m_groupSource;
53  };
54  protected:
55  std::vector<int32_t> m_groupDestination;
56  public:
57  const std::vector<int32_t>& getDestinationGroup() {
58  return m_groupDestination;
59  };
60  void addGroupDestination(int32_t _id) {
61  m_groupDestination.push_back(_id);
62  };
63  protected:
64  vec3 m_positionSource;
65  public:
66  const vec3& getSourcePosition() {
67  return m_positionSource;
68  };
69  public:
70  ElementInteraction(int32_t _type, int32_t _groupSource, const vec3& _pos) :
71  m_type(_type),
72  m_groupSource(_groupSource),
73  m_positionSource(_pos)
74  { };
75  public:
76  virtual void applyEvent(ege::Element& _element) { };
77  };
78 
79  class Environement : public ewol::Object {
80  public:
81  // Signals
82  esignal::Signal<float> signalPlayTimeChange;
83  // properties:
84  eproperty::List<enum gameStatus> propertyStatus;
85  eproperty::Value<float> propertyRatio;
86  private:
87  //ememory::SharedPtr<btDynamicsWorld> m_dynamicsWorld; //!< curent system world description
88  ege::physics::Engine m_physicEngine;
89  std::vector<ememory::SharedPtr<ege::Element>> m_listElement;
90  protected:
91  Environement();
92  public:
93  DECLARE_FACTORY(Environement);
94  virtual ~Environement() { };
95  protected:
96  protected:
97  std::map<std::string, ememory::SharedPtr<ege::Camera>> m_listCamera;
98  public:
104  void addCamera(const std::string& _name, const ememory::SharedPtr<ege::Camera>& _camera);
110  ememory::SharedPtr<ege::Camera> getCamera(const std::string& _name);
115  std::map<std::string, ememory::SharedPtr<ege::Camera>> getCameraList() const {
116  return m_listCamera;
117  }
118  public:
122  void clear();
128  static void addCreator(const std::string& _type, ege::createElement_tf _creator);
137  ememory::SharedPtr<ege::Element> createElement(const std::string& _type, const std::string& _description, bool _autoAddElement=true);
138  ememory::SharedPtr<ege::Element> createElement(const std::string& _type, const ejson::Value& _value, bool _autoAddElement=true);
139  ememory::SharedPtr<ege::Element> createElement(const std::string& _type, const exml::Node& _node, bool _autoAddElement=true);
140  ememory::SharedPtr<ege::Element> createElement(const std::string& _type, void* _data, bool _autoAddElement=true);
141  ememory::SharedPtr<ege::Element> createElement(const std::string& _type, bool _autoAddElement=true);
142  public:
144  public:
146  float dist;
147  };
148  #if 0
149 
153  void setDynamicWorld(const ememory::SharedPtr<btDynamicsWorld>& _newWorld) {
154  m_dynamicsWorld=_newWorld;
155  };
160  ememory::SharedPtr<btDynamicsWorld> getDynamicWorld() {
161  return m_dynamicsWorld;
162  };
163  #endif
164  ege::physics::Engine& getPhysicEngine() {
165  return m_physicEngine;
166  }
171  std::vector<ememory::SharedPtr<ege::Element>>& getElement() {
172  return m_listElement;
173  };
180  ememory::SharedPtr<ege::Element> getElementNearest(ememory::SharedPtr<ege::Element> _sourceRequest, float& _distance);
181 
182  void getElementNearest(const vec3& _sourcePosition,
183  float _distanceMax,
184  std::vector<ege::Environement::ResultNearestElement>& _resultList);
185  void getElementNearestFixed(const vec3& _sourcePosition,
186  float _distanceMax,
187  std::vector<ege::Environement::ResultNearestElement>& _resultList);
192  void addElement(ememory::SharedPtr<ege::Element> _newElement);
197  void rmElement(ememory::SharedPtr<ege::Element> _removeElement);
204  void getOrderedElementForDisplay(std::vector<ege::Environement::ResultNearestElement>& _resultList, const vec3& _position, const vec3& _direction);
209  void generateInteraction(ege::ElementInteraction& _event);
210  private:
211  ege::ParticuleEngine m_particuleEngine;
212  public:
218  return m_particuleEngine;
219  };
220  protected:
221  int64_t m_gameTime;
222  public:
223  esignal::Connection m_periodicCallConnection;
224  private:
225  void onCallbackPeriodicCall(const ewol::event::Time& _event);
226  protected:
227  std::vector<ememory::SharedPtr<ege::resource::Mesh>> m_listMeshToDrawFirst;
228  public:
229  void addStaticMeshToDraw(const ememory::SharedPtr<ege::resource::Mesh>& _mesh) {
230  m_listMeshToDrawFirst.push_back(_mesh);
231  }
232  std::vector<ememory::SharedPtr<ege::resource::Mesh>>& getStaticMeshToDraw() {
233  return m_listMeshToDrawFirst;
234  }
235  virtual void onChangePropertyStatus();
236  };
237 }
238 
239 
Definition: Environement.hpp:79
Definition: Environement.hpp:143
ege::ParticuleEngine & getParticuleEngine()
get the particule engine reference.
Definition: Environement.hpp:217
Definition: AudioElement.hpp:8
Definition: ParticuleEngine.hpp:16
Definition: Engine.hpp:41
void clear()
std::map< std::string, ememory::SharedPtr< ege::Camera > > getCameraList() const
Get List of all camera.
Definition: Environement.hpp:115
Definition: Environement.hpp:41
int64_t m_gameTime
time of the game running
Definition: Environement.hpp:219
eproperty::Value< float > propertyRatio
Speed ratio.
Definition: Environement.hpp:85
std::map< std::string, ememory::SharedPtr< ege::Camera > > m_listCamera
list of all camera in the world
Definition: Environement.hpp:94
eproperty::List< enum gameStatus > propertyStatus
the display is running (not in pause)
Definition: Environement.hpp:84
std::vector< ememory::SharedPtr< ege::Element > > & getElement()
Definition: Environement.hpp:171
Definition: Element.hpp:28