gKit2 light
draw.h
Go to the documentation of this file.
1 
2 #ifndef _DRAW_H
3 #define _DRAW_H
4 
5 #include "mesh.h"
6 #include "orbiter.h"
7 #include "window.h"
8 
9 
12 
15 
17 void draw( Mesh& m, const Transform& model, const Transform& view, const Transform& projection );
19 void draw( Mesh& m, const Transform& model, const Transform& view, const Transform& projection, const GLuint texture );
20 
22 void draw( Mesh& m, const Orbiter& camera );
24 void draw( Mesh& m, const Transform& model, const Orbiter& camera );
25 
27 void draw( Mesh& m, const Orbiter& camera, const GLuint texture );
29 void draw( Mesh& m, const Transform& model, const Orbiter& camera, const GLuint texture );
30 
50 class DrawParam
51 {
52 public:
54  DrawParam( ) : m_model(), m_view(), m_projection(), m_use_light(false), m_light(), m_light_color(), m_use_texture(false), m_texture(0) {}
55 
57  DrawParam& model( const Transform& m ) { m_model= m; return *this; }
59  DrawParam& view( const Transform& m ) { m_view= m; return *this; }
61  DrawParam& projection( const Transform& m ) { m_projection= m; return *this; }
62 
64  DrawParam& camera( const Orbiter& o ) { m_view= o.view(); m_projection= o.projection((float) window_width(), (float) window_height(), 45); return *this; }
66  DrawParam& camera( const Orbiter& o, const float width, const float height, const float fov ) { m_view= o.view(); m_projection= o.projection(width, height, fov); return *this; }
68  DrawParam& light( const Point& p, const Color& c= White() ) { m_use_light= true; m_light= p; m_light_color=c; return *this; }
70  DrawParam& texture( const GLuint t ) { m_use_texture= true; m_texture= t; return *this; }
71 
73  void draw( Mesh& mesh ) const;
74 
76  const Point& light() const { return m_light; }
77 
78 protected:
79  Transform m_model;
80  Transform m_view;
81  Transform m_projection;
82 
83  bool m_use_light;
84  Point m_light;
85  Color m_light_color;
86 
87  bool m_use_texture;
88  GLuint m_texture;
89 };
90 
92 void draw( Mesh& mesh, const DrawParam& param );
93 
95 #endif
representation de la camera, type orbiter, placee sur une sphere autour du centre de l'objet...
Definition: orbiter.h:16
void draw(Mesh &m, const Transform &model, const Transform &view, const Transform &projection)
dessine l'objet avec les transformations model, vue et projection.
Definition: draw.cpp:11
DrawParam & camera(const Orbiter &o)
utilise les transformations view et projection definies par une camera.
Definition: draw.h:64
representation d'un objet / maillage.
Definition: mesh.h:88
representation d'une couleur (rgba) transparente ou opaque.
Definition: color.h:13
Definition: draw.h:50
DrawParam & projection(const Transform &m)
modifie la transformation projection utilisee pour afficher l'objet.
Definition: draw.h:61
Transform view() const
renvoie la transformation vue.
Definition: orbiter.cpp:40
int window_width()
renvoie la largeur de la fenetre de l'application.
Definition: window.cpp:14
Color White()
utilitaire. renvoie une couleur blanche.
Definition: color.cpp:10
void draw(Mesh &mesh) const
dessine l'objet avec l'ensemble des parametres definis.
Definition: draw.cpp:41
Transform projection(const float width, const float height, const float fov) const
renvoie la projection reglee pour une image d'aspect width / height, et une ouverture de fov degres...
Definition: orbiter.cpp:47
DrawParam & model(const Transform &m)
modifie la transformation model utilisee pour afficher l'objet.
Definition: draw.h:57
DrawParam & view(const Transform &m)
modifie la transformation view utilisee pour afficher l'objet.
Definition: draw.h:59
DrawParam & light(const Point &p, const Color &c=White())
eclaire l'objet avec une source ponctuelle, de position p et de couleur c.
Definition: draw.h:68
int window_height()
renvoie la hauteur de la fenetre de l'application.
Definition: window.cpp:18
representation d'une transformation, une matrice 4x4, organisee par ligne / row major.
Definition: mat.h:20
DrawParam & camera(const Orbiter &o, const float width, const float height, const float fov)
utilise les transformations view et projection definies par une camera. parametres explicites de la p...
Definition: draw.h:66
representation d'un point 3d.
Definition: vec.h:19
const Point & light() const
renvoie la position de la lumière
Definition: draw.h:76
DrawParam & texture(const GLuint t)
plaque une texture a la surface de l'objet.
Definition: draw.h:70
DrawParam()
constructeur par defaut.
Definition: draw.h:54