From 589e509469072e6a05068022ebf81bd0bb450b99 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 7 Jan 2009 16:24:56 -0600 Subject: [PATCH] L-system: Add rotating pedestal --- extra/L-system/L-system.factor | 51 +++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/extra/L-system/L-system.factor b/extra/L-system/L-system.factor index a38581b0f9..43e6cbbfa6 100644 --- a/extra/L-system/L-system.factor +++ b/extra/L-system/L-system.factor @@ -1,9 +1,9 @@ -USING: accessors arrays assocs colors combinators.short-circuit -kernel locals math math.functions math.matrices math.order -math.parser math.trig math.vectors opengl opengl.demo-support -opengl.gl sbufs sequences strings ui.gadgets ui.gadgets.worlds -ui.gestures ui.render ; +USING: accessors arrays assocs calendar colors +combinators.short-circuit kernel locals math math.functions +math.matrices math.order math.parser math.trig math.vectors +opengl opengl.demo-support opengl.gl sbufs sequences strings +threads ui.gadgets ui.gadgets.worlds ui.gestures ui.render ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -254,7 +254,27 @@ DEFER: default-L-parser-values ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -TUPLE: < gadget camera display-list commands axiom rules string ; +TUPLE: < gadget + camera display-list pedestal paused commands axiom rules string ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: iterate-system ( GADGET -- ) GADGET pedestal>> 0.5 + GADGET (>>pedestal) ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: start-rotation-thread ( GADGET -- ) + GADGET f >>paused drop + [ + [ + GADGET paused>> + [ f ] + [ GADGET iterate-system GADGET relayout-1 25 milliseconds sleep t ] + if + ] + loop + ] + in-thread ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -385,6 +405,10 @@ M:: draw-gadget* ( L-SYSTEM -- ) ! draw axis white gl-color GL_LINES glBegin { 0 0 0 } gl-vertex { 0 0 1 } gl-vertex glEnd + ! rotate pedestal + + L-SYSTEM pedestal>> 0 0 1 glRotated + L-SYSTEM display-list>> glCallList ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -417,6 +441,11 @@ H{ { T{ key-down f f "a" } [ [ 1 step-turtle ] with-camera ] } { T{ key-down f f "z" } [ [ -1 step-turtle ] with-camera ] } + { T{ key-down f f "q" } [ [ 5 roll-left ] with-camera ] } + { T{ key-down f f "w" } [ [ 5 roll-right ] with-camera ] } + + { T{ key-down f f "r" } [ start-rotation-thread ] } + { T{ key-down f f "x" } [ @@ -435,8 +464,16 @@ set-gestures : L-system ( -- L-system ) new-gadget + + 0 >>pedestal - turtle 45 turn-left 45 pitch-up 5 step-turtle 180 turn-left >>camera ; + ! turtle 45 turn-left 45 pitch-up 5 step-turtle 180 turn-left >>camera ; + + turtle 90 pitch-down -5 step-turtle 2 strafe-up >>camera + + dup start-rotation-thread + + ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -- 2.34.1