How to Retrieve an vgObject's Position

 

Vega Code Example

 

 

 

 

 

 
 

This example function illustrates :

  • How to get the position of a vgObject
  • How to get the just the X, Y,  Z coordinates of a vgObject
  • How to get the just  H, P, R coordinates of a vgObject
  • How to get the X,Y, Z,H,P,R coordinates of a vgObject
  • How to use vgDelete
  • How create a vgPos instance
  • How to delete a vgPos instance
  • How to get the vgObject position with vpGetPos

 

 
   
 

 

 
 
 
    
 

 

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

 

void

getVegaObjectsLocalXYZ( vgObject *obj, float *x, float *y, float *z ){

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

// # Public  function  

// #

// #   Function shows to retrieve the current local X,Y,Z coordinates

// #   of the give Vega Object

// #

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

float       d   = 0.0f;

vgPosition *pos = NULL;

 

    

    //

    //  Sanity check we need a vgObject

    //     

    if( obj == NULL )

        return;

 

 

    //

    //  Create a vgPos

    //     

    pos = vgNewPos();

    if( pos == NULL )

        return;

 

    

    //

    //  Retrieve the current local position from the object

    //     

    vgGetPos( obj, pos );

 

 

    //

    //  Now retrieve the position translation vector

    //     

    vgGetPos( pos, x, y, z, d, d, d );

 

 

 

    //

    //  Release the vgPos as where done

    //     

    vgDelPos( pos);

 

} // getVegaObjectsLocalXYZ

 

 

void

getVegaObjectsLocalHPR( vgObject *obj, float *h, float *p, float *r ){

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

// # Public  function  

// #

// #   Function shows to retrieve the current local H,P,R coordinates

// #   of the give Vega Object

// #

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

float       d   = 0.0f;

vgPosition *pos = NULL;

 

    

    //

    //  Sanity check we need a vgObject

    //     

    if( obj == NULL )

        return;

 

 

    //

    //  Create a vgPos

    //     

    pos = vgNewPos();

    if( pos == NULL )

        return;

 

    

    //

    //  Retrieve the current local position from the object

    //     

    vgGetPos( obj, pos );

 

 

   //

    //  Now retrieve the positions orientation vector

    //     

    vgGetPos( pos, d, d, d, h, p, r );

 

 

 

    //

    //  Release the vgPos as where done

    //     

    vgDelPos( pos);

 

} // getVegaObjectsLocalHPR

 

 

 

void

getVegaObjectsLocalPos( vgObject *obj

                      , float *x, float *y, float *z

                      , float *h, float *p, float *r ){

 

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

// # Public  function  

// #

// #   Function shows to retrieve the current local X,Y,Z H,P,R

// #   coordinates of the give Vega Object

// #

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

vgPosition *pos = NULL;

 

    

    //

    //  Sanity check we need a vgObject

    //     

    if( obj == NULL )

        return;

 

 

    //

    //  Create a vgPos

    //     

    pos = vgNewPos();

    if( pos == NULL )

        return;

 

    

    //

    //  Retrieve the current local position from the object

    //     

    vgGetPos( obj, pos );

 

 

    //

    //  Now retrieve the position translation vector

    //     

    vgGetPos( pos, x, y, z, h, p, r );

 

 

 

    //

    //  Release the vgPos as where done

    //     

    vgDelPos( pos);

 

} // getVegaObjectsLocalPos

 

 

  

   

 
    
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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