From: divisor on
Hello mathGroup:

While debugging some issue I had in my code concerning the Lighting
specification, I corrected the follwing example in the Help for this
option. It is an interesting example and since there were multiple
syntax errors, I am posting it here for interested parties:

In[1]:= $Version

Out[1]= "7.0 for Microsoft Windows (64-bit) (February 18, 2009)"

(* Build a scene with multiple objects and light sources: *)

col = {Red, Green, Blue};
objs = Graphics3D[{Specularity[White, 2], EdgeForm[],
Cylinder[{{2, 2, 0}, {2, 2, 4}}], Cylinder[{{6, 2, 0}, {6, 2,
4}}],
Cylinder[{{10, 2, 0}, {10, 2, 4}}]}];
walls = ParametricPlot3D[{{u, v - 2, 0}, {u, 4, 2 v}}, {u, -2, 14},
{v, 0, 6},
PlotPoints -> 15, MaxRecursion -> 0, PlotStyle ->
Specularity[White, 2],
Mesh -> None, Axes -> False];
srcs[pos_] :=
Graphics3D[
MapThread[{Lighting -> {{"Directional", #1, {{0, -1, 0}, {0, 0,
0}}}},
Sphere[{#2, 0, 8}, .3]} &, {col, pos}]];
lights[pos_] :=
Join[{{"Ambient", GrayLevel[.1]}},
Flatten[MapThread[{{"Spot", #1, {{#2, 0, 8}, {#2, 3, 0}}, {Pi/2,
20}}, {"Point", #1, {#2, 0, 8}, {0, 8, 0}}} &, {col, pos}],
1]];

(* Animate the spotlights: *)

Animate[With[{rx = -6 Cos[t] + 6, gx = 6 Sin[t] + 6, bx = 6 Cos[t] +
6},
Show[objs, walls, srcs[{rx, gx, bx}]
, Lighting -> lights[{rx, gx, bx}]
, Background -> Black, Boxed -> False, ImageSize -> 300]], {t, 0, 2
Pi},
SaveDefinitions -> True, AnimationRunning -> False]

HTH.

Roger Williams
Franklin Laboratory
http://www.youtube.com/congruentlight

 | 
Pages: 1
Prev: find index in an array
Next: union table