diff options
| author | BastiaanOlij | 2017-04-23 22:10:41 +1000 |
|---|---|---|
| committer | BastiaanOlij | 2017-07-28 10:39:15 +1000 |
| commit | d2ba2d08733647dc345db123469988966c8b31b0 (patch) | |
| tree | 878817443d5929948e1b05e1d1eb39fe2091cd40 /servers/visual/visual_server_scene.cpp | |
| parent | 411f09a512d5847fc9c6270439308d1e3093f211 (diff) | |
| download | godot-d2ba2d08733647dc345db123469988966c8b31b0.tar.gz godot-d2ba2d08733647dc345db123469988966c8b31b0.tar.zst godot-d2ba2d08733647dc345db123469988966c8b31b0.zip | |
Adding base classes and structures for ARVR support
Added ArVrScriptInterface
Added ARVRCamera, ARVRController and ARVROrigin helper objects
Diffstat (limited to 'servers/visual/visual_server_scene.cpp')
| -rw-r--r-- | servers/visual/visual_server_scene.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 97583dc84..01f89ed37 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -1658,6 +1658,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons } void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) { + // render to mono camera Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); @@ -1697,6 +1698,25 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view _render_scene(camera->transform, camera_matrix, ortho, camera->env, camera->visible_layers, p_scenario, p_shadow_atlas, RID(), -1); } +void VisualServerScene::render_camera(Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) { + // render for AR/VR interface + + Camera *camera = camera_owner.getornull(p_camera); + ERR_FAIL_COND(!camera); + + /* SETUP CAMERA, we are ignoring type and FOV here */ + bool ortho = false; + float aspect = p_viewport_size.width / (float)p_viewport_size.height; + CameraMatrix camera_matrix = p_interface->get_projection_for_eye(p_eye, aspect, camera->znear, camera->zfar); + + // We also ignore our camera position, it will have been positioned with a slightly old tracking position. + // Instead we take our origin point and have our ar/vr interface add fresh tracking data! Whoohoo! + Transform world_origin = ARVRServer::get_singleton()->get_world_origin(); + Transform cam_transform = p_interface->get_transform_for_eye(p_eye, world_origin); + + _render_scene(cam_transform, camera_matrix, ortho, camera->env, camera->visible_layers, p_scenario, p_shadow_atlas, RID(), -1); +}; + void VisualServerScene::_render_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) { Scenario *scenario = scenario_owner.getornull(p_scenario); |
