how to update the position of the camera and view it
i made some code that is supposed to have the camera move to the pose that it gets updated with in real time. it looks something like this `actcam= pyrender.PerspectiveCamera(yfov=np.pi / 3.0, aspectRatio=1.414) actcam = pyrender.Node(camera=actcam, matrix=np.eye(4)) scene.add_node(actcam) v = pyrender.Viewer(scene,use_raymond_lighting=True, run_in_thread=True,use_perspective_cam=True) while True: v.render_lock.acquire() scene.set_pose(cam,pose) scene.main_camera_node.matrix
v.render_lock.release()
` where the value pose is a transform matrix which i have other code that changes it over time but when i run this code the camera in the view does not move to the correct position in fact i can move around in the scene by interacting with it like you normally would how do i fix this?
In order to move the camera you have to go through the trackball. Here's a code snippet to move the camera up the Z axis by a specified amount. You would just apply your needed transform to the _camera_node.matrix before setting it.
############################################################################### import pyrender from pyrender.trackball import Trackball #snip... viewer = pyrender.Viewer(scene,viewport_size=(width, height), registered_keys=reg_keys, run_in_thread=True) #snip... viewer.render_lock.acquire() move_increment = 10.0 camera_pose_current = viewer._camera_node.matrix camera_pose_current[2,3] += move_increment viewer._trackball = Trackball(camera_pose_current, viewer.viewport_size, 1.0) #not sure why _scale value of 1500.0 but panning is much smaller if not set to this ?!? #your values may be different based on scale and world coordinates viewer._trackball._scale = 1500.0 viewer.render_lock.release() ###############################################################################
This is kind of late reply but hopefully someone can use it.