This module provides definitions of simple 3D graphics objects and scenes containing them, in a form that can be fed to the molecular visualization program VMD. Scenes can either be written as VMD script files, or visualized directly by running VMD.
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 is almost compatible with the modules VRML and VRML2, which provide visualization by VRML browsers. There is no Polygon objects, and the only material attribute supported is diffuse_color. Note also that loading a scene with many cubes into VMD is very slow, because each cube is represented by 12 individual triangles.
Example:
from VMD 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.
A VMD scene is a collection of graphics objects that can be written to a VMD script file or fed directly to VMD.
Constructor: Scene(objects=None, **|options|)
a list of graphics objects or None for an empty scene
options as keyword arguments. The only option available is "scale", whose value must be a positive number which specifies a scale factor applied to all coordinates of geometrical objects except for molecule objects, which cannot be scaled.
Adds object to the list of graphics objects.
Writes the scene to a VRML file with name filename.
Start VMD for the scene.
Constructor: Molecules(pdb_file)
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
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 accepted attributes are "ambient_color", "diffuse_color", "specular_color", "emissive_color", "shininess", and "transparency". Only "diffuse_color" is used, the others are permitted for compatibility with the VRML modules.