This  example function illustrates how to restructure  Performer pfSwitch node

Use findNamedSwitchNodeInVgObject to find a pfSwitch instance

The function shows how to restructure the pfSwitch node so that the pfGroup node that the MultiGen OpenFlight loader inserts '_MgSwitchGroup' underneath a pfSwitch node is removed

This node controls the Masks that Creator uses to allow multiple nodes to be on under a pfSwitch.

By removing this pfGroup the pfSwitch will behave as you would expect when using pfSwitchVal to set the visible node. That is to switch to the N'th child rather than to the N'th mask

See MultiGen-Paradigm Creator online help for more information on masks

 

 
   
 

 

 
 
 
 

 

#include "vg.h"          // Required for the standard Vega classes
#include "pf.h"          // Required for the standard Performer classes

 

void
restructureSwitch
( pfSwitch *swNode ){
// #####################################################################

// #

// #  Public function

// #

// #   This function restructures the passed pfSwitch node so that

// #  the node that the MultiGen loader inserts _MgSwitchGroup

// #  underneath a switch node is removed, this removes the

// #  the Creator masking node. This means that the switch will

// #  behave as expected when using pfSwitchVal for the child nodes,

// #

// #  That is switch to the N'th child rather than to the N'th mask

// #

// #  See MultiGen-Paradigm Creator online help for more information on masks

// #

// #####################################################################

 

 

    //

    // Sanity check we need a pointer

    //

    if(swNode ){

 

    //

    //  No need really if only one or no children

    //

    if( pfGetNumChildren( swNode ) < 2){

 

        pfGroup *mgGroup = (pfGroup *)pfGetChild( swNode, 0 );

 

        //

        // Detatch the group from the Switch

        //

        pfRemoveChild( swNode, mgGroup );

 

        //

        //  Attach each child of the detached group to the switch

        //  

        int num = pfGetNumChildren( mgGroup );

 

        for( int child = 0; child < num ; child++ ){

 

            pfAddChild( swNode, pfGetChild( mgGroup, child ));

 

            }

 

        //

        // Delete the MultiGen loader group

        //

        pfUnrefDelete( mgGroup );

 

        }

 

    

} // restructureSwitch

 

 

 
 

 

 

Copyright 2004 Gordon Tomlinson  All Rights Reserved.

All logos, trademarks and copyrights in this site are property of their respective owner.