How to Switch the Observer between a vgNavigator and Motion Model

 

Vega Code Example

 

 

 

 

 

 
 

This example provides 2 functions which  illustrates :

  • How to switch vgObserver to a vgMotion Model
  • How to switch a vgObserver to a vgNavigator
  • How to get a pointer to a vgObserver
  • How to get a pointer to a vgNavigator
  • How to get a pointer to a vgPlayer
  • How to get a pointer to a vgMotion model
  • How to enable a vgNavigator
  • How to disable a vgNavigator
  • How to enable a vgObserver
  • How to enable a vgMotion model
  • How to disable a vgMotion model
  • How to set the tethered state of vgObserver to dynamic
  • How to set the tethered state of vgObserver  to fixed
  • How to make a vgObserver use a vgPlayers as its coordinate origin
  • How to make a vgObserver use an absolute coordinate origin
  • How to associate a vgNavigator with a vgPlayer
  • How to associate a vgObserver with a vgNavigator
  • How to associate a vgObserver with a vgMotion model  

 

 
   
 

 

 
 
 
    
 

 

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

 

void

switchObvserverToNavigator( const int navIdx ){

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

// # Local Function

// #

// # This functions show how to change from using a Motion

// # model to attaching to a vgNavigator

// #

// # Note that this code assumes the observer is currently

// #  attached to a motion model

// #

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

    

    //

    // We need a pointer to the observer assmume first observer

    //

    vgObserver *obs = vgGetObserv(0)

 

 

    //

    //  Get our Navigator and enable it

    //

    vgNavigator *nav = (vgNavigator*) vgGetSplineNavigator( navIdx );

    vgProp( nav, VGCOMMON_ENABLED, VG_ON );

    vgProp( nav, VGPLYR_SPLINE_NAVIGATOR, VG_ON );

 

 

    //

    //  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(0);

 

 

    //

    // Associate the navigator with the player

    //

    vgPlyrNav( plyr, nav );

    

    //

    // Associate the Player with the Observer

    //

    vgObservPlyr( obs, plyr );

 

 

} // switchObvserverToNavigator

 

 

 

 

void

switchObserverMotionModel( const int motIdx ){

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

// # Local Function

// #

// # This functions show how to change from using a vgNavigator

// # and attaching to a vgMotion Model

// #

// # Note that this code assumes the observer is currently

// # attached to a vgNavigator

// #

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

 

    //

    // We need a pointer to the observer assmume first observer

    //

    vgObserver *obs = vgGetObserv(0);

 

    //

    // Remove the Navigator association with the Observer

    //

    vgObservNav(  obs, NULL );

 

    //

    // Remove the Player association with the Observer

    //

    vgObservPlyr( obs, NULL );

 

    //

    // Turn the navigator off , assume we using the first navigator

    //

    vgNavigator *nav = (vgNavigator*) vgGetSplineNavigator(0);

    vgProp( nav, VGCOMMON_ENABLED, VG_OFF );

    vgProp( nav, VGPLYR_SPLINE_NAVIGATOR, VG_OFF );

    

    //

    // Retrieve the motion model and enable it

    //

    vgMotion *mot = vgGetMot(motIdx);

    

    vgProp( mot, VGCOMMON_ENABLED, VG_ON );

    

    vgUpdate( mot );

 

 

    //

    // Associate the motion model with the observer

    //

    vgObservMot(  obs, mot );       

 

 

    //

    // The Observer needs to be relative to the origin

    //

    vgProp( obs, VGOBS_TETHERCOORD, VGOBS_TABSOLUTE);

    

    //

    // The Observer now needs to be Dynamic Tethered state

    //

    vgProp( obs, VGOBS_TETHERSTATE, VGOBS_DYNAMIC  );

    

    //

    // Finally enable the Observer

    //

    vgProp( obs, VGCOMMON_ENABLED,  VG_ON  );  

 

 

} // switchObserverMotionModel

 

 

   

 
    
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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