LSystems


#1

Just thought I’d post some images I made today. The objects were generated by an LSystem lscript I’m working on. I hope to make more progress with the script over Christmas break, and one way or another, I’ll eventually release it.

-click images for larger versions -


Enjoy.


#2

Another one, and the script that made it:


Make sure you are in “Polygon” select mode, not “Point”…or you’ll lock up Modeler in a near-infinite loop.


#3

Coool beans dude!


#4

would it be that hard to code in to the script to tell it to switch to poly mode first? then would save crashs when people make that mistake


#5

Nice work, Zuzzabuzz! And, thank you! I have been a BIG fan of L-systems for a long time and have wanted to be able to work with them in LW. Do you know what you plan to support with your scripts? Branching? Texture changing? Polychains? There was an L-System program I used to use by a guy named Laurens Lapre, I think it was called Lparser. It had a really good L-system language and if you can find information about it you might find some useful ideas.

Do you need help? Someone to help with testing?

Your images look great and I can’t wait to play with the script you have posted!

Link to Laurens stuff (I just looked it up)… hope you find it interesting.

http://home.wanadoo.nl/laurens.lapre/


#6

KillMe: It might not be hard. I don’t know yet. I’m learning LScript as I go along, so if there is a way, I don’t know how to do it yet. I’m planning on changing it to work with existing geometry, so if you want a six-sided shape instead of a four, you could just start with that.

SirReality: I’m also a big fan of LSystems. It’s been a while since I’ve been at Laurens’ site. I’d forgotten about it. I used to use LParser but then I found a program named LSystem @ a domain named thinkpiece.com (no longer exists). It provided a built in viewer, was windows based, so I had better luck with it.

My experience with wrangling vectors and working with 3D trigonometry is minimal. So, I’m having troubles with rotation (among other things!)
I plan to have a GUI with:
iteration limit, default angle, default segment length, new surface with each iteration?, limit to X number polys (bail out), limit to X number of seconds (another bail out), rule entry (of course). Once I get that stuff figured, I want to add ‘gravity’ options, and the ability to randomize variables slightly, etc.

You can certainly be an alpha tester. I’ll update this thread as I make progress, and you can try the stuff out. Thanks for your interest. Nice to find another LSystem fan. I’ve always wanted a good LSystem solution for Lightwave (avoiding the DXF bridge). Hopefully this script will suffice.


#7

you rock man, I am another Lsystem fan. Just a fan of fractals and mathematically generated paterns (that was redundent), in general. I am eager to try this out when I get home.


#8

Instead of making my own base polygon, I now use whatever polygon the user selects.
Currently only works on quads, and only one at a time. But, it’s kind of fun to play with.

Here’s the script and here’s a little something I made with it:


#9

I actually ported Laurens implementation to a LW plugin over a year ago. I have the full code still if anyone wants to take a crack at working on it. Had other things push it way to the back burner.

If a coder wants the source and a spring board (me), I am all for it.

EDIT:

Sorry for the thread jack in advance.

uploaded the code anywho :slight_smile:

http://www.giftingguide.com/lparser.rar

Here is a pic of original Laurens L-Systems done with the code I wrote:

Someone would just need to tweak some of the interface stuff to get it out the door. That and documentation, which I did start, there is a PDF in the rar file. It is about 50% complete, but obviously one wouldn’t have to write up the history and use of Lsystems as I started to do.

There are some differences with my symbols. I made them slightly (I Hope) easier to remember and expand, as well as included some functionality Laurens originally did not have (He used the original Lindenmeyer constructs to generate forms).

I actually have some time now, but do have other projects cooking for the non LW world, but if someone wanted to run with this I can surely lend a hand, if not two :slight_smile:


#10

My thread! My precious thread! :slight_smile:
I think any LSystem info pertaining to lightwave would be great to have in this thread. My C++ is not too strong though, and I’ll probably keep plugging away on the lscript for now. The code for RotateAroundVector will probably help me a lot.

