DoctorBuzz Posted December 15, 2004 Share Posted December 15, 2004 Hi guys, I'm very new to C++ code and so I have to ask some question to the masters here I'm trying to write a simple plugin modifying one of the samples. I have (well...I wish to have actually ) a SOP with 2 inputs. In the second input I have to attach a spline curve and of that spline I have to know the arclength, the point position along it and the tangents. Now I found some functions on GEO_Curve.h that I think do exactly what I want... float arcLength (float u0, float u1, bool use_frwd_diff=true, int divs=10) const virtual int evaluatePoint (UT_Vector4 &pos, float u_unit, float=0, unsigned du=0, unsigned=0) const virtual int evaluatePointWAttrib (UT_Vector4 &pos, GB_AttributeData &adata, const GB_FloatOffsets &foffsets, float u_unit, float=0, unsigned du=0, unsigned=0) const Now I' not able to use them...anyone can tell me how to use them? Also...anyone knows how to use the HDK with the editor of Visual C to access directly the information about class inside it? Also it seems to me that the hcbrowse utility mentioned in the documentation is not available on windows. Thank you in advance and sorry for my english Quote Link to comment Share on other sites More sharing options...
George Posted December 16, 2004 Share Posted December 16, 2004 Now I found some functions on GEO_Curve.h that I think do exactly what I want...... Now I' not able to use them...anyone can tell me how to use them? 15524[/snapback] In order to use the GEO_Curve code, you must have a curve primitive. You can get the primitive from the gdp using gdp->primitives() (that will give you an array of primitives). On those primitives you need to discover if the primitive is in fact a GEO_Curve before you can use it. Here's an example: GEO_Primitive *prim = gdp->primitive()(i); if (prim && (prim->getPrimitiveId() & GEOCURVE)) { GEO_Curve *curve = (GEO_Curve *)prim; // use your curve. } Also...anyone knows how to use the HDK with the editor of Visual C to access directly the information about class inside it?Also it seems to me that the hcbrowse utility mentioned in the documentation is not available on windows. 15524[/snapback] If you take a look in the toolkit directory of where you installed the HDK, you may find some files in the makefiles directory. There is one called Makefile.nmake. This is a makefile in Microsoft's nmake format. I believe Visual Studio can read this and convert it to the dsp and dsw files that it uses with its IDE. I could be wrong about that, you may have to experiment. Also, I don't believe that hcbrowse is necessary anymore since the headers are publicly available. Hope that helps. Quote Link to comment Share on other sites More sharing options...
DoctorBuzz Posted December 17, 2004 Author Share Posted December 17, 2004 Thanks.... it helps a lot. Just I'm not able to use the GEO_Curve::evaluatepoint method without errors... More precisely that "UT_Vector4 &pos" argument give me problems... Any help on this? Thank you again. Quote Link to comment Share on other sites More sharing options...
DoctorBuzz Posted December 17, 2004 Author Share Posted December 17, 2004 Here I am again I have another problem... I have 2 inputs... On the first one there's the geometry to deform and on the second the deformation spline... well it seems that if both inputs are nurbs the SOP doesn't crash, but if I change the first one to poly (and that's the way i want to use it) the SOP crash houdini . May be I don't understand very well how to use 2 inputs (some more examples would help)... Well..here it is my code (please don't kill me ) SOP_SplineDeformer::cookMySop(OP_Context &context) { GEO_Point *ppt; GEO_Curve *spline; GEO_Primitive *prim; float now; float offset; float splen; UT_Vector4 pos, tan, p, t; // Before we do anything, we must lock our inputs. Before returning, // we have to make sure that the inputs get unlocked. if (lockInputs(context) >= UT_ERROR_ABORT) return error(); now = context.myTime; // Here we determine which groups we have to work on. We only // handle point groups. if (error() < UT_ERROR_ABORT && cookInputGroups(context) < UT_ERROR_ABORT) { duplicateSource(1, context); offset = OFFSET(now); prim = gdp->primitives()(0); spline = (GEO_Curve *)prim; splen = spline->arcLength(0,1,true,10); duplicateSource(0, context); FOR_ALL_GPOINTS(gdp, ppt) { offset = fmod((ppt->getPos()(2)/splen+offset), 1); if (spline->getPrimitiveId() == GEOPRIMNURBCURVE | spline->getPrimitiveId() == GEOPRIMBEZCURVE) { p = spline->evaluatePoint(pos, offset, 0, 0, 0); t = spline->evaluatePoint(tan, offset, 0, 1, 0); } // here I'll write the deformation routine } } unlockInputs(); return error(); } I hope that someone can help me... Quote Link to comment Share on other sites More sharing options...
DoctorBuzz Posted December 18, 2004 Author Share Posted December 18, 2004 I'm really blocked... Did I requested too stupid questions that anyone answer me? Anyone can post an example on how to use multiple inputs? My problems comes from the second "duplicateSource" (well...i think ) Really some example on how to use multiple inputs (possibly on the first a polygonal geometry and on the second a spline), would be very appreciated. C'mon...I know that for some of you could be a really simple thing... Quote Link to comment Share on other sites More sharing options...
Jason Posted December 19, 2004 Share Posted December 19, 2004 Hi there, The key is to use inputGeo() instead. Here is a code snippet from a SOP with two inputs: GU_Detail *secondinput; const GU_Detail *original; ... duplicateChangedSource(0, context); original = inputGeo(0, context); secondinput = (GU_Detail *)inputGeo(1, context); If you aren't using the Doxygen Docs for Houdini 7, then you'll love it Quote Link to comment Share on other sites More sharing options...
George Posted December 20, 2004 Share Posted December 20, 2004 More precisely that "UT_Vector4 &pos" argument give me problems...Any help on this? Thank you again. 15539[/snapback] Can you post the error that you are getting? Also, as for the two input problems you are having, as Jason said, you probably just want to duplicateSource on the first input (since that's the input you want to keep and deform). The second input is just used as a guide, so you don't need a copy of it into your SOP's gdp, you can just use inputGeo(). Incidentally, this is also more efficient. If you did want to copy both gdps into your current gdp (like Merge SOP for example), you should not be using duplicateSource anyhow, and would probably be better off with GEO_Detail::copy(). But again, it doesn't sound like that's what you need. Take care, George. Quote Link to comment Share on other sites More sharing options...
DoctorBuzz Posted December 20, 2004 Author Share Posted December 20, 2004 Thanks guys, I solved these problems, and your help was great. What I need to find now is a way to calculate the relative bbox of a point (like the same function in VEX and VOP)... If some of you have this answer too Anyway thanks again for your support. Quote Link to comment Share on other sites More sharing options...
George Posted December 20, 2004 Share Posted December 20, 2004 You may want to have a look at GB_Detail::getBBox() and the UT_BoundingBox class. Quote Link to comment Share on other sites More sharing options...
DoctorBuzz Posted December 21, 2004 Author Share Posted December 21, 2004 Hi BoboFancy I take a look at that classes and function but I have not found one that returns the relative position of a point inside an object bbox, while it's available both in the Point SOP and expression and in the VEX or VOPs. If you have any suggestion... Anyway thanks for your help. Quote Link to comment Share on other sites More sharing options...
Jason Posted December 21, 2004 Share Posted December 21, 2004 I believe you're going to have quickly calculate that yourself. I don't think the overhead of calling a function is going to be efficient compared to the simple divide it takes to calculate it yourself. Quote Link to comment Share on other sites More sharing options...
George Posted December 23, 2004 Share Posted December 23, 2004 I agree with Jason. Plus if you're doing it on a bunch of points, then you can compute the bounding box only once whereas such a function would have to calculate the bounding box for each point (which would be quite inefficient) since the detail doesn't cache the bounding box to my knowledge. Take care, George. 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.