kxgames / glooey

An object-oriented GUI library for pyglet.
MIT License
91 stars 6 forks source link

RatCave integration #59

Open gadese opened 2 years ago

gadese commented 2 years ago

Hi,

I've been using RatCave (based on Pyglet) to build 3D scenes, and I'm looking to build a GUI around it in order to be able to modify the scene by adding objects, moving them around, etc.

What I am looking to have is a container on the left with the UI, and a viewer on the right showing the 3D scene, so HBox seems perfect. My issue is I can't seem to make it work with a custom RatCave widget. This should be relatively similar to this older issue with Trimesh, but I'm kind of stuck and I can't make it work.

When I try to run it with a custom widget, I just get a blank screen in the viewer. See code below. Any help or insight would be very appreciated.

Thanks

`

import ratcave as rc
import pyglet
import glooey

class RatCaveWidget(glooey.Widget):
    def __init__(self, scene: rc.Scene):
        super().__init__()
        self.scene = scene

    def do_attach(self):
        pyglet.clock.schedule_interval(self.on_update, 1/60)

    def do_detach(self):
        pyglet.clock.unschedule(self.on_update)

    def do_claim(self):
        return 0, 0

    def do_draw(self):
        with rc.default_shader:
            self.scene.draw()

    def do_undraw(self):
        self.scene.clear()

    def on_update(self, dt):
        self._draw()

window = pyglet.window.Window(width=1280, height=480)
gui = glooey.Gui(window)

hbox = glooey.HBox()

#Building the RatCave scene
obj_filename = rc.resources.obj_primitives
obj_reader = rc.WavefrontReader(obj_filename)
cube= obj_reader.get_mesh("Cube", position=(0, 0, -1.5), scale=4)
rc_scene = rc.Scene(meshes=[cube])

scene = RatCaveWidget(rc_scene)
hbox.add(scene)
hbox.add(glooey.Placeholder(min_width=640, min_height=480))

gui.add(hbox)

pyglet.app.run()

`

matt-fevold commented 9 months ago

I'm just poking around different GUIs for pyglet so take my comment FWIW, glooey looked intersting but i've no experience yet (especially since it doesn't seem to support pyglet 2.0), that said - ratcave is now abandonware This repository has been archived by the owner on Sep 25, 2022. It is now read-only.

kalekundert commented 9 months ago

Sorry for the slow response. This project isn't really maintained anymore either. I'd consider merging PRs, but I probably won't be doing any more development myself.