1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
<a name="Module:Scientific.Visualization.VRML"><h1>Module Scientific.Visualization.VRML</h1></a>
<p>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).</p>
There are a few attributes that are common to all graphics objects:
<p><dl>
<dt>material</dt>
<dd><p>
a Material object defining color and surface properties</p></dd>
<dt>comment</dt>
<dd><p>
a comment string that will be written to the VRML file</p></dd>
<dt>reuse</dt>
<dd><p>
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.</p></dd>
</dl>
</p>
<p>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.</p>
<p>Example:</p>
<pre>
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()
</pre>
<hr width=70%>
<h2>Functions</h2>
<ul>
<li> <p>
<a name="Function:Scientific.Visualization.VRML.DiffuseMaterial"><b><i>DiffuseMaterial</i></b>(<i>color</i>)</a><br>
</p>
<p>Returns a material with the <tt>diffuse color</tt> attribute set to <i>color</i>.</p><li> <p>
<a name="Function:Scientific.Visualization.VRML.EmissiveMaterial"><b><i>EmissiveMaterial</i></b>(<i>color</i>)</a><br>
</p>
<p>Returns a material with the <tt>emissive color</tt> attribute set to <i>color</i>.</p></ul>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Scene"><h2>Class Scene: VRML scene</h2></a>
<p>A VRML scene is a collection of graphics objects that can be
written to a VRML file or fed directly to a VRML browser.</p>
<p>Constructor: Scene(<i>objects</i>=None, <i>cameras</i>=None, **|options|)</p>
<p><dl>
<dt><i>objects</i></dt>
<dd><p>
a list of graphics objects or <tt>None</tt> for an empty scene</p></dd>
<dt><i>cameras</i></dt>
<dd><p>
a list of cameras (not yet implemented)</p></dd>
<dt><i>options</i></dt>
<dd><p>
options as keyword arguments (none defined at the moment;
this argument is provided for compatibility with
other modules)
</p></dd>
</dl>
</p>
<b>Methods:</b><br>
<ul>
<li> <b><i>addObject</i></b>(<i>object</i>)
<p>Adds <i>object</i> to the list of graphics objects.</p>
<li> <b><i>addCamera</i></b>(<i>camera</i>)
<p>Adds <i>camers</i> to the list of cameras.</p>
<li> <b><i>writeToFile</i></b>(<i>filename</i>)
<p>Writes the scene to a VRML file with name <i>filename</i>.</p>
<li> <b><i>view</i></b>()
<p>Start a VRML browser for the scene.</p>
</ul>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Sphere"><h2>Class Sphere: Sphere</h2></a>
<p>Constructor: Sphere(<i>center</i>, <i>radius</i>, **|attributes|)</p>
<p><dl>
<dt><i>center</i></dt>
<dd><p>
the center of the sphere (a vector)</p></dd>
<dt><i>radius</i></dt>
<dd><p>
the sphere radius (a positive number)</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute
</p></dd>
</dl>
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Cube"><h2>Class Cube: Cube</h2></a>
<p>Constructor: Cube(<i>center</i>, <i>edge</i>, **|attributes|)</p>
<p><dl>
<dt><i>center</i></dt>
<dd><p>
the center of the cube (a vector)</p></dd>
<dt><i>edge</i></dt>
<dd><p>
the length of an edge (a positive number)</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute</p></dd>
</dl>
</p>
<p>The edges of a cube are always parallel to the coordinate axes.
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Cylinder"><h2>Class Cylinder: Cylinder</h2></a>
<p>Constructor: Cylinder(<i>point1</i>, <i>point2</i>, <i>radius</i>,
<i>faces</i>=<tt>(1, 1, 1)</tt>, **|attributes|)</p>
<p><dl>
<dt><i>point1</i>, <i>point2</i></dt>
<dd><p>
the end points of the cylinder axis (vectors)</p></dd>
<dt><i>radius</i></dt>
<dd><p>
the radius (a positive number)</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute</p></dd>
<dt><i>faces</i></dt>
<dd><p>
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.
</p></dd>
</dl>
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Cone"><h2>Class Cone: Cone</h2></a>
<p>Constructor: Cone(<i>point1</i>, <i>point2</i>, <i>radius</i>, <i>face</i>=<tt>1</tt>, **|attributes|)</p>
<p><dl>
<dt><i>point1</i>, <i>point2</i></dt>
<dd><p>
the end points of the cylinder axis (vectors).
<i>point1</i> is the tip of the cone.</p></dd>
<dt><i>radius</i></dt>
<dd><p>
the radius (a positive number)</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute</p></dd>
<dt><i>face</i></dt>
<dd><p>
a boolean flag, specifying if the circular bottom is visible
</p></dd>
</dl>
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Line"><h2>Class Line: Line</h2></a>
<p>Constructor: Line(<i>point1</i>, <i>point2</i>, **|attributes|)</p>
<p><dl>
<dt><i>point1</i>, <i>point2</i></dt>
<dd><p>
the end points of the line (vectors)</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute
</p></dd>
</dl>
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.PolyLines"><h2>Class PolyLines: Multiple connected lines</h2></a>
<p>Constructor: PolyLines(<i>points</i>, **|attributes|)</p>
<p><dl>
<dt><i>points</i></dt>
<dd><p>
a sequence of points to be connected by lines</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute
</p></dd>
</dl>
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Polygons"><h2>Class Polygons: Polygons</h2></a>
<p>Constructor: Polygons(<i>points</i>, <i>index_lists</i>, **|attributes|)</p>
<p><dl>
<dt><i>points</i></dt>
<dd><p>
a sequence of points</p></dd>
<dt><i>index_lists</i></dt>
<dd><p>
a sequence of index lists, one for each polygon.
The index list for a polygon defines which points
in <i>points</i> are vertices of the polygon.</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute
</p></dd>
</dl>
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Arrow"><h2>Class Arrow: Arrow</h2></a>
<p>An arrow consists of a cylinder and a cone.</p>
<p>Constructor: Arrow(<i>point1</i>, <i>point2</i>, <i>radius</i>, **|attributes|)</p>
<p><dl>
<dt><i>point1</i>, <i>point2</i></dt>
<dd><p>
the end points of the arrow (vectors).
<i>point2</i> defines the tip of the arrow.</p></dd>
<dt><i>radius</i></dt>
<dd><p>
the radius of the arrow shaft (a positive number)</p></dd>
<dt><i>attributes</i></dt>
<dd><p>
any graphics object attribute
</p></dd>
</dl>
</p>
<hr width=70%>
<a name="Class:Scientific.Visualization.VRML.Material"><h2>Class Material: Material for graphics objects</h2></a>
<p>A material defines the color and surface properties of an object.</p>
<p>Constructor: Material(**|attributes|)</p>
<p>The attributes are "ambient_color", "diffuse_color", "specular_color",
"emissive_color", "shininess", and "transparency".
</p>
|