%!PS-Adobe-2.0 %%BoundingBox: 42 68 530 515 % basic library: (ps3d.inc) run % data for a cube: (cube.inc) run 1 setlinejoin % ------------------------------------------------ /page-setup { 72 dup scale 1 72 div setlinewidth 4 5 translate } def [0 0 3 1] set-display /light [-0.25 1 0.2 0] def /floor [0 1 0 3] def /A 40 def /dA 10 def /t 0 def /dt 0.1 def 0 0.5 0 translate3d { page-setup 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 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]]] 1 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 /O origin cim3d transform3d def % O = origin in current coordinates /L light cim3d transform3d normalized def % L = light in current coordinates cube { % [ n [P[0] P[1] ... P[n-1]]] dup 0 get /n exch def 1 get /f exch def % n = normal function /ell f length def n O 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.4 0.6 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