GEF3D Coordinate Systems
In GEF, there usually is one global coordinate system and figure-local coordinate systems to deal with. Generally, mouse coordinates can be translate to the global coordinate system and the figure-local coordinate systems in a simple and straightforward fashion, and users of the framework seldomly have to deal with these issues. In GEF3D however, there are more coordinate systems involved and dealing with those can become cumbersome. This article aims to describe the concepts of coordinate systems and coordinate system conversion in GEF3D.
Mouse coordinates are used to specify the location of the mouse cursor relative to a control. In the case of GEF3D, the control is the OpenGL canvas, in which the OpenGL viewport is rendered.
The origin of the mouse coordinate system is in the top left corner of the viewport, so mouse coordinates are always positive. In the picture, the current mouse coordinates are (147,105), and these are the same values that are contained in the mouse events that the GEF lightweight system receives and dispatches to figures and tools. In GEF3D however, these coordinates are handled a bit differently in order to allow seamless integration of embedded 2D editors (see below.
3D coordinates in world space
Inverted Coordinate System
origin seems to be in the upper left / front corner
Figure-local 3D Coordinates
2D coordinates supplied to embedded 2D editors
- global world coordinates <-> figure-local 3D coordinates
- surface coordinates <-> global world coordinates
- screen coordinates + depth value -> global world coordinates
- screen coordinates -> figure-local 3D coordinates
- screen coordinates -> surface coordinates
Embedded 2D GEF Editors
Make Yourself at Home: Creating a Fake 2D Environment
Coordinate conversion, Virtual picking, modified SWT events