Hello Guest

27 Cubes meet Mouse X and Ys, kinda?

  • 2 Replies
  • 5002 Views
27 Cubes meet Mouse X and Ys, kinda?
« on: November 21, 2005, 16:31:03 »
Well, basically I'm working on something that rotates 27 cubes around the screen.  When I right click the mouse rotation is haulted and the player can click to place a marker on the cube.  The problem is that I have no earthly idea how to translate the 3D Float points to something I can compare the X and Y with... any ideas?

*

Offline CaseyB

  • ***
  • 118
27 Cubes meet Mouse X and Ys, kinda?
« Reply #1 on: November 21, 2005, 18:38:20 »
You can either use picking, or gluProject/gluUnProject.  That's as much as I know, unfortunately!  I need to do the same kind of thing and haven't been able to get it working!

*

Offline napier

  • ***
  • 104
    • http://potatoland.org
27 Cubes meet Mouse X and Ys, kinda?
« Reply #2 on: November 22, 2005, 15:37:48 »
Here's a simple demo that does screen/world translations:

   http://potatoland.com/code/gl/lwjgl_demoScene.zip

In GLApp_DemoScene.java, the functions mouseMove() and mouseDown() translate screen coords to world.

I wrap the gluUnproject calls in a base class function called getWorldCoordsAtScreen(), which may be helpful or annoying depending on how you like to code ;-)
penGL/Java/LWJGL demos and code: http://potatoland.org/code/gl