Skip to content
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

Scene viewer as a widget in a window #368

Closed
wkentaro opened this issue Apr 11, 2019 · 8 comments
Closed

Scene viewer as a widget in a window #368

wkentaro opened this issue Apr 11, 2019 · 8 comments

Comments

@wkentaro
Copy link
Contributor

To use SceneViewer as a widget in a window (for real application with buttons, labels, and additional image widgets), glooey looks good.
(trimesh.SceneViewer is a pyglet.Window by itself, so we can create multiple windows but we cannot tile multiple SceneViewer in a single window.)

Does anyone know any other options?


In glooey, it creates pyglet.Window and add Widgets (e.g., glooey.Image) to that.
So, in order to render trimesh.Scene or trimesh.Trimesh in a widget, we need creates a custom widget (e.g, TrimeshSceneViewerWidget), which is similar to trimesh.viewer.SceneViewer.

Here is a workaround of this (actually it still doesn't work): https://gist.github.com/wkentaro/d8cc30c6634389db02ba53adb7b934b2

@mikedh
Copy link
Owner

mikedh commented Apr 13, 2019

I played with this briefly- glooey looks awesome! Heh I tried their example, but just replacing the window like:

import trimesh
from trimesh.viewer import windowed
mesh= trimesh.load('models/featuretype.STL')
window = windowed.SceneViewer(mesh.scene(),
                              start_loop=False)

And it didn't work immediately. The widget would be a nice abstraction for sure, seems like it would however require a lot of re- implementation.

@wkentaro
Copy link
Contributor Author

At least, below example does work, right?

#!/usr/bin/env python

import glooey
import pyglet
import trimesh
from trimesh.viewer import windowed

mesh= trimesh.load('models/featuretype.STL')
window = windowed.SceneViewer(mesh.scene(),
                              start_loop=False)

gui = glooey.Gui(window)
pyglet.app.run()

But it doesn't work with other widget like glooey.HBox. I'm working on this by asking the developers of glooey: kxgames/glooey#24.

@wkentaro
Copy link
Contributor Author

I successfully implemented the widget that visualizes trimesh's scene object.
https://github.com/wkentaro/trimesh-glooey/blob/master/scene_widget.py

If you run this script, the window looks like below:
Screencast 2019-04-20 20:02:50

It supports multiple trimesh scenes visualized on a single window, which is desired when we create a single-window application.
What do you think of adding this widget to trimesh with an optional dependency on glooey?

Another thing, this is a bit out of the scope of this issue, but I felt pyrender.Trackball is quite easy to rotate the camera compared to trimesh.transformations.Arcball.
That's why I use pyrender.Trackball in the above script.
I think that would be great if we integrate pyrender.Trackball into trimesh if it's license-ok. What do you think of this?

cc @kalekundert

@mikedh
Copy link
Owner

mikedh commented Apr 21, 2019

Oh neat! Yeah definitely, maybe included as something like:
trimesh/viewers/widget.py
Then main as:
examples/widget.py

What do you think? Your example looked pretty much ready to go, though if you could add a few docstrings it would be nice.

With regards to including pyrender.trackball as something like trimesh.viewers.trackball, or trimesh.scene.trackball, sounds great to me unless @mmatl objects (license is compatible). It doesn't have any external dependencies and looks better than trimesh.transformations.Arcball for sure.

@wkentaro
Copy link
Contributor Author

wkentaro commented Apr 22, 2019

Nice. First of all, I sent PR about Trackball here: #381

@mmatl
Copy link
Contributor

mmatl commented Apr 22, 2019

I'm totally cool with it, of course! Feel free to copy code over as needed.

@wkentaro
Copy link
Contributor Author

Thanks, @mmatl !

@mikedh
Copy link
Owner

mikedh commented Apr 23, 2019

Added in #387. Thanks for the PR!

@mikedh mikedh closed this as completed Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants