@arturo Do you mean something like this?
for (int i = 0; i < _instruction.length(); i++) {
char c = _instruction[i];
if (c == 'F') {
branching = true;
}else if (c == '+') {
auto jointBranch = Branch();
jointBranch.setParent(branch);
jointBranch.roll(45);
auto branch = Branch();
branch.setParent(jointBranch);
}
if(branching){
if(mesh.getNumVertices() == 0){
//add the first branch to the root
branch.move(ofVec3f(0, -100, 0));
mesh.addVertex(branch.getGlobalPosition());
mesh.addColor(ofFloatColor(1.0, 1.0, 0.0));
branching = false;
}else{
//add a new branch
auto oldBranch = Branch(branch);
auto branch = Branch();
branch.setParent(oldBranch);
branch.move(ofVec3f(0, -100,0));
mesh.addVertex(branch.getGlobalPosition());
mesh.addColor(ofFloatColor(1.0, 1.0, 0.0));
branching = false;
};
}
This is also not working, i think the problem is re-assigning a ofNode. This is the output of this code:
Image may be NSFW.
Clik here to view.