camera.hpp
Go to the documentation of this file.
1 /*
2 ** TP CPE Lyon
3 ** Copyright (C) 2013 Damien Rohmer
4 **
5 ** This program is free software: you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation, either version 3 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef CAMERA_HPP
20 #define CAMERA_HPP
21 
22 #include <vec3.hpp>
23 
24 namespace cpe
25 {
26 class p2d;
27 
29 class camera
30 {
31  public:
32 
33  // ********************************************* //
34  // ********************************************* //
35  // Constructor
36  // ********************************************* //
37  // ********************************************* //
38 
40  camera(const vec3& center=vec3(0,0,-2),
41  const vec3& direction=vec3(0,0,1),
42  const vec3& up=vec3(0,1,0),
43  float dist_screen=2.0,
44  float length_screen=4.0);
45 
46  // ********************************************* //
47  // ********************************************* //
48  // Access parameters
49  // ********************************************* //
50  // ********************************************* //
51 
53  const vec3& get_center() const;
55  const vec3& get_direction() const;
57  const vec3& get_up() const;
59  float get_dist_screen() const;
61  float get_length_screen() const;
62 
63  // ********************************************* //
64  // ********************************************* //
65  // Compute position on the screen
66  // ********************************************* //
67  // ********************************************* //
68 
69  private:
70 
78  float dist_screen;
81 };
82 
86 vec3 screen_position(const camera& cam,float u,float v);
87 
88 }
89 
90 #endif