load camera from gltf
This commit is contained in:
parent
eabbc338e1
commit
916e68443f
2 changed files with 52 additions and 8 deletions
|
|
@ -12,7 +12,8 @@
|
|||
"name":"Scene",
|
||||
"nodes":[
|
||||
0,
|
||||
1
|
||||
1,
|
||||
2
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -26,6 +27,21 @@
|
|||
300
|
||||
]
|
||||
},
|
||||
{
|
||||
"camera":0,
|
||||
"name":"Camera",
|
||||
"rotation":[
|
||||
-0.4850793778896332,
|
||||
0.011384948156774044,
|
||||
0.006316010374575853,
|
||||
0.874373197555542
|
||||
],
|
||||
"translation":[
|
||||
22.192241668701172,
|
||||
739.938720703125,
|
||||
580.302978515625
|
||||
]
|
||||
},
|
||||
{
|
||||
"mesh":1,
|
||||
"name":"Plane",
|
||||
|
|
@ -41,15 +57,27 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"cameras":[
|
||||
{
|
||||
"name":"Camera",
|
||||
"perspective":{
|
||||
"aspectRatio":1,
|
||||
"yfov":0.6911112070083618,
|
||||
"zfar":2000,
|
||||
"znear":0.10000000149011612
|
||||
},
|
||||
"type":"perspective"
|
||||
}
|
||||
],
|
||||
"materials":[
|
||||
{
|
||||
"doubleSided":true,
|
||||
"name":"Material",
|
||||
"pbrMetallicRoughness":{
|
||||
"baseColorFactor":[
|
||||
0.800000011920929,
|
||||
0.800000011920929,
|
||||
0.800000011920929,
|
||||
0.8003232479095459,
|
||||
0.052682049572467804,
|
||||
0.03800351545214653,
|
||||
1
|
||||
],
|
||||
"metallicFactor":0,
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue