Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are good libraries for creating a python program for (visually appealing) 3D physics simulations/visualizations?

What are good libraries for creating a python program for (visually appealing) 3D physics simulations/visualizations?

I've looked at Vpython but the simulations I have seen look ugly, I want them to be visually appealing. It also looks like an old library. For 3D programming I've seen suggestions of using Panda3D and python-ogre but I'm not sure if it is really suited for exact simulations. Also, I would prefer a library that combines well with other libraries (E.g. pygame does not combine so well with other libraries).

like image 995
Bentley4 Avatar asked May 07 '12 21:05

Bentley4


3 Answers

3D support for python is fairly weak compared to other languages, but with the way that most of them are built, the appearance of the program is far more mutable than you might think. For instance, you talked about Vpython, while many of their examples are not visually appealing, most of them are also from previous releases, the most recent release includes both extrusions, materials, and skins, which allow you to customize your appearance much moreso than before.

It is probably worth noting also, that it is simply not possible to make render-quality images in real time (cycles is a huge step in that direction, but it's still not quite there). I believe that most of your issue here is you are looking for something that technology is simply not capable of now, however if you are willing to take on the burden for making your simulation look visually appealing, Vpython (which is a gussied up version of PyOpenGL) is probably your best bet. Below is a run down of different technologies though, in case you are looking for anything more general:

Blender: The most powerful python graphics program available, however it is made for graphic design and special effects, though it has very complex physics running underneath it, Blender is not made for physics simulations. Self contained.

Panda3D: A program very often compared to Blender, however mostly useful for games. The game engine is nicer to work with than Blender's, but the render quality is far lower, as is the feature-richness. Self contained

Ogre: A library that was very popular for game development back in the day, with a lot of powerful functionality, especially for creating game environments. Event handling is also very well implemented. Can be made to integrate with other libraries, but with difficulty.

VPython: A library intended for physics simulations that removes a lot of the texture mapping and rendering power compared to the other methods, however this capability is still there, as VPython is largely built from OpenGL, which is one of the most versatile graphics libraries around. As such, VPython also is very easy to integrate with other libraries.

PyOpenGL: OpenGL for Python. OpenGL is one of the most widely use graphics libraries, and is without a doubt capable of producing some of the nicest visuals on this list (Except for Blender, which is a class of its own), however it will not be easy to do so. PyOpenGL is very bare bones, and while the functionality is there, it will be harder to implement than anything else. Plays very will with other libraries, but only if you know what you're doing.

like image 98
Slater Victoroff Avatar answered Nov 09 '22 11:11

Slater Victoroff


Try PyOpenGL. It is a library that provides Python bindings to OpenGL through the Python ctypes library.

Heres a demo of this:

PyOpenGL baseball demo

like image 2
C0deH4cker Avatar answered Nov 09 '22 12:11

C0deH4cker


If I needed a visualization package for python, I would start with Processing.py: https://github.com/jdf/processing.py

This is a python binding for the java-based Processing.org codes. A quick comparison can be found here: http://wiki.processing.org/w/Python_Comparison

Of course, if you are not constrained to python, then Processing itself would also be a good starting point: http://processing.org

There are also python bindings out there for Visualization Toolkit (VTK), but most of their examples are either C++ or Tk.

If all you're looking for is scene graph to move geometries around, not native vis, then I have seen some python binding for Open Scene Graph out there, eg: http://code.google.com/p/osgswig/

Good Luck!

like image 2
Ruan Caiman Avatar answered Nov 09 '22 12:11

Ruan Caiman