| |||||||||
|
|
| |||||||
|
| ||||||||
| |||||||||
#include "vg.h" // Required for the standard Vega classes
vgSplineNavigator* createSimpleVegaNavigatorAndVegaPath(){ // ################################################### // # Public Function // # // # // # This functions show you how to create a // # simple and vgNavigator and control point // # event markers // # // # // ################################################### vgSplineNavigator *navigator = NULL; vgPath *path = NULL; vgPosition *pos = NULL; float xVec = 0.0f; float yVec = 0.0f; FILE file = NULL;
// // We need to create the vega position // pos = vgNewPos();
// // Create the new empty vgPath instance // path = vgNewPath( NULL, NULL);
// // Clear the path file to zero bytes // file = fopen( "my_vgPath_1.pth", "w+"); fclose( file );
// // Set the file name for the path instance // and name the instance // vgPathFileName( path , "my_vgPath_1.pth" );
vgName( path, "Path_1" );
// // Clear the navigator file to zero bytes // file = fopen( "myVgNav1.nav", "w+");
fclose( file );
// // Create a new blank navigator passing the vgpath // instance for the actual definition of the way points // navigator = vgNewSplineNavigator( "my_vgNav_1.nav", path );
// // Set the file name for the path instance // and name the instance // vgNavigatorFileName( navigator, "my_vgNav_1.nav");
vgName( navigator, "Nav_1" );
// // Create 50 waypoints in the vgpath instance and // the create the required control point markers // for( int i = 0; i < 50; i++ ){
// // Create some coordinates for the vgPath way point // vgPosVec( pos, xVec, yVec, 1.83f, 0.0f, 0.0f, 0.0f);
if( i < 26 ){
xVec += 35.0f; yVec += 25.0f;
} else {
xVec -= 35.0f; yVec -= 25.0f;
}
// // Add the position as anew control point on the path // vgPathAddCtrlPointPos(path, pos);
// // For the first control point add the event markers that // describe the vgNavigator // if ( i == 0) {
// // Make the path a Hermite Spline, this will be a Cardinal as // no tangents are supplied // vgNavigatorAddMarker( navigator, 0, VGSPLINENAV_HERMITE, 0, NULL, 0);
// // Turn rendering of the path Off // vgNavigatorAddMarker( navigator, 0, VGSPLINENAV_RENDER, VG_OFF,NULL, 0);
// // Step the HPR to interpet the HPR as additive to the curve // vgNavigatorAddMarker( navigator, 0, VGSPLINENAV_ABSOLUTE_HPR, TRUE, NULL, 0);
// // Set the tension value how close through the control // points the segment goes // vgNavigatorAddMarker(navigator,0,VGSPLINENAV_TENSION_FACTOR, 4.5,NULL, 0);
// // Set the initial speed to 20 // vgNavigatorAddMarker( navigator, 0, VGSPLINENAV_VELOCITY, 20.0, NULL, 0); } else{
// // Step the HPR to linterpet the HPR as additive to the curve // vgNavigatorAddMarker( navigator, i, VGSPLINENAV_ABSOLUTE_HPR, TRUE, NULL, 0);
// // Set the tension value how close through the control // points the segment goes // vgNavigatorAddMarker(navigator, i,VGSPLINENAV_TENSION_FACTOR, 4.5, NULL, 0);
// // Set the same velocity on each control point // vgNavigatorAddMarker( navigator, i, VGSPLINENAV_VELOCITY, 20.0, NULL, 0); } }
// // Navigator will restart when it get to the end control point // vgNavigatorAddMarker( navigator, i - 1, VGSPLINENAV_LOOP, VG_OFF, NULL, 0);
vgProp( navigator, VGSPLINENAV_STOP_AT_END, VG_OFF );
// // Write out vgPath to its file // vgPathWriteFile( path );
// // Tell the Navigator to make spline // vgMakeSplineNavigator( navigator );
// // Write out the Navigator to its file // vgNavigatorWriteFile ( navigator );
// // Release the vgPos now were done with it // vgDelPos( pos );
return navigator;
} // createSimpleVegaNavigatorAndVegaPath
| ||
© Copyright 2004 Gordon Tomlinson All Rights Reserved. All logos, trademarks and copyrights in this site are property of their respective owner. |