load camera from gltf

This commit is contained in:
CDaut 2024-05-13 18:41:43 +02:00
parent eabbc338e1
commit 916e68443f
Signed by: clara
GPG key ID: 223391B52FAD4463
2 changed files with 52 additions and 8 deletions

View file

@ -91,10 +91,6 @@ int main(int argc, char** argv)
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow* window = glfwCreateWindow(SAMPLE_WIDTH, SAMPLE_HEIGHT, PROJECT_NAME, nullptr, nullptr);
// Setup camera
CameraManip.setWindowSize(SAMPLE_WIDTH, SAMPLE_HEIGHT);
CameraManip.setLookat(glm::vec3(0, 0, 15), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));
// Setup Vulkan
if(!glfwVulkanSupported())
{
@ -164,6 +160,26 @@ int main(int argc, char** argv)
// Creation of the example
helloVk.loadScene(nvh::findFile("media/scenes/grid.gltf", defaultSearchPaths, true));
// Setup camera
CameraManip.setWindowSize(SAMPLE_WIDTH, SAMPLE_HEIGHT);
//do not set a camera if none are in the scene
glm::vec3 eye, center, up;
if(helloVk.m_gltfScene.m_cameras.empty())
{
eye = {0.f, 0.f, 15.f};
center = vec3(0.f);
up = {0.f, 1.f, 0.f};
}
else
{
auto main_camera = helloVk.m_gltfScene.m_cameras[0];
eye = main_camera.eye;
center = main_camera.center;
up = main_camera.up;
}
//set camera
CameraManip.setLookat(eye, center, up);
helloVk.createOffscreenRender();
helloVk.createDescriptorSetLayout();