-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamera.h
76 lines (65 loc) · 2.7 KB
/
Camera.h
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
// --------------------------------------------------------------------------
// gMini,
// a minimal Glut/OpenGL app to extend
//
// Copyright(C) 2007-2009
// Tamy Boubekeur
//
// All rights reserved.
//
// 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 2 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 (http://www.gnu.org/licenses/gpl.txt)
// for more details.
//
// --------------------------------------------------------------------------
#pragma once
#include "Vec3D.h"
class Camera {
public:
Camera ();
virtual ~Camera () {}
inline float getFovAngle () const { return fovAngle; }
inline void setFovAngle (float newFovAngle) { fovAngle = newFovAngle; }
inline float getAspectRatio () const { return aspectRatio; }
inline float getNearPlane () const { return nearPlane; }
inline void setNearPlane (float newNearPlane) { nearPlane = newNearPlane; }
inline float getFarPlane () const { return farPlane; }
inline void setFarPlane (float newFarPlane) { farPlane = newFarPlane; }
inline unsigned int getScreenWidth () const { return W; }
inline unsigned int getScreenHeight () const { return H; }
void resize (int W, int H);
void initPos ();
void move (float dx, float dy, float dz);
void beginRotate (int u, int v);
void rotate (int u, int v);
void endRotate ();
void zoom (float z);
void apply ();
void getPos (float & x, float & y, float & z);
inline void getPos (Vec3Df & p) { getPos (p[0], p[1], p[2]); }
private:
float fovAngle;
float aspectRatio;
float nearPlane;
float farPlane;
int spinning, moving;
int beginu, beginv;
int H, W;
float curquat[4];
float lastquat[4];
float x, y, z;
float _zoom;
};
// Some Emacs-Hints -- please don't remove:
//
// Local Variables:
// mode:C++
// tab-width:4
// End: