
Thu, 03/30/2023 - 00:58
Forums:
Hello all,
this code will start and display the viewport on my HTC Vive:
void OccView::cameraStereoVR()
{
Aspect_OpenVRSession* openVR = new Aspect_OpenVRSession();
m_view->View()->SetXRSession(openVR);
m_view->View()->XRSession()->SetUnitFactor(1000);
m_view->View()->XRSession()->SetTrackingOrigin(Aspect_OpenVRSession::TrackingUniverseOrigin::TrackingUniverseOrigin_Standing);
m_view->View()->XRSession()->Open();
m_view->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Stereo);
m_view->ChangeRenderingParams().StereoMode = Graphic3d_StereoMode_OpenVR;
openVR->ProcessEvents();
NCollection_Vec2< int > viewPorts = openVR->RecommendedViewport();
qDebug() << viewPorts[0] << viewPorts[1];
//NCollection_Mat4<double> coll = openVR->EyeToHeadTransform(Aspect_Eye::Aspect_Eye_Left);
//qDebug() << coll.GetRow(1);
//NCollection_Mat4<double> projection = openVR->ProjectionMatrix (Aspect_Eye::Aspect_Eye_Left, 10, 100);
//qDebug() << projection.GetRow(1);
//qDebug() << "NamedTrackedDevice" << openVR->NamedTrackedDevice(Aspect_XRTrackedDeviceRole::Aspect_XRTrackedDeviceRole_Head);
while (true)
{
m_view->Redraw();
//m_view->View()->XRSession()->ProcessEvents();
if (openVR->WaitPoses())
{
qDebug() << "pose";
}
QApplication::processEvents();
}
}
But I can not ready any information
openVR->EyeToHeadTransform(Aspect_Eye::Aspect_Eye_Left)
and
openVR->ProjectionMatrix (Aspect_Eye::Aspect_Eye_Left, 10, 100);
will crash.
Question: How can I "look around" with the headset?
I assume I have to read the position/rotation of the headset and then adjust the camera? Is that not automatically done?
Thanks for pointing me in the right direction!
Cheers!
PS: I am using MinGW
Thu, 03/30/2023 - 03:22
Doooh,
I was only looking in Aspect_OpenVRSession but all those functions are found in Aspect_XRSession - so all good.
Wondering if this is working of the shelf with windows compiler? I had similar problems with GI rendering where I also have to run in a loop to get rendering going?
Thu, 03/30/2023 - 11:51
The for-loop in your code snippet is not how this API is expected to be used. There is a lot of logic in
AIS_ViewController
- so it is better relying on this tool, or check it source code to see how XR could be managed (methods likeAIS_ViewController::handleXRInput()
and similar).Fri, 03/31/2023 - 18:43
The class is using AIS_ViewController:
but this
is just showing one picture. And when I move the headset the picture is disapearing and comes back when the headset ist back in same position.
Also those lines
Do nothing - I can't see any controller/hands or whatever may should be there
My loop is the only way I get a continues picture.
If there is an better way please let me know.
I am using MinGW64, QT5 under windows.
Thanks!