| |||||||||
|
|
| |||||||
|
| ||||||||
| |||||||||
#include "vg.h" // for the standard Vega classes and defines #include "vgperf.h" // for the Vega Performer node functions #include "pf.h" // for the standard Performer classes #include <pfflt.h> // Flight loader callback structures etc
static void fltDatasetCB(vgCommon *dataset, void *udata){ // ######################################################## // # // # Local Static Function // # // # Dataset pre load class callback used to set up the // # instance callback for the particular dataset // # // ########################################################
vgAddFunc(dataset, VGDS_MGFLTBEAD, flightLoaderBeadCB, udata); }
static void flightLoaderBeadCB( pfNode *node, int beadOpcode, int *beadData, COMMENTcb *comment, void *udata ){ // ################################################################################## // # // # Local Static Function // # // # 'node' is a "parent" node in the scene hierarchy for this bead // # // # 'beadOpcode' is an opcode of the bead // # // # 'beadData' is a pointer to either 1) a callback structure for pre // # defined beads (see pfflt.h that comes with Performer FLT // # loader or 2) it is a pointer to a chunck of memory that // # holds an extension bead data. // # // # // # 'comment' is a pointer to COMMENTcb structure (see pfflt.h) // # // # 'udata' is a pointer to user data. // # // ####################################################################################
// // Check which bean/node type has been passed // switch(beadOpcode){
case CB_DOF: DOFcb *dofData = (DOFcb *)beadData;
if(dofData){ // // Check Dof's comment field // if(comment && (comment->text)) { // // do your stuff // print("Dof Node : %s has the following comment field\n" ,pfGetNodeName());
print(" text : %s \n\n", comment->text ); } }
break;
case CB_GROUP: GROUPcb *grpData = (GROUPcb *)beadData;
if( grpData ){ // // Check Groups comment field // if(comment && (comment->text)) { // // do your stuff // print("Group Node : %s has the following comment field\n" ,pfGetNodeName());
print(" text : %s \n\n", comment->text ); } } break;
case CB_OBJECT: OBJcb *objData = (OBJcb *)beadData;
if(objData ){ // // Check the Objects comment field // if(comment && (comment->text)) { // // do your stuff // print("Object Node : %s has the following comment field\n" ,pfGetNodeName());
print(" text : %s \n\n", comment->text ); } } break;
case CB_HEADER : HEADERcb *hdrData = (HEADERcb*)beadData;
if(objData ){ // // Check the Header comment field // if(comment && (comment->text)) { // // do your stuff // print("Header Node : %s has the following comment field\n" , pfGetNodeName());
print(" text : %s \n\n", comment->text ); } } break;
// // Ignore all the other bead types // default: break; }
}
//////////////////////////////////////////////////////////////////////////// // // // Very simple Vega Program to show how to install an OpenFlight // loader callback, note we need a valid ADF file for this program // // ////////////////////////////////////////////////////////////////////////////
int main( int argc, char *argv[] ){
if ( argc < 2 ) { printf ( "syntax : %s <config file>\n" , argv[0] ); exit ( -1 ); }
vgInitSys( );
vgDefineSys( argv[1] );
// // Note the Call-back has to be installed after vgInitSys and before // vgConfigSys() other wise we will missed any flight files in // contained in the ADF file //
// Install a callback on the DataLoader which is were the Flight files // are actually loaded with vega. So that for every time a new OpenFlight // bead/node is processed the flightLoaderBeadCB callback will be called // the last parameter is user data that is passed through, here we are // not using it but we could pass a vgList and store all the comments etc // vgAddClassFunc( VGTYPE_DATASET, VGDS_PREFLTLOAD, fltDatasetCB, NULL );
vgConfigSys();
while( true ) {
vgSyncFrame ();
vgFrame ();
}
return 0; }
|
|
© Copyright 2004 Gordon Tomlinson All Rights Reserved. All logos, trademarks and copyrights in this site are property of their respective owner |
.