%!PS-Adobe-2.0 %%BoundingBox: 0 0 372 180 /w 372 def /h 180 def (ps3d.inc) run (cube.inc) run (epsetup.inc) run 1 setlinejoin % ------------------------------------------------ [0 0 5 1] set-eye /floor [0 1 0 3] def /A 40 def /dA 10 def /t 0 def /dt 0.1 def 0 0.5 0 translate3d 0.5 dup dup scale3d { page-begin gsave 0.8 0.8 0.8 setrgbcolor newpath -2 1 2 { /i exch def i -3 -3 moveto3d i -3 1 lineto3d } for -3 1 1 { /i exch def -2 -3 i moveto3d 2 -3 i lineto3d } for stroke grestore gsave3d % the shadow gsave 0.6 0.6 0.6 setrgbcolor floor light-source plane-project /shift 0 t dup mul sub def 0 0 shift translate3d [1 1 1] A rotate3d -0.5 -0.5 -0.5 translate3d cube { % [ n [P[0] P[1] ... P[n-1]]] 0 get /f exch def /ell f length def newpath f ell 1 sub get aload pop moveto3d f { aload pop lineto3d } forall fill } forall grestore grestore3d gsave3d 0 0 shift translate3d [1 1 1] A rotate3d -0.5 -0.5 -0.5 translate3d /E get-virtual-eye def /L get-virtual-light def cube { % [ n [P[0] P[1] ... P[n-1]]] dup 1 get /n exch def 0 get /f exch def % n = normal function /ell f length def n E dot-product 0 ge { newpath f ell 1 sub get aload pop moveto3d f { aload pop lineto3d } forall gsave n normalized L dot-product [0.3 0.3 0.8 1 ] shade 0 0 setrgbcolor fill grestore stroke } if } forall grestore3d grestore showpage /A A dA add def /t t dt add def } loop