How to Traverse HIP file to find Geometry nodes (C++) [Solved]

   912   0   0
User Avatar
Member
2 posts
Joined: May 2018
Offline
So I am looking at the traverse.C standalone application trying to figure out how to query an OP_Node from the OP_Network to determine if it contains geometry (GA_Detail)?

These are the nodes I need to find in the scene:
- Camera (OBJ_Camera) used for rendering (the main scene camera). I am going to need to pull the projection matrix from it to transform any geometry I find into screen space
- Any nodes containing “GA_Detail”. Again, not certain how to query an OP_Node to see if it's actually some sort of geometry within the scene

It would be ideal if I could easily traverse a .hip file from a standalone app and be able to get geometry nodes that I can then query for vertices it contains.

edit-
Made some progress. I am able to at least able to get traverse.C to print out all the objects contained within my scene. Just need to solve how to cast from OP_Node -> OBJ_Node. But I will also still need to solve how to get a GA_Detail out of OBJ_Geometry nodes

edit2 - This might be solved. Just found this doc: https://www.sidefx.com/docs/hdk/_h_d_k__node_intro__working_with_nodes.html [www.sidefx.com]

edit3 - Just need to get a GA_Detail out of this OBJ_Geometry node!!!

edit4 - Solved, make sure to visit the link above to HDK docs on ‘working with nodes’.
// node == OP_Node
OBJ_Node* obj_node = CAST_OBJNODE(node);
// This gives you the OBJ_Node. Make sure to check for NULL
OBJ_Camera* camera = obj_node->castToOBJCamera();
OBJ_Geometry* geo = obj_node->castToOBJGeometry();

// Note- also can recurse into child nodes to check for SOP_Node that cooks geo
const GU_Detail* detail = obj_node->getRenderGeometry(context);

Thanks
Edited by sandboxgod - May 23, 2018 19:15:48
  • Quick Links