I am trying to get a result like what is in this eight second video but with a ball on my terrain:
https://www.youtube.com/watch?v=7oNWtzplLCk
here is my camera code:
void Camera::updateCameraVectors(void)
{
// Calculate the new Front vector
glm::vec3 front;
front.x = cos(glm::radians(this->yaw)) * cos(glm::radians(this->pitch));
front.y = sin(glm::radians(this->pitch));
front.z = sin(glm::radians(this->yaw)) * cos(glm::radians(this->pitch));
glm::vec3 temp = this->front;
this->front = glm::normalize(front);
// Also re-calculate the Right and Up vector
this->right = glm::normalize(glm::cross(this->front, this->worldUp)); // Normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
this->up = glm::normalize(glm::cross(this->right, this->front));
//this didn't work:
//ball.xadj = ball.xadj + front.x;
//ball.zadj = ball.zadj - front.z;
}
glm::mat4 Camera::GetViewMatrix(void)
{
return glm::lookAt(this->position, this->position + this->front, this->up);
}
How can I get the camera and the translate command to work in an opposite numeric manner?
Thanks,
Josheir