Shape coordinates & use of camera

pmbpmb
edited March 2014 in How To...

Hi,

I am a long-time Java programmer, but very new to Processing. And I have what I suppose to be a very rudimentary question.

If I use Processing's camera (or peasycam) to "look at" a shape, the appearance of the screen can change radically. Shapes appear to have moved, but I think that they really have not. All I've done is change my perspective on the scene.

Is there a way to somehow "re-map" the coordinates of the shapes after changing perspective by means of the camera? Here's an example of what I mean:

  • a. click on a shape
  • b. identify the clicked shape by relating its X,Y coordinates to the mouse X,Y; and point the camera at it
  • c. in pointing the camera at the clicked shape, all the shapes appear to change positions
  • d. click on the same shape
  • e. now unable to identify the clicked shape by its X,Y coordinates

In fact, if instead of (d), I click on the empty place where the shape used to be (before step (b)), my code reports that I've clicked on the shape.

I'd like to be able to continue clicking on any shape, regardless of where the camera is positioned, and still be able to identify it by means of its apparent X,Y location in relationship to the mouse.

Thank you for your help - and patience.

-Paul

Answers

  • it's called picking, quark has a picking library for that

    you can program one yourself when having an invisible PImage with unique colors

    ;-)

Sign In or Register to comment.