alrighty, so i tried a simple app to test the translation but am having no luck…
i translate the view (and draw a rect for reference), then rotate, then draw a rect which needs to receive mouse events. I am content to measure distance between 2 points to get rollover states for now. one point being the cursor, the other being the center of the rect acting as a button.
in the code below, if i can get the ellipse to appear on top of the second rect, it should work (prints “over” to the console).
#ifndef _TEST_APP
#define _TEST_APP
#include "ofMain.h"
#define OF_ADDON_USING_OFXVECTORMATH
#include "ofAddons.h"
class testApp : public ofSimpleApp{
public:
bool debug, fullscreen;
int mx, my, w, x, y;
ofxVec2f mouse, button;
float angle;
void setup(){
ofBackground(0,0,0);
w = 20; //width of objects
ofSetRectMode(OF_RECTMODE_CENTER);
x = 200;//pos to translate to
y = 200;
angle = 45;//angle to rotate
}
void draw(){
glPushMatrix();
//translate to pos:
glTranslatef(x,y,0);
ofSetColor(0xFFFFFF);
ofRect(0,0,w,w);
//rotate:
glRotatef(angle,0,0,1);
ofSetColor(0xFFFFFF);
//draw square at new location from rotation point
ofRect(100,0,w,w);
glPopMatrix();
//draw vector for button loc
ofSetColor(0xCCCCCC);
ofEllipse(button.x,button.y,w/2,w/2);
}
int distance(int x1, int x2, int y1, int y2){
return sqrt(pow(x2-x1,2) + pow(y2-y1,2));
}
void mouseMoved(int _x, int _y ){
mouse.set(_x,_y);
button.set(x,y);
button.rotate(-angle);
button.set(button.x+100, button.y);
//printf("menu::onMouseMove(x: %f, y: %f)\n", mouse.x, mouse.y);
int dist = distance(mouse.x,button.x,mouse.y,button.y);
if (dist <= 10) cout<<"over"<<endl;
//printf("dist %i\n",dist);
}
};
#endif