L-System openFrameworks addons

#1

Hey! I’ve just published two new addons to generate L-Systems using openFrameworks.
The First one is ofxLSystemGrammar, an addon that generates sequences of strings starting from an axiom, the second one is called https://github.com/edap/ofxLSystem and it is a 3D turtle graphic interpretation of LSystem. Both addons come with examples included.

ofxLSystemGrammar it just rewrites string following the the L-Systems grammars described in the book “The Algorithmic Beauty of Plants”, it does not include a graphic turtle program.

ofxLSystem is, instead, a 3D graphic turtle interpretation of L-Systems, and it uses internally the previous addon. It inherits from of3DPrimitive, that means you can generate trees and use them like a ofBoxPrimitive, move them around, rotate them ecc… This last addon may change the interface in the next days.

7 Likes
#2

Here some code that produces beautiful plants. I believe they are the nicest without using shaders or lights.
#pragma once
#include “ofMain.h”

class Renderer
{
public:
void setup();
void draw();

int angleDepart = 0;
const int kWindow_height = 1000;
const int kWindow_width = 1200;
void splitLine(int iX, int iY, int iThickness, float angle);
};

#include “renderer.h”

void Renderer::setup()
{
ofSetFrameRate(3);
ofSetWindowShape(kWindow_width, kWindow_height);
}

void Renderer::draw()
{
ofFill();
ofSetLineWidth(10);
ofClear(0);
ofScale(1.0f, -1.0f);
ofTranslate(kWindow_width / 2, -kWindow_height + 75);
ofLine(0,0,0, 300);
angleDepart -= 1;
splitLine(0, 300, 20, angleDepart); // faire varier le 20, en 10 et 20, c’est le plus intéressant
}

void Renderer::splitLine(int iX, int iY, int iThickness, float iAngle)
{
if (iThickness - 1 > 0)
{
ofPushMatrix();
ofTranslate(iX, iY);
ofRotateZ(iAngle);
ofSetLineWidth(iThickness - 1);
ofLine(0, 0, iX * 0.75, iY * 0.75);
splitLine(iX * 0.75, iY * 0.75, iThickness - 1, iAngle);
ofPopMatrix();

ofPushMatrix();
ofLine(0, 0, iX * 0.75, iY * 0.75);
ofSetColor(65, ofRandom(255), 0);
splitLine(iX * 0.75, iY * 0.75, iThickness - 2, -iAngle);
ofPopMatrix();

}
}

#include “ofMain.h”
#include “application.h”

int main( )
{
ofSetupOpenGL(512, 512, OF_WINDOW);
ofRunApp(new Application());
}