I searched Flay for LSystem plugins, but found none. Maybe “we” can get LSizzl (great name!) going as well. Thanks for the code and such.

more later.


#11

Too bad your L-System is unfinished, amorano. Could you compile a version for download? I do have an intern here who knows C and C++, but he has no idea about the LW SDK so he’s a bit stumped. I just would love to have this great tool back. Back then I created a lot of custom files for it and it was just fun. In contrast to you, buzz, I also thing the DOS version was much more usable - just a simple set of batch files and doskey and off it went. The win implementation was quite crap - slow, unstable and not half as interactive.

Mylenium


#12

Probably so, but I preferred the more instantaneous feedback to understand how the rules were going to work. When I’m on windows machines, I still enjoy using HF-Lab to make heightfields, for the same reason as you like the DOS version. :slight_smile:


#13

I sure can :slight_smile:

Sometime next week I will get around to compiling it all back up into a .p plugin.

I actually have some time comming up (holidays) so I may just polish it off myself. Not much more to be done in there really. I wanted to add support for more than the base shape I currently use to draw the actual lengths (currently its a box), and fix a few of the commands, and tighten up the parse code so it can build the strings a lot faster.

That is just some of the work. So, yeah, I’ll make a build of what is currently there (thought I had one in the rar file) and possibly work on fixing a few things.

O, and tell yer coder over there no worries. The SDK is not the friendliest thing to any coder I have run across yet. It takes a little time to work through its, cough, interesting ways of doing things.

One thing I am dying for is for the SDK to be able to talk with C# a little better. Think of zero turn around time for developing Mac, PC and Linux plugins.


#14

This is too cool.

Zuzz, your idea for bailouts (time, polygon) are great! I once wrote an L-system type parser that targeted POV-ray and it would take FOREVER starting around five iterations. Any thoughts on the ever-popular rule mutation…?

Zuzz and Amorano, thanks for sharing the scripts and code. With the holidays here I too might have a little bit of time and will enjoy looking through them even if I can’t add anything useful… and if I am able to do anything useful I will post it back to this thread. I think I am more comfortable playing with scripts right now (been too long since I last fired up my compiler and I am not familiar with LW’s SDK at all), but you never know.

Thanks again, this is a cool topic, and a powerful LSystem tool (especially one freely available to the community) will make a huge difference to anyone who uses it for their work.


#15

Things are coming along ok. I have code to rotate about an arbitrary axis using quaternions, but I still need to keep track of my left/up axes, and when chosing a polygon, there can be some ambiguity as to what the best “left” and “up” might be. It’s all been a bit of a struggle since I’ve not really dealt with this math before, but I’ve found a nice site:

http://skal.planet-d.net/demo/matrixfaq.htm

and I’m using a book which gives a fast introduction to 3d mathematics for programming. I couldn’t quite figure out what the RotateAroundAnAxis function in Amorano’s code was doing, so I’m probably reinventing the wheel. :shrug:

I may step back and not allow operation on user selected polys, and instead generate my own base poly. This will give me a know orientation to work with. Once the rotation stuff is reliable, I’ll work on the rule parser. After that, perhaps mutation (definitely want some angle/length randomization options). I’ll post the script before my christmas break so people can use it as a jumping off point, but hopefully by the end of my christmas break, there will be a more useful script to play with. :slight_smile:


#16

Zuzz,

I’ve written a rule parser before and judging by your code comments you are not looking forward to this… I think this may be the first thing that I look at. If I can get the parser taken care of it would free you from needing to worry about it. I’m prone to thinking in terms of an LParser-styled language (common symbols used in it were +, -, l, [, ], etc). Any objections?


#17

I hope to just copy the commands used in Timothy Perz’s LSystem program.
If you have ideas that contradict this, I’m open to them.
I also plan to offer arguments such as +(90) = turn left 90 degrees, F(2) = forward two units, etc etc.

