SFML community forums

Help => Graphics => Topic started by: sheadovas on May 27, 2014, 04:01:07 pm

Title: [SOLVED]ConvexShape - getting current position of the point
Post by: sheadovas on May 27, 2014, 04:01:07 pm
I have a convex shape:
ConvexShape shape(3);
shape.setPoint(0,Vector2f(5,20));
shape.setPoint(1,Vector2f(5,30));
shape.setPoint(2,Vector2f(9,12));

I need the current position of points after moving, rotating, etc. Unfortunately
virtual Vector2f sf::ConvexShape::getPoint(unsigned int index) const
returns old position
Title: Re: ConvexShape - getting current position of the point
Post by: eXpl0it3r on May 27, 2014, 04:27:18 pm
You can do:
shape.getTransform().transformPoint(shape.getPoint(0));

The online documentation isn't clear about this, but it has been clarified (https://github.com/SFML/SFML/blob/master/include/SFML/Graphics/ConvexShape.hpp#L96) in the source code already.

Quote
The returned point is in local coordinates, that is,
the shape's transforms (position, rotation, scale) are
not taken into account.
The result is undefined if \a index is out of the valid range.
Title: Re: ConvexShape - getting current position of the point
Post by: sheadovas on May 27, 2014, 04:39:12 pm
Thx