You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the VR camera is observed, and the callback makes changes in the MRML scene, then the OpenGL context produces strange symptoms, such as showing nothing, or even a previously shown scene in one VR view while the other is showing the proper scene.
def onVrCameraModified(self,caller,event):
avatarTransformNode = self.headAvatarModelNode.GetParentTransformNode()
# Move and orient avatar model to VR camera
import numpy as np
position = self.vrCamera.GetPosition()
positionVector = np.array(position)
focalPointVector = np.array(self.vrCamera.GetFocalPoint())
viewUpVector = np.array(self.vrCamera.GetViewUp())
# Z
zAxis = focalPointVector - positionVector
zAxisLength = np.linalg.norm(zAxis)
zAxis = zAxis / zAxisLength
# X
xAxis = np.array(viewUpVector)
# Y
yAxis = np.cross(zAxis, xAxis)
# Matrix
avatarTransformMatrix = vtk.vtkMatrix4x4()
for z in xrange(3):
avatarTransformMatrix.SetElement(z,2,zAxis[z])
for y in xrange(3):
avatarTransformMatrix.SetElement(y,1,yAxis[y])
for x in xrange(3):
avatarTransformMatrix.SetElement(x,0,xAxis[x])
for p in xrange(3):
avatarTransformMatrix.SetElement(p,3,position[p])
avatarTransformNode.SetMatrixTransformToParent(avatarTransformMatrix)
If a QTimer.singleShot triggers a function that does this calculation and SetMatrixTransformToParent, then everything works well.
Maybe if the VR camera is modified with a different timing, then this issue wouldn't come up. For example it could be done as the first step and not while doing the rendering, or an event could be invoked that sets the camera.
The text was updated successfully, but these errors were encountered:
If the VR camera is observed, and the callback makes changes in the MRML scene, then the OpenGL context produces strange symptoms, such as showing nothing, or even a previously shown scene in one VR view while the other is showing the proper scene.
To reproduce:
If a QTimer.singleShot triggers a function that does this calculation and SetMatrixTransformToParent, then everything works well.
Maybe if the VR camera is modified with a different timing, then this issue wouldn't come up. For example it could be done as the first step and not while doing the rendering, or an event could be invoked that sets the camera.
The text was updated successfully, but these errors were encountered: