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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Mashandar

Pages: [1]
1
Graphics / Wierd glitch after using FlipX()
« on: April 29, 2009, 05:46:44 pm »
Hello,
         I finally got my pixel-perfect collision detection working but It's acting
         funky after using FlipX(true) on a sprite. when I check GetPixel to see
         what's going on, it's reporting that pixels are there, when, visually
         nothing is seen, so the pixels shouldn't be there (the alpha values
         of these pixels is 255).

         I have uploaded the image to imagebin and a sample test
         code to pastebin which shows this.

        Code: http://pastebin.com/m53275387
        Image: http://imagebin.ca/view/5qzsUj5.html

         I'm rather baffled, so I'm hoping someone can help.

EDIT: in the given example, if compiled, you'll see the flipped sprites (top sprites) colliding permaturely (stopping before reaching the other sprite)
and the unflipped sprites (bottom sprites) colliding as they should.

2
Graphics / TransformToLocal/TransformToGlobal Confusion
« on: April 22, 2009, 05:23:13 pm »
Hello,
I'm trying to implement a pixel based collision detection,
and what I planned to do was to iterate through the pixels of one
sprite (go from 0,0 to sprite.GetSize().x, sprite.GetSize().y respectively),
use TransformToGlobal to get a global co-ordinate, then use the
opposing sprite's TransformToLocal, to check whether that pixel position
in that opposing sprite's space.

unfortunately, after using TransformToLocal on the opposing sprite, I
get unusual results.

Example

Sprite 1 Position: 265.83, 599.309
Sprite 2 Position: 327.316, 596.533

(Using TransformToGlobal)
Sprite 1 Global Position of 0, 0: 233.83, 567.309
Sprite 2 Global Position of 0, 0: 295.316, 564.533

(Using TransformToLocal of sprite 1's global position of (0, 0) on sprite 2)
-1229.72, 55.5112 -> Unusual  

Here's some code to help explain what I'm doing:

Code: [Select]
sf::Vector2f pos1, pos2;
sf::Color colour;
int i;

for(i=0;i<sprite1.GetSize().x;i++) {
  for(j=0;j<sprite1.GetSize().y;j++) {
    pos1 = sprite1.TransformToGlobal(sf::Vector2f(i, j));
    pos2 = sprite2.TransformToLocal(pos1);

    if (<pos2's value is not invalid. eg. >= (0,0) or < sprite2.GetSize()>) {
     colour = sprite2.GetPixel(pos2);
     if (colour.a > 0) { return true; }
    }
  }
}

return false;

etc.

now in the cases I have been testing, the rotation and scale and even
center points on each object are the same, and I'm rather stumped as
to why wierd values are coming out. (especially such large negative values, I had values going up to -6000+)

I really hope someone can help.

Regards,
             Mashandar

P.S. I apologise for the large posting, I just wanted to make sure there's
plenty of information about my problem.

Pages: [1]