# Khaotic Engine Reborn: camera_class Class Reference

Loading...
Searching...
No Matches
camera_class Class Reference

## Public Member Functions

| camera_class (const camera_class &)
void | set_position (float, float, float)
void | set_rotation (float, float, float)
XMFLOAT3 | get_position ()
XMFLOAT3 | get_rotation ()
void | render ()
XMMATRIX | get_view_matrix (XMMATRIX &view_matrix) const
void | render_reflection (float)
void | get_reflection_view_matrix (XMMATRIX &) const

## Detailed Description

Definition at line 18 of file camera_class.h.

## Constructor & Destructor Documentation

## camera_class() [1/2]

camera_class::camera_class | ( |  | ) |

Definition at line 6 of file camera_class.cpp.

{
position_x_ = 0.0f;
position_y_ = 0.0f;
position_z_ = 0.0f;
rotation_x_ = 0.0f;
rotation_y_ = 0.0f;
rotation_z_ = 0.0f;
}

## camera_class() [2/2]

camera_class::camera_class | ( | const camera_class & | other | ) |

Definition at line 18 of file camera_class.cpp.

{
}

## ~camera_class()

camera_class::~camera_class | ( |  | ) |

Definition at line 23 of file camera_class.cpp.

{
}

## Member Function Documentation

## get_position()

XMFLOAT3 camera_class::get_position | ( |  | ) |

Definition at line 44 of file camera_class.cpp.

{
return XMFLOAT3(position_x_, position_y_, position_z_);
}

## get_reflection_view_matrix()

void camera_class::get_reflection_view_matrix | ( | XMMATRIX & | reflectionViewMatrix | ) | const

Definition at line 167 of file camera_class.cpp.

{
reflectionViewMatrix = reflection_view_matrix_;
return;
}

## get_rotation()

XMFLOAT3 camera_class::get_rotation | ( |  | ) |

Definition at line 50 of file camera_class.cpp.

{
return XMFLOAT3(rotation_x_, rotation_y_, rotation_z_);
}

## get_view_matrix()

XMMATRIX camera_class::get_view_matrix | ( | XMMATRIX & | view_matrix | ) | const

Definition at line 108 of file camera_class.cpp.

{
view_matrix = view_matrix_;
return view_matrix;
}

## render()

void camera_class::render | ( |  | ) |

Definition at line 55 of file camera_class.cpp.

{
XMFLOAT3 up, position, lookAt;
XMVECTOR upVector, positionVector, lookAtVector;
float yaw, pitch, roll;
XMMATRIX rotationMatrix;
// Setup the vector that points upwards.
up.x = 0.0f;
up.y = 1.0f;
up.z = 0.0f;
// Load it into a XMVECTOR structure.
upVector = XMLoadFloat3(&up);
// Setup the position of the camera in the world.
position.x = position_x_;
position.y = position_y_;
position.z = position_z_;
// Load it into a XMVECTOR structure.
positionVector = XMLoadFloat3(&position);
// Setup where the camera is looking by default.
lookAt.x = 0.0f;
lookAt.y = 0.0f;
lookAt.z = 1.0f;
// Load it into a XMVECTOR structure.
lookAtVector = XMLoadFloat3(&lookAt);
// Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians.
pitch = rotation_x_ * 0.0174532925f;
yaw = rotation_y_ * 0.0174532925f;
roll = rotation_z_ * 0.0174532925f;
// Create the rotation matrix from the yaw, pitch, and roll values.
rotationMatrix = XMMatrixRotationRollPitchYaw(pitch, yaw, roll);
// Transform the lookAt and up vector by the rotation matrix so the view is correctly rotated at the origin.
lookAtVector = XMVector3TransformCoord(lookAtVector, rotationMatrix);
upVector = XMVector3TransformCoord(upVector, rotationMatrix);
// Translate the rotated camera position to the location of the viewer.
lookAtVector = XMVectorAdd(positionVector, lookAtVector);
// Finally create the view matrix from the three updated vectors.
view_matrix_ = XMMatrixLookAtLH(positionVector, lookAtVector, upVector);
return;
}

## render_reflection()

void camera_class::render_reflection | ( | float | height | ) |

Definition at line 114 of file camera_class.cpp.

{
XMFLOAT3 up, position, lookAt;
XMVECTOR upVector, positionVector, lookAtVector;
float yaw, pitch, roll;
XMMATRIX rotationMatrix;
// Setup the vector that points upwards.
up.x = 0.0f;
up.y = 1.0f;
up.z = 0.0f;
// Load it into a XMVECTOR structure.
upVector = XMLoadFloat3(&up);
// Setup the position of the camera in the world.
position.x = position_x_;
position.y = -position_y_ + (height * 2.0f);
position.z = position_z_;
// Load it into a XMVECTOR structure.
positionVector = XMLoadFloat3(&position);
// Setup where the camera is looking by default.
lookAt.x = 0.0f;
lookAt.y = 0.0f;
lookAt.z = 1.0f;
// Load it into a XMVECTOR structure.
lookAtVector = XMLoadFloat3(&lookAt);
// Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians.
pitch = (-1.0f * rotation_x_) * 0.0174532925f; // Invert for reflection
yaw = rotation_y_ * 0.0174532925f;
roll = rotation_z_ * 0.0174532925f;
// Create the rotation matrix from the yaw, pitch, and roll values.
rotationMatrix = XMMatrixRotationRollPitchYaw(pitch, yaw, roll);
// Transform the lookAt and up vector by the rotation matrix so the view is correctly rotated at the origin.
lookAtVector = XMVector3TransformCoord(lookAtVector, rotationMatrix);
upVector = XMVector3TransformCoord(upVector, rotationMatrix);
// Translate the rotated camera position to the location of the viewer.
lookAtVector = XMVectorAdd(positionVector, lookAtVector);
// Finally create the view matrix from the three updated vectors.
reflection_view_matrix_ = XMMatrixLookAtLH(positionVector, lookAtVector, upVector);
return;
}

## set_position()

void camera_class::set_position | ( | float | x,
|  | float | y,
|  | float | z )

Definition at line 27 of file camera_class.cpp.

{
position_x_ = x;
position_y_ = y;
position_z_ = z;
return;
}

## set_rotation()

void camera_class::set_rotation | ( | float | x,
|  | float | y,
|  | float | z )

Definition at line 36 of file camera_class.cpp.

{
rotation_x_ = x;
rotation_y_ = y;
rotation_z_ = z;
return;
}

The documentation for this class was generated from the following files:

- enginecustom/src/inc/system/camera_class.h
- enginecustom/src/src/system/camera_class.cpp