OpenVR : Moving the head while grabbing in virtual reality
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 :
// 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,pos,pos,1.0); ren->WorldToDisplay(); double *displayCoords = ren->GetDisplayPoint(); this->SetEventPosition(displayCoords,displayCoords,pointerIndex); this->SetWorldEventPosition(pos,pos,pos,pointerIndex); this->SetPhysicalEventPosition(ppos, ppos, ppos, pointerIndex); this->SetWorldEventOrientation(wxyz,wxyz,wxyz,wxyz,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.