3#include "../HoudiniCore.h"
9 static std::string
GetString(HAPI_Session& session, HAPI_StringHandle stringHandle)
11 if (stringHandle == 0)
17 HAPI_GetStringBufLength(&session, stringHandle, &bufferLength);
19 char* buffer =
new char[bufferLength];
20 HAPI_GetString(&session, stringHandle, buffer, bufferLength);
22 std::string result(buffer);
30 std::cout <<
"Child Node Ids" << std::endl;
31 for (
int i = 0; i < childrenNodes.size(); ++i)
34 HE_CHECK(HAPI_GetNodeInfo(&session, childrenNodes[i], &nInfo))
36 std::cout <<
" " << childrenNodes[i] <<
" - " << (nInfo.createdPostAssetLoad ?
"NEW" :
"EXISTING") << std::endl;
40 static void ProcessFloatAttrib(HAPI_Session& session, HAPI_AssetInfo& assetInfo, HAPI_NodeId objectNode, HAPI_NodeId geoNode, HAPI_PartId partId, HAPI_AttributeOwner owner, std::string name)
42 HAPI_AttributeInfo attribInfo;
43 HE_CHECK(HAPI_GetAttributeInfo(&session, geoNode, partId, name.c_str(), owner, &attribInfo))
45 std::vector<
float> attribData(attribInfo.count * attribInfo.tupleSize);
46 HE_CHECK(HAPI_GetAttributeFloatData(&session, geoNode, partId, name.c_str(), &attribInfo, -1, attribData.data(), 0, attribInfo.count))
48 for (
int elemIndex = 0; elemIndex < attribInfo.count; ++elemIndex)
50 for (
int tupleIndex = 0; tupleIndex < attribInfo.count; ++tupleIndex)
52 std::cout << attribData[elemIndex * attribInfo.tupleSize + tupleIndex] <<
" ";
54 std::cout << std::endl;
58 static void ProcessGeoPart(HAPI_Session& session, HAPI_AssetInfo& assetInfo, HAPI_NodeId objectNode, HAPI_NodeId geoNode, HAPI_PartId partId)
60 std::cout <<
"Object" << objectNode <<
", Geo" << geoNode <<
", Part" << partId << std::endl;
62 HAPI_PartInfo partInfo;
63 HE_CHECK(HAPI_GetPartInfo(&session, geoNode, partId, &partInfo))
65 std::vector<HAPI_StringHandle> attributeNameSh(partInfo.attributeCounts[HAPI_ATTROWNER_POINT]);
66 HE_CHECK(HAPI_GetAttributeNames(&session, geoNode, partInfo.id, HAPI_ATTROWNER_POINT, attributeNameSh.data(), partInfo.attributeCounts[HAPI_ATTROWNER_POINT]))
68 for (
int attribIndex = 0; attribIndex < partInfo.attributeCounts[HAPI_ATTROWNER_POINT]; ++attribIndex)
70 std::string attribName = GetString(session, attributeNameSh[attribIndex]);
71 std::cout <<
" " << attribName << std::endl;
74 std::cout <<
"Point Positions: " << std::endl;
76 ProcessFloatAttrib(session, assetInfo, objectNode, geoNode, partId, HAPI_ATTROWNER_POINT,
"P");
78 std::cout <<
"Number of Faces: " << partInfo.faceCount << std::endl;
80 if (partInfo.type != HAPI_PARTTYPE_CURVE)
82 std::vector<
int> faceCounts(partInfo.faceCount);
84 HE_CHECK(HAPI_GetFaceCounts(&session, geoNode, partId, faceCounts.data(), 0, partInfo.faceCount))
86 for (
int ii = 0; ii < partInfo.faceCount; ++ii)
88 std::cout << faceCounts[ii] <<
", ";
91 std::cout << std::endl;
93 std::vector<
int> vertexList(partInfo.vertexCount);
94 HE_CHECK(HAPI_GetVertexList(&session, geoNode, partId, vertexList.data(), 0, partInfo.vertexCount))
96 std::cout <<
"Vertex Indices into Points array: " << std::endl;
98 for (
int ii = 0; ii < partInfo.faceCount; ii++)
100 for (
int jj = 0; jj < faceCounts[ii]; jj++)
102 std::cout <<
"Vertex: " << currIndex <<
", belonging to face: "
104 << vertexList[currIndex] <<
"of points array\n";
111 static void PrintPartInfo(HAPI_Session& session, HAPI_NodeId nodeId, HAPI_PartId partId, std::string indent)
113 HAPI_PartInfo partInfo;
114 HE_CHECK(HAPI_GetPartInfo(&session, nodeId, partId, &partInfo))
116 if (partInfo.type == HAPI_PARTTYPE_MESH)
118 std::cout << indent <<
"Part " << partId <<
":" << std::endl;
119 std::cout << indent <<
" Type = Mesh" << std::endl;
120 std::cout << indent <<
" Point Count = " << partInfo.pointCount << std::endl;
122 else if(partInfo.type == HAPI_PARTTYPE_CURVE)
124 std::cout << indent <<
"Part " << partId <<
":" << std::endl;
125 std::cout << indent <<
" Type = Curve" << std::endl;
126 std::cout << indent <<
" Point Count = " << partInfo.pointCount << std::endl;
128 else if (partInfo.type == HAPI_PARTTYPE_INSTANCER)
130 std::cout << indent <<
"Part " << partId <<
":" << std::endl;
131 std::cout << indent <<
" Type = Instancer" << std::endl;
132 std::cout << indent <<
" Point Count = " << partInfo.pointCount << std::endl;
133 std::cout << indent <<
" Instance Count = " << partInfo.instanceCount << std::endl;
134 std::cout << indent <<
" Instanced Part Count = " << partInfo.instancedPartCount << std::endl;
136 std::vector<HAPI_Transform> instanceTransforms(partInfo.instanceCount);
137 HE_CHECK(HAPI_GetInstancerPartTransforms(&session, nodeId, partId, HAPI_RSTORDER_DEFAULT, instanceTransforms.data(), 0, partInfo.instanceCount))
139 std::cout << indent <<
" Instance Transforms: " << std::endl;
141 for (
auto instanceTransform : instanceTransforms)
143 float* p = &instanceTransform.position[0];
144 std::cout << indent <<
" " << p[0] <<
"." << p[1] <<
"." << p[2] << std::endl;
147 std::vector<HAPI_PartId> instancedPartIds(partInfo.instancedPartCount);
148 HE_CHECK(HAPI_GetInstancedPartIds(&session, nodeId, partId, instancedPartIds.data(), 0, partInfo.instancedPartCount))
150 std::cout << indent <<
" Instanced Parts: " << std::endl;
152 for (
auto instancedPartId : instancedPartIds)
154 PrintPartInfo(session, nodeId, instancedPartId,
" ->");
159 static void CookAndPrintNode(HAPI_Session& session, HAPI_CookOptions& co, HAPI_NodeId nodeId, HAPI_PackedPrimInstancingMode mode)
163 case HAPI_PACKEDPRIM_INSTANCING_MODE_DISABLED:
164 std::cout <<
"Using: HAPI_PACKEDPRIM_INSTANCING_MODE_DISABLED" << std::endl;
166 case HAPI_PACKEDPRIM_INSTANCING_MODE_HIERARCHY:
167 std::cout <<
"Using: HAPI_PACKEDPRIM_INSTANCING_MODE_HIERARCHY" << std::endl;
169 case HAPI_PACKEDPRIM_INSTANCING_MODE_FLAT:
170 std::cout <<
"Using: HAPI_PACKEDPRIM_INSTANCING_MODE_FLAT" << std::endl;
174 co.packedPrimInstancingMode = mode;
176 HE_CHECK(HAPI_CookNode(&session, nodeId, &co))
179 HAPI_Result cookResult;
183 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
185 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
190 HAPI_NodeInfo nodeInfo;
191 HE_CHECK(HAPI_GetNodeInfo(&session, nodeId, &nodeInfo))
194 HE_CHECK(HAPI_ComposeChildNodeList(&session, nodeId, HAPI_NODETYPE_SOP, HAPI_NODEFLAGS_ANY,
false, &childCount))
196 std::vector<HAPI_NodeId> childIds(childCount);
197 HE_CHECK(HAPI_GetComposedChildNodeList(&session, nodeId, childIds.data(), childCount))
199 for (
int i = 0; i < childCount; ++i)
201 HAPI_GeoInfo geoInfo;
202 HE_CHECK(HAPI_GetGeoInfo(&session, childIds[i], &geoInfo))
203 std::cout <<
"Part count for geo node " << i <<
": " << geoInfo.partCount << std::endl;
205 for (
int j = 0; j < geoInfo.partCount; ++j)
207 PrintPartInfo(session, childIds[i], j,
"");
214 HAPI_NodeInfo nodeInfo;
215 HE_CHECK(HAPI_GetNodeInfo(&session, nodeId, &nodeInfo))
218 HAPI_ObjectInfo* objectInfos = 0;
220 if (nodeInfo.type == HAPI_NODETYPE_SOP)
225 objectInfos =
new HAPI_ObjectInfo[objectCount];
226 HE_CHECK(HAPI_GetObjectInfo(&session, nodeInfo.parentId, &objectInfos[0]))
228 else if (nodeInfo.type == HAPI_NODETYPE_OBJ)
234 HE_CHECK(HAPI_ComposeObjectList(&session, nodeId,
nullptr, &objectCount))
238 objectInfos =
new HAPI_ObjectInfo[objectCount];
239 HE_CHECK(HAPI_GetComposedObjectList(&session, nodeInfo.parentId, objectInfos, 0, objectCount))
244 objectInfos =
new HAPI_ObjectInfo[objectCount];
245 HE_CHECK(HAPI_GetObjectInfo(&session, nodeId, &objectInfos[0]))
250 std::cout <<
"Unsupported node type: " << HAPI_NODETYPE_OBJ << std::endl;
254 for (
int objectIndex = 0; objectIndex < objectCount; ++objectIndex)
256 HAPI_ObjectInfo& objectInfo = objectInfos[objectIndex];
257 HAPI_GeoInfo geoInfo;
258 HE_CHECK(HAPI_GetDisplayGeoInfo(&session, objectInfo.nodeId, &geoInfo))
260 for (
int partIndex = 0; partIndex < geoInfo.partCount; ++partIndex)
262 ProcessGeoPart(session, assetInfo, objectInfo.nodeId, geoInfo.nodeId, partIndex);
266 delete[] objectInfos;
272 HAPI_Session session;
274 HAPI_ThriftServerOptions serverOptions{ 0 };
275 serverOptions.autoClose =
true;
276 serverOptions.timeoutMs = 3000.0f;
278 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
280 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
282 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
285 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
286 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
290 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode,
"Marshalling_Point_Clouds"))
292 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
296 HAPI_Result cookResult;
300 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
302 while (cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
307 HAPI_PartInfo newNodePart = HAPI_PartInfo_Create();
308 newNodePart.type = HAPI_PARTTYPE_MESH;
309 newNodePart.faceCount = 1;
310 newNodePart.vertexCount = 3;
311 newNodePart.pointCount = 3;
312 HE_CHECK(HAPI_SetPartInfo(&session, newNode, 0, &newNodePart))
315 HAPI_AttributeInfo newNodePointInfo = HAPI_AttributeInfo_Create();
316 newNodePointInfo.count = 3;
317 newNodePointInfo.tupleSize = 3;
318 newNodePointInfo.exists =
true;
319 newNodePointInfo.storage = HAPI_STORAGETYPE_FLOAT;
320 newNodePointInfo.owner = HAPI_ATTROWNER_POINT;
321 HE_CHECK(HAPI_AddAttribute(&session, newNode, 0,
"P", &newNodePointInfo))
324 float positions[9] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f };
325 HE_CHECK(HAPI_SetAttributeFloatData(&session, newNode, 0,
"P", &newNodePointInfo, positions, 0, 3))
328 int vertices[3] = { 0, 1, 2 };
329 HE_CHECK(HAPI_SetVertexList(&session, newNode, 0, vertices, 0, 3))
332 int face_counts[1] = { 3 };
333 HE_CHECK(HAPI_SetFaceCounts(&session, newNode, 0, face_counts, 0, 1))
336 std::array<
char*, 3> strs;
337 strs[0] = _strdup(
"strPoint1");
338 strs[1] = _strdup(
"strPoint2");
339 strs[2] = _strdup(
"strPoint3");
341 newNodePointInfo.count = 3;
342 newNodePointInfo.tupleSize = 1;
343 newNodePointInfo.exists =
true;
344 newNodePointInfo.storage = HAPI_STORAGETYPE_STRING;
345 newNodePointInfo.owner = HAPI_ATTROWNER_POINT;
347 HE_CHECK(HAPI_AddAttribute(&session, newNode, 0,
"srcData", &newNodePointInfo))
348 HE_CHECK(HAPI_SetAttributeStringData(&session, newNode, 0,
"srcData", &newNodePointInfo, (
const char**)strs.data(), 0, 3))
351 HE_CHECK(HAPI_CommitGeo(&session, newNode));
354 HE_CHECK(HAPI_SaveHIPFile(&session,
"C:/Users/Administrator/Desktop/Marshalling_Point_Clouds.hip",
false))
365 HAPI_Session session;
367 HAPI_ThriftServerOptions serverOptions{ 0 };
368 serverOptions.autoClose =
true;
369 serverOptions.timeoutMs = 3000.0f;
371 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
373 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
375 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
378 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
379 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
383 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode,
"Marshalling_Point_Clouds"))
385 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
388 HAPI_Result cookResult;
392 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
394 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
400 HAPI_GeoInfo newNodeGeoInfo;
401 HE_CHECK(HAPI_GetDisplayGeoInfo(&session, newNode, &newNodeGeoInfo))
403 HAPI_NodeId sopNodeId = newNodeGeoInfo.nodeId;
405 HAPI_PartInfo newNodePart = HAPI_PartInfo_Create();
406 newNodePart.type = HAPI_PARTTYPE_MESH;
407 newNodePart.faceCount = 0;
408 newNodePart.vertexCount = 0;
409 newNodePart.pointCount = 8;
410 HE_CHECK(HAPI_SetPartInfo(&session, sopNodeId, 0, &newNodePart))
412 HAPI_AttributeInfo newNodePointInfo = HAPI_AttributeInfo_Create();
413 newNodePointInfo.count = 8;
414 newNodePointInfo.tupleSize = 3;
415 newNodePointInfo.exists =
true;
416 newNodePointInfo.storage = HAPI_STORAGETYPE_FLOAT;
417 newNodePointInfo.owner = HAPI_ATTROWNER_POINT;
418 HE_CHECK(HAPI_AddAttribute(&session, sopNodeId, 0,
"P", &newNodePointInfo))
420 float positions[24] = {
431 HE_CHECK(HAPI_SetAttributeFloatData(&session, sopNodeId, 0,
"P", &newNodePointInfo, positions, 0, 8))
433 HE_CHECK(HAPI_CommitGeo(&session, sopNodeId))
435 HE_CHECK(HAPI_SaveHIPFile(&session,
"C:/Users/Administrator/Desktop/Marshalling_Point_Clouds.hip",
false))
444 HAPI_Session session;
446 HAPI_ThriftServerOptions serverOptions{ 0 };
447 serverOptions.autoClose =
true;
448 serverOptions.timeoutMs = 3000.0f;
450 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
452 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
454 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
456 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
457 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
461 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode,
"Connecting_Assets"))
462 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
465 HAPI_Result cookResult;
469 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
471 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
476 HAPI_PartInfo newNodePart = HAPI_PartInfo_Create();
478 newNodePart.type = HAPI_PARTTYPE_MESH;
479 newNodePart.faceCount = 6;
480 newNodePart.vertexCount = 24;
481 newNodePart.pointCount = 8;
483 HE_CHECK(HAPI_SetPartInfo(&session, newNode, 0 , &newNodePart))
485 HAPI_AttributeInfo newNodePointInfo = HAPI_AttributeInfo_Create();
486 newNodePointInfo.count = 8;
487 newNodePointInfo.tupleSize = 3;
488 newNodePointInfo.exists =
true;
489 newNodePointInfo.storage = HAPI_STORAGETYPE_FLOAT;
490 newNodePointInfo.owner = HAPI_ATTROWNER_POINT;
492 HE_CHECK(HAPI_AddAttribute(&session, newNode, 0,
"P", &newNodePointInfo))
494 float positions[24] = {
505 HE_CHECK(HAPI_SetAttributeFloatData(&session, newNode, 0,
"P", &newNodePointInfo, positions, 0, 8))
516 HE_CHECK(HAPI_SetVertexList(&session, newNode, 0, vertices, 0, 24))
518 int face_counts[6] = {4, 4, 4, 4, 4, 4};
519 HE_CHECK(HAPI_SetFaceCounts(&session, newNode, 0, face_counts, 0, 6))
520 HE_CHECK(HAPI_CommitGeo(&session, newNode))
522 HAPI_NodeId subdivideNode;
523 HE_CHECK(HAPI_CreateNode(&session, -1,
"Sop/subdivide",
"Cube Subdivider",
true, &subdivideNode))
524 HE_CHECK(HAPI_ConnectNodeInput(&session, subdivideNode, 0, newNode, 0))
525 HE_CHECK(HAPI_SaveHIPFile(&session,
"C:/Users/Administrator/Desktop/Connecting_Assets.hip",
false))
533 HAPI_Session session;
535 HAPI_ThriftServerOptions serverOptions{ 0 };
536 serverOptions.autoClose =
true;
537 serverOptions.timeoutMs = 3000.0f;
539 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
541 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
543 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
545 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
546 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
548 HAPI_NodeId curveNode;
550 HE_CHECK(HAPI_CreateNode(&session, -1,
"sop/curve",
"NURBS",
false, &curveNode))
551 HE_CHECK(HAPI_CookNode(&session, curveNode, &cookOptions))
554 HAPI_Result cookResult;
558 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
560 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
565 HAPI_NodeInfo curveNodeInfo;
566 HE_CHECK(HAPI_GetNodeInfo(&session, curveNode, &curveNodeInfo))
568 std::vector<HAPI_ParmInfo> paramInfos;
569 paramInfos.resize(curveNodeInfo.parmCount);
570 HE_CHECK(HAPI_GetParameters(&session, curveNode, paramInfos.data(), 0, curveNodeInfo.parmCount))
572 int coordsParmIndex = -1;
573 int typeParmIndex = -1;
574 for (
int i = 0; i < curveNodeInfo.parmCount; i++)
576 std::string parmName = GetString(session, paramInfos[i].nameSH);
577 if (parmName ==
"coords")
581 if (parmName ==
"type")
587 if (coordsParmIndex == -1 || typeParmIndex == -1)
589 std::stringstream ss;
590 ss <<
"Could not find coords/type parameter on curve node";
592 SPICES_CORE_WARN(ss.str());
598 HE_CHECK(HAPI_GetParameters(&session, curveNode, &parm, typeParmIndex, 1))
601 HE_CHECK(HAPI_SetParmIntValues(&session, curveNode, &typeValue, parm.intValuesIndex, 1))
603 HE_CHECK(HAPI_GetParameters(&session, curveNode, &parm, coordsParmIndex, 1))
604 HE_CHECK(HAPI_SetParmStringValue(&session, curveNode,
"-4, 0, 4, -4, 0, -4, 4, 0, -4, 4, 0, 4", parm.id, 0))
605 HE_CHECK(HAPI_SaveHIPFile(&session,
"C:/Users/Administrator/Desktop/Curve_Node.hip",
true))
614 HAPI_Session session;
616 HAPI_ThriftServerOptions serverOptions{ 0 };
617 serverOptions.autoClose =
true;
618 serverOptions.timeoutMs = 3000.0f;
620 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
622 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
624 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
626 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
627 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
630 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode,
"Curve"))
631 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
634 HAPI_Result cookResult;
638 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
640 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
645 HAPI_PartInfo newNodePart = HAPI_PartInfo_Create();
646 newNodePart.type = HAPI_PARTTYPE_CURVE;
647 newNodePart.faceCount = 1;
648 newNodePart.vertexCount = 4;
649 newNodePart.pointCount = 4;
650 HE_CHECK(HAPI_SetPartInfo(&session, newNode, 0, &newNodePart))
652 HAPI_CurveInfo curveInfo;
653 curveInfo.curveType = HAPI_CURVETYPE_NURBS;
654 curveInfo.curveCount = 1;
655 curveInfo.vertexCount = 4;
656 curveInfo.knotCount = 8;
657 curveInfo.isPeriodic =
false;
659 curveInfo.hasKnots =
true;
660 HE_CHECK(HAPI_SetCurveInfo(&session, newNode, 0, &curveInfo))
663 HE_CHECK(HAPI_SetCurveCounts(&session, newNode, newNodePart.id, &curveCount, 0, 1))
665 float curveKnots[8] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f };
666 HE_CHECK(HAPI_SetCurveKnots(&session, newNode, newNodePart.id, curveKnots, 0, 8))
668 HAPI_AttributeInfo attrInfo = HAPI_AttributeInfo_Create();
670 attrInfo.tupleSize = 3;
671 attrInfo.exists =
true;
672 attrInfo.storage = HAPI_STORAGETYPE_FLOAT;
673 attrInfo.owner = HAPI_ATTROWNER_POINT;
675 HE_CHECK(HAPI_AddAttribute(&session, newNode, 0,
"P", &attrInfo))
677 float positions[12] = { -4.0f, 0.0f, 4.0f, -4.0f, 0.0f, -4.0f, 4.0f, 0.0f, -4.0f, 4.0f, 0.0f, 4.0f };
678 HE_CHECK(HAPI_SetAttributeFloatData(&session, newNode, 0,
"P", &attrInfo, positions, 0, 4))
680 HE_CHECK(HAPI_CommitGeo(&session, newNode))
681 HE_CHECK(HAPI_SaveHIPFile(&session,
"C:/Users/Administrator/Desktop/Curve_Marshalling.hip",
true))
690 const char* hdaFile =
"examples/nurbs_curve.hda";
691 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
693 HAPI_Session session;
694 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
695 HE_CHECK(HAPI_CreateInProcessSession(&session, &sessionInfo))
696 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
698 HAPI_AssetLibraryId assetLibId;
699 HE_CHECK(HAPI_LoadAssetLibraryFromFile(&session, hdaFile,
true, &assetLibId))
702 HE_CHECK(HAPI_GetAvailableAssetCount(&session, assetLibId, &assetCount))
706 std::cout <<
"Should only be loading 1 asset here" << std::endl;
716 HAPI_Session session;
718 HAPI_ThriftServerOptions serverOptions{ 0 };
719 serverOptions.autoClose =
true;
720 serverOptions.timeoutMs = 3000.0f;
722 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
724 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
726 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
728 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
729 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
731 HAPI_NodeId cubeNode;
733 HE_CHECK(HAPI_CreateInputNode(&session, -1, &cubeNode,
"Cube"))
734 HE_CHECK(HAPI_CookNode(&session, cubeNode, &cookOptions))
737 HAPI_Result cookResult;
741 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
743 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
748 HAPI_PartInfo cubePart = HAPI_PartInfo_Create();
750 cubePart.type = HAPI_PARTTYPE_MESH;
751 cubePart.faceCount = 6;
752 cubePart.vertexCount = 24;
753 cubePart.pointCount = 8;
755 HE_CHECK(HAPI_SetPartInfo(&session, cubeNode, 0, &cubePart))
757 HAPI_AttributeInfo attrInfo = HAPI_AttributeInfo_Create();
760 attrInfo.tupleSize = 3;
761 attrInfo.exists =
true;
762 attrInfo.storage = HAPI_STORAGETYPE_FLOAT;
763 attrInfo.owner = HAPI_ATTROWNER_POINT;
765 HE_CHECK(HAPI_AddAttribute(&session, cubeNode, 0,
"P", &attrInfo))
767 float positions[24] = {
778 HE_CHECK(HAPI_SetAttributeFloatData(&session, cubeNode, 0,
"P", &attrInfo, positions, 0, 8))
789 HE_CHECK(HAPI_SetVertexList(&session, cubeNode, 0, vertices, 0, 24))
791 int face_counts[6] = {4, 4, 4, 4, 4, 4};
792 HE_CHECK(HAPI_SetFaceCounts(&session, cubeNode, 0, face_counts, 0, 6))
794 HE_CHECK(HAPI_AddGroup(&session, cubeNode, cubePart.id, HAPI_GROUPTYPE_POINT,
"pointGroup"))
795 int groupElementCount = HAPI_PartInfo_GetElementCountByGroupType(&cubePart, HAPI_GROUPTYPE_POINT);
797 int* pointMembership =
new int[groupElementCount];
798 for (
int ii = 0; ii < groupElementCount; ++ii)
802 pointMembership[ii] = 1;
806 pointMembership[ii] = 0;
809 HE_CHECK(HAPI_SetGroupMembership(&session, cubeNode, cubePart.id, HAPI_GROUPTYPE_POINT,
"pointGroup", pointMembership, 0, groupElementCount))
810 HE_CHECK(HAPI_CommitGeo(&session, cubeNode))
812 HAPI_NodeId xformNode;
813 HE_CHECK(HAPI_CreateNode(&session, -1,
"Sop/xform",
"PointGroupManipulator",
false, &xformNode))
814 HE_CHECK(HAPI_ConnectNodeInput(&session, xformNode, 0, cubeNode, 0))
816 HAPI_NodeInfo xformInfo;
817 HE_CHECK(HAPI_GetNodeInfo(&session, xformNode, &xformInfo))
819 HAPI_ParmInfo* parmInfos =
new HAPI_ParmInfo[xformInfo.parmCount];
820 HE_CHECK(HAPI_GetParameters(&session, xformNode, parmInfos, 0, xformInfo.parmCount))
822 int groupParmIndex = -1;
825 for (
int ii = 0; ii < xformInfo.parmCount; ++ii)
827 std::string parmName = GetString(session, parmInfos[ii].nameSH);
828 if (parmName ==
"group")
838 if (groupParmIndex < 0 || tParmIndex < 0)
840 std::stringstream ss;
841 ss <<
"Could not find coords/type parameter on curve node";
843 SPICES_CORE_WARN(ss.str());
848 float tParmValue[3] = { 0.0f, 1.0f, 0.0f };
849 HE_CHECK(HAPI_SetParmFloatValues(&session, xformNode, tParmValue, parmInfos[tParmIndex].floatValuesIndex, 3))
850 HE_CHECK(HAPI_SetParmStringValue(&session, xformNode,
"pointGroup", groupParmIndex, 0))
851 HE_CHECK(HAPI_CookNode(&session, xformNode, &cookOptions))
854 HAPI_Result xformCookResult;
858 xformCookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_RESULT, &xformCookStatus);
860 while(xformCookStatus > HAPI_STATE_MAX_READY_STATE && xformCookResult == HAPI_RESULT_SUCCESS);
865 HE_CHECK(HAPI_SaveHIPFile(&session,
"C:/Users/Administrator/Desktop/Groups_Sample.hip",
false))
867 HAPI_GeoInfo xformGeoInfo;
868 HE_CHECK(HAPI_GetGeoInfo(&session, xformNode, &xformGeoInfo))
870 int numGroups = HAPI_GeoInfo_GetGroupCountByType(&xformGeoInfo, HAPI_GROUPTYPE_POINT);
872 HAPI_PartInfo partInfo;
873 HE_CHECK(HAPI_GetPartInfo(&session, xformNode, 0, &partInfo))
875 int numElementsInGroup = HAPI_PartInfo_GetElementCountByGroupType(&partInfo, HAPI_GROUPTYPE_POINT);
877 int* memberShip =
new int[numElementsInGroup];
878 HE_CHECK(HAPI_GetGroupMembership(&session, xformNode, partInfo.id, HAPI_GROUPTYPE_POINT,
"pointGroup",
nullptr, memberShip, 0, numElementsInGroup))
880 for(
int ii = 0; ii < numElementsInGroup; ++ii)
884 std::cout <<
"Point" << ii <<
"is in pointGroup" << std::endl;
888 delete[] pointMembership;
897 const char* hdaFile =
"";
899 HAPI_Session session;
901 HAPI_ThriftServerOptions serverOptions{ 0 };
902 serverOptions.autoClose =
true;
903 serverOptions.timeoutMs = 3000.0f;
905 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
907 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
908 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
910 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
911 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
913 HAPI_AssetLibraryId assetLibId;
914 HE_CHECK(HAPI_LoadAssetLibraryFromFile(&session, hdaFile,
true, &assetLibId));
917 HE_CHECK(HAPI_GetAvailableAssetCount(&session, assetLibId, &assetCount))
921 std::cout <<
"Should only be loading 1 asset here" << std::endl;
924 HAPI_StringHandle assetSh;
925 HE_CHECK(HAPI_GetAvailableAssets(&session, assetLibId, &assetSh, assetCount))
927 std::string assetName = GetString(session, assetSh);
930 HE_CHECK(HAPI_CreateNode(&session, -1, assetName.c_str(),
"BrandonTest",
false, &nodeId))
932 HE_CHECK(HAPI_CookNode(&session, nodeId, &cookOptions))
935 HAPI_Result cookResult;
939 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
941 while (cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
946 HAPI_GeoInfo geoInfo;
947 HE_CHECK(HAPI_GetDisplayGeoInfo(&session, nodeId, &geoInfo))
949 HAPI_PartInfo partInfo;
950 HE_CHECK(HAPI_GetPartInfo(&session, geoInfo.nodeId, 0, &partInfo))
952 bool areAllTheSame =
false;
953 std::vector<HAPI_NodeId> materialIds(partInfo.faceCount);
954 HE_CHECK(HAPI_GetMaterialNodeIdsOnFaces(&session, geoInfo.nodeId, partInfo.id, &areAllTheSame, &materialIds.front(), 0, partInfo.faceCount))
958 std::cout <<
"All materials should be the same." << std::endl;
961 for (
int i = 0; i < partInfo.faceCount; ++i)
963 if (materialIds[i] != materialIds[0])
965 std::cout <<
"All material ids should be the same." << std::endl;
969 HAPI_MaterialInfo materialInfo;
970 HE_CHECK(HAPI_GetMaterialInfo(&session, materialIds[0], &materialInfo))
972 if (materialInfo.nodeId != materialIds[0] ||
973 materialInfo.nodeId < 0 ||
974 materialInfo.exists !=
true ||
975 materialInfo.hasChanged !=
true)
977 std::cout <<
"Did not successfully extract the first material" << std::endl;
980 HAPI_NodeInfo materialNodeInfo;
981 HE_CHECK(HAPI_GetNodeInfo(&session, materialInfo.nodeId, &materialNodeInfo))
983 std::cout << GetString(session, materialNodeInfo.nameSH) << std::endl;
985 std::vector<HAPI_ParmInfo> parmInfos(materialNodeInfo.parmCount);
986 HE_CHECK(HAPI_GetParameters(&session, materialNodeInfo.id, parmInfos.data(), 0, materialNodeInfo.parmCount))
988 int baseColorMapIndex = -1;
989 for (
int i = 0; i < materialNodeInfo.parmCount; ++i)
991 if (GetString(session, parmInfos[i].nameSH) ==
"baseColorMap")
993 baseColorMapIndex = i;
998 if (baseColorMapIndex < 0)
1000 std::cout <<
"Could not find the base color map parameter" << std::endl;
1003 HAPI_StringHandle basePath;
1004 HE_CHECK(HAPI_GetParmStringValue(&session, materialNodeInfo.id,
"baseColorMap", 0,
true, &basePath))
1006 std::cout <<
"Base Color Map Path: " << GetString(session, basePath) << std::endl;
1008 HE_CHECK(HAPI_RenderTextureToImage(&session, materialNodeInfo.id, baseColorMapIndex))
1010 HAPI_ImageInfo imgInfo;
1011 HE_CHECK(HAPI_GetImageInfo(&session, materialNodeInfo.id, &imgInfo))
1013 std::cout <<
"Image Width = " << imgInfo.xRes << std::endl
1014 <<
"Image Height = " << imgInfo.yRes << std::endl
1015 <<
"Image Format = " << GetString(session, imgInfo.imageFileFormatNameSH) << std::endl;
1017 HE_CHECK(HAPI_SetImageInfo(&session, materialNodeInfo.id, &imgInfo))
1019 int imagePlaneCount;
1020 HE_CHECK(HAPI_GetImagePlaneCount(&session, materialNodeInfo.id, &imagePlaneCount))
1022 std::vector<HAPI_StringHandle> imagePlanes(imagePlaneCount);
1023 HE_CHECK(HAPI_GetImagePlanes(&session, materialNodeInfo.id, imagePlanes.data(), imagePlaneCount))
1025 for (
int j = 0; j < imagePlaneCount; ++j)
1027 std::string imagePlaneName = GetString(session, imagePlanes[j]);
1028 std::cout <<
"Image Plane [ " << j <<
" ] = " << imagePlaneName << std::endl;
1030 int destinationFilePath;
1031 HE_CHECK(HAPI_ExtractImageToFile(&session, materialNodeInfo.id,
nullptr, imagePlaneName.c_str(),
"./examples/",
nullptr, &destinationFilePath))
1039 const char* hdaFile =
"";
1041 HAPI_Session session;
1043 HAPI_ThriftServerOptions serverOptions{ 0 };
1044 serverOptions.autoClose =
true;
1045 serverOptions.timeoutMs = 3000.0f;
1047 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
1049 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
1050 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
1052 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
1053 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
1055 HAPI_AssetLibraryId assetLibId;
1056 HE_CHECK(HAPI_LoadAssetLibraryFromFile(&session, hdaFile,
true, &assetLibId))
1059 HE_CHECK(HAPI_GetAvailableAssetCount(&session, assetLibId, &assetCount))
1063 std::cout <<
"Should only be loading 1 asset here" << std::endl;
1066 HAPI_StringHandle assetSh;
1067 HE_CHECK(HAPI_GetAvailableAssets(&session, assetLibId, &assetSh, assetCount))
1069 std::string assetName = GetString(session, assetSh);
1071 HAPI_NodeId editableNetworkId;
1072 HE_CHECK(HAPI_CreateNode(&session, -1, assetName.c_str(),
"FourShape",
false, &editableNetworkId))
1074 HE_CHECK(HAPI_CookNode(&session, editableNetworkId, &cookOptions))
1077 HAPI_Result cookResult;
1081 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
1083 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
1089 HE_CHECK(HAPI_ComposeChildNodeList(&session, editableNetworkId, HAPI_NODETYPE_ANY, HAPI_NODEFLAGS_ANY,
false, &childCount))
1091 std::cout <<
"Editable Node Network Child Count: " << childCount << std::endl;
1093 std::vector<HAPI_NodeId> childNodeIds(childCount);
1094 HE_CHECK(HAPI_GetComposedChildNodeList(&session, editableNetworkId, &childNodeIds.front(), childCount))
1096 PrintChildNodeInfo(session, childNodeIds);
1098 HAPI_NodeId anotherBoxNode;
1099 HE_CHECK(HAPI_CreateNode(&session, editableNetworkId,
"geo",
"ProgrammaticBox",
false, &anotherBoxNode))
1101 HE_CHECK(HAPI_ConnectNodeInput(&session, anotherBoxNode, 0, childNodeIds[0], 0))
1102 HE_CHECK(HAPI_CookNode(&session, anotherBoxNode, &cookOptions))
1105 HAPI_Result boxCookResult;
1109 boxCookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &boxCookStatus);
1111 while (boxCookStatus > HAPI_STATE_MAX_READY_STATE && boxCookResult == HAPI_RESULT_SUCCESS);
1116 HAPI_NodeId connectedNodeId;
1117 HE_CHECK(HAPI_QueryNodeInput(&session, anotherBoxNode, 0, &connectedNodeId))
1119 if (connectedNodeId != childNodeIds[0])
1121 std::cout <<
"The connected node id is" << connectedNodeId <<
" When it should be " << editableNetworkId << std::endl;
1124 HE_CHECK(HAPI_ComposeChildNodeList(&session, editableNetworkId, HAPI_NODETYPE_ANY, HAPI_NODEFLAGS_ANY,
false, &childCount))
1126 std::vector<HAPI_NodeId> newChildNodes(childCount);
1127 HE_CHECK(HAPI_GetComposedChildNodeList(&session, editableNetworkId, &newChildNodes.front(), childCount))
1129 std::cout <<
"After CONNECT NODE" << std::endl;
1130 PrintChildNodeInfo(session, newChildNodes);
1132 HE_CHECK(HAPI_SaveHIPFile(&session,
"",
false))
1133 HE_CHECK(HAPI_DisconnectNodeInput(&session, anotherBoxNode, 0))
1134 HE_CHECK(HAPI_DeleteNode(&session, anotherBoxNode))
1136 std::cout <<
"After DELETING NODE" << std::endl;
1138 HE_CHECK(HAPI_ComposeChildNodeList(&session, editableNetworkId, HAPI_NODETYPE_ANY, HAPI_NODEFLAGS_ANY,
false, &childCount))
1140 std::vector<HAPI_NodeId> finalChildList(childCount);
1141 HE_CHECK(HAPI_GetComposedChildNodeList(&session, editableNetworkId, &finalChildList.front(), childCount))
1142 PrintChildNodeInfo(session, finalChildList);
1149 const char* hdaFile =
"";
1151 HAPI_Session session;
1152 HAPI_ThriftServerOptions serverOptions{ 0 };
1153 serverOptions.autoClose =
true;
1154 serverOptions.timeoutMs = 3000.0f;
1156 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
1158 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
1159 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
1161 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
1162 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
1164 HAPI_AssetLibraryId assetLibId;
1165 HE_CHECK(HAPI_LoadAssetLibraryFromFile(&session, hdaFile,
true, &assetLibId))
1168 HE_CHECK(HAPI_GetAvailableAssetCount(&session, assetLibId, &assetCount))
1172 std::cout <<
"Should only be loading 1 asset here" << std::endl;
1175 HAPI_StringHandle assetSh;
1176 HE_CHECK(HAPI_GetAvailableAssets(&session, assetLibId, &assetSh, assetCount))
1178 std::string assetName = GetString(session, assetSh);
1181 HE_CHECK(HAPI_CreateNode(&session, -1, assetName.c_str(),
"TestObject",
false, &nodeId))
1182 HE_CHECK(HAPI_CookNode(&session, nodeId, &cookOptions))
1185 HAPI_Result cookResult;
1189 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
1191 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
1196 HAPI_AssetInfo assetInfo;
1197 HE_CHECK(HAPI_GetAssetInfo(&session, nodeId, &assetInfo))
1199 PrintCompleteNodeInfo(session, nodeId, assetInfo);
1206 const char* hdaFile =
"";
1208 HAPI_Session session;
1209 HAPI_ThriftServerOptions serverOptions{ 0 };
1210 serverOptions.autoClose =
true;
1211 serverOptions.timeoutMs = 3000.0f;
1213 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
1215 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
1216 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
1218 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
1219 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
1221 HAPI_AssetLibraryId assetLibId;
1222 HE_CHECK(HAPI_LoadAssetLibraryFromFile(&session, hdaFile,
true, &assetLibId))
1225 HE_CHECK(HAPI_GetAvailableAssetCount(&session, assetLibId, &assetCount))
1229 std::cout <<
"Should only be loading 1 asset here" << std::endl;
1232 HAPI_StringHandle assetSh;
1233 HE_CHECK(HAPI_GetAvailableAssets(&session, assetLibId, &assetSh, assetCount))
1235 std::string assetName = GetString(session, assetSh);
1238 HE_CHECK(HAPI_CreateNode(&session, -1, assetName.c_str(),
"PackedPrimitive",
false, &nodeId))
1240 CookAndPrintNode(session, cookOptions, nodeId, HAPI_PACKEDPRIM_INSTANCING_MODE_DISABLED);
1241 CookAndPrintNode(session, cookOptions, nodeId, HAPI_PACKEDPRIM_INSTANCING_MODE_HIERARCHY);
1242 CookAndPrintNode(session, cookOptions, nodeId, HAPI_PACKEDPRIM_INSTANCING_MODE_FLAT);
1249 const char* hdaFile =
"";
1251 HAPI_Session session;
1252 HAPI_ThriftServerOptions serverOptions{ 0 };
1253 serverOptions.autoClose =
true;
1254 serverOptions.timeoutMs = 3000.0f;
1256 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
1258 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
1259 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session,
"hapi", &sessionInfo))
1261 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
1262 HE_CHECK(HAPI_Initialize(&session, &cookOptions,
true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
1264 HAPI_AssetLibraryId assetLibId;
1265 HE_CHECK(HAPI_LoadAssetLibraryFromFile(&session, hdaFile,
true, &assetLibId))
1268 HE_CHECK(HAPI_GetAvailableAssetCount(&session, assetLibId, &assetCount))
1272 std::cout <<
"Should only be loading 1 asset here" << std::endl;
1275 HAPI_StringHandle assetSh;
1276 HE_CHECK(HAPI_GetAvailableAssets(&session, assetLibId, &assetSh, assetCount))
1278 std::string assetName = GetString(session, assetSh);
1281 HE_CHECK(HAPI_CreateNode(&session, -1, assetName.c_str(),
"AnAsset",
false, &nodeId))
1283 HE_CHECK(HAPI_CookNode(&session, nodeId, &cookOptions))
1286 HAPI_Result cookResult;
1290 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
1292 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
1297 HAPI_NodeInfo nodeInfo;
1298 HE_CHECK(HAPI_GetNodeInfo(&session, nodeId, &nodeInfo))
1300 std::vector<HAPI_ParmInfo> parmInfos(nodeInfo.parmCount);
1301 HE_CHECK(HAPI_GetParameters(&session, nodeId, parmInfos.data(), 0, nodeInfo.parmCount))
1303 std::cout <<
"Parameters: " << std::endl;
1304 for (
int i = 0; i < nodeInfo.parmCount; ++i)
1306 std::cout <<
"===========" << std::endl;
1308 std::cout <<
" Name: "
1309 << GetString(session, parmInfos[i].nameSH)
1312 std::cout <<
" Value: (";
1314 if (HAPI_ParmInfo_IsInt(&parmInfos[i]))
1316 int parmIntCount = HAPI_ParmInfo_GetIntValueCount(&parmInfos[i]);
1318 std::vector<
int> parmIntValues(parmIntCount);
1320 HE_CHECK(HAPI_GetParmIntValues(&session, nodeId, parmIntValues.data(), parmInfos[i].intValuesIndex, parmIntCount))
1322 for (
int v = 0; v < parmIntCount; ++v)
1328 std::cout << parmIntValues[v];
1331 else if (HAPI_ParmInfo_IsFloat(&parmInfos[i]))
1334 int parmFloatCount = HAPI_ParmInfo_GetFloatValueCount(&parmInfos[i]);
1336 std::vector<
float> parmFloatValues(parmFloatCount);
1338 HE_CHECK(HAPI_GetParmFloatValues(&session, nodeId, parmFloatValues.data(), parmInfos[i].floatValuesIndex, parmFloatCount))
1340 for (
int v = 0; v < parmFloatCount; ++v)
1346 std::cout << parmFloatValues[v];
1349 else if (HAPI_ParmInfo_IsString(&parmInfos[i]))
1351 int parmStringCount = HAPI_ParmInfo_GetStringValueCount(&parmInfos[i]);
1352 std::vector<HAPI_StringHandle> parmSHValues(parmStringCount);
1354 HE_CHECK(HAPI_GetParmStringValues(&session, nodeId,
true, parmSHValues.data(), parmInfos[i].stringValuesIndex, parmStringCount));
1356 for (
int v = 0; v < parmStringCount; ++v)
1363 std::cout << GetString(session, parmSHValues[v]);
#define HE_CHECK_COOK(expr)
HoudiniEngine Check Cook macro. Verify HoudiniEngine Cook API Effectiveness.
#define HE_CHECK(expr)
HoudiniEngine Check macro. Verify HoudiniEngine API Effectiveness.
virtual ~HoudiniSession()=default
static void PDG_Cooking_With_Events()
static void Marshalling_Geometry_Into_Houdini()
static std::string GetHoudiniLastError()
static void ProcessFloatAttrib(HAPI_Session &session, HAPI_AssetInfo &assetInfo, HAPI_NodeId objectNode, HAPI_NodeId geoNode, HAPI_PartId partId, HAPI_AttributeOwner owner, std::string name)
static void Parameters_Sample()
static std::string GetHoudiniLastCookError()
static void Groups_Sample()
static void Connecting_Assets()
static void Parts_Sample()
static void Curve_Output()
static void Curve_Marshalling()
static void Materials_Sample()
static std::string GetString(HAPI_Session &session, HAPI_StringHandle stringHandle)
static void Marshalling_Point_Clouds()
static void CookAndPrintNode(HAPI_Session &session, HAPI_CookOptions &co, HAPI_NodeId nodeId, HAPI_PackedPrimInstancingMode mode)
static void PrintChildNodeInfo(HAPI_Session &session, std::vector< HAPI_NodeId > &childrenNodes)
static void PrintCompleteNodeInfo(HAPI_Session &session, HAPI_NodeId nodeId, HAPI_AssetInfo &assetInfo)
static void PrintPartInfo(HAPI_Session &session, HAPI_NodeId nodeId, HAPI_PartId partId, std::string indent)
static void Packed_Primitives_Sample()
static void ProcessGeoPart(HAPI_Session &session, HAPI_AssetInfo &assetInfo, HAPI_NodeId objectNode, HAPI_NodeId geoNode, HAPI_PartId partId)
static void Node_Creation_Sample()