@@ -172,6 +172,7 @@ void Viewport::setLibrary(const std::string &libName, bool doAsync)
172
172
173
173
m_perspCamera = anari::newObject<anari::Camera>(d, " perspective" );
174
174
m_orthoCamera = anari::newObject<anari::Camera>(d, " orthographic" );
175
+ m_omniCamera = anari::newObject<anari::Camera>(d, " omnidirectional" );
175
176
176
177
tsd::logStatus (" [viewport] populating render index..." );
177
178
@@ -226,12 +227,14 @@ void Viewport::teardownDevice()
226
227
227
228
anari::release (m_device, m_perspCamera);
228
229
anari::release (m_device, m_orthoCamera);
230
+ anari::release (m_device, m_omniCamera);
229
231
for (auto &r : m_renderers)
230
232
anari::release (m_device, r);
231
233
anari::release (m_device, m_device);
232
234
233
235
m_perspCamera = nullptr ;
234
236
m_orthoCamera = nullptr ;
237
+ m_omniCamera = nullptr ;
235
238
m_renderers.clear ();
236
239
m_rendererObjects.clear ();
237
240
m_device = nullptr ;
@@ -324,7 +327,12 @@ void Viewport::updateFrame()
324
327
return ;
325
328
326
329
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);
328
336
m_anariPass->setRenderer (m_rud.r );
329
337
m_anariPass->setWorld (m_rIdx->world ());
330
338
}
@@ -348,6 +356,10 @@ void Viewport::updateCamera(bool force)
348
356
anari::setParameter (
349
357
m_device, m_orthoCamera, " height" , m_arcball->distance () * 0 .75f );
350
358
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
+
351
363
anari::setParameter (m_device,
352
364
m_perspCamera,
353
365
" aspect" ,
@@ -365,6 +377,7 @@ void Viewport::updateCamera(bool force)
365
377
366
378
anari::commitParameters (m_device, m_perspCamera);
367
379
anari::commitParameters (m_device, m_orthoCamera);
380
+ anari::commitParameters (m_device, m_omniCamera);
368
381
369
382
if (m_echoCameraConfig)
370
383
echoCameraConfig ();
@@ -504,7 +517,7 @@ void Viewport::ui_picking()
504
517
505
518
// Pick view center //
506
519
507
- const bool shouldPickCenter = !m_useOrthoCamera
520
+ const bool shouldPickCenter = m_cameraModel == CameraModel::Perspective
508
521
&& ImGui::IsMouseDoubleClicked (ImGuiMouseButton_Left)
509
522
&& io.KeysDown [GLFW_KEY_LEFT_SHIFT];
510
523
if (shouldPickCenter && ImGui::IsWindowHovered ()) {
@@ -637,10 +650,15 @@ void Viewport::ui_contextMenu()
637
650
ImGui::Text (" Camera:" );
638
651
ImGui::Indent (INDENT_AMOUNT);
639
652
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))
641
659
updateFrame ();
642
660
643
- ImGui::BeginDisabled (m_useOrthoCamera );
661
+ ImGui::BeginDisabled (m_cameraModel != CameraModel::Perspective );
644
662
645
663
if (ImGui::SliderFloat (" fov" , &m_fov, 0 .1f , 180 .f ))
646
664
updateCamera (true );
0 commit comments