| |||||||||
| 
             
  | 
             
  | 
             
  | |||||||
| 
             
  | 
            
  | ||||||||
| 
             
  | |||||||||
| 
                     
 #include "vg.h"           // Required for the standard Vega classes
 // // Declare the Pre and Post Node Draw as STATIC these have to be static // // 
 
 static int highlightPreDrawTravFunc ( pfTraverser *trav, void *data ); static int highlightPostDrawTravFunc ( pfTraverser *trav, void *data ); static int remhighlightPostDrawTravFuncFIX( pfTraverser *trav, void *data); 
 pfHighlight* createHighlight( const float r ,const float g ,const float b ,const unsigned int fill ); 
 void remHighlightFromVegaObject( vgObject *object ); void setHighlightOnVegaObject ( vgObject *object ); 
 
 
 
 pfHighlight* createHighlight( const float r ,const float g ,const float b ,const unsigned int fill ) { // #################################################### // # Public function // # // # Create a and return a new pfHighlight instance // # // # Note it is upto the caller to manage the deletion // # of this instance // # // #################################################### 
 
 // // create the new blank highlight instance // pfHighlight *hlight = pfNewHlight( vgGetSharedArena()); 
 
 // Set the fill/ out line mode for the highlight // // The following are possible high style note thatsome may not supported // on all platforms, also note that the style can be or'd together // to form combinations of high lights // // See the Performer PGuide and man pages for further details // // // PFHL_LINES PFHL_LINES_R // PFHL_LINESPAT PFHL_LINESPAT2 // PFHL_LINESMASK PFHL_FILL // PFHL_FILLPAT PFHL_FILLPAT2 // PFHL_FILLTEX PFHL_FILL_R // PFHL_FILLMASK PFHL_SKIP_BASE // PFHL_POINTS PFHL_NORMALS // PFHL_BBOX_LINES PFHL_BBOX_FILL // // pfHlightMode( hlight, fill ) ; 
 // // Set the forground and background color for the highlight // pfHlightColor( hlight, PFHL_FGCOLOR, r, g, b ); pfHlightColor( hlight, PFHL_BGCOLOR, r, g, b ); 
 // // Set the alpha to opaque as transparent is not supported // on many systems // pfHlightAlpha( hlight, 1.0f ); 
 
 // // Set the line width for line styles // pfHlightLineWidth( hlight, 1 .0f); 
 // // // When showing normals make them short // pfHlightNormalLength( hlight, 0.5f, 0.0f ); 
 
 return hlight; 
 } // createHighlight 
 
 
 int highlightPreDrawTravFunc( pfTraverser *trav, void *data){ // #################################################### // # // # STATIC Function: (PFTRAV_DRAW) // # // # Pre Draw traversal function placed on a node which // # enables and applies the highlight to the node and // # all the nodes children // # // # note this function MUST be declared as STATIC // # // #################################################### 
 // // We need to first save the current Performer State // pfPushState(); 
 
 // // Now we can enable the highlighting // pfEnable( PFEN_HIGHLIGHTING ); 
 // // Now retrieve the highlight from the passed user data // pfHighlight *hlight = (pfHighlight *)data; 
 // // If we have a highlight then make it current // if( hlight) pfApplyHlight( hlight ); 
 // // We need to tell Performer to continue the traverse of this node // return (PFTRAV_CONT); 
 } // highlightPreDrawTravFunc 
 
 
 int highlightPostDrawTravFunc( pfTraverser *trav, void *data){ // ###################################################### // # // # STATIC Function: (PFTRAV_DRAW) // # // # Post Draw traversal function on a node which disables // # the highlight applied in the corresponding pre draw // # fucntion // # // # note this function MUST be declared as STATIC // # // ###################################################### 
 
 // // Now we disable the highlighting we enabled // pfDisable( PFEN_HIGHLIGHTING ); 
 // // And restore the Performer state // pfPopState(); 
 // // We need to tell Performer to continue the traverse of this node // return (PFTRAV_CONT); 
 
 } // highlightPostDrawTravFunc 
 
 
 
 int remhighlightPostDrawTravFuncFIX( pfTraverser *trav, void *data){ // ################################################################# // # // # STATIC Function: (PFTRAV_DRAW) // # // # Post Draw traversal function on a node which disables // # the highlight applied in the corresponding pre draw // # fucntion // # // # // # This should be added in the remove highligh function // # because when pfNodeTravFuncs( node, PFTRAV_DRAW, NULL, NULL ) // # called the call backs are removed but an apparent bug in Vega // # means that the Predraw gets applied but the post draw function // # does not and the highlight stays on this fixes the problem by // # explicitly disbaling the highlighitng // # // # // # note this function MUST be declared as STATIC // # // ################################################################# 
 
 // // Now we disable the highlighting we enabled // pfDisable( PFEN_HIGHLIGHTING ); 
 // // Retrieve which node we are // pfNode *node = pfGetTravNode( trav ); 
 // // We only need to call this one so we can self remove // pfNodeTravFuncs( node, PFTRAV_DRAW, NULL, NULL); 
 // // We need to tell Performer to continue the traverse of this node // return (PFTRAV_CONT); 
 } // remhighlightPostDrawTravFuncFIX 
 
 void setHighlightOnVegaObject( vgObject *object ){ // ########################################################## // # // # Public Function // # // # Example of how to add Highlightinh to a Vega Object // # // ########################################################## 
 
 // // Sanity check we need a object // if( object == NULL ) return; 
 // // Get the root Performer node of the object // pfNode *node = vgGetObjPfNode( object ); if( node == NULL ) return; 
 // // Create the Highlight instance, Red and Filled // pfHighlight *hlight = createHighlight( 1.0f, 0.0f, 0.0f, PFHL_FILL); if( hlight == NULL ) return; 
 
 // // Set the Pre and Post draw callback which enable and disable the highlight // pfNodeTravFuncs( node, PFTRAV_DRAW, highlightPreDrawTravFunc, highlightPostDrawTravFunc ); 
 // // Set the highlight instance as the user data for the callbacks // pfNodeTravData( node, PFTRAV_DRAW, hlight ); 
 
 } //setHighlightOnVegaObject 
 
 
 void remHighlightFromVegaObject( vgObject *object ){ // ########################################################## // # // # Public Function // # // # Remove the highlight Callbacks from the passed object // # // ########################################################## 
 
 // // Sanity check we need a object // if( object == NULL ) return; 
 
 // // Get the root Performer node of the object // pfNode *node = vgGetObjPfNode( object ); if( node == NULL ) return; 
 // // Retrieve the highlight instance from the user data // pfHighlight *hlight = (pfHighlight *)pfGetNodeTravData( node, PFTRAV_DRAW ); 
 // // Remove the highlight call back functions by simply setting // them to NULL on the Node, Performer only supports one call // pre and post traversal callbacks per node // pfNodeTravFuncs( node, PFTRAV_DRAW, NULL, NULL); 
 
 // // // Theres an apperent bug in Vega where the Highlight will stay on // becuase the removal of the draw function gets called with the // highlight enabled but the post never gets called to remove the // highlight, so the state is wrong this is a work around that will // ensure that the highlight is removed // // pfNodeTravFuncs( node, PFTRAV_DRAW, NULL, remhighlightPostDrawTravFuncFIX); 
 // // And remove the data simply by // pfNodeTravData( node, PFTRAV_DRAW, NULL ); 
 
 // // If we got a highlight back from the user data // then we delete it // if( hlight != NULL ) pfDelete( hlight); 
 
 } // remHighlightFromVegaObject 
 
  | ||
| 
              
 
 © Copyright 2004 Gordon Tomlinson All Rights Reserved. All logos, trademarks and copyrights in this site are property of their respective owner.  | ||