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

Author Topic: getPoint() Absolute coordinates  (Read 4454 times)

0 Members and 1 Guest are viewing this topic.

TheGameDev

  • Newbie
  • *
  • Posts: 7
    • View Profile
getPoint() Absolute coordinates
« 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.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: getPoint() Absolute coordinates
« Reply #1 on: August 04, 2014, 08:57:25 pm »
RectangleShape.getGlobalBounds();
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

TheGameDev

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: getPoint() Absolute coordinates
« Reply #2 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....

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: getPoint() Absolute coordinates
« Reply #3 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().
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheGameDev

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: getPoint() Absolute coordinates
« Reply #4 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 :)


Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: getPoint() Absolute coordinates
« Reply #5 on: August 04, 2014, 09:27:23 pm »
By the way, please post in the "Help" section next time, not in "General Discussions" ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: getPoint() Absolute coordinates
« Reply #6 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
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: getPoint() Absolute coordinates
« Reply #7 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.
Laurent Gomila - SFML developer