Hello all,

I have been searching for some time to find the most appropriate enviroment to draw lines and simple tri's / quads in three dimensional space. I have recently experiemented with the floatcanvas class in wxpython and I really like it for 2D work, but extending it into the third dimension (by mapping 3d points to a 2d plane then calculating the order elements should be drawn) turned out to acheive rather poor results.

I am a structural engineer, and write a number of small applications to make like easier for myself for designing structures etc. ALmost all structures I deal with a represented in 3D as shown in the links below (links to thrid party applications). I want to add a new dimension to my projects, with adding graphical disply / input which greatly speeds up verification of models.

http://www.microstran.com.au/gallery_loader.htm

http://www.spacegass.com/index.asp?resend=/sgplates.asp&referer=

I know there is opengl, but I find reference material (python specific) is rather limited. A opengl equivalent to FloatCanvas would be ideal to avoid building everything up from a low level but I think I am dreaming there. I did a bit with MATLAB in uni, and it handled drawing these primatives with ease using high level functions so I guess I was hoping something similiar exists out there in the universe. I dont mind if I have to learn a new language, but I would prefer to use python if possible since I am familiar and productive with it at the moment (wxpython is working well for me to date). I will probally only ever need 1000 line elements / 1000 quads maximum so I dont think I need anything as fast a pure C solution.

At the end of the day I need to be able to draw the basic elements noted above, rotate the view and basic navigation, select objects etc. Does anyone have any suggestions on what they would use to acheive this?

Looking forward to your suggestions. If I have been a bit light on providing information, please let me know and I will endeavor to further explain myself.

Many thanks,
Elbarto

Ps. I am not a programmers boot lace but I know just enough python to be dangerous (familiar with OOP, wxpython etc). I have tried to avoid learning a new language and focus on becoming proficient in python before I move on. Maybe the time has come?

There is Blender that uses Python as a scripting language.
See:
http://wiki.blender.org/

Used to come along with Stani's Python Editor (SPE).

I have played around with VPython and find it very powerful.
Here is a typical VPython coded example ...

# draw a green cylinder and a red sphere in a frame
# press the right mouse button to drag/rotate the objects
# experiments with visual Python (VPython) from: http://vpython.org/

import visual as vs

f = vs.frame()

# pos=(x,y,z)  color=(r,g,b)
# can also use vs.color.red and vs.color.green
vs.cylinder(frame=f, pos=(1,1,0), radius=0.2, length=4, color=(0,1,0))
vs.sphere(frame=f, pos=(1,1,0), radius=0.7, color=(1,0,0))

# position the frame (x,y,z)
f.axis = (0,0,1)
f.pos = (-1,0,0)

Have a look at Blender. It's a free and open source tool for 3D modelling and rendering, using Python as a scripting language.

There's also Caligari's Truespace. Microsoft acquired Caligari a few years back and made TrueSpace freely available. Unfortunately the software no longer appears to be maintained, but you might still find a legitimate copy via a reputable download site.

Panda3D is a 3D rendering and game engine developed for Python. Another free and open source project.

Some time has elapsed since I dabbled with Python and 3D, about eight years, so my recommendations aren't up-to-date. As Python was gaining in popularity as an embedded scripting language you may find there are better and newer options. Also, if your preferred application doesn't explicitly support Python, check to see if the app exports a COM interface that can be used for scripting.

Thanks for the response guys. I have looked into Panda3D, Blender and Mayavi but they look like they are pretty heavy packages. Since I distribute these applications with my colleagues, I would prefer to have something pretty lightweight, especially since my 3D needs dont require to much advance rendering. Blender and Mayavi seem more like an interactive enviroment to develope complex geometry etc.

I looked into Vpython a while ago, but I think I had problems trying to incorperate it into a wx GUI. This is a shame because it does not take much to get a good look scene together quickly.

Maybe I can revisit making something work with FloatCanvas.Does anyone have some reference material for how to determine the order in which to draw lines / quads in 3D space? I tried to render by drawing the furtherest away element first, but I based the distance on the centre of the element so results were not always as expected.

I guess my next question would be, is python the right choice to do this type of basic 3D work. Is a python + opengl solution possible that would alow me to detect clicks on individual points, lines, quads etc or is this a big job?

Many thanks for your replies. I appreciate the time you took to help me out.

Regards Elbarto

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.