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

Author Topic: [SOLVED]ConvexShape - getting current position of the point  (Read 1122 times)

0 Members and 1 Guest are viewing this topic.

sheadovas

  • Newbie
  • *
  • Posts: 2
    • View Profile
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
« Last Edit: May 27, 2014, 04:39:36 pm by sheadovas »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10823
    • View Profile
    • development blog
    • Email
Re: ConvexShape - getting current position of the point
« Reply #1 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 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.
« Last Edit: May 27, 2014, 04:39:43 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sheadovas

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: ConvexShape - getting current position of the point
« Reply #2 on: May 27, 2014, 04:39:12 pm »
Thx

 

anything