playing with another shader for a sun type thing and WAY better camera movement
This commit is contained in:
1 parent
9eb8d55630
commit
b299a8d8a2
5 files changed
+175
-41
No files matched your search
@@ -11,15 +11,25 @@ class Camera
|
||||
glm::vec3 target;
|
||||
glm::vec3 direction;
|
||||
glm::vec3 up;
|
||||
|
||||
// Movement
|
||||
glm::vec3 horizontal_velocity;
|
||||
glm::vec3 forward_velocity;
|
||||
glm::vec3 vertical_velocity;
|
||||
|
||||
float speed;
|
||||
|
||||
glm::vec3 worldUp;
|
||||
|
||||
Camera(float speed)
|
||||
Camera(float speed, glm::vec3 pos)
|
||||
{
|
||||
this->speed = speed;
|
||||
this->vertical_velocity = glm::vec3(0.0f);
|
||||
|
||||
this->position = glm::vec3(0.0f, 0.0f, 3.0f);
|
||||
this->horizontal_velocity = glm::vec3(0.0f);
|
||||
this->forward_velocity = glm::vec3(0.0f);
|
||||
|
||||
this->position = pos;
|
||||
this->target = glm::vec3(0.0f, 0.0f, -1.0f);
|
||||
|
||||
this->direction = glm::normalize(this->position);
|
||||
@@ -32,6 +42,10 @@ class Camera
|
||||
Camera(glm::vec3 pos, glm::vec3 target, float speed)
|
||||
{
|
||||
this->speed = speed;
|
||||
this->vertical_velocity = glm::vec3(0.0f);
|
||||
|
||||
this->horizontal_velocity = glm::vec3(0.0f);
|
||||
this->forward_velocity = glm::vec3(0.0f);
|
||||
|
||||
this->position = pos;
|
||||
this->target = target;
|
||||
@@ -50,6 +64,26 @@ class Camera
|
||||
this->worldUp);
|
||||
}
|
||||
|
||||
void move(float time) // time passed in seconds since last move
|
||||
{
|
||||
if (this->position.y > 0)
|
||||
this->vertical_velocity.y -= (9.8 * time); // gravity is 9.8m/s^2 no way! physics reference?
|
||||
|
||||
std::cout << "pos: " << this->position.x << " " << this->position.y << " " << this->position.z << std::endl;
|
||||
|
||||
glm::vec3 velocity = this->forward_velocity + this->horizontal_velocity + this->vertical_velocity;
|
||||
|
||||
glm::vec3 movement = (velocity * time);
|
||||
this->position += movement;
|
||||
|
||||
// Don't want to clip into the ground right
|
||||
if (this->position.y < 0)
|
||||
{
|
||||
this->position.y = 0;
|
||||
this->vertical_velocity.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user