I want to flip Horizontally my Sprite/Texture however the SpriteEffects.FlipHorizontally isn't cutting it for me as it just flips the texture in place.
I want to flip the texture over a specified Vector2/Vector3?
Thanks!
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityI want to flip Horizontally my Sprite/Texture however the SpriteEffects.FlipHorizontally isn't cutting it for me as it just flips the texture in place.
I want to flip the texture over a specified Vector2/Vector3?
Thanks!
some quick resources i found:
http://forums.create.msdn.com/forums/p/80526/487062.aspx
C = A - (2 * B * (A dot B)) where A is original vector, B the mirror, C result.
http://en.wikipedia.org/wiki/Reflection_(mathematics)
edit: Sorry, I actually forgot what the actual question was. But yeah, you should be able to manipulate UV-values with that formula anyway.
edit2: http://mathworld.wolfram.com/Reflection.html
This has the actual formula you wanted.
To do this you would most likely have to write a custom shader which provides a mechanism for flipping.
Create your shader and load it as an effect in xna. Then set it before doing any draw calls. You can load this shader through the content manager.
In your shader you will want to change the pixel shader. What you will want to do is mirror the texture coordinate supplied to the pixel shader in the vector. Also, remember to create a global variable, for the vector, which you can set in your xna code trough;
effect.parameter["name"].setValue(Val);