clipPlane derived from ygNode | Example | Source | Header |
Messages |
node | node | set the name of the node to be affected |
on | turn the clipping plane on | |
off | [bool] | turn the clipping plane off |
Comments |
method planeNumber
constructor clipPlane
1 allocate shared memory clipData structure for pre and post callbacks
2 increment the plane number used by each clipPlane node (need test for max planes)
3 set the plane number in the shared memory structure
4 distribute the name of the node affected
5 distribute the on/off state of the clipping plane
destructor ~clipPlane
method reset
1 clear the affected node name
2 set the plane to active
3 set the axis to 0,0,1
4 set the distance to 0.0
method message
1 set the name of the node to be affected
2 turn the clipping plane on
3 turn the clipping plane off
method setClipNode
1 if an affected node is being clipped then
1.1 reset the traversal functions to NULL2 find the desired affected node
3 if node is found then
3.1 set the pre and post draw traversal functions for affected pfNode
method app
0.1 get current node transformation
0.2 get the position from the transformation
0.3 transform a unit vector by the transformation
0.4 get the normal by subtracting the position from unit vector
0.5 normalize the normal
0.6 set the plane equation to the three values of the normal vector
0.7 calculate the dot product of the normal and the position vector
0.8 set the distance to the plane equal to the dot product
method clipPreDraw
1 cast the traversal data as the clipData structure
2 if the plane is active then
2.1 construct an array of size 4
2.2 set array to hold plane equation
2.3 enable clipping plane indicated by plane number
2.4 call glClipPlane to set the plane equation
method clipPostDraw
1 cast the traversal data as the clipData structure
2 disable the clipping plane indicated by plane number