Japanese

★Matrix operation



ListReference

function

slInitMatrix


Matrix initialization

Format

    #include "sgl.h"

    void slInitMatrix( void )

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Initializing variables and buffers used in matrix operations

example

    Initialize 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 the matrix

Format

    #include "sgl.h"

    Bool slPushMatrix( void )

argument

    void - gives nothing.

Return number

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

function

Advances the matrix stack pointer and copies the current matrix to it.
Up to 20 matrices can be nested, but an error will be returned if this is exceeded.

example

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

Note

This function is used when building a model that stores 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 the matrix

Format

    #include "sgl.h"

    Bool slPushUnitMatrix( void )

argument

    void - gives nothing.

Return number

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

function

Advances the matrix stack pointer and sets the identity matrix there.
Returns an error if nested too much.

example

    Save the unit matrix to 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 the matrix one stack

Format

    #include "sgl.h"

    Bool slIncMatrixPtr( void )

argument

    void - gives nothing.

Return number

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

function

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

example

    Advance the matrix stack pointer by one and check whether a stack overflow has occurred.
if ( slIncMatrixPtr () == NG ) { /* Stack Overflow. */ } else { /* Stack safety. */ }

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


Restoring the matrix

Format

    #include "sgl.h"

    Bool slPopMatrix( void )

argument

    void - gives nothing.

Return number

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

function

Returns one pointer to the matrix stack.
If it goes back too much, it returns an error.

example

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

reference

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



ListReference

function

slDecMatrixPtr


Matrix restoration

Format

    #include "sgl.h"

    Bool slDecMatrixPtr( void )

argument

    void - gives nothing.

Return number

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

function

Returns one pointer to the matrix stack.
If it goes back too much, it returns an error.

example

    Return one pointer to the matrix stack and check whether a stack underflow has occurred.
if ( slDecMatrixPtr () == NG ) { /* Stack underflow. */ } else { /* Stack safety. */ } slPushMatrix (); { : } slDecMatrixPtr ();

Note

This is a function with the same functionality as slPopMatrix .

reference

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



ListReference

function

slUnitMatrix


Make a matrix an identity matrix

Format

    #include "sgl.h"

    MATRIX *mtptr;

    void slUnitMatrix( mtptr )

argument

    MATRIX *mtptr - pointer to the MATRIX data type representing the matrix you want to be the identity matrix

Return number

    void - returns nothing.

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 rotational components of the matrix

Format

    #include "sgl.h"

    MATRIX *mtptr;

    void slUnitAngle( mtptr )

argument

    MATRIX *mtptr - pointer to the MATRIX data type representing the matrix you want to unitize

Return number

    void - returns nothing.

function

Make the rotated part (3×3) of the matrix into a unit matrix. The parallel movement part will not be 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 parallel component of the matrix to 0

Format

    #include "sgl.h"

    MATRIX *mtptr;

    void slUnitTranslate( mtptr )

argument

    MATRIX *mtptr - Pointer to the MATRIX data type representing the matrix whose parallel components you want to zero out.

Return number

    void - returns nothing.

function

Set the parallel translation part of the matrix to 0. The rotating part remains unchanged.
If CURRENT is specified for the matrix, the current matrix will be changed.

example

    Set the parallel 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

Format

    #include "sgl.h"

    MATRIX *mtptr;

    void slLoadMatrix( mtptr )

argument

    MATRIX *mtptr - Pointer to MATRIX data type indicating the matrix you want to copy to the current matrix.

Return number

    void - returns nothing.

function

Copies the specified matrix to the current matrix.

example

    Copies 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

Format

    #include "sgl.h"

    Bool slCopyMatrix( void )

argument

    void - gives nothing.

Return number

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

function

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

example

    Puts the contents of the matrix stack into the current matrix and decrements the matrix stack pointer by one.
