SpiecsEngine
 
Loading...
Searching...
No Matches

◆ Marshalling_Point_Clouds()

static void HoudiniEngine::Marshalling_Point_Clouds ( )
static

Definition at line 362 of file HoudiniTestSource.h.

363 {
364 // Create Session
365 HAPI_Session session;
366
367 HAPI_ThriftServerOptions serverOptions{ 0 };
368 serverOptions.autoClose = true;
369 serverOptions.timeoutMs = 3000.0f;
370
371 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions, "hapi", nullptr, nullptr))
372
373 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
374
375 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session, "hapi", &sessionInfo))
376
377 // Initialize Session
378 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
379 HE_CHECK(HAPI_Initialize(&session, &cookOptions, true, -1, nullptr, nullptr, nullptr, nullptr, nullptr))
380
381 // create null node
382 HAPI_NodeId newNode;
383 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode, "Marshalling_Point_Clouds"))
384 // cook null node
385 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
386
387 int cookStatus;
388 HAPI_Result cookResult;
389
390 do
391 {
392 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
393 }
394 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
395
396 HE_CHECK(cookResult)
397 HE_CHECK_COOK(cookStatus)
398
399 // get null node geo info
400 HAPI_GeoInfo newNodeGeoInfo;
401 HE_CHECK(HAPI_GetDisplayGeoInfo(&session, newNode, &newNodeGeoInfo))
402
403 HAPI_NodeId sopNodeId = newNodeGeoInfo.nodeId;
404
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))
411
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))
419
420 float positions[24] = {
421 0.0f, 0.0f, 0.0f,
422 1.0f, 0.0f, 0.0f,
423 1.0f, 0.0f, 1.0f,
424 0.0f, 0.0f, 1.0f,
425 0.0f, 1.0f, 0.0f,
426 1.0f, 1.0f, 0.0f,
427 1.0f, 1.0f, 1.0f,
428 0.0f, 1.0f, 1.0f
429 };
430
431 HE_CHECK(HAPI_SetAttributeFloatData(&session, sopNodeId, 0, "P", &newNodePointInfo, positions, 0, 8))
432
433 HE_CHECK(HAPI_CommitGeo(&session, sopNodeId))
434
435 HE_CHECK(HAPI_SaveHIPFile(&session, "C:/Users/Administrator/Desktop/Marshalling_Point_Clouds.hip", false))
436
437 HE_CHECK(HAPI_Cleanup(&session))
438
439 return;
440 }
#define HE_CHECK_COOK(expr)
HoudiniEngine Check Cook macro. Verify HoudiniEngine Cook API Effectiveness.
Definition HoudiniCore.h:32
#define HE_CHECK(expr)
HoudiniEngine Check macro. Verify HoudiniEngine API Effectiveness.
Definition HoudiniCore.h:17