Page 1 of 1
Using love.graphics coordinates in other functions
Posted: Tue Jan 30, 2018 10:02 am
by dfgworm
So i have learned to use those coordinates translations in love.graphics (love.graphics.translate, love.graphics.rotate, etc.) and found them extremely useful, optimized and simple. But now i wonder if there's a simple way to bring those coordinates into my other functions (like for connecting it with physics or whatever), other than by making my own coordinate conjugating tools that could work the same way. Maybe i am blind, but i can't see anything similar on wiki. Actually i have already made representation of translate+rotate, but then realized that making the same for scale won't be as easy and i have no idea how shearing works mathematically.
So is this already in love or is there a fast library hidden somewhere deep in forums?
Re: Using love.graphics coordinates in other functions
Posted: Tue Jan 30, 2018 7:01 pm
by pgimeno
It's not all that clear what you're asking. The result of a series of transforms (a multiplication of matrices) is another transform (another matrix). Up to 0.10.2, Löve doesn't provide any means to retrieve the current transformation matrix.
There is a workaround. You can track the theoretical value of the current matrix by hooking the transformation functions, so you can obtain the inverse matrix. There is an implementation in this post:
viewtopic.php?p=201884#p201884
But again, I'm not sure if that's what you mean.
Re: Using love.graphics coordinates in other functions
Posted: Wed Jan 31, 2018 4:15 am
by dfgworm
Yeah, sorry for unclear question, but you got everything exactly right and even provided the answer i needed. Thanks!
What i want out of this is having 2 images (probably 2 different creatures) with different scaling, shearing and rotation being able to cooperate graphically. Like 1 heavily transformed guy having his heavily transfromed hand exactly on a shoulder of another heavily transformed guy.
May be i am a little bit too obsessed with perfection, but all those transformations don't seem like they affect performance, so i thought this is more than possible.
Edit: Wow, i honestly didnt expect more than just an "idk lul" or at max some shearing formula, but this is just perfect. I had no idea matrices are involved here, and would just use some retarded(yet working) self-made formulas of mine to modify plain coordinates. Cant imagine how much time i would waste to realize i need more than just X and Y stored for best performance.
You, man, are truly the Murderer-of-senseless-maths-wanderings.