How to Position  a vgObject

 

Vega Code Example

 

 

 

 

 

 
 

This example function illustrates :

  • How to position a  vgObject
  • How to test if a vgObject is positionable
  • How to set the X,Y, Z,H,P,R coordinates of an vgObject
  • How to use vgDeletePos
  • How create a vgPos instance
  • How to use a vgPos instance
  • Note an 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

setVegaObjectPosition( vgObject *object

                    , const float x, const float y, const float z

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

 

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

// # Public  function  

// #

// #   Function shows how to set the position 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;

 

    

    //

    //  Set the vgPos to the passed in 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;

 

} // setVegaObjectsPosition

 

   

  
    
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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