goldleaf Posted February 10, 2016 Share Posted February 10, 2016 I'm not sure how to use GU_PrimRBezCurve and create a new Bezier Curve. Does anyone have an example snippet lying around they could share? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
symek Posted February 10, 2016 Share Posted February 10, 2016 I'm not sure how to use GU_PrimRBezCurve and create a new Bezier Curve. Does anyone have an example snippet lying around they could share? Thanks in advance! I'm far from being an expert on the curves' specialities like basis, knots, break poinst and similar, but primitive-wise curve should follow. #include <GU/GU_Detail.h> #include <GU/GU_PrimRBezCurve.h> GU_Detail gdp; GU_PrimRBezCurve *curve; uint npoints = 100; curve = GU_PrimRBezCurve::build(&gdp, npoints); GA_Primitive::const_iterator it; for (curve->beginVertex(it); !it.atEnd(); ++it) { const uint i = (uint)it.getPointOffset(); const UT_Vector3 pos = UT_Vector3(sin(i*25.0/npoints), i*2.0/npoints, cos(i*25.0/npoints)); gdp.setPos3(it.getPointOffset(), pos); } There are now some optimized functions to build curves in parrallel or via primitive factories etc, so this really might be not-so-cleaver way of doing this. But works. 1 Quote Link to comment Share on other sites More sharing options...
goldleaf Posted February 10, 2016 Author Share Posted February 10, 2016 Perfect, thank you Symek! I'll have to keep my eye out for, and figure out how to use, those alternate methods (parallel and/or factory), I didn't realize it was possible to generate geometry in parallel! Cheers! Quote Link to comment Share on other sites More sharing options...
symek Posted February 10, 2016 Share Posted February 10, 2016 Perfect, thank you Symek! I'll have to keep my eye out for, and figure out how to use, those alternate methods (parallel and/or factory), I didn't realize it was possible to generate geometry in parallel! Cheers! I think this is special scenario created specifically for a fur pipeline, but I see also a couple of places where HDK allows for creation geometry multi-threaded via special method. That is, this is not something you're allowed to do, but you can ask gdp to make some number of primitives for you. AFAIK that way gdp can book keeping geometry. Many primitive types have *appendBlock method. Also points (see bellow). GU_Detail gdp; const uint npoints = 1000000; const uint curvelength = 4; const uint order = 4; UT_Array<int> curvepointnumbers(npoints, npoints); UT_Array<int> porders(npoints, npoints); GEO_PolyCounts curvesizelist; curvesizelist.append(curvelength, npoints/curvelength); const GA_Offset startpt = gdp.appendPointBlock((GA_Size)npoints); const GA_OffsetList list = gdp.getPointMap().getOffsetFromIndexList(); for (GA_Offset ptoff = list.get(0); ptoff != list.last(); ++ptoff) { const uint i = static_cast<int>(ptoff); curvepointnumbers(i) = i; porders(i) = order; } GU_PrimRBezCurve::buildBlock(&gdp, startpt, (GA_Size)npoints, curvesizelist, &curvepointnumbers(0), porders, 4, false); 1 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.