★ Matrix operation



ListReference

function

slInitMatrix


Matrix initialization

Form

    #include "sgl.h"

    void slInitMatrix (void)

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    Initialization of variables and buffers used in matrix operations

Example

    Initializes the matrix buffer.
slInitMatrix ();

reference

 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slPushMatrix


Evacuation of matrix

Form

    #include "sgl.h"

    Bool slPushMatrix (void)

argument

    void --Do not give anything.

Number of returns

    Bool --Returns NG if an error occurs and OK if successful.

function

    Advance the pointer on the matrix stack and copy the current matrix to it.
You can nest up to 20 matrices, but if you exceed this, an error will be returned.

Example

    Save the current matrix to the matrix stack and use the contents of that matrix for the next process.
slPushMatrix (); { slScale (...); ::

caution


    This function is used when you want to save the past current matrix information such as a hierarchical model.

reference

 slInitMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr
 MatrixCount 



ListReference

function

slPushUnitMatrix


Evacuation of matrix

Form

    #include "sgl.h"

    Bool slPushUnitMatrix (void)

argument

    void --Do not give anything.

Number of returns

    Bool --Returns NG if an error occurs and OK if successful.

function

    Advance the pointer on the matrix stack and set the identity matrix there.
If it is over-nested, it will return an error.

Example

    Save the unit matrix in the matrix buffer.
slPushUnitMatrix (); { slTranslate (...); :: slPutPolygonX (...); } slPopMatrix (); At this point, the current matrix becomes an identity matrix.

reference

 slInitMatrix
 slPushMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr
 MatrixCount 



ListReference

function

slIncMatrixPtr


Advance one stack in the matrix

Form

    #include "sgl.h"

    Bool slIncMatrixPtr (void)

argument

    void --Do not give anything.

Number of returns

    Bool --Returns NG if an error occurs and OK if successful.

function

    Advance the pointer on the matrix stack.
You can nest up to 20 matrices, but if you exceed this, an error will be returned.

Example

    Advance the pointer of the matrix stack by one and check if stack overflow has occurred.
if ( slIncMatrixPtr () == NG ) { / * Stack Over flow. * / } else { / * Stack safty. * / }

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr
 MatrixCount 



ListReference

function

slPopMatrix


Matrix restoration

Form

    #include "sgl.h"

    Bool slPopMatrix (void)

argument

    void --Do not give anything.

Number of returns

    Bool --Returns NG if an error occurs and OK if successful.

function

    Returns one pointer on the matrix stack.
If it is returned too much, an error will be returned.

Example

    The matrix saved in the current matrix is restored and reused.
slPushMatrix (); <-(A) { slTranslate (..); :: } slPopMatrix (); <-(B) At the time of (B), the current matrix is in the same state as (A).

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr
 MatrixCount 



ListReference

function

slDecMatrixPtr


Matrix restoration

Form

    #include "sgl.h"

    Bool slDecMatrixPtr (void)

argument

    void --Do not give anything.

Number of returns

    Bool --Returns NG if an error occurs and OK if successful.

function

    Returns one pointer on the matrix stack.
If it is returned too much, an error will be returned.

Example

    Return one pointer to the matrix stack and check if stack underflow is occurring.
if ( slDecMatrixPtr () == NG ) { / * Stack underflow. * / } else { / * Stack safty. * / } slPushMatrix (); { :: } slDecMatrixPtr ();

caution


    This function has the same function as slPopMatrix.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr
 MatrixCount 



ListReference

function

slUnitMatrix


Make the matrix an identity matrix

Form

    #include "sgl.h"

    MATRIX * mtptr;

    void slUnitMatrix (mtptr)

argument

    MATRIX * mtptr-Pointer to the MATRIX data type that represents the matrix you want to be the identity matrix

Number of returns

    void --Nothing is returned.

function

    Makes the specified matrix an identity matrix. If CURRENT is specified for the matrix, the current matrix of the matrix stack is targeted.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slUnitAngle


Unitize the rotation components of the matrix

Form

    #include "sgl.h"

    MATRIX * mtptr;

    void slUnitAngle (mtptr)

argument

    MATRIX * mtptr-Pointer to the MATRIX data type that represents the matrix you want to unitize

Number of returns

    void --Nothing is returned.

function

    Make the rotating part (3 × 3) of the matrix an identity matrix. The translation part is not changed.
If CURRENT is specified for the matrix, the current matrix will be changed.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slUnitTranslate


Set the translation component of the matrix to 0

Form

    #include "sgl.h"

    MATRIX * mtptr;

    void slUnitTranslate (mtptr)

argument

    MATRIX * mtptr --A pointer to the MATRIX data type that represents the matrix for which you want the parallel component to be zero.

Number of returns

    void --Nothing is returned.

function

    Set the parallel movement part of the matrix to 0. The rotating part does not change.
If CURRENT is specified for the matrix, the current matrix will be changed.

Example

    Set the translation component of the matrix to 0.
MATRIX matr :: slUnitTranslate (& matr);

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slLoadMatrix


Copy to current matrix

Form

    #include "sgl.h"

    MATRIX * mtptr;

    void slLoadMatrix (mtptr)

argument

    MATRIX * mtptr --A pointer to the MATRIX data type that indicates the matrix you want to copy to the current matrix.

Number of returns

    void --Nothing is returned.

function

    Copies the specified matrix to the current matrix.

Example

    Copy the contents of the specified matrix to the current matrix.
MATRIX matr = { :: }; slPushMatrix (); { slLoadMatrix (& matr); slRotX (...); :: } slPopMatrix ();

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slCopyMatrix


Copy to current matrix

Form

    #include "sgl.h"

    Bool slCopyMatrix (void)

argument

    void --Do not give anything.

Number of returns

    Bool --Returns NG if an error occurs and OK if successful.

function

    Copy the previous matrix to the current matrix.
Returns an error if the matrix is not nested.

Example

    Put the contents of the matrix stack on the current matrix and decrement the pointer on the matrix stack by one.
: <-(A) slPushMatrix (); {<-(B) slTranslate (..); :: slCopyMatrix (); <-(C) } slPopMatrix (); : <-(D) At the time of (C), the current matrix is in the same state as (A).
However, since the pointer of the matrix stack is not manipulated, the state of the matrix stack at the time of (C) is the same as that of (B) and not the same as that of (A). Starting at the time of (D), It will be in the same state as (A).

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slRegistMatrix


New matrix buffer registration

Form

    #include "sgl.h"

    MATRIX * mtptr;

    void slRegistMatrix (mtptr)

argument

    MATRIX * mtptr --A pointer to the MATRIX data type that represents the matrix you want to register on the matrix stack.

Number of returns

    void --Nothing is returned.

function

    Copies the specified matrix to the matrix buffer.
If CURRENT is specified for the matrix, the current matrix of the matrix stack is targeted.

Example

    Register the specified matrix on the matrix stack.
MATRIX matr; :: slRegistMatrix (& matr);

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr
 MatrixCount 



ListReference

function

slGetMatrix


Copy of current matrix

Form

    #include "sgl.h"

    MATRIX * mtptr;

    void slGetMatrix (mtptr)

argument

    MATRIX * mtptr --A pointer to MATRIX type data that copies the contents of the current matrix.

Number of returns

    void --Nothing is returned. (However, the result of processing is reflected in the MATRIX data indicated by the argument mtptr.)

function

    Copies the current matrix to the specified matrix.

Example

    Copy the contents of the current matrix to another location.
MATRIX * matr; slGetMatrix (matr); The contents of the current matrix are copied to matr.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr
 MatrixCount 



ListReference

function

slGetTranslate


Extraction of translation components from the current matrix

Form

    #include "sgl.h"

    FIXED pos [ XYZ ]

    void slGetTranslate (pos)

argument

    FIXED pos [ XYZ ] --A pointer to a FIXED type array that stores the extracted parallel components.

Number of returns

    void --Nothing is returned. (However, the result of processing is reflected in the FIXED type data indicated by the argument pos.)

function

    Extracts the translation component from the current matrix and copies it to the specified buffer.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slLoadTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slMultiMatrix
 slTranslate
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slLoadTranslate


Translation component update

Form

    #include "sgl.h"

    FIXED x_dif, y_dif, z_dif;

    void slLoadTranslate (x_dif, y_dif, z_dif)

argument

    FIXED x_dif --The X value of the translation component.
FIXED y_dif --The Y value of the translation component.
FIXED z_dif --Z value of the translation component.

Number of returns

    void --Nothing is returned.

function

    Updates only the translated part of the current matrix.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slInversMatrix
 slTransposeMatrix
 slRegistTranslate
 slTranslate
 slMultiMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slInversMatrix


Make the current matrix inverse

Form

    #include "sgl.h"

    void slInversMatrix (void)

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    Make the current matrix inverse.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slTransposeMatrix
 slRegistTranslate
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slTransposeMatrix


Make the current matrix a transposed matrix

Form

    #include "sgl.h"

    void slTransposeMatrix (void)

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    Makes the current matrix a transposed matrix.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slRegistTranslate
 slScrMatConv
 slScrMatSet
 mtptr 


★ Affine transformation



ListReference

function

slRotX


Perform X-axis rotation transformation on the current matrix

Form

    #include "sgl.h"

    ANGLE angx;

    void slRotX (angx)

argument

    ANGLE angx --Rotation angle

Number of returns

    void --Nothing is returned.

function

    Multiply the current matrix by the rotation matrix around the X axis.
The rotation matrix is 1.0 0.0 0.0 0.0 0.0 cos Θ sin Θ 0.0 0.0 -sin Θ cos Θ 0.0 0.0 0.0 0.0 1.0

reference

 slRotXSC
 slRotY
 slRotYSC
 slRotZ
 slRotZSC
 slRotAX
 slZrotR
 mtptr 



ListReference

function

slRotXSC


Perform X-axis rotation transformation on the current matrix

Form

    #include "sgl.h"

    FIXED sin;
    FIXED cos;

    void slRotXSC (sin, cos)

argument

    FIXED sin --The value of sin given during rotational transformation.
FIXED cos-The value of cos given during rotational transformation.

Number of returns

    void --Nothing is returned.

function

    Specify the sine and cosine to rotate around the X axis.
1.0 0.0 0.0 0.0 0.0 cos sin 0.0 0.0 -sin cos 0.0 0.0 0.0 0.0 1.0

reference

 slRotX
 slRotY
 slRotYSC
 slRotZ
 slRotZSC
 slRotAX
 slZrotR
 mtptr 



ListReference

function

slRotY


Perform X-axis rotation transformation on the current matrix

Form

    #include "sgl.h"

    ANGLE angy;

    void slRotY (angy)

argument

    ANGLE angy --Rotation angle

Number of returns

    void --Nothing is returned.

function

    Multiply the current matrix by the rotation matrix around the Y axis.
cosΘ 0.0 -sinΘ 0.0 0.0 1.0 0.0 0.0 sinΘ 0.0 cosΘ 0.0 0.0 0.0 0.0 1.0

reference

 slRotX
 slRotXSC
 slRotYSC
 slRotZ
 slRotZSC
 slRotAX
 slZrotR
 mtptr 



ListReference

function

slRotYSC


Perform X-axis rotation transformation on the current matrix

Form

    #include "sgl.h"

    FIXED sin;
    FIXED cos;

    void slRotYSC (sin, cos)

argument

    FIXED sin --The value of sin given during rotational transformation.
FIXED cos-The value of cos given during rotational transformation.

Number of returns

    void --Nothing is returned.

function

    Specify the sine and cosine to rotate around the Y axis.
cos 0.0 -sin 0.0 0.0 1.0 0.0 0.0 sin 0.0 cos 0.0 0.0 0.0 0.0 1.0

reference

 slRotX
 slRotXSC
 slRotY
 slRotZ
 slRotZSC
 slRotAX
 slZrotR
 mtptr 



ListReference

function

slRotZ


Perform Z-axis rotation transformation on the current matrix

Form

    #include "sgl.h"

    ANGLE angz;

    void slRotZ (angz)

argument

    ANGLE angz --Rotation angle

Number of returns

    void --Nothing is returned.

function

    Multiply the current matrix by the rotation matrix around the Z axis.
cos Θ sin Θ 0.0 0.0 -sin Θ cos Θ 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0

reference

 slRotX
 slRotXSC
 slRotY
 slRotYSC
 slRotZSC
 slRotAX
 slZrotR
 mtptr 



ListReference

function

slRotZSC


Perform Z-axis rotation transformation on the current matrix

Form

    #include "sgl.h"

    FIXED sin;
    FIXED cos;

    void slRotZSC ( FIXED sin, FIXED cos)

argument

    FIXED sin --The value of sin given during rotational transformation.
FIXED cos-The value of cos given during rotational transformation.

Number of returns

    void --Nothing is returned.

function

    Specify the sine and cosine to rotate around the Z axis.
cos sin 0.0 0.0 -sin cos 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0

reference

 slRotX
 slRotXSC
 slRotY
 slRotYSC
 slRotZ
 slRotAX
 slZrotR
 mtptr 



ListReference

function

slRotAX


Perform rotation transformation around an arbitrary axis on the current matrix

Form

    #include "sgl.h"

    FIXED vecx, vecy, vecz;
    ANGLE ang;

    void slRotAX (vecx, vecy, vecz, ang)

argument

    FIXED vecx - X component of the vector representing the rotation axis FIXED vecy - Y component of the vector representing the rotation axis FIXED Vecz - Z components of the vector representing the rotation axis ANGLE ang - rotation angle

Number of returns

    void --Nothing is returned.

function

    Rotate around an arbitrary axis passing through the origin. The axis is specified by the unit vector.
NxNx (1-C) + C NxNy (1-C) + NzS NxNz (1-C)-NyS 0.0 NyNx (1-C)-NzS NyNy (1-C) + C NyNz (1-C) + NxS 0.0 NzNx (1-C) + NyS NzNy (1-C)-NxS NzNz (1-C) + C 0.0 0.0 0.0 0.0 1.0 Nx, Ny, and Nz are components of the unit vector that represents the axis.
C stands for cosine and S stands for sine.

reference

 slRotX
 slRotXSC
 slRotY
 slRotYSC
 slRotZ
 slRotZSC
 slZrotR
 mtptr 



ListReference

function

slTranslate


Translate the current matrix

Form

    #include "sgl.h"

    FIXED x_dif, y_dif, z_di; f

    void slTranslate (x_dif, y_dif, z_dif)

argument

    FIXED X_dif - translation X component FIXED Y_dif - translation of the Y component FIXED Z_dif - Z component of the translation

Number of returns

    void --Nothing is returned.

function

    Translates the current matrix.
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 tx ty tz 1.0

reference

 slGetTranslate
 slRegistTranslate
 mtptr 



ListReference

function

slRegistTranslate


Take the matrix out of the matrix buffer and translate it

Form

    #include "sgl.h"

    FIXED x_dif, y_dif, z_di; f

    void slRegistTranslate (x_dif, y_dif, z_dif)

argument

    FIXED X_dif - translation X component FIXED Y_dif - translation of the Y component FIXED Z_dif - Z component of the translation

Number of returns

    void --Nothing is returned.

function

    Copies the translated translation of the matrix buffer into the current matrix. However, the matrix buffer does not change.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slScrMatConv
 slScrMatSet
 mtptr 



ListReference

function

slScale


Perform scale conversion on the current matrix

Form

    #include "sgl.h"

    FIXED scl_x, scl_y, scl_z;

    void slScale ( FIXED scl_x, FIXED scl_y, FIXED scl_z)

argument

    FIXED scl_x --Scale value in the X direction.
FIXED scl_y --Scale value in the Y direction.
FIXED scl_z --Scale value in the Z direction.

Number of returns

    void --Nothing is returned.

function

    Scale with respect to the current matrix.
scl_x 0.0 0.0 0.0 0.0 scl_y 0.0 0.0 0.0 0.0 scl_z 0.0 0.0 0.0 0.0 1.0

reference

 mtptr 



ListReference

function

slMultiMatrix


Multiply the current matrix by the matrix

Form

    #include "sgl.h"

    MATRIX mtrx

    void slMultiMatrix (mtrx)

argument

    MATRIX mtrx --The matrix you want to multiply by the current matrix.

Number of returns

    void --Nothing is returned.

function

    Multiplies the current matrix by the specified matrix.

reference

 slInitMatrix
 slPushMatrix
 slPushUnitMatrix
 slIncMatrixPtr
 slPopMatrix
 slDecMatrixPtr
 slUnitMatrix
 slUnitAngle
 slUnitTranslate
 slLoadMatrix
 slCopyMatrix
 slRegistMatrix
 slGetMatrix
 slGetTranslate
 slLoadTranslate
 slInversMatrix
 slRegistTranslate
 slScrMatConv
 slScrMatSet
 mtptr 


★ Viewpoint operation



ListReference

function

slLookAt


Viewpoint transformation for the current matrix

Form

    #include "sgl.h"

    FIXED camera [ XYZ ];
    FIXED target [ XYZ ];
    ANGLE angz;

    void slLookAt (camera, target, angz)

argument

    FIXED camera [ XYZ ] --Camera (viewpoint position)
    FIXED target [ XYZ ] --A vector that represents the direction of the line of sight.
ANGLE angz --Rotating component with respect to the line-of-sight direction.

Number of returns

    void --Nothing is returned.

function

    Multiply the current matrix by the matrix that looks in the target direction from the camera position.
At that time, it also rotates around the Z axis.

caution


    In the direction along the Y axis, the vector on the XZ plane becomes small and may not be calculated correctly.

reference

 mtptr 


★ Vector calculation



ListReference

function

slCheckOnScreen


Determine if the specified sphere is displayed on the screen

Form

    #include "sgl.h"

    FIXED obj [ XYZ ];
    FIXED size;

    FIXED slCheckOnScreen (obj, size)

argument

    FIXED obj [ XYZ ] --The position of the object. 
    FIXED size-The radius of the object.

Number of returns

    Z position of the FIXED object. When off the screen, a negative number is returned.

function

    Converts the position of the specified object through the current matrix
    Tests if an object of the specified size is displayed on the screen at that position and returns the result.
Returns -1 (FFFFFFFF) if it is in front of the screen, -2 (FFFFFFFE) if it is up, down, left or right, and Z position if it is in the screen.

Example

    if ( slCheckOnScreen (obj, obj_size) < toFIXED (0.0)) {
      / * Do not draw because it is not displayed on the screen. * /
    } else {
      slPutPolygonX (...);
    }

reference

 slCheckOnScreen0
 slConvert3Dto2DFX
 slConvert3Dto2D
 mtptr 



ListReference

function

slCheckOnScreen0


Determine if the sphere at the origin is displayed in that size

Form

    #include "sgl.h"

    FIXED size [ XYZ ];

    FIXED slCheckOnScreen0 (size)

argument

    FIXED size-The radius of the object.

Number of returns

    Z position of the FIXED object. When off the screen, a negative number is returned.

function

    Tests if the object at position (0,0,0) is displayed on the screen with the specified size and returns the result.
Returns -1 (FFFFFFFF) if it is in front of the screen, -2 (FFFFFFFE) if it is up, down, left or right, and Z position if it is in the screen.

reference

 slCheckOnScreen
 slConvert3Dto2DFX
 slConvert3Dto2D
 mtptr 



ListReference

function

slCalcPoint


Coordinate transformation of the specified point with the current matrix

Form

    #include "sgl.h"

    FIXED pos_x, pos_y, pos_z;
    FIXED ans [ XYZ ];

    void slCalcPoint (pos_x, pos_y, pos_z, ans)

argument

    FIXED pos_x, pos_y, pos_z --The point you want to convert with the current matrix.
FIXED ans [ XYZ ] --FIXED type array to store the operation result.

Number of returns

    void --Nothing is returned. (However, the result of the operation is in the ans given as an argument.)

function

    Returns the result of coordinate transformation of the specified point in the current matrix to the buffer.
→ a = (pos_x, pos_y, pos_z) → b = ans When the current matrix is M, →→ b = M · a Is calculated.

Example

    slPushMatrix ();
    {
       slScale (...);
             ::
       slPutPolygonX (...);
       slCalcPoint (...);
    }
    slPopMatrix ();

reference

 mtptr 



ListReference

function

slConvert3Dto2DFX



ListReference

function

slConvert3Dto2D


Conversion from 3D coordinates to screen coordinates

Form

    #include "sgl.h"

    FIXED pos [ XYZ ];
    FIXED ans_fx [ XY ];
    Sint32 ans_si [ XY ];

    FIXED slConvert3Dto2DFX (pos, ans_fx);
    FIXED slConvert3Dto2D (pos, ans_si);

argument

    FIXED pos [ XYZ ] --Coordinates to be converted to screen coordinates (However, the coordinates in the coordinate space given by the current matrix, that is, the relative coordinates.)
    FIXED Ans_si [ XY ] - add the result of the operation FIXED -type sequence.
FIXED Ans_fx [ XY ] - add the result of the operation FIXED -type sequence.

Number of returns

    FIXED The Z position of the given coordinates. (The operation result is returned to ans given to the argument.)

function

    Returns the screen coordinate values ans_fx / ans_si when actually displayed on the screen from the 3D relative coordinate pos using the current matrix. Returns the Z value as a function value.

Example

    Find the screen coordinates of the center position of a model.
FIXED pos [ XYZ ] = { toFIXED (1.0), toFIXED (2.0), toFIXED (3.0)}; FIXED ans [ XY ]; :: slPushMatrix (); { slTranslate ( toFIXED (3.5), toFIXED (6.2), toFIXED (2.1)); slRotX ( debugtoANG (20.0)); slRotY (ang_para_y); slRotZ (ang_para_z); slPutPolygon (...); slConvert3Dto2D (pos, ans); } slPopMatrix ();

reference

 slCheckOnScreen
 slCheckOnScreen0
 mtptr

return
Copyright SEGA ENTERPRISES, LTD., 1997