I’m doing an OF application with rectangles moving around a center point (center of the screen). The idea is: when you click on a rectangle, another one appears in a random position.
My problem is to know when one of these rectangles was clicked, because i can’t check the position because the rectangle is always moving.
The rectangles are a simple ofRectangle. I was looking for somekind of method or function to check if the rectangle was clicked.
maybe you can solve this problem by using ofMSAinteractiveObjects. À Class written by Mehmet Akten. You will find it, when u search for it, there should also Be an example.
@zach: i have a class very similar as Mikkel Koser’s ofBall class. The problem is to update the position of my rectangle. It’s moving around the center of the screen, something like:
glPushMatrix();
// Translate coordinate origin
glTranslatef(ofGetWidth()/2,ofGetHeight()/2,0);
// Rotate rectangles around it
j -= 0.05;
glRotatef(j,0,1,0);
// ... here i draw the rectangles
glPopMatrix();
I can’t find the way to update the position and check if the rectangle have been clicked (just the same way like you posted). :?
I’m trying to make some maths to update the x position, but the z position it’s important because it modifies the w of the rectangle.
Based on the vectorMathExample, using ofxVec3f as arturo said, i can control at any time the coordinates of my rectangle!! (look at the grid coordinates)
I have the squares moving around a central axis. I have the position of the squares (x, y and z) around the central axis. But the problem is… the axis of the mouse are respect the screen [center (0,0) on the top left], and the axis of the squares are respect the center of the screen.
I tried to calculate it by substracting the center weight and height to the mouse coordinates, but it doesn’t work.