Hi Ed

I looked rapidly to your code, there are lot of interesting things.

1. locals

:: do-camera-look-at ( CAMERA -- )
   [let | EYE   [ CAMERA pos>> ]
          FOCUS [ CAMERA clone 1 step-turtle pos>> ]
UP [ CAMERA clone 90 pitch-up 1 step-turtle pos>> CAMERA pos>> v- ]
        |
     EYE FOCUS UP gl-look-at ] ;

can be compared to old "camera" vocab

: camera-eye ( -- point ) turtle-pos> ;
: camera-focus ( -- point ) [ 1 step-turtle turtle-pos> ] save-self ;
: camera-up ( -- dirvec )
[ 90 pitch-up turtle-pos> 1 step-turtle turtle-pos> swap v- ] save- self ;
: do-look-at ( camera -- )
[ >self camera-eye camera-focus camera-up gl-look-at ] with-scope ;


I must admit that "self" vocab is very un-intuitive, in that case [let seems to be a good choice.
I will have to look closer at it (Even if you use uppercase format ;-)

Nevertheless in "generate-display-list" I think that a cleave would have been easier to read.



2. Rx, Ry Rz

Your solution is nice but very long. I would prefer to see "deep- cleave-quots" word back. It was the nicest solution I saw.

I don't know what are performance of locals but is it possible to mix :: with MEMO: ?



3. color-table

There is an implicit link between color position in color-table and the code of models, not nice, maybe a hash-table would be better.
But as you just cycle colors it's not very important.

"colors" vocab has a limited number of colors, that's probably why you didn't use them and redefined your own colors. It would probably be useful to add a few colors to "colors" (or in an other vocab), emacs colors for example.



4. other points

You included everything in one file. Will you separate your work into distinct reusable vocabs ?
        - turtle
        - camera
I hope so !



In your code there are some "magical" values that appear

in : L-parser-dialect { "'" [ 0.9 scale-length    ] }
M:: <L-system> pref-dim* ( L-SYSTEM -- dim ) { 400 400 } ;
{ T{ key-down f f "LEFT"  } [ [  5 turn-left   ] with-camera ] }

Why 0.9 and not 0.854 ?
What will append when you want a bigger window or have a quicker turn- button ?

I wrote "loadable-values" to gather all those values at the beginning of the file and to be able to modify them with a simple config file.




Thanks for that code, I will have to look back to 4DNav that I left for the moment.

Jeff



Le 26 janv. 09 à 18:41, Eduardo Cavazos a écrit :


Hello,

Over the years, I've written a bunch of programs in Factor. As the
language evolves, it's interesting to revisit old code and update it for new idioms. One of the earliest programs I wrote in Factor was a program
to generate and display L-systems. I recently rewrote it and
incorporated alot of the idioms I've picked up over the years.

You're welcome to try it out. These are the "runnable" vocabularies:

     "L-system.models.abop-1"
     "L-system.models.abop-2"
     "L-system.models.abop-3"
     "L-system.models.abop-4"
     "L-system.models.abop-5"
     "L-system.models.abop-5-angular"
     "L-system.models.abop-6"
     "L-system.models.airhorse"
     "L-system.models.tree-5"

So, from a listener you can do:

     "L-system.models.abop-1" run

Or, from a shell:

     $ ./factor -run=L-system.models.abop-1

Press 'x' to iterate the model by one step.

Press F1 in the window for more help.

Ed

PS to Jeff: I know that parts of 4DNav were based on the old 'lsys'.
Feel free to mine the new 'L-system' for code and ideas that might be
useful in 4DNav.

---------------------------------------------------------------------- --------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to