Python showcase example

Create issue
Issue #21 new
Matt Williams created an issue

In order to test the Python bindings and to showcase what can be done with them, we should add a small/medium scale application which provides an interactive experience.

I'm imagining something which provides the following:

  • Free-flying camera
    • also control camera from console
  • Only edit the volume through console-type commands
    • load a volume from a file?
    • edit voxel by:
      • xyz position
      • where the camera is pointing right now (raycast)
  • probably cubic terrain
  • multiple materials or colours

Either the terminal could be embedded into the window or the application could be launched from the Python REPL.

The whole program should be pure Python and its single entry point to PolyVox should be through (via SWIG).

For input and rendering I could use PyGame (with PyOpenGL).

Due to scale and scope, maybe it should be outside of the PolyVox source tree?

Comments (6)

  1. David Williams

    Yes, I think this would be a good idea. I would indeed recommend going with the Cubic surface as I think people find these easier to understand, and it's also easier to make editing tools for (especially if people will be 'editing' through code).

    The functionality is completely up to you but your suggestions sound good. I'm sure you have some interesting ideas about how it should work. As for whether it belongs inside PolyVox, well, let's see how big it gets. Python has a nice way of letting you get a lot of functionality with only a little code :-)

    I'm sure you'll come up against questions/issues so just ask away (here or by email).

  2. Jesse Johnson

    Any update on this? Eagerly await the chance to test it out and look over the code. Python would be great for quick prototyping.

  3. Matt Williams reporter

    @holocronweaver, Currently in the develop Git branch there is a simple Python example using PyOpenGL. Once you've built PolyVox (and making sure that the Python bindings were built too), go to build/examples/Python and run You need numpy, PyOpenGL, and pygame along with a graphics card and drivers which support OpenGL 3.0 or above.

    Most of the PolyVox related stuff happens in just the first third of the file (up line 75 or so) with the rest being mostly OpenGL stuff. I've tried to document it thoroughly to explain what is going on.

    I'm still working on a second, more complex example with dynamically editable data and the other points mentioned in my first post above but in the meantime, the simple PythonExample should be enough to get you going. Feel free to ask any questions you want on the forums.

  4. Jesse Johnson

    Thanks for the quick response. Unfortunately all I got from running the example is a window with all black contents. I am on Ubuntu 12.04 using a AMD HD6950 (OpenGL 4.2) with the latest drivers. All other 3D apps are working fine.

  5. David Williams

    Note that the Python bindings (more generally the SWIG bindings) are currently broken because of extensive refactoring on my part and the switch to being header-only. A Python interface to PolyVox would still be very interesting, but we've also discussed the idea of making a higher-level wrapper around PolyVox (C interface, free from template complexities, etc) which would be easier to use and might insulate Python/SWIG from further breaking changes in PolyVox (in some sense Cubiquity was/is such a wrapper, though maybe not quite what we want here).

    Note that not every part of PolyVox needs to be exposed, e.g. we could have PagedVolume (with a simple built-in pager that can't be changed) but no RawVolume. Such a system would still be useful to people wanting to work with voxels in Python.

  6. Log in to comment