[ADD] comments to camera and toolbox
This commit is contained in:
@@ -10,8 +10,11 @@ namespace entities
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
void Camera::Follow(glm::vec3 follow_position) {
|
void Camera::Follow(glm::vec3 follow_position) {
|
||||||
|
//set position to follow in front of the camera
|
||||||
follow_position.z += 100;
|
follow_position.z += 100;
|
||||||
|
//set position to follow a bit lower
|
||||||
follow_position.y += 50;
|
follow_position.y += 50;
|
||||||
|
//move position from original position to fiven position with smoothing
|
||||||
position = toolbox::Lerp(position, follow_position, 0.1);
|
position = toolbox::Lerp(position, follow_position, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +56,5 @@ namespace entities
|
|||||||
position.x += side_speed;
|
position.x += side_speed;
|
||||||
position.z += movement_speed;
|
position.z += movement_speed;
|
||||||
position.y += up_down_speed;
|
position.y += up_down_speed;
|
||||||
std::cout <<"x= " << position.x <<"\ny= " << position.y << "\nz= " << position.z << "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ namespace entities
|
|||||||
private:
|
private:
|
||||||
// The movement speed of the camera
|
// The movement speed of the camera
|
||||||
const float SPEED = 0.5f;
|
const float SPEED = 0.5f;
|
||||||
const float UP_SPEED = 0.9f;
|
const float UP_SPEED = 1.0f;
|
||||||
|
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
glm::vec3 rotation;
|
glm::vec3 rotation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Camera(const ::glm::vec3& position, const ::glm::vec3& rotation);
|
Camera(const ::glm::vec3& position, const ::glm::vec3& rotation);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -29,6 +30,11 @@ namespace entities
|
|||||||
*/
|
*/
|
||||||
void Move(GLFWwindow* window);
|
void Move(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief follows the given position with smoothing
|
||||||
|
*
|
||||||
|
* @param follow_position the position of the object the camera has to follow
|
||||||
|
*/
|
||||||
void Follow(glm::vec3 follow_position);
|
void Follow(glm::vec3 follow_position);
|
||||||
|
|
||||||
inline glm::vec3 GetPosition() const{ return position; }
|
inline glm::vec3 GetPosition() const{ return position; }
|
||||||
|
|||||||
@@ -47,7 +47,25 @@ namespace toolbox
|
|||||||
*/
|
*/
|
||||||
glm::mat4 CreateViewMatrix(entities::Camera& camera);
|
glm::mat4 CreateViewMatrix(entities::Camera& camera);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @biref go to one coordinate to another with smooting
|
||||||
|
*
|
||||||
|
* @param from one coordinate of the start
|
||||||
|
* @param to one coordinate of where to go
|
||||||
|
* @param amount the amount of smoothing (lower is smoother)
|
||||||
|
*
|
||||||
|
* @return coordinate of where to go
|
||||||
|
*/
|
||||||
float Lerp(float from, float to, float amount);
|
float Lerp(float from, float to, float amount);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @biref go from one position to another with smoothing
|
||||||
|
*
|
||||||
|
* @param from position of the start
|
||||||
|
* @param to position of where to go
|
||||||
|
* @param amount the amount of smoothing (lower is smoother)
|
||||||
|
*
|
||||||
|
* @return position of where to go
|
||||||
|
*/
|
||||||
glm::vec3 Lerp(glm::vec3 from, glm::vec3 to, float amount);
|
glm::vec3 Lerp(glm::vec3 from, glm::vec3 to, float amount);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user