443 {
444 HAPI_Session session;
445
446 HAPI_ThriftServerOptions serverOptions{ 0 };
447 serverOptions.autoClose = true;
448 serverOptions.timeoutMs = 3000.0f;
449
450 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
451
452 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
453
454 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session, "hapi", &sessionInfo))
455
456 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
457 HE_CHECK(HAPI_Initialize(&session, &cookOptions, true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
458
459 HAPI_NodeId newNode;
460
461 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode, "Connecting_Assets"))
462 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
463
464 int cookStatus;
465 HAPI_Result cookResult;
466
467 do
468 {
469 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
470 }
471 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
472
475
476 HAPI_PartInfo newNodePart = HAPI_PartInfo_Create();
477
478 newNodePart.type = HAPI_PARTTYPE_MESH;
479 newNodePart.faceCount = 6;
480 newNodePart.vertexCount = 24;
481 newNodePart.pointCount = 8;
482
483 HE_CHECK(HAPI_SetPartInfo(&session, newNode, 0 , &newNodePart))
484
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;
491
492 HE_CHECK(HAPI_AddAttribute(&session, newNode, 0,
"P", &newNodePointInfo))
493
494 float positions[24] = {
495 0.0f, 0.0f, 0.0f,
496 0.0f, 0.0f, 1.0f,
497 0.0f, 1.0f, 0.0f,
498 0.0f, 1.0f, 1.0f,
499 1.0f, 0.0f, 0.0f,
500 1.0f, 0.0f, 1.0f,
501 1.0f, 1.0f, 0.0f,
502 1.0f, 1.0f, 1.0f
503 };
504
505 HE_CHECK(HAPI_SetAttributeFloatData(&session, newNode, 0,
"P", &newNodePointInfo, positions, 0, 8))
506
507 int vertices[24] = {
508 0, 2, 6, 4,
509 2, 3, 7, 6,
510 2, 0, 1, 3,
511 1, 5, 7, 3,
512 5, 4, 6, 7,
513 0, 4, 5, 1
514 };
515
516 HE_CHECK(HAPI_SetVertexList(&session, newNode, 0, vertices, 0, 24))
517
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))
521
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))
527
528 return;
529 }
#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.