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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/visual/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>new features</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #0000A0}
-->
</style>
<style type="text/css">
<!--
.style2 {
font-size: x-large;
color: #FF0000;
font-weight: bold;
}
.style2 {font-size: xx-large}
-->
</style>
<style type="text/css">
<!--
.style3 { font-size: large;
font-weight: bold;
color: #0000A0;
}
-->
</style>
<!-- InstanceEndEditable -->
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="800" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutDefaultTable-->
<tr>
<td width="10" valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell--> </td>
<td width="10" height="272" valign="top" bgcolor="#DDDDDD"><p> </p> </td>
<td width="173" valign="top" bgcolor="#DDDDDD"><p class="Normal"><a href="index.html">Home</a></p>
<p class="Normal">If you're new to Python <br />
and VPython: <a href="VisualIntro.html">Introduction</a></p>
<p class="Normal">A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p>
<p class="Normal"><a href="primitives.html">Pictures</a> of 3D objects</p>
<p class="Normal">Choose a 3D object:</p>
<select name="jumpMenu4" id="jumpMenu4" onchange="MM_jumpMenu('parent',this,0)">
<option>Choose an object</option>
<option value="cylinder.html">Overview</option>
<option value="arrow.html">arrow</option>
<option value="box.html">box</option>
<option value="cone.html">cone</option>
<option value="convex.html">convex</option>
<option value="curve.html">curve</option>
<option value="cylinder.html">cylinder</option>
<option value="ellipsoid.html">ellipsoid</option>
<option value="faces.html">faces</option>
<option value="frame.html">frame</option>
<option value="helix.html">helix</option>
<option value="label.html">label</option>
<option value="lights.html">lights</option>
<option value="points.html">points</option>
<option value="pyramid.html">pyramid</option>
<option value="ring.html">ring</option>
<option value="sphere.html">sphere</option>
</select>
<p class="Normal">Work with 3D objects:</p>
<select name="jumpMenu4" id="jumpMenu5" onchange="MM_jumpMenu('parent',this,0)">
<option>Choose an option</option>
<option value="color.html">Color & Opacity</option>
<option value="lights.html">Lighting</option>
<option value="materials.html">Materials & Textures</option>
<option value="defaults.html">Defaults</option>
<option value="rate.html">Animation Speed</option>
<option value="rotation.html">Rotations</option>
<option value="options.html">Additional Options</option>
<option value="delete.html">Delete an Object</option>
<option value="float.html">3/4 = 0?</option>
</select>
<p class="Normal">Windows, Events, & Files:</p>
<select name="jumpMenu4" id="jumpMenu6" onchange="MM_jumpMenu('parent',this,0)">
<option>Choose a topic</option>
<option value="display.html">Windows</option>
<option value="lights.html">Lighting</option>
<option value="mouse.html">Mouse Events</option>
<option value="mouse_click.html"> Mouse Click</option>
<option value="mouse_drag.html"> Mouse Drag</option>
<option value="keyboard.html">Keyboard Events</option>
<option value="controls.html">Buttons and Sliders</option>
<option value="files.html">Reading/Writing Files</option>
</select>
<p class="Normal"><a href="vector.html">Vector operations </a></p>
<p class="Normal"><a href="graph.html">Graphs</a></p>
<p class="Normal"><a href="factorial.html">factorial/combin</a></p>
<p class="Normal">What's new in <a href="new_features.html">Visual 5</a></p>
<p class="Normal"><a href="http://vpython.org" target="_blank">VPython web site</a><br />
<a href="license.txt" target="_blank">Visual license</a><br />
<a href="http://www.python.org" target="_blank">Python web site</a> <br />
<a href="http://www.python.org/doc/2.5.2/lib/module-math.html" target="_blank">Math module</a> (sqrt etc.)<br />
<a href="http://www.scipy.org/Documentation" target="_blank">Numpy module</a> (arrays) </p></td>
<td width="21" valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell--> </td>
<td width="586" rowspan="2" valign="top"><!-- InstanceBeginEditable name="content" -->
<table width="100%" border="1">
<tr>
<td width="76%"><div align="center" class="style2">New Features in
Visual 5</div></td>
<td width="24%"><img src="images/material_etc.jpg" alt="material etc" width="334" height="235" /></td>
</tr>
</table>
<h3><span class="Normal"><span class="style1">New features</span></span></h3>
<p class="Normal">There is a new example program <strong>texture_and_lighting.py</strong> that
displays many of the new features: a swinging light illuminates a translucent
ball that rolls on a wood table. Also see the
example programs <strong>material_test.py</strong>, <strong>stonehenge.py</strong>, and <strong>boxlighttest.py</strong>. </p>
<p class="Normal">There are a couple of known <a href="#incompatibilities">incompatibilities</a> with earlier versions of VPython. </p>
<h3 class="Normal"><span class="style1">Credits</span></h3>
<p class="Normal">Visual 5 was created by David Scherer and Bruce Sherwood.
Jonathan Brandmeyer provided support in Visual 4beta for opacity, local
lighting, and textures, and made some important architectural changes,
but had to stop work on the project before it was completed. Further
development has led to API changes which are incompatible with the Visual
4beta release, so this release is called version 5 instead of 4.</p>
<p class="Normal"> The late Arthur Siegel implemented dependence on the currently supported
numpy library in place of Numeric, which is no longer supported. Hugh
Fisher provided a big start on the native-mode Mac version. Michael
Temkine fixed some bugs and implemented keyboard handling for Windows.</p>
<p class="Normal"> Previous to Visual 4beta, Jonathan Brandmeyer made several major contributions
to Visual 3, including changing the connection between Python and C++
from CXX, which was no longer supported, to the Boost C++ libraries,
and implementing auto-configurable installations for Linux.<br />
</p>
<h3 class="style1">Transparency/opacity</h3>
<p class="Normal">You can make most objects be transparent by specifying a value from
0-1 inclusive for the attribute "<a href="color.html"><strong>opacity</strong></a>". For example, <span class="attribute"><strong>box(color=color.red,
opacity=0.8)</strong></span> is slightly transparent. An opacity value of 0 means totally
transparent,
and 1 means totally opaque. Currently curve, convex, faces, points, and helix objects
do not allow transparency. </p>
<p class="Normal">You may see incorrect rendering any time there is a translucent
object (opacity
< 1.0) which is not convex (e.g. ring), or two translucent objects
which overlap on the screen and also in their depth extents (distances
from the camera to the nearest and farthest planes perpendicular to scene.forward
which intersect the object). The objects need not
actually overlap in 3D space to have problems. The incorrect rendering
will usually have the effect of making the more distant object disappear
(fail to show through the nearer object). Accurate rendering
of ad hoc scenes with translucency is difficult and expensive, and we
did not want to wait for a perfect solution before introducing this useful
enhancement.</p>
<h3 class="style1">Materials</h3>
<p class="Normal">You can give a <a href="materials.html"><strong>material property</strong></a> such as wood to an object: </p>
<p class="program">box(color=color.orange, material=materials.wood)</p>
<p class="Normal">Materials currently available include wood, plastic,
marble, earth (continents and oceans), rough, diffuse, emissive, and
unshaded (that is, display the specified color unaffected by existing
lights). The example program
<strong>material_test.py</strong> shows examples of all of these materials.</p>
<p class="Normal">Materials will work with graphics cards that support
Pixel Shader 3.0 ("PS 3.0"). For details, see<br />
<a href="http://en.wikipedia.org/wiki/Pixel_shader#Hardware" target="_blank">http://en.wikipedia.org/wiki/Pixel_shader#Hardware</a>.
<em>Some</em> materials may work with graphics cards that support PS
2.0, but other materials may need to be manually disabled; see instructions
in the <strong>site-settings.py</strong> module in the Visual package
in your site-packages folder. If the graphics hardware does not support
pixel shaders, the material property is ignored. If you think you should
be able to use materials but have trouble with their display or performance,
we highly recommend upgrading your video card drivers to the latest version.<br />
</p>
<h3 class="style1">Lighting</h3>
<p class="Normal">In previous versions of Visual, lights were
restricted to being white and very distant from the scene ("at
infinity").
Now you can <a href="lights.html"><strong>create lights</strong></a> that
are local, near other objects, and you can specify colors for lights.
The following statement creates a yellow light positioned at (x,y,z):</p>
<p class="program">lamp = local_light(pos=(x,y,z), color=color.yellow)</p>
<p class="Normal">If you continually update lamp.p<span class="Normal">os,
the light will move.</span> You
may wish to place a sphere or box with material=materials.emissive at
the same location so that the lamp looks like a glowing lamp.</p>
<p class="Normal">If you want to disable all of the lights, so that the
only light is ambient light (scene.ambient), say <span class="attribute">scene.lights
= []</span>, making
an empty list of lights.</p>
<p class="Normal">A distant red light located in the direction (x,y,z) is created like this:</p>
<p class="program">distant_light(direction=(x,y,z), color=color.red)</p>
<h3 class="style1">Points object</h3>
<p class="Normal">A new <a href="points.html"><strong>points object</strong></a> is similar to a curve, but with disconnected points.
As with curve, the pos attribute is an array of points, and color can
also be an array. If you say <span class="attribute"><strong>shape="round"</strong></span>,
the points are round, which is the default; <span class="attribute"><strong>shape="square"</strong></span> makes
square points. </p>
<h3 class="style1">New frame options</h3>
<p class="Normal">You can now make a frame visible or invisible, and all objects in the frame
will be affected. </p>
<p class="Normal">There are now functions for converting between coordinates
within a frame and "world" coordinates.</p>
<h3 class="style1">New curve append option: retain</h3>
<p class="Normal">If "trail" is a curve, <span class="attribute"><strong>trail.append(pos=(x,y,z), retain = 50)</strong></span> means that only the 50 most recently added points of a curve will be displayed; the earlier ones are deleted. This is a nice option for having a moving object leave a tail behind itself, like a comet. </p>
<h3 class="style1">Fonts in labels</h3>
<p class="Normal">You can now specify a font for a label, including font='sans'
or 'serif' or 'monospace' (fixed-width). Python Unicode text is supported. </p>
<h3 class="style1">Specifying a gray</h3>
<p class="Normal">For convenience you can now say <span class="attribute"><strong>color=color.gray(0.7)</strong></span> to mean color=(0.7,0.7,0.7).</p>
<h3 class="style1">Reading and writing files</h3>
<p class="Normal">The new module <strong>visual.filedialog</strong> provides
a simple <a href="files.html"><strong>file dialog</strong></a> display for choosing files.</p>
<h3 class="style1">Render time </h3>
<p class="Normal">If you say <span class="attribute"><strong>scene.show_rendertime = True</strong></span>, in the lower left of the graphics window you will see the cycle time (time between renderings of the scene) and the render time (time taken to render the scene). This can be a useful diagnostic of performance issues.</p>
<h3 class="Normal"><span class="style1">Design for left-button events if possible </span></h3>
<p class="Normal">Visual 5 provides the basic mouse event functionality that was present in Visual 3 for handling events from right and middle buttons when userspin or userzoom is disabled, out of concern for supporting old programs. However, it has become evident that there are limitations to this approach which could preclude some kinds of mouse handling that people might want to do in the future. For example, you might want to allow userspin with right drags yet also pick up right clicks. For that reason it is conceivable that future developments in this area might break existing programs, and therefore for maximum forward compatibility it is prudent to use only left-button interactions in new programs.</p>
<h3><a name="incompatibilities" id="incompatibilities"></a><span class="style3">Known incompatibilities
in this new version</span></h3>
<p class="Normal">Here are known incompatibilities:</p>
<blockquote>
<p class="Normal">There are some unavoidable incompatibilities due to
the fact that the currently supported numerical array package <strong>numpy</strong> differs
from its predecessor <strong>Numeric</strong>. The only way to handle
some of these incompatibilies is by using the Python "try/except"
structure. For examples, see the example programs gas.py or stars.py.<br />
</p>
<p class="Normal">You can still set <strong>scene.lights</strong> in
the same way as in Visual 3, but you cannot read the information in
scene.lights in the same way as before, because in Visual 5 scene.lights
is a list of <strong>distant_light</strong> (and/or local_light) objects,
not a list of vector directions. If you read and used information in
scene.lights, you may need to use a Python "try/except" structure
to make your program run on both Visual 3 and Visual 5. For example,
suppose an old program wanted to have two lights, one 70% as bright
as the first light in the scene.lights list, and the other a duplicate
except coming from the back, to light both front and back of the scene.
Here is code to do this:</p>
<p class="program">try:<br />
L0 = 0.7*norm(scene.lights[0])<br />
L1 = vector(L0.x, L0.y, -L0.z)<br />
scene.lights = [L0, L1]<br />
except:<br />
L0 = scene.lights[0]<br />
L0.color = 0.7*vector(L0.color)<br />
scene.lights = [L0]<br />
d = L0.direction<br />
L1 = distant_light(direction=(d.x,d.y,-d.z),<br />
color=L0.color)</p>
</blockquote>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td height="16" colspan="4"></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
|