INFO804 Introduction à l'informatique graphique
Loading...
Searching...
No Matches
Viewer.cpp
Go to the documentation of this file.
1/// \file Viewer.cpp
2#include "Viewer.h"
3
4using namespace std;
5
6// Draws a tetrahedron with 4 colors.
8{
9 float colorBronzeDiff[4] = { 0.8, 0.6, 0.0, 1.0 };
10 float colorRedDiff [4] = { 1.0, 0.0, 0.0, 1.0 };
11 float colorGreenDiff [4] = { 0.0, 1.0, 0.0, 1.0 };
12 float colorBlueDiff [4] = { 0.0, 0.0, 1.0, 1.0 };
13
14 // Draws triangles given by 3 vertices.
15 glBegin(GL_TRIANGLES);
16 glColor4fv(colorBronzeDiff);
17 glVertex3f( 0.0, 0.0, 0.0 );
18 glVertex3f( 1.0, 0.0, 0.0 );
19 glVertex3f( 0.0, 1.0, 0.0 );
20 glColor4fv(colorRedDiff);
21 glVertex3f( 1.0, 0.0, 0.0 );
22 glVertex3f( 0.0, 1.0, 0.0 );
23 glVertex3f( 0.0, 0.0, 1.0 );
24 glColor4fv(colorGreenDiff);
25 glVertex3f( 0.0, 0.0, 0.0 );
26 glVertex3f( 0.0, 1.0, 0.0 );
27 glVertex3f( 0.0, 0.0, 1.0 );
28 glColor4fv(colorBlueDiff);
29 glVertex3f( 0.0, 0.0, 0.0 );
30 glVertex3f( 1.0, 0.0, 0.0 );
31 glVertex3f( 0.0, 0.0, 1.0 );
32 glEnd();
33}
34
35
37{
38 // Restore previous viewer state.
39 restoreStateFromFile();
40
41 // Opens help window
42 help();
43}
44
45QString Viewer::helpString() const
46{
47 QString text("<h2>S i m p l e V i e w e r</h2>");
48 text += "Use the mouse to move the camera around the object. ";
49 text += "You can respectively revolve around, zoom and translate with the three mouse buttons. ";
50 text += "Left and middle buttons pressed together rotate around the camera view direction axis<br><br>";
51 text += "Pressing <b>Alt</b> and one of the function keys (<b>F1</b>..<b>F12</b>) defines a camera keyFrame. ";
52 text += "Simply press the function key again to restore it. Several keyFrames define a ";
53 text += "camera path. Paths are saved when you quit the application and restored at next start.<br><br>";
54 text += "Press <b>F</b> to display the frame rate, <b>A</b> for the world axis, ";
55 text += "<b>Alt+Return</b> for full screen mode and <b>Control+S</b> to save a snapshot. ";
56 text += "See the <b>Keyboard</b> tab in this window for a complete shortcut list.<br><br>";
57 text += "Double clicks automates single click actions: A left button double click aligns the closer axis with the camera (if close enough). ";
58 text += "A middle button double click fits the zoom of the camera and the right button re-centers the scene.<br><br>";
59 text += "A left button double click while holding right button pressed defines the camera <i>Revolve Around Point</i>. ";
60 text += "See the <b>Mouse</b> tab and the documentation web pages for details.<br><br>";
61 text += "Press <b>Escape</b> to exit the viewer.";
62 return text;
63}
virtual void init()
Called before the first draw.
Definition Viewer.cpp:36
virtual void draw()
Called at each draw of the window.
Definition Viewer.cpp:7
virtual QString helpString() const
Called when pressing help.
Definition Viewer.cpp:45