|
Context Free Design Grammars for POV-Ray
ContextFree is a kickass free program for rendering fractal-like
images from context free design grammars. I've been playing wiht it a lot recently and wanted to do something
simmilar in 3d using POV-Ray. This is the first beta version of a script to do that. The language is not fully
supported yet and there is some new stuff I'd like to add. Bug reports, comments, and images to
my gmail address, I'd love to see what you make with this thing :-)
[Download source code]
rules go here:
instructions
This program is meant as a 3d approximation of the excellent
Context Free renderer, so you'll need to
learn to use that first. The syntax for myCFDG3d is mostly the same, except that r (rotate) becomes rx and ry
to rotate on the x and y axes, and objects can now also be transformed on the z axis. CIRCLE becomes SPHERE,
SQUARE becomes CUBE and I've added a new shape, CYLINDER. No TRIANGLE as yet, flip and looping not yet supported.
TODO
- Check the math for object-space rotation, I think there may be a bug there.
- Support more shapes, and user-defined shapes.
- Support HSL color, alpha blending, as with Context Free.
- Think about implementing transparency, refection, textures and other POV-Ray stuff.
- If there is interest, add a user gallery, as at chriscoyne.com
Ideas
Add rand(min - max) as an option for variables, as in:
somerule {y 1, z rand(3, 10), rx rand(20, 50) }
Terminating cases - allow rule definitions reference another rule to switch to once object space reaches a
certain size, eg:
rule STALK 100 terminate 0.3 FLOWER { CIRCLE {} STALK {y 1, rx 1, size 0.97 } }
In this case STALK behaves normally until object space becomes 0.3 the size of world space, then FLOWER is
called in its place. Not quite context free.
Limitations
This copy of the program only runs to four thousand iterations. I know that's not lot. Generating million line
text documents, several at a time, would affect the other sites running off this server. Ideally the server
would also render the POV-Ray script to an image, for this heavily loaded box it's too expensive in memory and
CPU time. If you can host a mirror with higher spec, please let me know an I'll link you from the front page. Thanks :-)
|
|
|
Example
startshape tree
rule tree {
branch { ry 30, rx 30 }
branch { ry -30, rx -30 }
branch { ry -30, rx 30 }
branch { ry 30, rx -30 }
}
rule branch 10 {
CIRCLE {}
branch { y 1, ry -5, size 0.95 }
}
rule branch 10 {
CIRCLE {}
branch { y 1, ry 5, size 0.95 }
}
rule branch {
CIRCLE {}
branch { rx 20, size 0.95 }
branch { rx -20, size 0.95 }
}
rule branch {
CIRCLE {}
branch { ry 20, size 0.95 }
branch { ry -20, size 0.95 }
}
|