Module Scientific.Visualization.VRML

This module provides definitions of simple 3D graphics objects and VRML scenes containing them. The objects are appropriate for data visualization, not for virtual reality modelling. Scenes can be written to VRML files or visualized immediately using a VRML browser, whose name is taken from the environment variable VRMLVIEWER (under Unix).

There are a few attributes that are common to all graphics objects:

material

a Material object defining color and surface properties

comment

a comment string that will be written to the VRML file

reuse

a boolean flag (defaulting to false). If set to one, the object may share its VRML definition with other objects. This reduces the size of the VRML file, but can yield surprising side effects in some cases.

This module used the original VRML definition, version 1.0. For the newer VRML 2 or VRML97, use the module VRML2, which uses exactly the same interface. There is another almost perfectly compatible module VMD, which produces input files for the molecular visualization program VMD.

Example:

from Scientific.Visualization.VRML import *
scene = Scene([])
scale = ColorScale(10.)
for x in range(11):
    color = scale(x)
    scene.addObject(Cube(Vector(x, 0., 0.), 0.2,
                         material=Material(diffuse_color = color)))
scene.view()

Functions


Class Scene: VRML scene

A VRML scene is a collection of graphics objects that can be written to a VRML file or fed directly to a VRML browser.

Constructor: Scene(objects=None, cameras=None, **|options|)

objects

a list of graphics objects or None for an empty scene

cameras

a list of cameras (not yet implemented)

options

options as keyword arguments (none defined at the moment; this argument is provided for compatibility with other modules)

Methods:

Class Sphere: Sphere

Constructor: Sphere(center, radius, **|attributes|)

center

the center of the sphere (a vector)

radius

the sphere radius (a positive number)

attributes

any graphics object attribute


Class Cube: Cube

Constructor: Cube(center, edge, **|attributes|)

center

the center of the cube (a vector)

edge

the length of an edge (a positive number)

attributes

any graphics object attribute

The edges of a cube are always parallel to the coordinate axes.


Class Cylinder: Cylinder

Constructor: Cylinder(point1, point2, radius, faces=(1, 1, 1), **|attributes|)

point1, point2

the end points of the cylinder axis (vectors)

radius

the radius (a positive number)

attributes

any graphics object attribute

faces

a sequence of three boolean flags, corresponding to the cylinder hull and the two circular end pieces, specifying for each of these parts whether it is visible or not.


Class Cone: Cone

Constructor: Cone(point1, point2, radius, face=1, **|attributes|)

point1, point2

the end points of the cylinder axis (vectors). point1 is the tip of the cone.

radius

the radius (a positive number)

attributes

any graphics object attribute

face

a boolean flag, specifying if the circular bottom is visible


Class Line: Line

Constructor: Line(point1, point2, **|attributes|)

point1, point2

the end points of the line (vectors)

attributes

any graphics object attribute


Class PolyLines: Multiple connected lines

Constructor: PolyLines(points, **|attributes|)

points

a sequence of points to be connected by lines

attributes

any graphics object attribute


Class Polygons: Polygons

Constructor: Polygons(points, index_lists, **|attributes|)

points

a sequence of points

index_lists

a sequence of index lists, one for each polygon. The index list for a polygon defines which points in points are vertices of the polygon.

attributes

any graphics object attribute


Class Arrow: Arrow

An arrow consists of a cylinder and a cone.

Constructor: Arrow(point1, point2, radius, **|attributes|)

point1, point2

the end points of the arrow (vectors). point2 defines the tip of the arrow.

radius

the radius of the arrow shaft (a positive number)

attributes

any graphics object attribute


Class Material: Material for graphics objects

A material defines the color and surface properties of an object.

Constructor: Material(**|attributes|)

The attributes are "ambient_color", "diffuse_color", "specular_color", "emissive_color", "shininess", and "transparency".