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.
Page Index Toggle Pages: 1
cursor in 3d space (Read 816 times)
cursor in 3d space
Feb 9th, 2006, 6:10pm
 
I realise this has been covered before, but having read all the relevant threads I've not found a solution.

What I'd like to do is know whether a 3d object in 3d space is under the cursor or not.

The sensible way to do this seems to me to take the x/y screen position of the cursor, give it a z position (all my objects are at the same depth, handily, so this is known and constant) and 'ask' processing where it is.

I've come across modelX/Y/Z and screenX/Y/Z, it seemed that feeding the values described above into modelX/Y was what I was after, but doing that and creating a box at the returned vales, well, the box doesn't follow the cursor. It seems to do something similar to creating a box at mouseX, mouseY and a known Z.

What I would like to know is whether there is an inbuilt way of doing this. Am I just using modelX etc wrong?

I realise I could do this mathematically but that seems to me to negate the point of using a 3d engine.

Would appreciate any help/pointers.

I'll rephrase because I'm not the best at explaining:

I'd like an object to follow the mouse pointer exactly, yet exist in 3d space at a known Z position.
Re: cursor in 3d space
Reply #1 - Feb 12th, 2006, 9:37pm
 
I think what you actually want to do is take the 3D object, work out it's outer bounds, then get the screenX/screenY for those coordinates. This will tell you where on screen those points are, then you just check mouseX/mouseY against the values of the bounds of your object.
Re: cursor in 3d space
Reply #2 - Feb 12th, 2006, 10:22pm
 
I'd wondered about that but was trying to avoid it because of the number of objects on screen (bout 5000, although they're all just boxes, mostly of the same dimensions).

I'd wanted to avoid extra loops, but you've made me realise I don't need one, I can do it when it loops through to draw them.

Thank you.
Page Index Toggle Pages: 1