Map screen coord to 3d scene with Vispy -
is there way of doing built in function?
i understand have revert transformation of projection screen. tried first obtaining simplified chain matrix with:
canvas.render_cs.node_transform(canvas.view.scene).simplified()
, canvas.canvas_cs.node_transform(canvas.view.scene).simplified()
but lost here when both return chain object.
then tried canvas "node_transform" method:
canvas.render_cs.node_transform(canvas.view.scene).map((0, 0))
that gives result vector of 4 elements. thought coords of line, isn't.
here example code:
import sys vispy import app,scene class canvas(scene.scenecanvas): def __init__(self): scene.scenecanvas.__init__(self, keys='interactive', show=true) self.view = self.central_widget.add_view() camera = scene.cameras.turntablecamera(fov=45, azimuth=80, parent=self.view.scene) self.view.camera = camera self.show() def on_mouse_press(self, event): """pan view based on change in mouse position.""" if event.button == 1: x0, y0 = event.last_event.pos[0], event.last_event.pos[1] x1, y1 = event.pos[0], event.pos[1] print x1,y1 print self.view.scene.node_transform(self.canvas_cs).simplified() print self.view.scene.node_transform(self.canvas_cs).map((x1,y1)) if __name__ == '__main__': canvas = canvas() axis = scene.visuals.xyzaxis(parent=canvas.view.scene) if sys.flags.interactive != 1: app.run()
Comments
Post a Comment