47 lines
948 B
C++
47 lines
948 B
C++
#pragma once
|
|
#ifndef __Camera__
|
|
#define __Camera__
|
|
|
|
#include <memory>
|
|
|
|
#define GLM_FORCE_RADIANS
|
|
#include <glm/glm.hpp>
|
|
|
|
class MatrixStack;
|
|
|
|
class Camera
|
|
{
|
|
public:
|
|
enum {
|
|
ROTATE = 0,
|
|
TRANSLATE,
|
|
SCALE
|
|
};
|
|
|
|
Camera();
|
|
virtual ~Camera();
|
|
void setInitDistance(float z) { translations.z = -std::abs(z); }
|
|
void setAspect(float a) { aspect = a; };
|
|
void setRotationFactor(float f) { rfactor = f; };
|
|
void setTranslationFactor(float f) { tfactor = f; };
|
|
void setScaleFactor(float f) { sfactor = f; };
|
|
void mouseClicked(float x, float y, bool shift, bool ctrl, bool alt);
|
|
void mouseMoved(float x, float y);
|
|
void applyProjectionMatrix(std::shared_ptr<MatrixStack> P) const;
|
|
void applyViewMatrix(std::shared_ptr<MatrixStack> MV) const;
|
|
|
|
private:
|
|
float aspect;
|
|
float fovy;
|
|
float znear;
|
|
float zfar;
|
|
glm::vec2 rotations;
|
|
glm::vec3 translations;
|
|
glm::vec2 mousePrev;
|
|
int state;
|
|
float rfactor;
|
|
float tfactor;
|
|
float sfactor;
|
|
};
|
|
|
|
#endif
|