How to Position a vgPart

 

Vega Code Example

 

 

 

 

 

 
 

This example function illustrates :

  • How to position a  vgPart
  • How to retrieve the node type of a vgPart
  • How to test if a vgPart is a DCS node
  • How to set the X,Y, Z,H,P,R coordinates of a vgPart
  • How to use vgDeletePos
  • How create a vgPos instance
  • How to use a vgPos instance

 

 
   
 

 

 
 
 
    
 

 

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

 

int

setVegaPartsPosition( vgPart *part

                    , 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 vgPart

// #   returns VG_SUCCESS if the Part can be positioned

// #            otherwise retruns VG_FAILURE

// #

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

vgPosition *pos    = NULL;

int         result = VG_FAILURE;

    

    //

    //  Sanity check we need a vgPart

    //     

    if( part == NULL )

        return result;

 

 

    //

    //  Retrieve the node type of the part

    //     

    int parttype = vgGetProp ( part, VGPART_TYPE );

 

    //

    //  If the part is a DCS we can position it

    //     

    if( parttype == VGPART_DCS ){

 

 

        //

        //  Create a vgPos

        //     

        pos = vgNewPos();

        if( pos == NULL )

            return result;

 

    

        //

        //  Set the vgPos to the passed in coordinates

        //     

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

 

 

        //

        //  Set position of the vgpart

        //     

        vgPos( part, pos );

 

 

        result = VG_SUCCESS;

 

        //

        //  Release the vgPos as where done

        //     

        vgDelPos( pos);

        }

 

 

return result;

 

} // setVegaPartsPosition

 

   

  
    
 

 

 

© Copyright 2004 Gordon Tomlinson  All Rights Reserved.

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