How to find a named Switch node in a vgObject

 

Vega Code Example

 

 

 

 

 

 
 

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

 

Note that the pfFindNode function is case sensitive.

 

Also you should be aware that if the vgObject 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*
findNamedSwitchNodeInVgObject( vgObject *obj, const char *swName ) {
// #################################################################
// # Public Function
// #
// # Attempts to find the named Performer Switch Node/Bead
// # within the passed vgObject
// #
// # return a pointer to the performer pfSwitch node if found
// #
// # return NULL otherwise
// #
// #################################################################

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

    //
    // Sanity check we need an Object
    //

   
 if( obj == NULL )
       
 return NULL;

    //
    // Retrieve the Object root pfNode
    //
    node = vgGetObjectPfNode( obj );
   
 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;

}
// findNamedSwitchNodeInVgObject

 

 
 

 

 

Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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