-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.h
executable file
·81 lines (67 loc) · 1.76 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
77
78
79
80
81
//
// Camera.h
// RealtimeRending
//
// Created by Philipp Lensing on 22.10.14.
// Copyright (c) 2014 Philipp Lensing. All rights reserved.
//
#ifndef __RealtimeRending__Camera__
#define __RealtimeRending__Camera__
#include <iostream>
#ifdef WIN32
#include <GL/glew.h>
#include <glfw/glfw3.h>
#else
#define GLFW_INCLUDE_GLCOREARB
#define GLFW_INCLUDE_GLEXT
#include <glfw/glfw3.h>
#endif
#include "vector.h"
#include "matrix.h"
class BaseCamera
{
public:
virtual void update() = 0;
virtual const Matrix& getViewMatrix() const = 0;
virtual const Matrix& getProjectionMatrix() const = 0;
virtual Vector position() const = 0;
virtual ~BaseCamera() {};
};
class Camera : public BaseCamera
{
public:
Camera(GLFWwindow* pWin);
virtual ~Camera() {};
virtual Vector position() const;
Vector target() const;
Vector up() const;
void setPosition( const Vector& Pos);
void setTarget( const Vector& Target);
void setUp( const Vector& Up);
void mouseInput( int x, int y, int Button, int State);
virtual void update();
virtual const Matrix& getViewMatrix() const;
virtual const Matrix& getProjectionMatrix() const;
protected:
void updateMouseInput();
void pan( float dx, float dy);
void zoom( float dz);
void rotate( float x, float y );
Vector getVSpherePos( float x, float y);
Vector rotateAxisAngle( Vector v, Vector n, float a);
Matrix m_ViewMatrix;
Matrix m_ProjMatrix;
Vector m_Position;
Vector m_Target;
Vector m_Up;
Vector m_Panning;
Vector m_Zoom;
Vector m_Rotation;
int m_LastMouseX;
int m_LastMouseY;
int WindowWidth;
int WindowHeight;
GLFWwindow* pWindow;
private:
};
#endif /* defined(__RealtimeRending__Camera__) */