stencilBuffer derived from ygNode Example Source Header

Description: a node that implements stencil buffering

notes:
Category: Attributes
Author: Alex Hill
Revision: 10/02/04

    Messages
scene node set the name of the node to be affected
on turn the stencil buffer on
off [bool] turn the stencil buffer off
depth [bool] use the depth buffer true/false
reverse [bool] reverse the stencil buffer test
    Comments

constructor stencilBuffer

1 allocate shared memorystencilData structure for pre and post callbacks
2 set the pre and post draw traversal functions for stencil writing
3 distribute the off state of the stencil buffer
4 distribute the depth test mode
5 distribute the on/off state of the stencil buffer

destructor ~stencilBuffer

method reset

1 clear the affected node name
2 set the plane to active
3 set the depth mode to true
4 set the reverse mode to false

method message

1 set the name of the node to be affected
1.1 if an affected node is being stenciled then
1.1.1 reset the traversal functions to NULL
1.1.1 find the desired affected node
1.1.2 if node is found then
1.1.2.1 set the pre and post draw traversal functions for affected pfNode
2 turn the stencil buffer on
3 turn the stencil buffer off
4 use the depth buffer true/false
5 reverse the stencil buffer test

method app

0.1 remove clone children
0.2 add clone children

method setStencilNode

method writePreDraw

1 cast the traversal data as the stencilData structure
2 if the plane is active then
2.1 disable writing to the color buffer
2.2 disable writing to the depth buffer
2.3 set stencil function to always fail
2.4 enable stencil testing

method writePostDraw

1 cast the traversal data as the stencilData structure
2 disable writing to the stencil buffer
3 enable writing to the color buffer
4 enable writing to the depth buffer

method stencilPreDraw

1 cast the traversal data as the stencilData structure
2 if the plane is active then
2.1 set stencil function to write when stencil equals 1
2.2 enable stencil testing

method stencilPostDraw

1 cast the traversal data as the stencilData structure
2 disable the stencil testing

method clonePreDraw

1 cast the traversal data as the stencilData structure
2 disable depth testing if necessary
3 disable writing to the color buffer

method clonePostDraw

1 enable writing to the color buffer