HDK: How to call PolyExtrude on open curve?

   698   2   1
User Avatar
Member
27 posts
Joined: 3月 2020
Offline
Having trouble calling PolyExtrude in an HDK. Nothing happens when I pass it an open curve. If I close the curve, it works. I don't know what I'm missing. Probably related but it also doesn't work if I have a closed curve but then use ConvertLine to get rid of the face.

Here's my code snippet. I have a class derived from SOP_NodeVerb and code is called within cook().

class SOP_MyVerb : public SOP_NodeVerb
{
public:
void SOP_PolyExtrudeModVerb::cook(const SOP_NodeVerb::CookParms &cookparms) const {
GU_Detail *detail = cookparms.gdh().gdpNC();
GOP_Manager group_manager;
const GA_PrimitiveGroup *grp = group_manager.parsePrimitiveGroups("*", GOP_Manager::GroupCreator(detail));

GU_PolyExtrude2 polyExtrude(detail, grp);
polyExtrude.setExtrusionMode(GU_PolyExtrude2::ExtrusionMode::PRIM_OR_EDGE_NORMAL);
polyExtrude.setOutputFront(true);
polyExtrude.setOutputSide(true);
polyExtrude.extrude(1.0);
}
}
Edited by goingbananas - 2020年8月30日 01:45:32
User Avatar
Member
159 posts
Joined: 2月 2018
Offline
It's because the group type is Primitive and your geometry is a curve. So set the Primitive_Group to Edge_Group and it should work.

change this line
const GA_PrimitiveGroup *grp = group_manager.parsePrimitiveGroups("*", GOP_Manager::GroupCreator(detail));
to this
const GA_EdgeGroup *grp = group_manager.parseEdgeGroups(sopparms.getGroup(), detail);
There gonna be more convinient way to deal with different types of group, hope someone could share it.
Edited by EricSheng - 2020年8月30日 04:42:40
User Avatar
Member
27 posts
Joined: 3月 2020
Offline
Thanks. I added a parameter drop down so I could switch between creating GA_PrimitiveGroup and GA_EdgeGroup in the code. Yeah, there's probably a way to determine group type based on input but I couldn't see how to do that.
  • Quick Links