SFML community forums
Help => Graphics => Topic started by: notnowlewis on July 08, 2013, 10:58:50 am
-
I have no idea how the values in a 3x3 matrix work to transform a sprite. I have done a little reading on the math of matrix transformations, but I can seem to make the connection between the values in the matric and how the look of my sprite changes. Where can I find some good examples and tutorials on using them?
-
So you know what I want to achieve, I want to take an image like this: http://i.imgur.com/qH8YCRS.png and apply a perspective effect, so it ends up like this: http://i.imgur.com/AUvpyKd.png
I know I can do that type of transformation in GIMP with a 3x3 matrix, but I want to understand *how* it works :)
-
It's not going to work with SFML. This kind of perspective transformation requires depth values (which SFML doesn't have), otherwise the texture mapping will be incorrect.
-
Ah, maybe I misunderstood or didn't explain myself very well. i don't want a 3d transform, I want to take a texture which is currently in a rectangle http://i.imgur.com/HYbDVos.png and squish it into a trapezoid http://i.imgur.com/uVl0d1y.png
Is that possible? Some of the reading I've done suggests "yes", some suggests "no". I just want to make sure in case I wasn't clear when i first asked :)
-
It was very clear, and my answer still applies. There was a thread about this exact problem a few years ago, but I can't find it.
-
Thanks, i tried searching but kept getting DB errors.
Thanks for clarifying things. I'll have to do a bit more thinking!
-
i tried searching but kept getting DB errors.
Don't keep all the forums selected, only check the relevant ones.
-
There's this (old) topic, not the one that I was looking for but it's the same issue:
http://en.sfml-dev.org/forums/index.php?topic=2893.0
I found the recent one on the french forum:
http://fr.sfml-dev.org/forums/index.php?topic=12121.0
If you don't understand you can just have a look at this picture:
https://en.wikipedia.org/wiki/File:Perspective_correct_texture_mapping.jpg
-
squish it into a trapezoid
As laurent said the depth part of what you want is impossible to do with SFML, but if all you want is a trapezoid then use an sf::VertextArray to draw your texture and on one edge move your points closer/farther away from each other.
-
squish it into a trapezoid
As laurent said the depth part of what you want is impossible to do with SFML, but if all you want is a trapezoid then use an sf::VertextArray to draw your texture and on one edge move your points closer/farther away from each other.
Would that clip the texture, or would I end up with the whole texture, but squished at one edge?
-
Would that clip the texture, or would I end up with the whole texture, but squished at one edge?
If you assign a rectangular texture area, it will be squished. But as I said (many times in this thread) it will lead to incorrect texture mapping as shown in the various links that I posted.
-
Would that clip the texture, or would I end up with the whole texture, but squished at one edge?
If you assign a rectangular texture area, it will be squished. But as I said (many times in this thread) it will lead to incorrect texture mapping as shown in the various links that I posted.
Ah, I missed those, I didn't have notifications turned on for this thread.
Thanks for being patient with me, I really appreciate the time you put in on the forums, and on SFML. Also, I finally understand the issues now!