-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no Plotter.camera #42
Comments
i see i can set it, it just isn't there to start. Now i'm trying to figure out how to control the camera in the k3d widget. |
HI, yes the The k3d backend is still a bit experimental and at present has a few limitations, loops , widget are not implemented... and camera positioning! from vtkplotter import settings
# ...
plt = vp.show(...)
plt
print(plt.camera) # a numpy object from k3d see https://github.com/K3D-tools/K3D-jupyter/blob/master/examples/camera_manipulation.ipynb
from vtkplotter import embedWindow
embedWindow(False)
# ...
vp.show(...)
print(vp.camera) # a vtkCamera object |
I see thanks… since vtk has a camera interface, can I suggest an alternative approach where you pass in a vtkCamera object, and you have convivence methods for making camera objects more easily and then you translate those camera parameters into k3d for the user?
This would let users setup their camera programmatically and pass it in in a unified way if they choose.. the present dictionary based method is a bit confusing as vtk parameterizes their camera in an odd way… I want to set the focalpoint, the up_vector and the distance, and have the camera’s position modified to make that true. However, vtk will move the focalpoint when you SetDistance, and so passing in those keyword arguments as you have it now doesn’t work so well… If I could just setup my camera as I like and then pass it in that would be better.
I’ve got a function for example that does this already so I can parameterize my camera initialization in the units I care to.
https://github.com/sdorkenw/MeshParty/blob/master/meshparty/trimesh_vtk.py#L512
|
Thanks a lot! Indeed you can already pass a whole camera object to vp = Plotter()
# place vtkCamera at a specific position
# (get these numbers by pressing Shift-C)
vp.camera.SetPosition([2.5, 2.5, 5.5])
vp.camera.SetFocalPoint([0.4, 0.4, 0.4])
vp.camera.SetParallelScale(1.8)
vp.camera.SetViewUp([-0.1, 1, -0.3]) or with your nice function: vp = Plotter()
vp.camera = oriented_camera((1,1,1), up_vector=(0, -1, 0), backoff=500, backoff_vector=(0,0,1)) i'll see if I can extend it to the k3d backend. |
@fcollman the last function is the one you were suggesting in the above messages, I hope this is addressing it, I wrote an example here: |
I think this does address it.. except for not yet in jupyter? |
in jupyter: You can form your vtkCamera object and then apply it to the rendered scene as ..or maybe you were suggesting something different? While playing with it I realize that K3D camera has some bug (viewup is not updated if the position is not modified): K3D-tools/K3D-jupyter#180 |
Got it working.. sorry was just confused by your comment about not in Jupyter earlier in the thread |
Is there any convenient way to set camera parameters like in pyrender? |
@LogWell |
Try with |
@marcomusy @LogWell I also has the problem, vp.camera.SetPosition() setted value will be replaced by default value when rendered. Is this a bug? |
This should be now fixed in the latest commit: from vtkplotter import *
vp = Plotter()
s1 = load(datadir+'cow.vtk')
vp.camera.SetPosition( [6.316, -3.586, 1.36] )
vp.camera.SetFocalPoint( [-0.195, -0.762, -0.802] )
vp.camera.SetViewUp( [-0.245, 0.166, 0.955] )
vp.camera.SetDistance( 7.42 )
vp.camera.SetClippingRange( [4.283, 11.386] )
vp.show(s1, resetcam=0) |
At present, it seems that you can install by Thank for your nice work! |
thanks @NaGenhao for your feedback.
|
I'm having the same issue with this code (or any other code with camera) in a jupyter notebook.
Yields
|
in my installation of vtkplotter, the plotter class doesn't seem to have a camera attribute. I see it in the source code...
any idea what might be going on?
The text was updated successfully, but these errors were encountered: