N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

## gSPBranchLessZ

Syntax

    #include <ultra64.h>  /* gbi.h */
    gSPBranchLessZ(
            Gfx *gdl,
            Gfx *branchdl,
            u32 vtx,
            f32 zval,
            f32 near,
            f32 far,
            s32 flag)
    gsSPBranchLessZ(
            Gfx *branchdl,
            u32 vtx,
            f32 zval,
            f32 near,
            f32 far,
            s32 flag)

Arguments

- gdl is the display list pointer.

- branchdl is the pointer to the display list branch.

- vtx is the vertex (index in the vertex buffer).

- zval is the Z value which becomes the branch condition.

- near is the location of the near plane (a value specified by either guPerspective or guOrtho).

- far is the location of the far plane (a value specified by either guPerspective or guOrtho).

- flag is the projection method:
  G_BZ_PERSP (Perspective projection).
  G_BZ_ORTHO (Orthogonal projection).

Explanation
Conditionally branches the display list. When the depth value of the vertex specified by vtx is less than or equal to zval, the display list is branched to the display list indicated by branchdl. When it is more than zval, nothing is done. This provides an easy way to perform LOD processing on a model.

Note
This macro assumes that the values of the two viewport Z-direction arguments vp.vscale[2] and vp.vtrans[2] (see g*SPViewport) are both G_MAXZ/2. When this is the case, the depth value is greater than 0 and less than G_MAXZ. Normally the depth value does not need to be changed in an application. However, if you are going to change this value, please use the g*SPBranchLessZrg macro.

Example
The following is an example of a model with 3-level LOD:

    Gfx model_near[ ] = {
    // Model's distance less than or equal to 200.
     .......
    	gsSPEndDisplayList( ),
    };
    Gfx model_mid[ ] = {
    // Model's distance between 201 and 800.
     .......
    	gsSPEndDisplayList( ),
    };
    Gfx model_far[ ] = {
    // Model's distance between 801 and 1600.
     .......
    	gsSPEndDisplayList( ),
    };
    Gfx model[ ] = {
    	gsSPVertex(testvtx, 1, 0),
    	gsSPBranchLessZ(model_near, 0,  200, 32, 2000, G_BZ_PERSP),// Model's distance less than or equal to 200.
    gsSPBranchLessZ(model_mid,  0,  800, 32, 2000, G_BZ_PERSP),// Model's distance between 201 and 800.
    	gsSPBranchLessZ(model_far,  0, 1600, 32, 2000, G_BZ_PERSP),// Model's distance between 801 and 1600.
    	gsSPEndDisplayList( ), // Model's distance greater than 1600.
    };

See also
gSPBranchLessZrg

Revision History
2/1/1999 Completely rewritten.

Nintendo® Confidential Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.
Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated March 1999