سؤال

I have a simple 3D L-System made from cylinders, and I currently just go through each symbol in the final string and do appropriate actions like draw, turn, rotate, push and pop. I am aware that push and pop pretty much resembles a new branch, but I tried changing the radius whenever push is called, but it leads to strange results.

Does anyone have the correct way of making newer branches becoming thinner than the previous branches?

Thanks.

    else if((*it) == Push)
    {
       Radius -= 0.1f;
       PushMatrix();
    }
    else if((*it) == Pop)
    {
       Radius += 0.1f;
       PopMatrix();
    }
هل كانت مفيدة؟

المحلول

You also need to reset the position of the turtle back to the point of the branch.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top