How to Switch an Observer to Follow a vgPlayer

 

Vega Code Example

 

 

 

 

 

 
 

This example provides 1 functions which  illustrates :

  • How to switch vgObserver to a vgPlayer so that Obserer follow the vgPlayer
  • How to get a pointer to a vgObserver
  • How to get a pointer to a vgPlayer
  • How to get a pointer to a vgMotion model
  • How to enable a vgObserver
  • How to disable a vgMotion model
  • How to set the tethered state of vgObserver  to fixed
  • How to make a vgObserver use a vgPlayers as its coordinate origin
  • How to associate a vgObserver with a vgPlayer
  • How to associate a vgObserver with a vgMotion model  

 

 
   
 

 

 
 
 
    
 

 

#include "vg.h"          // Required for the standard Vega classes

 

void

switchObvserver2Player( const int obsIdx, const int playerIdx ){

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

// # Local Function

// #

// # This functions show how to make an vgObsert follow a vgPlayer

// #

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

    

    //

    // We need a pointer to the observer

    //

    vgObserver *obs = vgGetObserv(obsIdx)

 

 

    //

    // Remove any Navigator association with the Observer

    //

    vgObservNav(  obs, NULL );

 

 

    //

    // Remove any MotionModel association with the Observer

    //

    vgObservMot(  obs, NULL );

 

    //

    //  Attach the observer to the player and navigator

    //

    vgProp( obs, VGCOMMON_ENABLED,  VG_ON );

 

    //

    // The Observer needs to be Fixed Tethered state

    //

    vgProp( obs, VGOBS_TETHERSTATE, VGOBS_FIXED );

 

    //

    // The Observer needs to be relative to a players coords

    //

    vgProp( obs, VGOBS_TETHERCOORD, VGOBS_TPLAYER );

 

    

    //

    // We need the player for the navigator assume first player

    //

    vgPlayer *plyr = vgGetPlyr(playerIdx);

 

    

    //

    // Associate the Player with the Observer

    //

    vgObservPlyr( obs, plyr );

 

 

} // switchObvserver2Player

 

   

 
    
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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