michaelw Posted December 21, 2012 Share Posted December 21, 2012 hi there, I tried to play around with hdk cookie (GU_Cookie) but it messed up. Basically I did these things in my code: 1. merge in input A and input B 2. create primitive and point groups for both inputs 3. call setGroups to setup groups 4. call cookie for the cookie operation With my understanding, the output should be in those [in/out/overlap] groups that I can check. But when I used two spheres for testing, the result is totally wrong. Anyone could give me a hint what I did wrong here? GU_Detail* input_geo0 = (GU_Detail *) inputGeo(0);GU_Detail* input_geo1 = (GU_Detail *) inputGeo(1);GA_PrimitiveGroup* pr_a = input_geo0->newPrimitiveGroup("pr_a");GA_PrimitiveGroup* pr_b = input_geo1->newPrimitiveGroup("pr_b");GA_PointGroup* pt_a = input_geo0->newPointGroup("pt_a");GA_PointGroup* pt_b = input_geo1->newPointGroup("pt_b");for (GA_Iterator it(input_geo0->getPrimitiveRange()); !it.atEnd(); it.advance()){GA_Offset offset = it.getOffset();pr_a->addOffset(offset);}for (GA_Iterator it(input_geo1->getPrimitiveRange()); !it.atEnd(); it.advance()){GA_Offset offset = it.getOffset();pr_b->addOffset(offset);}for (GA_Iterator it(input_geo0->getPointRange()); !it.atEnd(); it.advance()){GA_Offset offset = it.getOffset();pt_a->addOffset(offset);}for (GA_Iterator it(input_geo1->getPointRange()); !it.atEnd(); it.advance()){GA_Offset offset = it.getOffset();pt_b->addOffset(offset);}gdp -> merge(* input_geo0);gdp -> merge(* input_geo1);GU_Cookie m_cookie;m_cookie.setGroups(pr_a, pr_b, pt_a, pt_;GA_PrimitiveGroup* a_in = gdp->newPrimitiveGroup("a_in");GA_PrimitiveGroup* a_out = gdp->newPrimitiveGroup("a_out");GA_PrimitiveGroup* a_overlap = gdp->newPrimitiveGroup("a_overlap");GA_PrimitiveGroup* b_in = gdp->newPrimitiveGroup("b_in");GA_PrimitiveGroup* b_out = gdp->newPrimitiveGroup("b_out");GA_PrimitiveGroup* b_overlap = gdp->newPrimitiveGroup("b_overlap");m_cookie.cookie(*gdp,0,*a_in,*a_out,*a_overlap,1,*b_in,*b_out,*b_overlap,1,1 ); [/CODE] Quote Link to comment Share on other sites More sharing options...
michaelw Posted January 3, 2013 Author Share Posted January 3, 2013 one houdini master helped me figured out. In case someone has the same question: GU_Detail* input_geo0 = new GU_Detail; GU_Detail* input_geo1 = new GU_Detail; duplicateSource(0, context,input_geo0); duplicateSource(1, context,input_geo1); GA_PrimitiveGroup* pr_a = input_geo0->newPrimitiveGroup("pr_a"); GA_PrimitiveGroup* pr_b = input_geo1->newPrimitiveGroup("pr_b"); for (GA_Iterator it(input_geo0->getPrimitiveRange()); !it.atEnd(); it.advance()) { GA_Offset offset = it.getOffset(); pr_a->addOffset(offset); } for (GA_Iterator it(input_geo1->getPrimitiveRange()); !it.atEnd(); it.advance()) { GA_Offset offset = it.getOffset(); pr_b->addOffset(offset); } gdp->clearAndDestroy(); GU_Detail* gdp1 = new GU_Detail; gdp1 -> merge(* input_geo0); gdp1 -> merge(* input_geo1); GU_Cookie m_cookie; m_cookie.setTolerance(0.0001); GA_PrimitiveGroup* m_pr_a = gdp1->findPrimitiveGroup("pr_a"); GA_PrimitiveGroup* m_pr_b = gdp1->findPrimitiveGroup("pr_b"); m_cookie.setGroups(m_pr_a, m_pr_b, 0, 0); m_cookie.cookie(*gdp1, 0, * gdp1->newPrimitiveGroup("a_in"), * gdp1->newPrimitiveGroup("a_out"), * gdp1->newPrimitiveGroup("a_overlap"), 1, * gdp1->newPrimitiveGroup("b_in"), * gdp1->newPrimitiveGroup("b_out"), * gdp1->newPrimitiveGroup("b_overlap"), 1, 1 ); GU_Detail *new_gdp = m_cookie.getDetail(); gdp ->merge(*new_gdp); gdp1->clearAndDestroy(); input_geo0->clearAndDestroy(); input_geo1->clearAndDestroy(); [/CODE] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.