Hi i have a problem i need to rotate 4 points for each picture my app loads.
I gater the points and set them, and all works nice to the point whee i need to use:
.h
Is there ay reason that you don’t draw the lines at the same time as the image? And let opengl do the rotating?[/quote]
Yes the reason is the lines are only for my visual if it works, i need to keep tarck of the corners since its a multi touch application, and i need to make a function for picking, right now i have it working wit a simple check for a not rotated picture based on x,y,w,h
but as soon i rotate the picture i need to get the new points of the corners in screen space.
But thats just the first step then, i need to find a function or method to check if a x,y is over the new rotated points, but how do i do than?
is there a math formula for calculating if a point(x,y) is in the bounding s of the rotated picture
one trick to deal with selection is to render everything that is selectable with a single colour into an FBO, where the colour is the index of the object, so for example if the colour was 0x000001 then this would be object id 1. then you just take your mouse position and read the colour under the mouse cursor, this tells you what object your mouse is over.
I solved it by using 4points and calculate if xy is in the bounds of a polygon.
Now i need to figure out how to keep track of my finger corodiantes on the picture while moving… right now i just center the picture on the finger, what works good, but for more realistic i would need to find out how t keep my fingers on the spot where i moved it … mhh i will post the source code later so you guys can check it out for better help, since i am bad in explaining
I did this a couple of weeks ago aswell… I had to be able to move, scale and rotate a image on a multitouch table. My aproach to it was i had to function calls. PrimaryFingerDown, and secondaryFingerDown. All other fingers that where pressed after that where ignored. When one of the fingers where pressed i saved a offset (ofxVec2f) between the image and finger, and added that all the time to the calculations. That was the move part. The rotate and scaling part was a bit more tuff. I calculated the angle between the offsets and the current fingers to see how much they where rotated, and used that for rotation (but remember to rotate the offsets correctly aswell), and the scaling was the distance between the offsets compared with the fingers… Hope it helps.
all you need to do is remember where the mouse was last frame. so say your current mouse x is mouse_x, your previous mouse x is stored in prev_mouse_x, then you just go like this:
// in .h
int prev_mouse_x;
int prev_mouse_y;
// in .cpp, mouseDragged() or similar
my_picture.x += (mouse_x - prev_mouse_x);
my_picture.y += (mouse_y - prev_mouse_y);
prev_mouse_x = mouse_x;
prev_mouse_y = mouse_y;