Python and 3d

A

azrael

Has anyone any exipience with python and 3d.

I mean, is there a module to deal with popular 3d formats like 3ds, or
vrml. is it possible to import into python opengl models and then use
it in application for GUI purposes like through WX. I know that WX
supports OpenGL but how to import models from file.
 
M

Mike C. Fletcher

azrael said:
Has anyone any exipience with python and 3d.

I mean, is there a module to deal with popular 3d formats like 3ds, or
vrml. is it possible to import into python opengl models and then use
it in application for GUI purposes like through WX. I know that WX
supports OpenGL but how to import models from file.
http://www.vrplumber.com/py3d.py

There's a few older projects to load 3DS files, but I don't think any of
them is currently PyOpenGL 3.x compatible. OpenGLContext loads VRML97
files (with SimpleParse installed). Pyglet, OpenGLContext and Ian
Mallet's game engine all load .obj models (I believe Ian's engine is the
most advanced there). Pivy should load VRML files as well, and has a
very powerful engine (COIN) under the covers (OpenGLContext is more of a
demo/testing system). The big engines (Ogre, Soya, OpenSceneGraph,
Crystal Space, etc) should all have content loaders, though I haven't
played with them enough to be able to say what formats they support.

HTH,
Mike

--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
 
T

TerryP

Importing models from a file, obviously always raises the question,
what kind of model formats :p.

You should probably take a look at something like Python-Ogre or
Pygame for a starting point. Doing raw OpenGL is a bit more tricky and
even more dependent on format.
 
M

mbaas

Has anyone any exipience with python and 3d.

I mean, is there a module to deal with popular 3d formats like 3ds, or
vrml. is it possible to import into python opengl models and then use
it in application for GUI purposes like through WX. I know that WX
supports OpenGL but how to import models from file.

I have written a package called cgkit (http://cgkit.sourceforge.net/)
which can import a few 3D formats (see here for a list of supported
formats: http://cgkit.sourceforge.net/doc2/importplugins.html).
You could load the models into memory and then use their OpenGL
drawing methods within your own OpenGL code. The drawing code in cgkit
is written in C++, so it doesn't need PyOpenGL itself but works fine
together with it.
Or you could just extract the geometry data and do all the OpenGL
stuff yourself, that's up to you.

- Matthias -
 
S

sturlamolden

Dice3DS works fine with PyOpenGL 3.x.

PyOpenGL is a bad idea anyway, due to the overhead of Python function
calls and ctypes. Doing 3D in "pure" Python at least requires NumPy
arrays as vertex arrays and/or extensive use of display lists. But
there are better alternatives.

My current approach is use Cython + NumPy, and accumulate calls to
OpenGL in a C function. I prefer to keep calls to OpenGL in C (not
Cython), because this way I don't have to define the OpenGL API to
Cython. Cython merely becomes a glue layer between Python and C. With
NumPy support in Cython, this is a nice way of storing contiguous
vertex array. NumPy even allows Fortran ordering, which is used by
OpenGL.

Another nice way of using OpenGL from Python is the Fortran bindings
(f90gl or F03GL). One can accumulate calls to OpenGL in a Fortran 95
subroutine, and make it callable from Python with f2py.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top