piddle

Mike C. Fletcher mcfletch at rogers.com
Mon Dec 15 00:05:54 CET 2003


Not answering the question, but sounds like a job for one of the 3D 
engines, such as VPython, OpenGLContext, Ogre, etceteras.  e.g. in 
OpenGLContext (caveat, I wrote it, so I'm biased ;) ):

from OpenGLContext import testingcontext
BaseContext, MainFunction = testingcontext.getInteractive()
from Numeric import arange

from OpenGLContext.scenegraph.basenodes import *

class TestContext( BaseContext ):
    initialPosition = (0,0,3)
    def OnInit( self ):
        """Load/create the geometry"""
        line = arange(0.0,1.0,.02)
        self.scene = sceneGraph(
            children = [
                Shape(
                    geometry = PointSet(
                        coord = Coordinate(
                            point = map(None,[0]*len(line), line, 
[0]*len(line) ),
                        ),
                        color = Color(
                            color = map(None,[0]*len(line), line, 
[0]*len(line) ),
                        ),
                    ),
                ),
            ],
        )
    def getSceneGraph( self ):
        """Get the scene graph for the context (or None)"""
        return self.scene

if __name__ == "__main__":
    MainFunction ( TestContext)

The self.scene etceteras stuff is just creating a VRML97 scenegraph 
which, in this case, just has a series of coloured dots in a line (you 
could just as easily load the scene from a VRML97 format file). The 
library supports IndexedLineSet and IndexedFaceSet, so connected 
geometry and 3D faces are both readily created. 

You should include VRML97 PointLights if you want nice shading of the 
geometry.  There are Contexts available for wxPython, PyGame and GLUT, 
with wxPython being the most likely choice for an application where you 
want lots of GUI interactions outside the 3D context.

The approach would be similar in any scenegraph-based 3D system, I just 
don't have handy sample code for the other ones.

Have fun,
Mike

SamX wrote:

>Can some please tell me if PIDDLE can plot 3d (x, y, z) points on a
>canvas?
>This is to display airfoil cross-sections of a blade.  Each section
>has x-y coordinates and a z coordinate.
>Hopefully one can rotate, pan and zoom the display.  Or even better,
>the points can be connected by lines or even shade the surface of the
>blade so it appears solid.
>Thank you in advance.
>  
>
_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/








More information about the Python-list mailing list