@@ -172,6 +172,7 @@ void Viewport::setLibrary(const std::string &libName, bool doAsync)
172172
173173 m_perspCamera = anari::newObject<anari::Camera>(d, " perspective" );
174174 m_orthoCamera = anari::newObject<anari::Camera>(d, " orthographic" );
175+ m_omniCamera = anari::newObject<anari::Camera>(d, " omnidirectional" );
175176
176177 tsd::logStatus (" [viewport] populating render index..." );
177178
@@ -226,12 +227,14 @@ void Viewport::teardownDevice()
226227
227228 anari::release (m_device, m_perspCamera);
228229 anari::release (m_device, m_orthoCamera);
230+ anari::release (m_device, m_omniCamera);
229231 for (auto &r : m_renderers)
230232 anari::release (m_device, r);
231233 anari::release (m_device, m_device);
232234
233235 m_perspCamera = nullptr ;
234236 m_orthoCamera = nullptr ;
237+ m_omniCamera = nullptr ;
235238 m_renderers.clear ();
236239 m_rendererObjects.clear ();
237240 m_device = nullptr ;
@@ -324,7 +327,12 @@ void Viewport::updateFrame()
324327 return ;
325328
326329 m_rud.r = m_renderers[m_currentRenderer];
327- m_anariPass->setCamera (m_useOrthoCamera ? m_orthoCamera : m_perspCamera);
330+ if (m_cameraModel == CameraModel::Orthographic)
331+ m_anariPass->setCamera (m_orthoCamera);
332+ else if (m_cameraModel == CameraModel::Omnidirectional)
333+ m_anariPass->setCamera (m_omniCamera);
334+ else
335+ m_anariPass->setCamera (m_perspCamera);
328336 m_anariPass->setRenderer (m_rud.r );
329337 m_anariPass->setWorld (m_rIdx->world ());
330338}
@@ -348,6 +356,10 @@ void Viewport::updateCamera(bool force)
348356 anari::setParameter (
349357 m_device, m_orthoCamera, " height" , m_arcball->distance () * 0 .75f );
350358
359+ anari::setParameter (m_device, m_omniCamera, " position" , m_arcball->eye ());
360+ anari::setParameter (m_device, m_omniCamera, " direction" , m_arcball->dir ());
361+ anari::setParameter (m_device, m_omniCamera, " up" , m_arcball->up ());
362+
351363 anari::setParameter (m_device,
352364 m_perspCamera,
353365 " aspect" ,
@@ -365,6 +377,7 @@ void Viewport::updateCamera(bool force)
365377
366378 anari::commitParameters (m_device, m_perspCamera);
367379 anari::commitParameters (m_device, m_orthoCamera);
380+ anari::commitParameters (m_device, m_omniCamera);
368381
369382 if (m_echoCameraConfig)
370383 echoCameraConfig ();
@@ -504,7 +517,7 @@ void Viewport::ui_picking()
504517
505518 // Pick view center //
506519
507- const bool shouldPickCenter = !m_useOrthoCamera
520+ const bool shouldPickCenter = m_cameraModel == CameraModel::Perspective
508521 && ImGui::IsMouseDoubleClicked (ImGuiMouseButton_Left)
509522 && io.KeysDown [GLFW_KEY_LEFT_SHIFT];
510523 if (shouldPickCenter && ImGui::IsWindowHovered ()) {
@@ -637,10 +650,15 @@ void Viewport::ui_contextMenu()
637650 ImGui::Text (" Camera:" );
638651 ImGui::Indent (INDENT_AMOUNT);
639652
640- if (ImGui::Checkbox (" orthographic" , &m_useOrthoCamera))
653+ if (ImGui::RadioButton (
654+ " perspective" , &m_cameraModel, CameraModel::Perspective)
655+ || ImGui::RadioButton (
656+ " orthographic" , &m_cameraModel, CameraModel::Orthographic)
657+ || ImGui::RadioButton (
658+ " omnidirectional" , &m_cameraModel, CameraModel::Omnidirectional))
641659 updateFrame ();
642660
643- ImGui::BeginDisabled (m_useOrthoCamera );
661+ ImGui::BeginDisabled (m_cameraModel != CameraModel::Perspective );
644662
645663 if (ImGui::SliderFloat (" fov" , &m_fov, 0 .1f , 180 .f ))
646664 updateCamera (true );
0 commit comments