How to Set an vgObject's HPR 

 

Vega Code Example

 

 

 

 

 

 
 

This example function illustrates :

  • How to position a  vgObject
  • How to test if a vgObject is positionable
  • How to set just the H.P.R of an vgObject
  • How to use vgDeletePos
  • How create a vgPos instance
  • How to use a vgPos instancev
  • Notean vgObject coordinate system type property (VGOBJ_CS) must be set to VGPOBJ_DYNAMIC in order to be able to position an vgObject
  • Note if an vgObject is attached to a vgPlayer then you have to position the vgPlayer and not the vgObject

 

 
   
 

 

 
 
 
    
     
 

 

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

 

int

setVegaObjectHPR( vgObject *object,

                  const float h, const float p, const float r){

 

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

// # Public  function  

// #

// #   Function shows how to set the H P R of a vgObject

// #

// #   returns VG_SUCCESS if the Object can be positioned

// #

// #            otherwise returns VG_FAILURE

// #

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

vgPosition *pos    = NULL;

int         result = VG_FAILURE;

    

    //

    //  Sanity check we need a vgObject

    //     

    if( object == NULL )

        return VG_FAILURE;

 

 

    //

    //  Retrieve the coord type of the object

    //     

    int cstype = vgGetProp ( object, VGOBJ_CS );

 

    //

    //  If the object is a Static we cannot position it

    //     

    if( cstype == VGPOBJ_STATIC )

      return VG_FAILURE;

 

 

 

    //

    //  Create a vgPos

    //     

    pos = vgNewPos();

    if( pos == NULL )

        return VG_FAILURE;

 

 

    double  d = 0.0, x = 0.0, y = 0.0, z = 0.0;

 

    //

    //  Retrieve the current XYZ as we are only adjusting the HPR

    //    

    vgGetPos( object, pos );   

 

 

    vgGetPosVec( pos, &x, &y, &z, &d, &d, &d );

 

    

    //

    //  Set the vgPos to the passed in HPR coordinates

    //     

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

 

 

    //

    //  Set position of the object

    //     

    vgPos( object, pos );

 

 

 

    //

    //  Release the vgPos as where done

    //     

    vgDelPos( pos);

        

 

 

return VG_SUCCESS;

 

} // setVegaObjectsHPR

 

   

  
    
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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