Return to previous page | Return to menu | Go to next page


5-2. Object representation by hierarchical structure

This section describes the hierarchical structure of objects in a matrix using a stack. In short, this means having a relationship between multiple objects. This relationship is generally called parent-child structure .

Stack

A stack is a structural model for efficiently handling a matrix. This is shown in Figure 5-2, and the functions for performing this operation are “slPushMatrix” and “slPopMatrix”.
The matrix at the lowest level in the stack is called the current matrix, and various matrix conversion operations are performed on the current matrix.

【Bool slPushMatrix ( void ) ;】
Copies the current current matrix to the lower stack and moves the current matrix to the lower level at the same time. Used for temporary storage of matrix.
[Bool slPopMatrix (void);]
Restores the temporarily saved upper matrix and moves the current matrix to the upper level.
The lower stack matrix is ​​discarded.

Figure 5-2 Stack image model

Note) There are 20 stacks, and the matrix is ​​nested in order from the upper stack to the lower stack.

SGL maintains a matrix called the environment matrix as the current matrix when the matrix environment is initialized.
This defines the root of the 3D coordinate environment of SGL. If this is rewritten, various conversion operations may not be performed correctly.
Therefore, SGL supports “slInitMatrix” as a library function to initialize the stack and various matrix variables.

[void slInitMatrix (void)]
Initialize stack and matrix variables. At this time, the environment matrix is ​​secured on the stack as the current matrix.

Return to previous page | Return to menu | Go to next page