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

Author Topic: sf::Transformable combine  (Read 1652 times)

0 Members and 1 Guest are viewing this topic.

Nybble

  • Newbie
  • *
  • Posts: 17
    • View Profile
sf::Transformable combine
« on: April 01, 2016, 08:51:07 pm »
Hello every one, what I am trying to do is "combine" 2 transforms, but it is not working, it works fine when it collides on all sides BUT the left side of another rectangle... I just think I'm using the combine method wrongly.

Object object; //this is my own "Entity" class which inherits from sf::Transformable and has methods to get "rectangle dimensions"
Vector2f offset(100,100);// arbitrary number in this case
sf::Rect<int> bb;

sf::Transform temp(0,0,offset.x, 0,0,offset.y, 0,0,1);
temp.combine(object.getTransform());

        sf::FloatRect localBounds(0.f,0.f, object.Box.width, object.Box.height); // object.Box is just a sf::Rect<int>
        sf::FloatRect globalBounds( temp.transformRect( localBounds ) );
        bb = { globalBounds.left, globalBounds.top, globalBounds.width, globalBounds.height };
 

now if I just use:
sf::Transformable temp;
temp.setPosition(object.getPosition().x, object.getPosition().y);
temp.setOrigin(object.getOrigin());
temp.setRotation(object.getRotation());
temp.setScale(object.getScale());
 

then compute the local bounds and global bounds it works fine, so I'm pretty sure I'm just not using the combine method the right way, is not a big deal, since I got it working with the second method, I just want to know how to use the sf::Transform::combine method the right way, thanks.
« Last Edit: April 01, 2016, 08:53:22 pm by Nybble »