gKit2 light
Loading...
Searching...
No Matches
tuto_transformations_camera.cpp File Reference
#include "wavefront.h"
#include "texture.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_camera ()
int main (int argc, char **argv)

Function Documentation

◆ make_grid()

Mesh make_grid ( const int n = 10)

Definition at line 15 of file tuto_transformations_camera.cpp.

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

Mesh make_camera ( )

Definition at line 52 of file tuto_transformations_camera.cpp.

53{
54 Mesh camera= Mesh(GL_LINES);
55
56 camera.color(Yellow());
57 camera.vertex(0,0,0);
58 camera.vertex(-0.5, -0.5, -1);
59 camera.vertex(0,0,0);
60 camera.vertex(-0.5, 0.5, -1);
61 camera.vertex(0,0,0);
62 camera.vertex(0.5, 0.5, -1);
63 camera.vertex(0,0,0);
64 camera.vertex(0.5, -0.5, -1);
65
66 camera.vertex(-0.5, -0.5, -1);
67 camera.vertex(-0.5, 0.5, -1);
68
69 camera.vertex(-0.5, 0.5, -1);
70 camera.vertex(0.5, 0.5, -1);
71
72 camera.vertex(0.5, 0.5, -1);
73 camera.vertex(0.5, -0.5, -1);
74
75 camera.vertex(0.5, -0.5, -1);
76 camera.vertex(-0.5, -0.5, -1);
77
78 // axes XYZ
79 camera.color(Red());
80 camera.vertex(Point(0, 0, 0));
81 camera.vertex(Point(1, 0, 0));
82
83 camera.color(Green());
84 camera.vertex(Point(0, 0, 0));
85 camera.vertex(Point(0, 1, 0));
86
87 camera.color(Blue());
88 camera.vertex(Point(0, 0, 0));
89 camera.vertex(Point(0, 0, 1));
90
91 glLineWidth(2);
92
93 return camera;
94}
Color Yellow()
utilitaire. renvoie une couleur jaune.
Definition color.cpp:43
representation d'un point 3d.
Definition vec.h:21

◆ main()

int main ( int argc,
char ** argv )

Definition at line 223 of file tuto_transformations_camera.cpp.

224{
225 printf("appuyez sur 'espace' pour fixer la position de la camera\n");
226 printf("appuyez sur 'c' pour dessiner avec la camera\n");
227 printf("appuyez sur 'c' et 'espace' pour dessiner avec la camera attachee derriere le cube\n");
228 printf("deplacez le cube avec les fleches de directions\n");
229
230 // il ne reste plus qu'a creer un objet application et la lancer
231 TP tp;
232 tp.run();
233
234 return 0;
235}
int run()
execution de l'application.
Definition app.cpp:36
Definition alpha.cpp:58
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
Definition text.cpp:140