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.


Messages - Elusive

Pages: [1]
1
Graphics / sprite/texture/image bending
« on: October 23, 2011, 03:50:32 am »
Okay, I've implemented a simple bilinear filter, which makes it even more awesome.

Before:


After:


My implementation (assuming the surrounding code by Nexus):
Code: [Select]
sf::Vector2f pixelPos(source.GetWidth() * texCoords.x, source.GetHeight() * texCoords.y);
sf::Vector2i roundedPixelPos(pixelPos);
sf::Vector2f posFraction(pixelPos.x - roundedPixelPos.x, pixelPos.y - roundedPixelPos.y);
sf::Vector2f invertedPosFraction(1.0f - posFraction.x, 1.0f - posFraction.y);

sf::Color color1 = source.GetPixel(roundedPixelPos.x,                         roundedPixelPos.y                         );
sf::Color color2 = source.GetPixel(roundedPixelPos.x + 1 % source.GetWidth(), roundedPixelPos.y                         );
sf::Color color3 = source.GetPixel(roundedPixelPos.x,                         roundedPixelPos.y + 1 % source.GetHeight());
sf::Color color4 = source.GetPixel(roundedPixelPos.x + 1 % source.GetWidth(), roundedPixelPos.y + 1 % source.GetHeight());

sf::Color interpolatedColor;

// red
float r1 = invertedPosFraction.x * color1.r + posFraction.x * color2.r;
float r2 = invertedPosFraction.x * color3.r + posFraction.x * color4.r;
interpolatedColor.r = invertedPosFraction.y * r1 + posFraction.y * r2;

// green
float g1 = invertedPosFraction.x * color1.g + posFraction.x * color2.g;
float g2 = invertedPosFraction.x * color3.g + posFraction.x * color4.g;
interpolatedColor.g = invertedPosFraction.y * g1 + posFraction.y * g2;

// blue
float b1 = invertedPosFraction.x * color1.b + posFraction.x * color2.b;
float b2 = invertedPosFraction.x * color3.b + posFraction.x * color4.b;
interpolatedColor.b = invertedPosFraction.y * b1 + posFraction.y * b2;

// alpha
float a1 = invertedPosFraction.x * color1.a + posFraction.x * color2.a;
float a2 = invertedPosFraction.x * color3.a + posFraction.x * color4.a;
interpolatedColor.a = invertedPosFraction.y * a1 + posFraction.y * a2;

dest.SetPixel(x, y, interpolatedColor);


I am pretty happy with the result!

2
Graphics / sprite/texture/image bending
« on: October 22, 2011, 10:21:46 pm »
Just... wow, Nexus! This is exactly what i was looking for. Thanks a lot! It works like a charm. I think i'll need to take a closer look at your library ;)

I wonder if it would be possible to add bilinear interpolation, so that it looks smoother.

3
General / Problem with installation in Ubuntu SFML 1.6
« on: October 21, 2011, 11:55:30 pm »
The ATI linux drivers are really bad and very rarely updated, but this kind of thing seems to be normal when using OpenGL. Take a look at this: http://stackoverflow.com/questions/1997171/why-does-valgrind-say-basic-sdl-program-is-leaking-memory

What is happening exactly? Is the window even visible? Is the compiler warning about something?

4
Graphics / sprite/texture/image bending
« on: October 21, 2011, 11:43:55 pm »
Placing them at the correct position is not a problem. I am already doing that. The main problem is that the images are not always curved the same way. If the decorated circle is bigger, the angle at which they need to be bent needs to be smaller.


If i would use sprite 1 multiple times to form a full circle, it would be much smaller than the one for 2, since 1 is much more curved than 2. The intersections would differ, resulting in a manually tweaked image for every possible circle size. I would like to avoid that, if possible.

5
General / Problem with installation in Ubuntu SFML 1.6
« on: October 21, 2011, 11:13:23 pm »
I encountered the same problem a few weeks ago. The SFML libraries are probably missing in your LD_LIBRARY_PATH. Try reconfiguring ld:
Code: [Select]
$ sudo ldconfig -v
That did it for me.

6
Graphics / sprite/texture/image bending
« on: October 21, 2011, 11:10:10 pm »
I am trying to decorate big circle with multiple small rectangular images. They are supposed to fully cover the surface of the circle. This is how i first tried to align them:



It is possible to build it like that, but it requires tons of manual adjustment and tweaking to make sure that it fits properly at the intersection. Another Problem is that i would like to use the same images for bigger circles, too. Those would consist out of more of these small images to compensate for the bigger radius, but they would end up overlapping at another angle. That is where this idea comes in:



That way i would only need to adjust the images once (and it would be much simpler because i can put two images side-by-side in my image-editor instead of firing up the app each time i changed something).

How can I transform the sprites like that? I thought of Shaders (which I did not use very much before), but i think it would be better not to do it in realtime, since transformed sprites do not need to change once they are generated for a particular angle. Can someone point me in the right direction here?

7
Graphics / sf::View culling
« on: September 25, 2011, 02:08:04 pm »
Awesome! Thanks a lot! :)

8
Graphics / sf::View culling
« on: September 25, 2011, 01:59:36 pm »
That is not part of SFML, right? I'll look into that. Thanks!

9
Graphics / sf::View culling
« on: September 25, 2011, 01:09:27 pm »
That was my first guess, but what about the view rotation?

10
Graphics / sf::View culling
« on: September 25, 2011, 04:28:08 am »
Hi,

Is there a simple way of culling invisible items in the scene using sf::View? Is there some method of checking wether a boundary box is intersecting with the visible region?

-Elusive

Pages: [1]
anything