-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamaraInter.hpp
90 lines (77 loc) · 4.07 KB
/
CamaraInter.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// *********************************************************************
// **
// ** Gestion de cámaras interactivas (clase CamaraInteractiva)
// ** Declaraciones.
// **
// ** Copyright (C) 2017 Carlos Ureña
// **
// ** This program is free software: you can redistribute it and/or modify
// ** it under the terms of the GNU General Public License as published by
// ** the Free Software Foundation, either version 3 of the License, or
// ** (at your option) any later version.
// **
// ** This program is distributed in the hope that it will be useful,
// ** but WITHOUT ANY WARRANTY; without even the implied warranty of
// ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// ** GNU General Public License for more details.
// **
// ** You should have received a copy of the GNU General Public License
// ** along with this program. If not, see <http://www.gnu.org/licenses/>.
// **
//
#ifndef CAMARA_INTER_HPP
#define CAMARA_INTER_HPP
#include "tuplasg.hpp"
#include "matrices-tr.hpp"
#include "Camara.hpp"
// *********************************************************************
//
// Clase CamaraInteractiva
//
// *********************************************************************
class CamaraInteractiva : public Camara
{
public:
bool examinar; // modo: true --> examinar, false --> primera persona (inicialmente {\bf false})
bool perspectiva ; // true --> camara perspectiva, false --> cámara ortográfica
float ratio_yx_vp; // aspect ratio del viewport (alto/ancho)
float longi, // en modo examinar: ángulo (en radianes) en torno al eje Y (longitud) (inic. 0)
lati ; // en modo examinar: ángulo (en radianes) en torno al eje X (latitud) (inic. 0))
Tupla3f aten ; // en modo examinar: punto de atención (inicialmente el origen+dist)
float dist , // en modo examinar: distancia entre el punto de atención y el observador
hfov_grad, // para cámaras perspectiva: angulo de apertura horizontal
dx,dy ; // desplazamientos 'subpixel' para antialiasing (0 por inicialmente)
// Examen Prácticas Ejercicio 2
bool persona_rotaciones; // true--> primera persona con rotaciones, false --> primera persona sin rotaciones
// constructor de cámaras interactivas, los parámetros son:
//
// * examinar_ini: fija modo examinar (true) o modo primera persona (false)
// * ratio_yx_vp_ini: ratio del viewport (alto/ancho)
// * longi_ini_grad, lati_ini_grad: longitud y latitud iniciales (en grados)
// * aten_ini: punto de atención inicial
// * pers_ini: fija proy. perspectiva (true) u ortográfica (false)
//
CamaraInteractiva( bool examinar_ini, float ratio_yx_vp_ini,
float longi_ini_grad, float lati_ini_grad,
const Tupla3f & aten_ini, bool pers_ini,
float hfov_grad_ini = 80.0,
float dist_ini = 1.8 );
// métodos para manipular (desplazar o rotar) la cámara
void moverHV( float nh, float nv ); // desplazar o rotar la cámara en horizontal/vertical
void desplaZ( float nz ); // desplazar en el eje Z de la cámara (hacia adelante o hacia detrás)
// calcula view-frustum (vf) (la matriz de proyección) usando:
// perspectiva, dist, ratio_yx_vp
void calcularViewfrustum( );
// calcula el marco de referencia de la camara y la matriz de vista (mcv), usando:
// longi, lati, dist, aten
void calcularMarcoCamara() ;
// métodos para cambiar de modo
void modoExaminar( const Tupla3f & pAten ); // fija punt. aten. y activa modo examinar
void modoExaminar(); // pasa a modo examinar (mantiene p.aten.)
void modoPrimeraPersona() ; // pasa al modo primera persona
void modoPrimeraPersonaRotaciones();
// recalcular las matrices del marco de coorda de camara, a partir de:
// mcv.org, mcv.eje[X/Y/Z]
void recalcularMatrMCV();
} ;
#endif