1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
// Projection matrix : 45° Field of View, 16:9 ratio, display range : 0.1 unit <-> 100 units
const glm::mat4 Projection = glm::perspective(45.0f, 16.0f / 9.0f, 0.1f, 100.0f);
// Camera matrix
const Vector3& camPos = camera->GetPosition();
const Vector3 lookAt = camera->GetLookAt();
glm::mat4 View = glm::lookAt(
glm::vec3(camPos.x, camPos.y, camPos.z),
glm::vec3(lookAt.x, lookAt.y, lookAt.z),
glm::vec3(0,0,1) // Head is up
);
glm::mat4 Model = glm::translate(glm::mat4(1.0f),glm::vec3(position.x, position.y, position.z));
const Rotation& rotation = model->GetRotation();
Model = glm::rotate(Model, rotation.x, glm::vec3(1.0f, 0.0f, 0.0f));
Model = glm::rotate(Model, rotation.y, glm::vec3(0.0f, 1.0f, 0.0f));
Model = glm::rotate(Model, rotation.z, glm::vec3(0.0f, 0.0f, 1.0f)); |
Partager