SFML community forums

Help => Graphics => Topic started by: TheGameDev on August 04, 2014, 08:48:43 pm

Title: getPoint() Absolute coordinates
Post by: TheGameDev on August 04, 2014, 08:48:43 pm
Hello,

I'm trying to get the points of a RectangleShape, while he is moving. But it seams that the getPoint() method gives me only the local coordinates of the points.

Do you know how I can get that ?

Thank in advance.
Title: Re: getPoint() Absolute coordinates
Post by: zsbzsb on August 04, 2014, 08:57:25 pm
RectangleShape.getGlobalBounds();
Title: Re: getPoint() Absolute coordinates
Post by: TheGameDev on August 04, 2014, 09:04:46 pm
Hum, can I get more informations please, becasue I dont know how I could get points from getGlobalBounds....
Title: Re: getPoint() Absolute coordinates
Post by: Nexus on August 04, 2014, 09:10:31 pm
The global bounds give you the axis-aligned rectangle which is possibly larger than the shape's drawn rectangle. So zsbzsb's suggestion might not be what you want.

You have to transform each point; have a look at the documentation of the sf::Transform class and sf::RectangleShape::getTransform().
Title: Re: getPoint() Absolute coordinates
Post by: TheGameDev on August 04, 2014, 09:15:28 pm
Okay thank you, what I've done (for pepole who want to know):

rect.getTransform().transformPoint(rect.getPoint(0));

See ya :)

Title: Re: getPoint() Absolute coordinates
Post by: Nexus on August 04, 2014, 09:27:23 pm
By the way, please post in the "Help" section next time, not in "General Discussions" ;)
Title: Re: getPoint() Absolute coordinates
Post by: zsbzsb on August 05, 2014, 03:51:11 pm
Quote
So zsbzsb's suggestion might not be what you want.

Reading the original question made it seem as if the OP wanted to just get the bounds of the shape, not the actual points.   :P
Title: Re: getPoint() Absolute coordinates
Post by: Laurent on August 05, 2014, 07:43:10 pm
Quote
Reading the original question made it seem as if the OP wanted to just get the bounds of the shape, not the actual points.

Really? :P

Quote
I'm trying to get the points of a RectangleShape, while he is moving. But it seams that the getPoint() method gives me only the local coordinates of the points.