vkt camera rotation/transformation #788
-
Hello, I came across this video below, and I would like to know if any one of you knows how I could do this kind of predefined camera rotation/transformation ? The main idea That I'm trying like to implement is a way to constraint the render camera axis of rotation when I move the mouse without having to click on "ctrl", similar to what maltab does when you move a 3D plot with the mouse thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 12 replies
-
I think you should add one call_back() function bind to mouse move event. |
Beta Was this translation helpful? Give feedback.
-
yes, there are various ways of doing it... I would first check if any modes works for you out-of-the-box in
from vedo import *
def func(event):
k = event.keypress
if k=="Right":
plt.camera.Azimuth(1)
elif k=="Left":
plt.camera.Azimuth(-1)
elif k=="Down":
plt.camera.Elevation(1)
elif k=="Up":
plt.camera.Elevation(-1)
elif k=="r":
plt.reset_viewup()
return
plt.renderer.ResetCameraClippingRange()
plt.render()
settings.enable_default_keyboard_callbacks = False
settings.enable_default_mouse_callbacks = False
world = Box(size=(30,15,8)).wireframe()
airplane = Mesh(dataurl+"cessna.vtk").c("green")
plt = Plotter(axes=1)
plt.add_callback("keypress", func)
plt.show(world, airplane, mode="image") (this uses keypress events) Or from vedo import *
def func(event):
d = event.delta2d
if d[0] and d[1]:
return
if d[0]:
plt.camera.Azimuth(-d[0])
if d[1]:
plt.camera.Elevation(-d[1])
plt.renderer.ResetCameraClippingRange()
plt.render()
# settings.enable_default_keyboard_callbacks = False
settings.enable_default_mouse_callbacks = False
world = Box(size=(30,15,8)).wireframe()
airplane = Mesh(dataurl+"cessna.vtk").c("green")
plt = Plotter(axes=1)
plt.add_callback("Interaction", func)
plt.show(world, airplane, mode="image") (this uses mouse events)
|
Beta Was this translation helpful? Give feedback.
-
Could you please tell me what delta2d stands for ? |
Beta Was this translation helpful? Give feedback.
-
I have a pretty complete custom interactor here: https://github.com/RubendeBruin/DAVE/blob/master/src/DAVE/visual_helpers/vtkBlenderLikeInteractionStyle.py which does a lot of things, among others keeping the Z-axis vertical. I still have to contribute this back to vtk but havent found the time to do so. Feel free to use/abuse as you wish. |
Beta Was this translation helpful? Give feedback.
I have a pretty complete custom interactor here: https://github.com/RubendeBruin/DAVE/blob/master/src/DAVE/visual_helpers/vtkBlenderLikeInteractionStyle.py
which does a lot of things, among others keeping the Z-axis vertical.
I still have to contribute this back to vtk but havent found the time to do so. Feel free to use/abuse as you wish.