gKit2 light
Loading...
Searching...
No Matches
tuto_deferred_decal.cpp File Reference
#include "wavefront.h"
#include "texture.h"
#include "program.h"
#include "uniforms.h"
#include "framebuffer.h"
#include "orbiter.h"
#include "draw.h"
#include "app_camera.h"

Go to the source code of this file.

Classes

class  TP

Functions

Mesh make_grid (const int n=10)
Mesh make_ground (const int n=10)
Mesh make_xyz ()
Mesh make_frustum ()
int main (int argc, char **argv)

Function Documentation

◆ make_grid()

Mesh make_grid ( const int n = 10)

Definition at line 18 of file tuto_deferred_decal.cpp.

19{
20 glLineWidth(2);
21 Mesh grid= Mesh(GL_LINES);
22
23 // grille
24 grid.color(White());
25 float w= float(n-1) / 2;
26 for(int x= 0; x < n; x++)
27 {
28 grid.vertex(x -w, 0, -w);
29 grid.vertex(x -w, 0, w);
30 }
31
32 for(int z= 0; z < n; z++)
33 {
34 grid.vertex(-w, 0, z -w);
35 grid.vertex( w, 0, z -w);
36 }
37
38 // axes XYZ
39 grid.color(Red());
40 grid.vertex(0, .1, 0);
41 grid.vertex(1, .1, 0);
42
43 grid.color(Green());
44 grid.vertex(0, .1, 0);
45 grid.vertex(0, 1, 0);
46
47 grid.color(Blue());
48 grid.vertex(0, .1, 0);
49 grid.vertex(0, .1, 1);
50
51 return grid;
52}
representation d'un objet / maillage.
Definition mesh.h:121
unsigned int vertex(const vec3 &p)
insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(),...
Definition mesh.cpp:97
Mesh & color(const vec4 &c)
definit la couleur du prochain sommet.
Definition mesh.cpp:66
Color Red()
utilitaire. renvoie une couleur rouge.
Definition color.cpp:28
Color Blue()
utilitaire. renvoie une couleur bleue.
Definition color.cpp:38
Color Green()
utilitaire. renvoie une couleur verte.
Definition color.cpp:33
Color White()
utilitaire. renvoie une couleur blanche.
Definition color.cpp:23

◆ make_ground()

Mesh make_ground ( const int n = 10)

Definition at line 55 of file tuto_deferred_decal.cpp.

56{
57 Mesh grid= Mesh(GL_TRIANGLES);
58
59 grid.normal(0, 1, 0);
60 int a= grid.vertex(-n/2, -1, n/2);
61 int b= grid.vertex( n/2, -1, n/2);
62 int c= grid.vertex( n/2, -1, -n/2);
63 int d= grid.vertex(-n/2, -1, -n/2);
64 grid.triangle(a, b, c);
65 grid.triangle(a, c, d);
66
67 return grid;
68}
Mesh & triangle(const unsigned int a, const unsigned int b, const unsigned int c)
Definition mesh.cpp:178
Mesh & normal(const vec3 &n)
definit la normale du prochain sommet.
Definition mesh.cpp:76

◆ make_xyz()

Mesh make_xyz ( )

Definition at line 70 of file tuto_deferred_decal.cpp.

71{
72 glLineWidth(2);
73 Mesh camera= Mesh(GL_LINES);
74
75 // axes XYZ
76 camera.color(Red());
77 camera.vertex(Point(0, 0, 0));
78 camera.vertex(Point(1, 0, 0));
79
80 camera.color(Green());
81 camera.vertex(Point(0, 0, 0));
82 camera.vertex(Point(0, 1, 0));
83
84 camera.color(Blue());
85 camera.vertex(Point(0, 0, 0));
86 camera.vertex(Point(0, 0, 1));
87
88 return camera;
89}
representation d'un point 3d.
Definition vec.h:21

◆ make_frustum()

Mesh make_frustum ( )

Definition at line 91 of file tuto_deferred_decal.cpp.

92{
93 glLineWidth(2);
94 Mesh camera= Mesh(GL_LINES);
95
96 camera.color(Yellow());
97 // face avant
98 camera.vertex(-1, -1, -1);
99 camera.vertex(-1, 1, -1);
100 camera.vertex(-1, 1, -1);
101 camera.vertex(1, 1, -1);
102 camera.vertex(1, 1, -1);
103 camera.vertex(1, -1, -1);
104 camera.vertex(1, -1, -1);
105 camera.vertex(-1, -1, -1);
106
107 // face arriere
108 camera.vertex(-1, -1, 1);
109 camera.vertex(-1, 1, 1);
110 camera.vertex(-1, 1, 1);
111 camera.vertex(1, 1, 1);
112 camera.vertex(1, 1, 1);
113 camera.vertex(1, -1, 1);
114 camera.vertex(1, -1, 1);
115 camera.vertex(-1, -1, 1);
116
117 // aretes
118 camera.vertex(-1, -1, -1);
119 camera.vertex(-1, -1, 1);
120 camera.vertex(-1, 1, -1);
121 camera.vertex(-1, 1, 1);
122 camera.vertex(1, 1, -1);
123 camera.vertex(1, 1, 1);
124 camera.vertex(1, -1, -1);
125 camera.vertex(1, -1, 1);
126
127 return camera;
128}
Color Yellow()
utilitaire. renvoie une couleur jaune.
Definition color.cpp:43

◆ main()

int main ( int argc,
char ** argv )

Definition at line 336 of file tuto_deferred_decal.cpp.

337{
338 // il ne reste plus qu'a creer un objet application et la lancer
339 TP tp;
340 tp.run();
341
342 return 0;
343}
int run()
execution de l'application.
Definition app.cpp:36
Definition alpha.cpp:58