From J Wiki
Jump to navigation Jump to search
J6/OpenGL  | Class  | API  | Utils   Movement   Viewing

Using the OpenGL utilities, graphics are drawn at the origin, and then three viewing controls are applied. First, the graphic is rotated about one or more axes. Next, it is translated (moved) to a new position. Finally, the observer's view position is given.

These viewing controls are always applied. If not specified, defaults are used. Rotation and translation may be zero, leaving the graphic at the origin, as originally drawn.

(Since OpenGL applies viewing commands in the reverse order in which they are specified, they are here specified in the order: view, translate, rotate.)


The rotation angles are given in degrees in GS_ROTXYZ, and are applied in the order GS_ROTNDX.

By default GS_ROTNDX is 0 1 2, meaning the specification order is x-axis, y-axis and z-axis (and applied by OpenGL in the order z, y, x). When setting up a graphic, it is easiest to leave GS_ROTNDX as the default. However, the paint handlers may change the order to ensure smooth rotations when using the x y z keys to rotate the graphic.


Translation moves the graphic away from the origin, by the amount in GS_TRNXYZ. In most cases, there is no need to move the graphic.


The position of the observer is given in GS_VIEWXYZ, and the up direction in GS_VIEWUP. The observer always looks at the origin. If you set GS_VIEWXYZ manually, ensure that GS_VIEWUP is also given a suitable value.


A good way to experiment with viewing is to use the OpenGL demo Basic/Viewing. This shows the viewbox with the positive axes. Try to guess which way the graphic will move when each key is pressed.