270 {
271
272 HAPI_Session session;
273
274 HAPI_ThriftServerOptions serverOptions{ 0 };
275 serverOptions.autoClose = true;
276 serverOptions.timeoutMs = 3000.0f;
277
278 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions,
"hapi",
nullptr,
nullptr))
279
280 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
281
282 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session, "hapi", &sessionInfo))
283
284
285 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
286 HE_CHECK(HAPI_Initialize(&session, &cookOptions, true, -1,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr))
287
288
289 HAPI_NodeId newNode;
290 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode, "Marshalling_Point_Clouds"))
291
292 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
293
294
295 int cookStatus;
296 HAPI_Result cookResult;
297
298 do
299 {
300 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
301 }
302 while (cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
305
306
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))
313
314
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))
322
323
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))
326
327
328 int vertices[3] = { 0, 1, 2 };
329 HE_CHECK(HAPI_SetVertexList(&session, newNode, 0, vertices, 0, 3))
330
331
332 int face_counts[1] = { 3 };
333 HE_CHECK(HAPI_SetFaceCounts(&session, newNode, 0, face_counts, 0, 1))
334
335
336 std::array<
char*, 3> strs;
337 strs[0] = _strdup("strPoint1");
338 strs[1] = _strdup("strPoint2");
339 strs[2] = _strdup("strPoint3");
340
341 newNodePointInfo.count = 3;
342 newNodePointInfo.tupleSize = 1;
343 newNodePointInfo.exists = true;
344 newNodePointInfo.storage = HAPI_STORAGETYPE_STRING;
345 newNodePointInfo.owner = HAPI_ATTROWNER_POINT;
346
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))
349
350
351 HE_CHECK(HAPI_CommitGeo(&session, newNode));
352
353
354 HE_CHECK(HAPI_SaveHIPFile(&session, "C:/Users/Administrator/Desktop/Marshalling_Point_Clouds.hip", false))
355
356
358
359 return;
360 }
#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.