Saturday, March 12, 2011

Mouse picking

The latest version of env3d adds the ability to use the mouse to interact with objects in 3D space.

Previously, the only mouse position related methods are Env.getMouseX(), and Env.getMouseY(). These methods return only the screen coordinates but not the pointer coordinates in 3D space. This makes it hard to implement features such as using a mouse of select an object inside the 3D environment.

Users of env3d now has a few more methods to use, the details can be found at http://env3d.org/beta/node/113.

Perhaps that most important method is Env.getPick(int screenX, int screenY). This method takes the screen's x and y coordinate and returns the first object in 3D space under that coordinate. The object returned is of the generic Object type so users will have to cast it to the appropriate type before using it.

Labels: , , , , , ,