Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: L-System drawer  (Read 1645 times)

0 Members and 1 Guest are viewing this topic.

MenosGrandes

  • Newbie
  • *
  • Posts: 7
    • View Profile
L-System drawer
« on: July 07, 2015, 07:13:33 pm »
Hallo I have problem with drawing a L-System.
I have created a class that implementing base L-System, but I don't know how to draw it.
I have tried using sf::VertexArray with sf::LineStrip and sf::RectangleShape. In VertexArray I don't know how to rotate next line.

Any sugesstions?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: L-System drawer
« Reply #1 on: July 07, 2015, 07:55:09 pm »
How far did you actually "try"? I mean if you use vertices you obviously have to calculate the proper rotation yourself (maybe with use of an sf::Transform?). And what was the issue with rectangle shapes?

Since we don't know your system, all we can tell you is to draw something somehow. Maybe if you provide more information someone might be able to help further. Also don't assume that everybody just knows what an L-System is. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MenosGrandes

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: L-System drawer
« Reply #2 on: July 07, 2015, 10:03:52 pm »
I have something like this:

float currentRotation=0;
float rotate=90;

sf::Vector2f currentPosition(0,0);

        m_vertices.setPrimitiveType(sf::LinesStrip);
        m_vertices.resize(initializer.length());
       // sf::Vertex* quad2 = &m_vertices[0];
        //m_vertices[0].position = currentPosition;

for(int i=0;i<initializer.length();i++)
{


    char sign=initializer[i];
    switch(sign)
    {
        case '+' :
            //std::cout<<" + ";
/* Rotate left*/
currentRotation+=rotate;

            break;
        case '-' :
            /* Rotate right*/
           // std::cout<<" - ";
currentRotation-=rotate;
            break;
        case 'F' :
           // std::cout<<" F ";
currentPosition.x+=1;
currentPosition.y+=1;
m_vertices[i].position = sf::Vector2f((currentPosition.x), (currentPosition.y));
//std::cout<<quad[i].position.x<<" "<<quad[i].position.y<<"\n";
            break;

    }

}
 

and I dont know how to calulate the rotation..

kitteh-warrior

  • Guest
Re: L-System drawer
« Reply #3 on: July 07, 2015, 11:18:23 pm »
and I dont know how to calulate the rotation..

*cough* This may help you.

MenosGrandes

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: L-System drawer
« Reply #4 on: July 08, 2015, 06:01:36 pm »
I'm so dumb... thank you;)