New in Wolfram
Mathematica
8: Enhanced 2D and 3D Graphics
◄
previous
|
next
►
Graphics & Visualization
Dynamic Textures on Graphics Primitives
Any expression, including a dynamic object, can be used as a texture.
In[1]:=
X
vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}}; DynamicModule[{}, Graphics3D[{Dynamic[Texture[clock], UpdateInterval -> 1], Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, Lighting -> "Neutral", Boxed -> False], Initialization :> (clock := Module[{hour, min, sec, ht, mt, st}, {hour, min, sec} = Take[DateList[], -3]; ht = \[Pi]/2 - (hour \[Pi])/6 - (min \[Pi])/360; mt = \[Pi]/2 - (min \[Pi])/30; st = \[Pi]/2 - \[Pi]/30 Floor[sec]; Graphics[{AbsoluteThickness[5], Arrowheads[Large], Arrow[{{0, 0}, 0.6 {Cos[ht], Sin[ht]}}], Arrow[{{0, 0}, 0.9 {Cos[mt], Sin[mt]}}], PointSize[Large], Table[Point[0.9 {Cos[i], Sin[i]}], {i, 0, 2 \[Pi], \[Pi]/6}], Point[{0, 0}], Circle[], Red, Line[{{0, 0}, 0.85 {Cos[st], Sin[st]}}]}, ImageSize -> 500]])]
Play Animation
»
Stop Animation
»