SpiecsEngine
 
Loading...
Searching...
No Matches

◆ Marshalling_Geometry_Into_Houdini()

static void HoudiniEngine::Marshalling_Geometry_Into_Houdini ( )
static

Definition at line 269 of file HoudiniTestSource.h.

270 {
271 // Create Session
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 // Initialize Session
285 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
286 HE_CHECK(HAPI_Initialize(&session, &cookOptions, true, -1, nullptr, nullptr, nullptr, nullptr, nullptr))
287
288 // create null node
289 HAPI_NodeId newNode;
290 HE_CHECK(HAPI_CreateInputNode(&session, -1, &newNode, "Marshalling_Point_Clouds"))
291 // cook null node
292 HE_CHECK(HAPI_CookNode(&session, newNode, &cookOptions))
293
294 // Wait for cook over.
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);
303 HE_CHECK(cookResult)
304 HE_CHECK_COOK(cookStatus)
305
306 // null node part info
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 // null node attribute info
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 // set null node attribute
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 // set null node vertices
328 int vertices[3] = { 0, 1, 2 };
329 HE_CHECK(HAPI_SetVertexList(&session, newNode, 0, vertices, 0, 3))
330
331 // set null node faces
332 int face_counts[1] = { 3 };
333 HE_CHECK(HAPI_SetFaceCounts(&session, newNode, 0, face_counts, 0, 1))
334
335 // set null node str attriute
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 // commit null node
351 HE_CHECK(HAPI_CommitGeo(&session, newNode));
352
353 // save to hip file
354 HE_CHECK(HAPI_SaveHIPFile(&session, "C:/Users/Administrator/Desktop/Marshalling_Point_Clouds.hip", false))
355
356 // clean up session, needs recall initialize
357 HE_CHECK(HAPI_Cleanup(&session))
358
359 return;
360 }
#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
STL namespace.