gKit2 light
Loading...
Searching...
No Matches
tuto_shadows.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 17 of file tuto_shadows.cpp.

18{
19 glLineWidth(2);
20 Mesh grid= Mesh(GL_LINES);
21
22 // grille
23 grid.color(White());
24 float w= float(n-1) / 2;
25 for(int x= 0; x < n; x++)
26 {
27 grid.vertex(x -w, 0, -w);
28 grid.vertex(x -w, 0, w);
29 }
30
31 for(int z= 0; z < n; z++)
32 {
33 grid.vertex(-w, 0, z -w);
34 grid.vertex( w, 0, z -w);
35 }
36
37 // axes XYZ
38 grid.color(Red());
39 grid.vertex(0, .1, 0);
40 grid.vertex(1, .1, 0);
41
42 grid.color(Green());
43 grid.vertex(0, .1, 0);
44 grid.vertex(0, 1, 0);
45
46 grid.color(Blue());
47 grid.vertex(0, .1, 0);
48 grid.vertex(0, .1, 1);
49
50 return grid;
51}
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 54 of file tuto_shadows.cpp.

55{
56 Mesh grid= Mesh(GL_TRIANGLES);
57
58 grid.normal(0, 1, 0);
59 int a= grid.vertex(-n/2, -1, n/2);
60 int b= grid.vertex( n/2, -1, n/2);
61 int c= grid.vertex( n/2, -1, -n/2);
62 int d= grid.vertex(-n/2, -1, -n/2);
63 grid.triangle(a, b, c);
64 grid.triangle(a, c, d);
65
66 return grid;
67}
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 69 of file tuto_shadows.cpp.

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

◆ make_frustum()

Mesh make_frustum ( )

Definition at line 90 of file tuto_shadows.cpp.

91{
92 glLineWidth(2);
93 Mesh camera= Mesh(GL_LINES);
94
95 camera.color(Yellow());
96 // face avant
97 camera.vertex(-1, -1, -1);
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
106 // face arriere
107 camera.vertex(-1, -1, 1);
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
116 // aretes
117 camera.vertex(-1, -1, -1);
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
126 return camera;
127}
Color Yellow()
utilitaire. renvoie une couleur jaune.
Definition color.cpp:43

◆ main()

int main ( int argc,
char ** argv )

Definition at line 340 of file tuto_shadows.cpp.

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