gdk-graphics  1b6d84e044c2c953fd7c9501e628a67e80f4da0d
webgl1es2_entity.h
1 // © 2018 Joseph Cameron - All Rights Reserved
2 
3 #ifndef GDK_GFX_WEBGL1ES2_ENTITY_H
4 #define GDK_GFX_WEBGL1ES2_ENTITY_H
5 
6 #include <gdk/graphics_types.h>
7 #include <gdk/webgl1es2_texture.h>
8 #include <gdk/webgl1es2_material.h>
9 #include <jfc/default_ptr.h>
10 #include <gdk/entity.h>
11 
12 #include <iosfwd>
13 #include <memory>
14 #include <string_view>
15 
16 namespace gdk
17 {
18  class webgl1es2_model;
19  class webgl1es2_shader_program;
20 
27  class webgl1es2_entity final : public entity
28  {
29  private:
31  std::shared_ptr<webgl1es2_model> m_model;
32 
34  std::shared_ptr<webgl1es2_material> m_Material;
35 
37  graphics_mat4x4_type m_ModelMatrix;
38 
40  bool m_IsHidden = false;
41 
42  public:
44  virtual void hide() override;
45 
47  virtual void show() override;
48 
50  virtual bool isHidden() const override;
51 
53  virtual std::shared_ptr<model> getModel() const;
54 
56  virtual std::shared_ptr<material> getMaterial() const;
57 
61  //TODO throw if drwa is called and the currently bound model is not m_model?
62  void draw(const graphics_mat4x4_type &aViewMatrix, const graphics_mat4x4_type &aProjectionMatrix) const;
63 
65  virtual void set_model(const std::shared_ptr<model> a) override;
66  //void set_model(const std::shared_ptr<webgl1es2_model> a);
67 
69  virtual void set_model_matrix(const graphics_vector3_type &aWorldPos,
70  const graphics_quaternion_type &aRotation,
71  const graphics_vector3_type &aScale = graphics_vector3_type::One) override;
72 
73  virtual void set_model_matrix(const graphics_mat4x4_type& a) override;
74 
76  const graphics_mat4x4_type &getModelMatrix() const;
77 
79  webgl1es2_entity(const webgl1es2_entity &) = default;
81  webgl1es2_entity &operator=(const webgl1es2_entity &) = default;
82 
84  webgl1es2_entity(webgl1es2_entity &&) = default;
87 
89  webgl1es2_entity(const std::shared_ptr<webgl1es2_model>, const std::shared_ptr<webgl1es2_material>);
90 
92  ~webgl1es2_entity() = default;
93  };
94 }
95 
96 #endif
const graphics_mat4x4_type & getModelMatrix() const
returns a const ref to the model matrix
represents an observable 3d object.
Definition: entity.h:14
~webgl1es2_entity()=default
trivial destructor
Represents an observable 3D object.
Definition: webgl1es2_entity.h:27
virtual void set_model(const std::shared_ptr< model > a) override
sets this entity&#39;s model.
virtual std::shared_ptr< material > getMaterial() const
get the material
Definition: camera.h:9
virtual void hide() override
do not allow this entity to be drawn
void draw(const graphics_mat4x4_type &aViewMatrix, const graphics_mat4x4_type &aProjectionMatrix) const
draws the webgl1es2_entity at its current world position, with respect to a view and projection matri...
virtual void set_model_matrix(const graphics_vector3_type &aWorldPos, const graphics_quaternion_type &aRotation, const graphics_vector3_type &aScale=graphics_vector3_type::One) override
sets the model matrix using a vec3 position, quat rotation, vec3 scale
virtual void show() override
allow this entity to be drawn
webgl1es2_entity & operator=(const webgl1es2_entity &)=default
copy semantics
virtual std::shared_ptr< model > getModel() const
get the model
virtual bool isHidden() const override
check if the entity is hidden
webgl1es2_entity(const webgl1es2_entity &)=default
copy semantics