: <-- (A) slPushMatrix (); { <-- (B) slTranslate ( .. ); : slCopyMatrix (); <-- (C) } slPopMatrix (); : <-- (D) At point (C), the current matrix is in the same state as (A).
However, since the matrix stack pointer is not manipulated, the state of the matrix stack at the time of (C) is the same as that of (B), but not the same as that of (A). Starting at point (D), The situation will be the same as in (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


Register new matrix buffer

Format

    #include "sgl.h"

    MATRIX *mtptr;

    void slRegistMatrix( mtptr )

argument

    MATRIX *mtptr - Pointer to the MATRIX data type representing the matrix you want to register on the matrix stack.

Return number

    void - returns nothing.

function

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

example

    Registers the specified matrix to 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


Copying the current matrix

Format

    #include "sgl.h"

    MATRIX *mtptr;

    void slGetMatrix( mtptr )

argument

    MATRIX *mtptr - Pointer to MATRIX type data to copy the contents of the current matrix.

Return number

    void - returns nothing. (However, the processing results are 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
 Matrix Count 



ListReference

function

slGetTranslate


Extracting the parallel component from the current matrix

Format

    #include "sgl.h"

    FIXED pos[ XYZ ]

    void slGetTranslate( pos )

argument

    FIXED pos[ XYZ ] - Pointer to FIXED type array to store retrieved parallel components.

Return number

    void - returns nothing. (However, the processing result 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


Update translation component

Format

    #include "sgl.h"

    FIXED x_dif, y_dif, z_dif;

    void slLoadTranslate( x_dif, y_dif, z_dif )

argument

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

Return number

    void - returns nothing.

function

Updates only the parallel portion 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


Invert the current matrix

Format

    #include "sgl.h"

    void slInversMatrix( void )

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Inverse the current matrix.

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

Format

    #include "sgl.h"

    void slTransposeMatrix( void )

argument

    void - gives nothing.

Return number

    void - returns nothing.

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


Apply rotational transformation on the X axis to the current matrix

Format

    #include "sgl.h"

    ANGLE angx;

    void slRotX( angx )

argument

    ANGLE angx - rotation angle

Return number

    void - returns nothing.

function

Multiplies 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


Apply rotational transformation on the X axis to the current matrix

Format

    #include "sgl.h"

    FIXED sin;
    FIXED cos;

    void slRotXSC( sin, cos )

argument

    FIXED sin - value of sin to give during rotation transformation.
FIXED cos - Cos value given during rotation transformation.

Return number

    void - returns nothing.

function

Rotate around the X axis by specifying sine and cosine.
         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


Apply rotational transformation on the X axis to the current matrix

Format

    #include "sgl.h"

    ANGLE Angy;

    void slRotY(angy)

argument

    ANGLE angy - rotation angle

Return number

    void - returns nothing.

function

Multiplies 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


Apply rotational transformation on the X axis to the current matrix

Format

    #include "sgl.h"

    FIXED sin;
    FIXED cos;

    void slRotYSC( sin, cos )

argument

    FIXED sin - value of sin to give during rotation transformation.
FIXED cos - Cos value given during rotation transformation.

Return number

    void - returns nothing.

function

Specify 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


Apply Z-axis rotation transformation to the current matrix

Format

    #include "sgl.h"

    ANGLE angz;

    void slRotZ( angz )

argument

    ANGLE angz - rotation angle

Return number

    void - returns nothing.

function

Multiplies 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


Apply Z-axis rotation transformation to the current matrix

Format

    #include "sgl.h"

    FIXED sin;
    FIXED cos;

    void slRotZSC( FIXED sin , FIXED cos )

argument

    FIXED sin - value of sin to give during rotation transformation.
FIXED cos - Cos value given during rotation transformation.

Return number

    void - returns nothing.

function

Specify 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


Apply rotational transformation around an arbitrary axis to the current matrix

Format

    #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 component of the vector representing the rotation axis
ANGLE ang - Rotation angle

Return number

    void - returns nothing.

function

Rotate around an arbitrary axis passing through the origin. Axes are specified as unit vectors.
        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, Nz are the components of the unit vector representing the axis.
C stands for cosine and S stands for sine.

reference

 slRotX
 slRotXSC
 slRotY
 slRotYSC
 slRotZ
 slRotZSC
 slZrotR
 mtptr 



ListReference

function

slTranslate


Apply a translation transformation to the current matrix

Format

    #include "sgl.h"

    FIXED x_dif, y_dif, z_di;f

    void slTranslate( x_dif, y_dif, z_dif )

argument

    FIXED x_dif - X component of translation
FIXED y_dif - Y component of translation
FIXED z_dif - Z component of translation

Return number

    void - returns nothing.

function

Performs parallel movement on 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 out the matrix from the matrix buffer and move it in parallel

Format

    #include "sgl.h"

    FIXED x_dif, y_dif, z_di;f

    void slRegistTranslate( x_dif, y_dif, z_dif )

argument

    FIXED x_dif - X component of translation
FIXED y_dif - Y component of translation
FIXED z_dif - Z component of translation

Return number

    void - returns nothing.

function

Copies the parallel movement of the matrix buffer to the current matrix. However, the matrix buffer remains unchanged.

reference

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



ListReference

function

slScale


Apply scale transformation to current matrix

Format

    #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 Y direction.
FIXED scl_z - Scale value in Z direction.

Return number

    void - returns nothing.

function

Scales against 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 current matrix by matrix

Format

    #include "sgl.h"

    MATRIX mtrx

    void slMultiMatrix( mtrx )

argument

    MATRIX mtrx - Matrix to be applied to the current matrix.

Return number

    void - returns nothing.

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 current matrix

Format

    #include "sgl.h"

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

    void slLookAt( camera, target, angz )

argument

    FIXED camera[ XYZ ] - Camera (view position)
    FIXED target[ XYZ ] - A vector representing the viewing direction.
ANGLE angz - Rotational component relative to viewing direction.

Return number

    void - returns nothing.

function

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

Note

In a 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 whether the specified ball is displayed on the screen

Format

    #include "sgl.h"

    FIXED obj[ XYZ ];
    FIXED size;

    FIXED slCheckOnScreen( obj, size )

argument

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

Return number

    FIXED Z position of object. Returns a negative number when off-screen.

function

Transforms the position of the specified object through the current matrix, Tests whether an object of the specified size is visible on the screen at that location and returns the result.
Returns -1 (FFFFFFFF) if it is in front of the screen, -2 (FFFFFFFE) if it is above, below, left or right, and returns the Z position if it is within the screen.

example

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

reference

 slCheckOnScreen0
 slConvert3Dto2DFX
 slConvert3Dto2D
 mtptr 



ListReference

function

slCheckOnScreen0


Determine whether the sphere at the origin is displayed at that size

Format

    #include "sgl.h"

    FIXED size[ XYZ ];

    FIXED slCheckOnScreen0( size )

argument

    FIXED size - radius of the object.

Return number

    FIXED Z position of object. Returns a negative number when off-screen.

function

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

reference

 slCheckOnScreen
 slConvert3Dto2DFX
 slConvert3Dto2D
 mtptr 



ListReference

function

slCalcPoint


Transform the coordinates of the specified point using the current matrix

Format

    #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 - Points you want to transform in the current matrix.
FIXED ans[ XYZ ] - FIXED type array for storing operation results.

Return number

    void - returns nothing. (However, the result of the operation is stored in ans given as an argument.)

function

Returns the result of coordinate transformation of the specified point using the current matrix to the buffer.
    →
    a = (pos_x, pos_y, pos_z)
    →
    b = ans
    When the current matrix is M,
    → →
    b = M・a
    Calculations will be made.

example

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

reference

 mtptr 



ListReference

function

slConvert3Dto2DFX



ListReference

function

slConvert3Dto2D


Conversion from 3D coordinates to screen coordinates

Format

    #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 coordinate values in the coordinate space given by the current matrix are relative coordinates.)
    FIXED ans_si[ XY ] - FIXED type array containing the result of the operation.
FIXED ans_fx[ XY ] - FIXED type array containing the result of the operation.

Return number

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

function

Using the current matrix, returns the screen coordinate values ans_fx/ans_si when actually displayed on the screen from the 3D relative coordinate pos. Returns the Z value as the 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 ( DEGtoANG ( 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