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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Lekter

Pages: [1]
1
Graphics / Re: Сoordinates of all vertices
« on: December 10, 2014, 10:20:12 pm »
getPoint returned local coordinates, I need global.

2
Graphics / Сoordinates of all vertices
« on: December 10, 2014, 09:56:59 pm »
Hi, I have RectangleShape, how to get the global coordinates of all vertices(top-left,top-right,bottom-left,bottom-right) after rotate?
For example
  shape.setOrigin(size_a/2.f, size_b/2.f);
  shape.setPosition(windowWidth / 2, windowHeight / 2);
  shape.setSize({ size_a, size_b });
  shape.setRotation(10);
 
How to get coordinates of the all vertices?
Thanks.

3
Graphics / Re: Rotate the shapes relative to center
« on: October 21, 2014, 12:02:52 pm »
Thank You so much, in my first post all right, i was wrong.

4
Graphics / Re: Rotate the shapes relative to center
« on: October 21, 2014, 10:46:29 am »
Here is my full code:

const int windowWidth = 500;
const int windowHeight = 400;

class Box
{
public:
        RectangleShape shape;

        Box(float size_a, float size_b)
        {
                shape.setFillColor(Color::Blue);
                shape.setPosition(100, 100);
                shape.setSize({ size_a, size_b });
                shape.setOutlineThickness(2);
                shape.setOutlineColor(Color::Black);
        }

};

int main()
{
        Box box(200,150);

        RenderWindow window(VideoMode(windowWidth, windowHeight), "Box");
        window.setFramerateLimit(60);

        while (window.isOpen())
        {
                Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == Event::Closed)
                                window.close();
                }

                window.clear(Color::White);
                window.draw(box.shape);
                window.display();

        }
        return 0;
}
 
Get the following:


If I change constructor:
Box(float size_a, float size_b)
        {
                shape.setOrigin(100, 100);
                shape.setFillColor(Color::Blue);
                shape.setPosition(150, 150);
                shape.setSize({ size_a, size_b });
                shape.setOutlineThickness(2);
                shape.setOutlineColor(Color::Black);
               
                shape.setRotation(20);
        }
 
Produce this:

Top-left corner moving coordinates (x-100,y-100), and rotate relative to top-left corner.

5
Graphics / Rotate the shapes relative to center
« on: October 20, 2014, 11:06:21 pm »
Hi, I have RectangleShape, how to rotate it relative to center.
I have tried the following:
shape.setOrigin(size_a/2, size_b/2); //size_a, size_b - size of shape
shape.setPosition(100, 100);
shape.setSize({ size_a, size_b });
shape.setRotation(20);
 
However, rotate relative top-left corner. Am I doing something wrong?

Pages: [1]