We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › OpenGL + rotate() + mouse over
Page Index Toggle Pages: 1
OpenGL + rotate() + mouse over (Read 3074 times)
OpenGL + rotate() + mouse over
Apr 7th, 2009, 8:24am
 
Hello all!

I've got a simple problem to which i can't find a simple answer...

PROBLEM: i'm developing a multitouch environment with the typical scale, rotate, move actions using OpenGL for speed. When i rotate an image and try to test if a finger (or TUIO cursor in this case) is on top of it i can't find a simple way of testing the intersection of the rotated rectangular bounding box with the cursor coordinates.

This could be easily solved using the Rectangle java2d object and it's contains(x, y) function, but in order to apply transforms to this Rectangle i need to cast PGraphicsOpenGL to Graphics2D, which unfortunately is impossible.  Angry

So: how can i perform this test, in an easy way (ie. no separating axis theorem, vectors, etc) without having to choose PGraphics instead of PGraphicsOpenGL??

I'm hoping you coding wizards can help me solve this, since i've lost a whole working day struggling with this issue...

Thanks! Smiley
Pedro.
Re: OpenGL + rotate() + mouse over
Reply #1 - Apr 7th, 2009, 3:07pm
 
Olá.
this link explains what you want to do: http://processing.org/hacks/hacks:picking
Re: OpenGL + rotate() + mouse over
Reply #2 - Apr 8th, 2009, 4:23am
 
Obrigado!!

This is exactly what i needed! And since i have loads of objects at a time, i generated the color ids like this (might be useful for someone else!):

id = (int)random(0xFFFFFF) | 0xFF000000;

this way there's 16777216 different ids so there's a 0,000006% chance of repeating an id Smiley

Obrigadao Rui! E parabens pelo teu interface no moda lisboa, tive a ver o teu blog e curti mt!
Page Index Toggle Pages: 1