The parser may not be a bad thing to write, but I imagine it’s harder than I expect, hence the “ugh” :slight_smile:

Any assistance would be much appreciated!

COMMANDS
Drawing:
F Draw full unit
Z Draw half unit
Movement: (not planned for first version)
f Move full unit
z Move half unit
Orientation:

  • Turn left
  • Turn right
    & Pitch down
    ^ Pitch up
    < Roll left
    > Roll right
    Special Orientation: (not planned for first version)
    | Turn 180 deg
    % Roll 180 deg
    $ Roll until Horizontal
    ~ Turn/Pitch/Roll
    t Pitch down
    Structure:
    [ Store current location
    ] Return to location
    { Start polygon shape (Not planned)
    } End polygon shape
    Increment / Decrement:
    " Inc. length by 1.1
    ’ Dec. length by 0.9
    ; Inc. angle by 1.1
    : Dec. angle by 0.9
    ? Inc. thickness by 1.4
    ! Dec. thickness by 0.7

Additional: (planned for second version, increment surface…not color)
c Increment color index
c(x) Set color index to x


#18

Zuzz,

I’ve had a little time and done some crunching on your script (left your information in it and noted some of the stuff I tossed into it). I changed a lot of the function called “bi” so that it interprets commands. Still need to write code to let it read a file, but otherwise it is pretty well featured already (you stuck in some great functionality). I added support for multiple polygons selected when the script is run and some stuff to smooth out bends. Below is a sample of an object I created with it. I have NOT done any work on error checking (most notably a branch that isn’t closed is probably bad. Very BAD).

and the scripts (I hope my links work). EDIT: There are two scripts in the zip file. One is lsysclear. It will clear the object in modeler, create a small polygon, and select it. This was a handy script while I was working on this. The other script is lsys. It will follow the instructions defined in the lcode variable. Edit this variable before running the script to change the results. In the future this information will be loaded from a file. Select one or more polygons (quads) and run the script.


#19

Where does the LW SDK live these days? I looked around the Newtek site but couldn’t find a download for it.

I think that writing at least some of the l-system plug-in using C would be easier than lscript. Also, the plug-in should run much quicker when iterating. Still using lscript to read the final code an manipulate polygons in modeler should be okay (although making that faster wouldn’t be bad, either).

Also I am considering changing the script so that when it is run it will make a copy of the source polygon(s), move the copied poly to 0,0,0 with no rotation, running the l-system code on it, then moving it back to the position and rotation of the source poly. This would fix wierd things that happen when you run the script with a “side” facing poly (x axis?) versus an “up” (y axis) or “Front” (z axis) facing poly. Also symmetrical workflow is probably faster right now if you select a left-facing poly (or up, or back), run the l-system script, then mirror the results, instead of selecting the two polys and just letting the script chug through both of them.

There are other things that I think need attention as well (you might notice the image I posted doesn’t have nice smooth curves, I plan to try other implementations which would lead to smoother curves withough tearing-up the mesh during branching).


#20

The scripts you were working with were not as up to date as the versions I have. I’m currently integrating your parsing code into the new scripts, and adding a HELP tab to the GUI. You can get smoother curves by increasing the iterations, reducing the angle, and modifying the lsystem rules, so maybe that’s not such a big deal. When I’ve finished the code, I’ll post it here. If it’s not ready for primetime, but still usable, I’ll email it to you.

I’m working on the rotation routines so that there won’t be a need to move and rotate the poly and operate on it. There’d still be rotation anomalies with that approach anyway with the code in it’s current state.

Symettrical workflow assumes identical polygons. That may not always be the case.

It’d definetely run faster…and could handle Undo’s better…as a C compiled plugin. I’m not going to think about it until things are figured out in the LSCript version though. :slight_smile:
Thanks for the parser work. It’s much appreciated. I’ll get in touch with you via email with the updates.