As an example, the following code will loop through all of an asset's parameters, printing out basic information about them.
#include <iostream>
#include <string>
#define ENSURE_SUCCESS( result ) \
if ( (result) != HAPI_RESULT_SUCCESS ) \
{ \
std::cout << "Failure at " << __FILE__ << ": " << __LINE__ << std::endl; \
std::cout << getLastError() << std::endl; \
exit( 1 ); \
}
#define ENSURE_COOK_SUCCESS( result ) \
if ( (result) != HAPI_RESULT_SUCCESS ) \
{ \
std::cout << "Failure at " << __FILE__ << ": " << __LINE__ << std::endl; \
std::cout << getLastCookError() << std::endl; \
exit( 1 ); \
}
static std::string getLastError();
static std::string getLastCookError();
int
main( int argc, char ** argv )
{
const char * hdaFile = argc == 2 ? argv[ 1 ] : "examples/SideFX_spaceship.otl";
bool bUseInProcess = false;
if(bUseInProcess)
{
}
else
{
serverOptions.timeoutMs = 3000.0f;
}
&cookOptions,
true,
-1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr ) );
int assetCount;
if (assetCount > 1)
{
std::cout << "Should only be loading 1 asset here" << std::endl;
exit ( 1 );
}
std::string assetName = getString( assetSh );
ENSURE_SUCCESS(
HAPI_CreateNode( &session, -1, assetName.c_str(),
"AnAsset",
false, &nodeId ) );
ENSURE_SUCCESS(
HAPI_CookNode( &session, nodeId, &cookOptions ) );
int cookStatus;
do
{
}
ENSURE_SUCCESS( cookResult );
ENSURE_COOK_SUCCESS( cookStatus );
std::cout << "Parameters: " << std::endl;
for(
int i = 0; i < nodeInfo.
parmCount; ++i )
{
std::cout << "==========" << std::endl;
std::cout << " Name: "
<< getString( parmInfos[ i ].nameSH )
<< std::endl;
std::cout << " Values: (";
{
int * parmIntValues = new int[ parmIntCount ];
nodeId, parmIntValues,
parmInfos[ i ].intValuesIndex,
parmIntCount ) );
for ( int v = 0; v < parmIntCount; ++v )
{
if ( v != 0 )
std::cout << ", ";
std::cout << parmIntValues[ v ];
}
delete [] parmIntValues;
}
{
float * parmFloatValues = new float[ parmFloatCount ];
nodeId, parmFloatValues,
parmInfos[ i ].floatValuesIndex,
parmFloatCount ) );
for ( int v = 0; v < parmFloatCount; ++v )
{
if ( v != 0 )
std::cout << ", ";
std::cout << parmFloatValues[ v ];
}
delete [] parmFloatValues;
}
{
nodeId,
true, parmSHValues,
parmInfos[ i ].stringValuesIndex,
parmStringCount ) );
for ( int v = 0; v < parmStringCount; ++v )
{
if ( v != 0 )
std::cout << ", ";
std::cout << getString( parmSHValues[ v ] );
}
delete [] parmSHValues;
}
std::cout << ")" << std::endl;
}
delete [] parmInfos;
char in;
std::cout << "Press any key to exit" << std::endl;
std::cin >> in;
return 0;
}
static std::string
getLastError()
{
int bufferLength;
&bufferLength );
char * buffer = new char[ bufferLength ];
std::string result( buffer );
delete [] buffer;
return result;
}
static std::string
getLastCookError()
{
int bufferLength;
&bufferLength );
char * buffer = new char[ bufferLength ];
std::string result( buffer );
delete[] buffer;
return result;
}
static std::string
{
if ( stringHandle == 0 )
{
return "";
}
int bufferLength;
stringHandle,
&bufferLength );
char * buffer = new char[ bufferLength ];
std::string result( buffer );
delete [] buffer;
return result;
}