How to find a Named Switch Node in a vgPart

 

Vega Code Example

 

 

 

 

 

 
 

This example function illustrates how to fined a named Performer  Switch Node pfSwitch node that is part of the given vgPart.

 

Note that the pfFindNode function is case sensitive.

 

Also you should be aware that if the vgPart is from an OpenFlight file and the node uses the default name; such as sw1  and has not had its position  altered, then the node might get removed during the flatten and clean process done by default after the file is loaded.

 

It is good practice to name all Dof/Lod/Switch nodes or any  node of importance, this practice will save you time when debugging

 

 
   
 

 

 
 
 
 

 

#include "vg.h"          // Required for the standard Vega classes
#include "vgperf.h"      // Required for the vgGetXXXPfNode functions
#include "pf.h"          // Required for the standard Performer classes
#include "vgutil.h"
#include "pfutil.h"      // Required for pfFindNode


pfSwitch*
findNamedSwitchNodeInVgPart( vgPart  *part, const  char  *swName ) {
// #################################################################
// # Public Function
// #
// # Attempts to find the named Performer Switch Node/Bead
// # within the passed vgPart
// #
// # return a pointer to the performer pfSwitch node if found
// #
// # return NULL otherwise
// #
// #################################################################

pfSwitch  *swNode = NULL;
pfNode    *node    = NULL;

    //
    // Sanity check we need an part
    //

   
 if( part == NULL )
       
 return NULL;

    //
    // Retrieve the Parts root pfNode
    //
    node = vgGetPartPfNode( part );
   
 if( node == NULL )
      
 return NULL;

    //
    // Find the Named Switch node in the performer tree
    // Note the name search is case sensitive
    //


   swNode = (
pfSwitch *)pfFindNode( node, swName, pfGetSwitchClassType());

return swNode;

}
// findNamedSwitchNodeInVgPart

 

 
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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