OpenVR : Moving the head while grabbing in virtual reality
Hello,
I've been using the OpenVR build to try and make demonstrations of potential use of VTK in virtual reality. My first exemple is a live clipping of a geometry by moving a vtkPlaneWidget with the controler (the code is very simple, I attached it to the post).
I encountered a problem while grabbing the plane with one hand : if I moved my head, the position of the plane in the world would change. I traced the problem back to the fact that the grabbing scripts used are still for 2D. With OpenVR, grabbing and then moving my head to the right (making the object moving to the left on the screen) is interpreted as a mouse move to the left.
In there : vtkOpenVRRenderWindowInteractor::DoOneEvent
// so even though we have world coordinates we have to convert them to
// screen coordinates because all of VTKs picking code is currently
// based on screen coordinates
ren->SetWorldPoint(pos[0],pos[1],pos[2],1.0);
ren->WorldToDisplay();
double *displayCoords = ren->GetDisplayPoint();
this->SetEventPosition(displayCoords[0],displayCoords[1],pointerIndex);
this->SetWorldEventPosition(pos[0],pos[1],pos[2],pointerIndex);
this->SetPhysicalEventPosition(ppos[0], ppos[1], ppos[2], pointerIndex);
this->SetWorldEventOrientation(wxyz[0],wxyz[1],wxyz[2],wxyz[3],pointerIndex);
this->SetPointerIndex(pointerIndex);
DisplayCoords can change independently of pos, ppos and wxyz.
I've thought about storing the pose of the camera and comparing the displayCoords of the current camera and the previous one . But I have no idea if messing with those coordinates can affect other scripts.
David