views:

125

answers:

4

I am busy reading 3D building models from a tool and thus generating a bunch of Line(p1, p2) objects, each consisting of two Point(x, y, z) objects. I would like to display these things in a simple 3D viewer, kind of like SVG (which, as I understand, only supports 2D).

The reading is done in Python, specifically IronPython. I could use either a .NET viewer library or write out a text/xml/whatnot file with the data to be displayed by manually opening the result in the appropriate program.

What format / tool would you use to view the data?

(At the moment, this is only for debugging purposes, so it doesn't have to be top-notch. Just a wire-frame will do!)

I did check the mathplot library, but that seems to only plot functions...

EDIT: I eventually did go the X3D route and wrote a little blog post on how to do it. Here is a sample X3D wireframe file for a 1x1x1 cube:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"
  "http://www.web3d.org/specifications/x3d-3.0.dtd"&gt;
<X3D profile="Immersive" >
  <Scene>

    <Transform>
      <Shape>
        <LineSet vertexCount="5">
            <Coordinate point="1 0 0
                               1 1 0
                               0 1 0
                               0 0 0
                               1 0 0"
                               />
        </LineSet>
    </Shape>
    <Shape>
        <LineSet vertexCount="5">
            <Coordinate point="1 0 1
                               1 1 1
                               0 1 1
                               0 0 1
                               1 0 1"
                               />
        </LineSet>
    </Shape>
    <Shape>
        <LineSet vertexCount="5">
            <Coordinate point="0 0 1
                               1 0 1
                               1 0 0
                               0 0 0
                               0 0 1"
                               />
        </LineSet>
    </Shape>
    <Shape>
        <LineSet vertexCount="5">
            <Coordinate point="0 1 1
                               1 1 1
                               1 1 0
                               0 1 0
                               0 1 1"
                               />
        </LineSet>
      </Shape>
    </Transform>
  </Scene>
</X3D>
+1  A: 

I'm not a 3D-programming expert but there is a simple trick you can do.
If you imagine that the z axis is vertical to your screen then you can project a 3D point (x, y, z) like this: (zoom_factor*(x/z), zoom_factor*(y/z))

Nick D
thanks, I might have to resort to something like that.I was hoping for a ready made viewer that will take my 3D points, though. Also, using your technique I will have to do some transformations (should be easy) as z-axis actually goes up (elevation) and the x/y plane is normal to the screen...
Daren Thomas
ok Daren. I wish I could provide more help and tips :-)
Nick D
+1  A: 

You might try the PyQwt3D package. If that doesn't work, here's a list of other python packages that might be useful.

tgray
+1  A: 

For using the writing to file approach you could investigate X3D, which is the successor to VRML. Also see this list of vector graphics markup languages

danio
+1  A: 

You could look at POV-Ray. It's a ray tracer that has its own text based scene description language. IIRC, there is a python module which will generate the scene files, if not, it wouldn't be difficult to do by hand. Displaying line segments at low resolution should render fairly quickly.

Check here: http://code.activestate.com/recipes/205451/

Also, python is the scripting language for Blender.

Barton Chittenden