How to Check if a vgObject is in a Channels FOV

 

Vega Code Example

 

 

 
 

This  example function illustrates how to check to see if a given vgObject is with the bounds of a given vgChannels field of view (FOV)

  • How to use vgGetChan(...)

  • How to the vgObjects pfNode with vgGetObjPfNode

  • How to the vgChannels pfChannel using vgGetPfChan

  • How to get the bounding sphere of a pfNode using pfGetNodeBSphere

  • How to check if pfBSphere is within a pfChannels FOV with pfChanContainsSphere

 

 

 
   
 

 

 
 
 
 

 

#include "vg.h"           //  main include file for Vega         

#include "vgperf.h"       //  for the Vega Performer node functions

#include "vgutil.h"

#include "pf.h"           //  main include file for Performer    

#include "pfutil.h"

 

 

bool

isObjectWithChannelsFOV(vgObject *obj, vgChannel *chan){

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

// #  

// #  Public Function

// #  

// #  Returns true if the vgObject is with the current field of

// #  view of the vgChannel other wise returns false

// #  

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

bool result = false;

 

    //

    // Sanity check we object

    //

    if( obj == NULL )

        return result;

 

    //

    // if no channel use the first channel

    //

    if( chan == NULL )

        chan = vgGetChan(0);

 

 

    

    //

    // We need to get the Objects root pfNode

    //

    pfNode *node = vgGetObjPfNode( obj );

    if( node == NULL )

        return result;

 

 

    //

    // We need to get the Channels root pfNode

    //

    pfChannel *pfchan = vgGetPfChan( chan );

    if( pfchan == NULL )

        return result;

 

    //

    // We need to get the objects bounding sphere

    //

    pfSphere bsphere;

    pfGetNodeBSphere( node, &bsphere);

 

 

    //

    // Now do the test and return true is found in side

    //

    result = pfChanContainsSphere ( pfchan, &bsphere);

    

    if( (result & PFIS_ALL_IN ) || (result & PFIS_TRUE  ) ||

        (result & ( PFIS_TRUE | PFIS_ALL_IN | PFIS_MAYBE) ))

        return true

 

 

return false;

 

} // isObjectWithChannelsFOV

 

 

 

 

 

 
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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