A full program the retrieves and prints data on all objects, geos, and parts on an asset.
#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();
std::string name );
int
main( int argc, char ** argv )
{
const char * hdaFile = argc == 2 ? argv[ 1 ] : "examples/TestShapes.hda";
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(),
"TestObject",
false, &nodeId ) );
ENSURE_SUCCESS(
HAPI_CookNode ( &session, nodeId, &cookOptions ) );
int cookStatus;
do
{
}
ENSURE_SUCCESS( cookResult );
ENSURE_COOK_SUCCESS( cookStatus );
printCompleteNodeInfo( session, nodeId, assetInfo );
char in;
std::cout << "Press keys to exit." << std::endl;
std::cin >> in;
return 0;
}
static void
{
int objectCount = 0;
{
objectCount = 1;
}
{
nullptr, &objectCount ) );
if (objectCount > 0)
{
objectInfos, 0, objectCount ) );
}
else
{
objectCount = 1;
}
}
else
{
return;
}
for (int objectIndex = 0; objectIndex < objectCount; ++objectIndex)
{
for (
int partIndex = 0; partIndex < geoInfo.
partCount; ++partIndex)
{
processGeoPart( session, assetInfo, objectInfo.
nodeId,
}
}
delete[] objectInfos;
}
static void
std::string name )
{
name.c_str(), owner, &attribInfo ) );
float * attribData =
new float[ attribInfo.
count * attribInfo.
tupleSize ];
name.c_str(), &attribInfo, -1,
attribData, 0, attribInfo.
count ) );
for (
int elemIndex = 0; elemIndex < attribInfo.
count; ++elemIndex )
{
for (
int tupleIndex = 0; tupleIndex < attribInfo.
tupleSize;
++tupleIndex)
{
std::cout << attribData[
elemIndex * attribInfo.
tupleSize + tupleIndex ]
<< " ";
}
std::cout << std::endl;
}
delete [] attribData;
}
static void
{
std::cout << "Object " << objectNode << ", Geo " << geoNode
<< ", Part " << partId << std::endl;
partId, &partInfo ) );
{
std::string attribName = getString( attribNamesSh[ attribIndex ] );
std::cout << " " << attribName << std::endl;
}
delete [] attribNamesSh;
std::cout << "Point Positions: " << std::endl;
processFloatAttrib( session, assetInfo, objectNode, geoNode,
std::cout <<
"Number of Faces: " << partInfo.
faceCount << std::endl;
{
int * faceCounts =
new int[ partInfo.
faceCount ];
for (
int ii = 0; ii < partInfo.
faceCount; ++ii )
{
std::cout << faceCounts[ ii ] << ", ";
}
std::cout << std::endl;
std::cout << "Vertex Indices into Points array:" << std::endl;
int currIndex = 0;
for(
int ii = 0; ii < partInfo.
faceCount; ii++ )
{
for( int jj = 0; jj < faceCounts[ ii ]; jj++ )
{
std::cout
<< "Vertex :" << currIndex << ", belonging to face: "
<< ii <<", index: "
<< vertexList[ currIndex ] << " of points array\n";
currIndex++;
}
}
delete [] faceCounts;
delete [] vertexList;
}
}
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;
}