Going for a fast-prototype Lisp based language

Started by
29 comments, last by HairyTroll 18 years, 3 months ago
OK. I've come up with an XML-like mechanism for defining the world & the objects it contains. So instead of having a static file like the example below that needs to be read by an XML parser and then interpreted and executed by the application; in the tradition of Lisp I have extended the language to understand the XML-type definition. So the code below is valid Lisp code that can be debugged, looped, compiled, etc.

Here the the XML I started with.
<world scenegraph_rootnode="root-node">  <actor>    <cube>      </color red="random 1.0" green="random 1.0" blue="random 1.0">      </dimensions width=1.0 height=1.0 depth=1.0>    </cube>    <script>      </rotate x=1.0 y=1.0 z=0.0>    </script>  </actor></world>


And this is how it looks in Lisp.

(world (root-node)  (actor    (cube      (color (random 1.0) (random 1.0) (random 1.0))      (dimensions 1.0 1.0 1.0)      (position 1.0 1.0 1.0))    (script (new-rotate :dx 1.0 :dy 1.0 :dz 1.0))))	


With the following example I create a 10x10 grid of randomly colored cubes and rotate each around its x+y+z axis's by 1.0 degree a frame, above a flat plane.

(world (root-node)  (loop for i from 0 to 10      do (loop for j from 0 to 10           do (actor                (cube                  (color (random 1.0) (random 1.0) (random 1.0) 1.0)                  (dimensions 1.0 1.0 1.0)                  (position (* i 2.0) (* j 2.0) 0.0))                (script (new-rotate :dx 1.0 :dy 1.0 :dz 1.0)))))  (plane    (position 0.0 0.0 0.0)    (orientation :xz)))

This topic is closed to new replies.

Advertisement