ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
CameraLayout.cpp
Go to the documentation of this file.
1#include "CameraLayout.h"
2
4 this->forwardAxis = forwardAxis;
5 this->upAxis = upAxis;
6
8}
9
12 return !(upAxis == XUp || upAxis == XNUp);
13 } else if (forwardAxis == YForward || forwardAxis == YNForward) {
14 return !(upAxis == YUp || upAxis == YNUp);
15 } else {
16 return !(upAxis == ZUp || upAxis == ZNUp);
17 }
18}
19
21 Vector3D upVector, forwardVector, rightVector;
22
23 if (VerifyTransform()) {
24 upVector = GetUpVector();
25 forwardVector = GetForwardVector();
26 rightVector = upVector.CrossProduct(forwardVector);
27
28 rotation = Rotation(rightVector, forwardVector, upVector).GetQuaternion().UnitQuaternion();
29 }
30 // else bad transform
31}
32
36
40
42 Vector3D forwardVector;
43
44 switch (forwardAxis) {
45 case XForward: forwardVector.X = 1; break;
46 case YForward: forwardVector.Y = 1; break;
47 case XNForward: forwardVector.X = -1; break;
48 case YNForward: forwardVector.Y = -1; break;
49 case ZNForward: forwardVector.Z = -1; break;
50 default: forwardVector.Z = 1; break;
51 }
52
53 return forwardVector;
54}
55
57 Vector3D upVector;
58
59 switch (upAxis) {
60 case XUp: upVector.X = 1; break;
61 case ZUp: upVector.Z = 1; break;
62 case XNUp: upVector.X = -1; break;
63 case YNUp: upVector.Y = -1; break;
64 case ZNUp: upVector.Z = -1; break;
65 default: upVector.Y = 1; break;
66 }
67
68 return upVector;
69}
70
Declares the CameraLayout class for managing camera orientation and axis alignment.
UpAxis
Defines possible up axes for the camera.
@ XNUp
Up along the negative X-axis.
@ XUp
Up along the positive X-axis.
@ ZNUp
Up along the negative Z-axis.
@ ZUp
Up along the positive Z-axis.
@ YUp
Up along the positive Y-axis.
@ YNUp
Up along the negative Y-axis.
void CalculateTransform()
Calculates the camera's transformation based on its axes.
Quaternion rotation
Rotation representing the camera's orientation.
Quaternion GetRotation()
Retrieves the camera's rotation.
ForwardAxis GetForwardAxis()
Retrieves the camera's forward axis.
ForwardAxis
Defines possible forward axes for the camera.
@ XForward
Forward along the positive X-axis.
@ XNForward
Forward along the negative X-axis.
@ ZNForward
Forward along the negative Z-axis.
@ YNForward
Forward along the negative Y-axis.
@ YForward
Forward along the positive Y-axis.
UpAxis upAxis
The camera's up axis.
bool VerifyTransform()
Verifies the validity of the camera's transformation.
ForwardAxis forwardAxis
The camera's forward axis.
Vector3D GetForwardVector()
Retrieves the camera's forward vector.
UpAxis GetUpAxis()
Retrieves the camera's up axis.
CameraLayout(ForwardAxis forwardAxis, UpAxis upAxis)
Constructs a CameraLayout with specified forward and up axes.
Vector3D GetUpVector()
Retrieves the camera's up vector.
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Quaternion UnitQuaternion() const
Returns a unit quaternion (normalized) version of this quaternion.
Handles 3D rotations and conversions between various rotation representations.
Definition Rotation.h:32
Quaternion GetQuaternion()
Gets the quaternion representation of the rotation.
Definition Rotation.cpp:234
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26
Vector3D CrossProduct(const Vector3D &vector) const
Computes the cross product of this vector with another Vector3D.
Definition Vector3D.cpp:98
float Z
The Z-component of the 3D vector.
Definition Vector3D.h:30
float X
The X-component of the 3D vector.
Definition Vector3D.h:28
float Y
The Y-component of the 3D vector.
Definition Vector3D.h:29