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 VRML2VIEWER (under Unix).
There are a few attributes that are common to all graphics objects:a Material object defining color and surface properties
a comment string that will be written to the VRML file
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 VRML 2.0 definition, also known as VRML97. For the original VRML 1, use the module VRML, 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.VRML2 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()
DiffuseMaterial()
Returns a material with the diffuse color attribute set to color.
EmissiveMaterial()
Returns a material with the emissive color attribute set to color.
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|)
a list of graphics objects or None for an empty scene
a list of cameras
options as keyword arguments (none defined at the moment; this argument is provided for compatibility with other modules)
Adds object to the list of graphics objects.
Adds camera to the list of cameras.
Writes the scene to a VRML file with name filename.
Start a VRML browser for the scene.
Constructor: Camera(position, orientation, description, field_of_view)
the location of the camera (a vector)
an (axis, angle) tuple in which the axis is a vector and angle a number (in radians); axis and angle specify a rotation with respect to the standard orientation along the negative z axis
a label for the viewpoint (a string)
the field of view (a positive number)
Constructor: NavigationInfo(speed, type)
walking speed in length units per second
one of WALK, EXAMINE, FLY, NONE, ANY
Constructor: Sphere(center, radius, **|attributes|)
the center of the sphere (a vector)
the sphere radius (a positive number)
any graphics object attribute
Constructor: Cube(center, edge, **|attributes|)
the center of the cube (a vector)
the length of an edge (a positive number)
any graphics object attribute
The edges of a cube are always parallel to the coordinate axes.
Constructor: Cylinder(point1, point2, radius, faces=(1, 1, 1), **|attributes|)
the end points of the cylinder axis (vectors)
the radius (a positive number)
any graphics object attribute
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.
Constructor: Cone(point1, point2, radius, face=1, **|attributes|)
the end points of the cylinder axis (vectors). point1 is the tip of the cone.
the radius (a positive number)
any graphics object attribute
a boolean flag, specifying if the circular bottom is visible
Constructor: Line(point1, point2, **|attributes|)
the end points of the line (vectors)
any graphics object attribute
Constructor: PolyLines(points, **|attributes|)
a sequence of points to be connected by lines
any graphics object attribute
Constructor: Polygons(points, index_lists, **|attributes|)
a sequence of points
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.
any graphics object attribute
An arrow consists of a cylinder and a cone.
Constructor: Arrow(point1, point2, radius, **|attributes|)
the end points of the arrow (vectors). point2 defines the tip of the arrow.
the radius of the arrow shaft (a positive number)
any graphics object attribute
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".