use class for camera handling,
orbit does not work. Need to figure out why
This commit is contained in:
26
QtMeshViewer/Header/CameraInterface.h
Normal file
26
QtMeshViewer/Header/CameraInterface.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include <QMatrix4x4>
|
||||
|
||||
class CameraInterface
|
||||
{
|
||||
public:
|
||||
explicit CameraInterface() {};
|
||||
virtual ~CameraInterface() {};
|
||||
|
||||
// attributes
|
||||
protected:
|
||||
QMatrix4x4 m_matrix;
|
||||
double m_zSpeed = 1.0;
|
||||
|
||||
// functions
|
||||
public:
|
||||
virtual void setZoomSpeed(int percent) { m_zSpeed = (double) percent / 100; };
|
||||
|
||||
virtual void rotateAction(QVector2D diff) = 0;
|
||||
virtual void moveAction(QVector2D diff) = 0;
|
||||
virtual void wheelAction(double value) = 0;
|
||||
virtual void resetView() { m_matrix = QMatrix4x4(); m_zSpeed = 1.0; };
|
||||
|
||||
virtual void recalculateMatrix() = 0;
|
||||
virtual QMatrix4x4 getMatrix() { recalculateMatrix(); return m_matrix; };
|
||||
};
|
23
QtMeshViewer/Header/FreeCamera.h
Normal file
23
QtMeshViewer/Header/FreeCamera.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "CameraInterface.h"
|
||||
|
||||
|
||||
class FreeCamera : public CameraInterface
|
||||
{
|
||||
public:
|
||||
explicit FreeCamera();
|
||||
virtual ~FreeCamera();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
QVector3D m_translation;
|
||||
QQuaternion m_rotation;
|
||||
|
||||
// functions
|
||||
public:
|
||||
virtual void rotateAction(QVector2D diff) Q_DECL_OVERRIDE;
|
||||
virtual void moveAction(QVector2D diff) Q_DECL_OVERRIDE;
|
||||
virtual void wheelAction(double value) Q_DECL_OVERRIDE;
|
||||
virtual void recalculateMatrix() Q_DECL_OVERRIDE;
|
||||
virtual void resetView() Q_DECL_OVERRIDE;
|
||||
};
|
22
QtMeshViewer/Header/MoveCamera.h
Normal file
22
QtMeshViewer/Header/MoveCamera.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "CameraInterface.h"
|
||||
|
||||
|
||||
class MoveCamera : public CameraInterface
|
||||
{
|
||||
public:
|
||||
explicit MoveCamera();
|
||||
virtual ~MoveCamera();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
|
||||
|
||||
// functions
|
||||
public:
|
||||
virtual void rotateAction(QVector2D diff) Q_DECL_OVERRIDE;
|
||||
virtual void moveAction(QVector2D diff) Q_DECL_OVERRIDE;
|
||||
virtual void wheelAction(double value) Q_DECL_OVERRIDE;
|
||||
virtual void recalculateMatrix() Q_DECL_OVERRIDE;
|
||||
virtual void resetView() Q_DECL_OVERRIDE;
|
||||
};
|
@@ -5,6 +5,7 @@
|
||||
#include <QMatrix4x4>
|
||||
#include "GeometryEngine.h"
|
||||
#include "SettingsWindow.h"
|
||||
#include "CameraInterface.h"
|
||||
|
||||
|
||||
class GeometryEngine;
|
||||
@@ -37,25 +38,16 @@ private:
|
||||
bool headlight = false;
|
||||
} m_light;
|
||||
|
||||
SettingsWindow* m_settings;
|
||||
|
||||
struct {
|
||||
bool left = false;
|
||||
bool right = false;
|
||||
QVector2D position;
|
||||
} m_mouse;
|
||||
|
||||
struct {
|
||||
bool x = true;
|
||||
bool y = true;
|
||||
bool z = true;
|
||||
} m_rotDirections;
|
||||
|
||||
QMatrix4x4 m_projection;
|
||||
QVector3D m_translation;
|
||||
QQuaternion m_rotation;
|
||||
CameraInterface* m_camera;
|
||||
|
||||
double m_zSpeed = 1.0;
|
||||
SettingsWindow* m_settings;
|
||||
|
||||
// functions
|
||||
private:
|
||||
@@ -81,10 +73,13 @@ protected:
|
||||
// slots
|
||||
public slots:
|
||||
void loadFile(QString name);
|
||||
void toggleAxis(int axis);
|
||||
void useFreeCamera();
|
||||
void useOrbitCamera();
|
||||
void useMoveCamera();
|
||||
void toggleWireframe();
|
||||
void toggleLight();
|
||||
void showSettings();
|
||||
|
||||
void setBGColorOff(QVector3D value);
|
||||
void setBGColorOn(QVector3D value);
|
||||
void setLightColor(QVector3D value);
|
||||
@@ -92,7 +87,6 @@ public slots:
|
||||
void setAmbCoef(double value);
|
||||
void setHeadlight(bool value);
|
||||
void setBackfaceCulling(bool value);
|
||||
void setZoomSpeed(int percent);
|
||||
|
||||
};
|
||||
|
||||
|
24
QtMeshViewer/Header/OrbitCamera.h
Normal file
24
QtMeshViewer/Header/OrbitCamera.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "CameraInterface.h"
|
||||
|
||||
|
||||
class OrbitCamera : public CameraInterface
|
||||
{
|
||||
public:
|
||||
explicit OrbitCamera();
|
||||
virtual ~OrbitCamera();
|
||||
|
||||
// attributes
|
||||
private:
|
||||
double m_phi;
|
||||
double m_theta;
|
||||
double m_roh;
|
||||
|
||||
// functions
|
||||
public:
|
||||
virtual void rotateAction(QVector2D diff) Q_DECL_OVERRIDE;
|
||||
virtual void moveAction(QVector2D diff) Q_DECL_OVERRIDE;
|
||||
virtual void wheelAction(double value) Q_DECL_OVERRIDE;
|
||||
virtual void recalculateMatrix() Q_DECL_OVERRIDE;
|
||||
virtual void resetView() Q_DECL_OVERRIDE;
|
||||
};
|
Reference in New Issue
Block a user