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

Author Topic: TransformToGlobal doesn't care about the center  (Read 2505 times)

0 Members and 1 Guest are viewing this topic.

csiz

  • Newbie
  • *
  • Posts: 30
    • Yahoo Instant Messenger - calinutzu92
    • View Profile
    • Email
TransformToGlobal doesn't care about the center
« on: January 29, 2009, 02:33:02 pm »
I found a minor bug in Drawable


Code: [Select]
Sprite aaa;
aaa.SetImage(Imagini.SnakeTale);//40|40 image
aaa.SetCenter(20,20);
aaa.SetPosition(0,0);
cout<<aaa.TransformToGlobal(Vector2f(0,0)).x;//outputs -20


Shouldn't that output 0 ?
My new webpage calinmocanu

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
TransformToGlobal doesn't care about the center
« Reply #1 on: January 29, 2009, 03:20:37 pm »
First of all, TransformToXxx functions can't return a wrong result as they simply use the same matrix which is used to draw the object.

The output is correct, SetPosition sets the position of the center of the sprite. So, your new center (20, 20) will map to (0, 0) and (0, 0) will map to (-20, -20).
Laurent Gomila - SFML developer

csiz

  • Newbie
  • *
  • Posts: 30
    • Yahoo Instant Messenger - calinutzu92
    • View Profile
    • Email
TransformToGlobal doesn't care about the center
« Reply #2 on: January 30, 2009, 12:02:57 pm »
I thought it should be relative to the center, oh well I'll go around it
My new webpage calinmocanu

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
TransformToGlobal doesn't care about the center
« Reply #3 on: January 30, 2009, 12:24:05 pm »
Quote
I thought it should be relative to the center

You mean, the input point?
The input point is in local coordinate, which means it doesn't depend on any transformation applied to the object (including moving its center).
Laurent Gomila - SFML developer

csiz

  • Newbie
  • *
  • Posts: 30
    • Yahoo Instant Messenger - calinutzu92
    • View Profile
    • Email
TransformToGlobal doesn't care about the center
« Reply #4 on: January 30, 2009, 02:43:33 pm »
Aaaaa now it makes sense  :idea:  Sorry for bothering  :oops:
My new webpage calinmocanu

 

anything