diff --git a/ArcballCam.hpp b/ArcballCam.hpp index 1cc915b1..c39d3450 100644 --- a/ArcballCam.hpp +++ b/ArcballCam.hpp @@ -1,5 +1,5 @@ /** - * @file ArcballC.hpp + * @file ArcballCam.hpp * @brief Abstract Camera class * @author Dr. Jeffrey Paone * @@ -14,33 +14,31 @@ #include "Camera.hpp" -/// \namespace CSCI441 -/// \desc CSCI441 Helper Functions for OpenGL namespace CSCI441 { - /// \desc concrete CSCI441::Camera implementation to implement an ArcBall camera model + /// A camera that implements an ArcBall camera model. /// \note camera direction is controlled by setting theta & phi and rotating the camera class ArcballCam : public CSCI441::Camera { public: explicit ArcballCam(GLfloat minRadius = 2.0f, GLfloat maxRadius = 30.0f) : _minRadius(minRadius), _maxRadius(maxRadius) {} - /// \desc converts spherical theta & phi to cartesian x,y,z direction vector + /// converts spherical theta & phi to cartesian x,y,z direction vector /// \note sets the camera's position to be on a sphere centered /// at the camera's look at position. internally sets the /// camera's view matrix void recomputeOrientation() final; - /// \desc updates the camera's position by decreasing the camera's radius + /// updates the camera's position by decreasing the camera's radius /// \param movementFactor distance factor to scale the movement step /// \note internally sets the camera's view matrix void moveForward(GLfloat movementFactor) final; - /// \desc updates the camera's position by increasing the camera's radius + /// updates the camera's position by increasing the camera's radius /// \param movementFactor distance factor to scale the movement step /// \note internally sets the camera's view matrix void moveBackward(GLfloat movementFactor) final; private: - /// \desc updates the camera position and recalculates the view matrix + // updates the camera position and recalculates the view matrix void _updateArcballCameraViewMatrix(); void _clampRadius(); diff --git a/Camera.hpp b/Camera.hpp index d3fea5a6..e3816364 100644 --- a/Camera.hpp +++ b/Camera.hpp @@ -19,39 +19,37 @@ #include #ifndef M_PI -#define M_PI 3.14159265 +#define M_PI 3.14159265f #endif -/// \namespace CSCI441 -/// \desc CSCI441 Helper Functions for OpenGL namespace CSCI441 { - /// \desc Abstract Class to represent a synthetic camera. The following methods + /// Abstract Class to represent a synthetic camera. The following methods /// must be overridden:
/// - recomputeOrientation()
/// - moveForward()
/// - moveBackward()
class Camera { public: - /// \desc properly destroy concrete children + /// properly destroy concrete children virtual ~Camera() = default; - /// \desc Uses theta, phi, & radius to update the + /// Uses theta, phi, & radius to update the /// camera's view matrix parameters. /// The camera orientation is controlled via spherical coordinates /// and this method would orient and/or position the camera in /// cartesian coordinates. virtual void recomputeOrientation() = 0; - /// \desc steps forward along the camera's view + /// steps forward along the camera's view /// \param movementFactor scaling factor for distance to move virtual void moveForward(GLfloat movementFactor) = 0; - /// \desc steps backward along the camera's view + /// steps backward along the camera's view /// \param movementFactor scaling factor for distance to move virtual void moveBackward(GLfloat movementFactor) = 0; - /// \desc rotates the camera's POV by adding to theta & phi + /// rotates the camera's POV by adding to theta & phi /// then ensuring phi stays within the (0, pi) range and finally /// calls through to recomputeOrientation() to update the view /// parameters after the rotation @@ -62,65 +60,65 @@ namespace CSCI441 { /// and rotation can then be disabled. virtual void rotate(GLfloat dTheta, GLfloat dPhi); - /// \desc creates the View Matrix based on the position, lookAt point, and up vector + /// creates the View Matrix based on the position, lookAt point, and up vector void computeViewMatrix() { _viewMatrix = glm::lookAt( _position, _lookAtPoint, _upVector ); } - /// \desc returns the current view matrix + /// returns the current view matrix [[nodiscard]] glm::mat4 getViewMatrix() { return _viewMatrix; } - /// \desc returns the current camera position in world space + /// returns the current camera position in world space [[nodiscard]] glm::vec3 getPosition() const { return _position; } - /// \desc returns the current lookAt point in world space + /// returns the current lookAt point in world space [[nodiscard]] glm::vec3 getLookAtPoint() const { return _lookAtPoint; } - /// \desc returns the current up vector in world space + /// returns the current up vector in world space [[nodiscard]] glm::vec3 getUpVector() const { return _upVector; } - /// \desc returns the current theta value in radians + /// returns the current theta value in radians [[nodiscard]] GLfloat getTheta() const { return _theta; } - /// \desc returns the current phi value in radians + /// returns the current phi value in radians [[nodiscard]] GLfloat getPhi() const { return _phi; } - /// \desc sets the camera's position in world space + /// sets the camera's position in world space /// \param pos the new camera world space position void setPosition( glm::vec3 pos ) { _position = pos; } - /// \desc sets the camera's lookAt point in world space + /// sets the camera's lookAt point in world space /// \param lookAt the new camera world space lookAt point void setLookAtPoint( glm::vec3 lookAt ) { _lookAtPoint = lookAt; } - /// \desc sets the camera's up vector in world space + /// sets the camera's up vector in world space /// \param up the new camera world space up vector void setUpVector( glm::vec3 up ) { _upVector = up; } - /// \desc sets the camera's theta angle in radians + /// sets the camera's theta angle in radians /// \param t the new camera theta angle in radians void setTheta( GLfloat t ) { _theta = t; } - /// \desc sets the camera's phi angle in radians + /// sets the camera's phi angle in radians /// \param p the new camera phi angle in radians void setPhi( GLfloat p ) { _phi = p; } - /// \desc sets the camera's radius + /// sets the camera's radius /// \param r the new camera radius void setRadius( GLfloat r ) { _radius = r; } protected: Camera(); - /// \desc stores the View Matrix corresponding to the inverse of the Camera's Matrix + /// stores the View Matrix corresponding to the inverse of the Camera's Matrix glm::mat4 _viewMatrix; - /// \desc the cartesian position in world space of the camera + /// the cartesian position in world space of the camera glm::vec3 _position; - /// \desc the cartesian direction the camera is facing in world space + /// the cartesian direction the camera is facing in world space glm::vec3 _direction; - /// \desc the world space point in front of the camera + /// the world space point in front of the camera glm::vec3 _lookAtPoint; - /// \desc the up vector of the camera specified in world space + /// the up vector of the camera specified in world space glm::vec3 _upVector; - /// \desc spherical angle for yaw direction in radians + /// spherical angle for yaw direction in radians GLfloat _theta; - /// \desc spherical angle for pitch direction in radians + /// spherical angle for pitch direction in radians GLfloat _phi; - /// \desc spherical magnitude for direction in world space + /// spherical magnitude for direction in world space GLfloat _radius; private: - /// \desc keeps phi within the range (0, pi) to prevent the camera from flipping over + // keeps phi within the range (0, pi) to prevent the camera from flipping over void _clampPhi(); }; } diff --git a/FixedCam.hpp b/FixedCam.hpp index d42d46ef..0d009def 100644 --- a/FixedCam.hpp +++ b/FixedCam.hpp @@ -15,14 +15,18 @@ #include namespace CSCI441 { - /// \desc A camera that can be positioned and oriented but never moved or - /// rotated. + /// A camera that can be positioned and oriented but never moved or rotated. /// \note Must position via setPosition() /// \note Must orient via setLookAtPoint() class FixedCam : public CSCI441::Camera { public: + /// does nothing void recomputeOrientation() final; + /// does nothing + /// \param unused does nothing void moveForward(GLfloat unused) final; + /// does nothing + /// \param unused does nothing void moveBackward(GLfloat unused) final; }; } diff --git a/FreeCam.hpp b/FreeCam.hpp index bfa40925..bbb8493f 100644 --- a/FreeCam.hpp +++ b/FreeCam.hpp @@ -14,34 +14,32 @@ #include "Camera.hpp" -/// \namespace CSCI441 -/// \desc CSCI441 Helper Functions for OpenGL namespace CSCI441 { - /// \desc concrete CSCI441::Camera implementation to implement a FreeCam camera model + /// A camera that implements a FreeCam camera model. /// \note camera direction is controlled by setting theta & phi and rotating the camera class FreeCam : public CSCI441::Camera { public: - /// \desc converts spherical theta & phi to cartesian x,y,z direction vector + /// converts spherical theta & phi to cartesian x,y,z direction vector /// \note sets the camera's direction vector to point outward from a sphere centered /// at the camera's position and updates the camera's look at point to be a point /// on the sphere offset from the camera's position. internally sets the /// camera's view matrix void recomputeOrientation() final; - /// \desc updates the camera's position by the adding the camera's direction to the + /// updates the camera's position by the adding the camera's direction to the /// camera's position /// \param movementFactor distance factor to scale the movement step /// \note internally sets the camera's view matrix void moveForward(GLfloat movementFactor) final; - /// \desc updates the camera's position by the adding the camera's negative direction to the + /// updates the camera's position by the adding the camera's negative direction to the /// camera's position /// \param movementFactor distance factor to scale the movement step /// \note internally sets the camera's view matrix void moveBackward(GLfloat movementFactor) final; private: - /// \desc updates the look at point and recalculates the view matrix + // updates the look at point and recalculates the view matrix void _updateFreeCameraViewMatrix(); }; } diff --git a/docs/_arcball_cam_8hpp.html b/docs/_arcball_cam_8hpp.html new file mode 100644 index 00000000..47c8ff90 --- /dev/null +++ b/docs/_arcball_cam_8hpp.html @@ -0,0 +1,108 @@ + + + + + + + +CSCI441 OpenGL Library: ArcballCam.hpp File Reference + + + + + + + + + +
+
+ + + + + + +
+
CSCI441 OpenGL Library 3.12.1 +
+
CS@Mines CSCI441 Computer Graphics Course Library
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
+ +
ArcballCam.hpp File Reference
+
+
+ +

Abstract Camera class. +More...

+
#include "Camera.hpp"
+
+

Go to the source code of this file.

+ + + + +

+Classes

class  CSCI441::ArcballCam
 
+ + + + +

+Namespaces

namespace  CSCI441
 CSCI441 Helper Functions for OpenGL.
 
+

Detailed Description

+

Abstract Camera class.

+
Author
Dr. Jeffrey Paone
+ +

These functions, classes, and constants help minimize common code that needs to be written.

+
+ + + + diff --git a/docs/_arcball_cam_8hpp_source.html b/docs/_arcball_cam_8hpp_source.html index 1176de7b..4124746b 100644 --- a/docs/_arcball_cam_8hpp_source.html +++ b/docs/_arcball_cam_8hpp_source.html @@ -73,75 +73,76 @@
ArcballCam.hpp
-
1
+Go to the documentation of this file.
1
12#ifndef CSCI441_ARCBALL_CAM_HPP
13#define CSCI441_ARCBALL_CAM_HPP
14
15#include "Camera.hpp"
16
-
19namespace CSCI441 {
-
22 class ArcballCam : public CSCI441::Camera {
-
23 public:
-
24 explicit ArcballCam(GLfloat minRadius = 2.0f, GLfloat maxRadius = 30.0f) : _minRadius(minRadius), _maxRadius(maxRadius) {}
-
25
-
30 void recomputeOrientation() final;
-
31
-
35 void moveForward(GLfloat movementFactor) final;
-
36
-
40 void moveBackward(GLfloat movementFactor) final;
-
41
-
42 private:
-
44 void _updateArcballCameraViewMatrix();
+
17namespace CSCI441 {
+
20 class ArcballCam : public CSCI441::Camera {
+
21 public:
+
22 explicit ArcballCam(GLfloat minRadius = 2.0f, GLfloat maxRadius = 30.0f) : _minRadius(minRadius), _maxRadius(maxRadius) {}
+
23
+
28 void recomputeOrientation() final;
+
29
+
33 void moveForward(GLfloat movementFactor) final;
+
34
+
38 void moveBackward(GLfloat movementFactor) final;
+
39
+
40 private:
+
41 // updates the camera position and recalculates the view matrix
+
42 void _updateArcballCameraViewMatrix();
+
43
+
44 void _clampRadius();
45
-
46 void _clampRadius();
-
47
-
48 GLfloat _minRadius;
-
49 GLfloat _maxRadius;
-
50 };
-
51}
-
52
- -
54 // compute direction vector based on spherical to cartesian conversion
-
55 _direction.x = glm::sin( _theta )*glm::sin( _phi ) * _radius;
-
56 _direction.y = -glm::cos( _phi ) * _radius;
-
57 _direction.z = -glm::cos( _theta )*glm::sin( _phi ) * _radius;
-
58
-
59 _updateArcballCameraViewMatrix();
-
60}
-
61
-
62inline void CSCI441::ArcballCam::moveForward(GLfloat movementFactor) {
-
63 _radius -= movementFactor;
-
64 _clampRadius();
-
65 recomputeOrientation();
-
66}
-
67
-
68inline void CSCI441::ArcballCam::moveBackward(GLfloat movementFactor) {
-
69 _radius += movementFactor;
-
70 _clampRadius();
-
71 recomputeOrientation();
-
72}
-
73
-
74inline void CSCI441::ArcballCam::_updateArcballCameraViewMatrix() {
-
75 setPosition( _lookAtPoint + _direction );
-
76 computeViewMatrix();
-
77}
-
78
-
79inline void CSCI441::ArcballCam::_clampRadius() {
-
80 _radius = glm::clamp(_radius, _minRadius, _maxRadius);
-
81}
-
82
-
83#endif // CSCI441_ARCBALL_CAM_HPP
+
46 GLfloat _minRadius;
+
47 GLfloat _maxRadius;
+
48 };
+
49}
+
50
+ +
52 // compute direction vector based on spherical to cartesian conversion
+
53 _direction.x = glm::sin( _theta )*glm::sin( _phi ) * _radius;
+
54 _direction.y = -glm::cos( _phi ) * _radius;
+
55 _direction.z = -glm::cos( _theta )*glm::sin( _phi ) * _radius;
+
56
+
57 _updateArcballCameraViewMatrix();
+
58}
+
59
+
60inline void CSCI441::ArcballCam::moveForward(GLfloat movementFactor) {
+
61 _radius -= movementFactor;
+
62 _clampRadius();
+
63 recomputeOrientation();
+
64}
+
65
+
66inline void CSCI441::ArcballCam::moveBackward(GLfloat movementFactor) {
+
67 _radius += movementFactor;
+
68 _clampRadius();
+
69 recomputeOrientation();
+
70}
+
71
+
72inline void CSCI441::ArcballCam::_updateArcballCameraViewMatrix() {
+
73 setPosition( _lookAtPoint + _direction );
+
74 computeViewMatrix();
+
75}
+
76
+
77inline void CSCI441::ArcballCam::_clampRadius() {
+
78 _radius = glm::clamp(_radius, _minRadius, _maxRadius);
+
79}
+
80
+
81#endif // CSCI441_ARCBALL_CAM_HPP
Abstract Camera class.
-
Definition: ArcballCam.hpp:22
-
void recomputeOrientation() final
Definition: ArcballCam.hpp:53
-
void moveForward(GLfloat movementFactor) final
Definition: ArcballCam.hpp:62
-
void moveBackward(GLfloat movementFactor) final
Definition: ArcballCam.hpp:68
-
Definition: Camera.hpp:34
-
GLfloat _phi
\desc spherical angle for pitch direction in radians
Definition: Camera.hpp:118
-
glm::vec3 _direction
\desc the cartesian direction the camera is facing in world space
Definition: Camera.hpp:109
-
GLfloat _theta
\desc spherical angle for yaw direction in radians
Definition: Camera.hpp:116
-
GLfloat _radius
\desc spherical magnitude for direction in world space
Definition: Camera.hpp:120
-
CSCI441 Helper Functions for OpenGL.
+
Definition: ArcballCam.hpp:20
+
void recomputeOrientation() final
Definition: ArcballCam.hpp:51
+
void moveForward(GLfloat movementFactor) final
Definition: ArcballCam.hpp:60
+
void moveBackward(GLfloat movementFactor) final
Definition: ArcballCam.hpp:66
+
Definition: Camera.hpp:32
+
GLfloat _phi
spherical angle for pitch direction in radians
Definition: Camera.hpp:116
+
glm::vec3 _direction
the cartesian direction the camera is facing in world space
Definition: Camera.hpp:107
+
GLfloat _theta
spherical angle for yaw direction in radians
Definition: Camera.hpp:114
+
GLfloat _radius
spherical magnitude for direction in world space
Definition: Camera.hpp:118
+
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17