Jump to content

Noob question


Recommended Posts

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 :P

Link to comment
Share on other sites

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-&gt;primitive()(i);
if (prim &amp;&amp; (prim-&gt;getPrimitiveId() &amp; 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.

Link to comment
Share on other sites

Here I am again :P

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 :rolleyes: )

SOP_SplineDeformer::cookMySop(OP_Context &amp;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) &gt;= 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() &lt; UT_ERROR_ABORT &amp;&amp; cookInputGroups(context) &lt; UT_ERROR_ABORT)
	{
  duplicateSource(1, context);

  offset = OFFSET(now);
  prim = gdp-&gt;primitives()(0);
  spline = (GEO_Curve *)prim;
  splen = spline-&gt;arcLength(0,1,true,10);

  duplicateSource(0, context);

  FOR_ALL_GPOINTS(gdp, ppt)
  {
 	 offset = fmod((ppt-&gt;getPos()(2)/splen+offset), 1);
 	 if (spline-&gt;getPrimitiveId() == GEOPRIMNURBCURVE | spline-&gt;getPrimitiveId() == GEOPRIMBEZCURVE)
 	 {
    p = spline-&gt;evaluatePoint(pos, offset, 0, 0, 0);
    t = spline-&gt;evaluatePoint(tan, offset, 0, 1, 0);
 	 }
 	 // here I'll write the deformation routine
  }
	}
	unlockInputs();
	return error();
}

I hope that someone can help me...

Link to comment
Share on other sites

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 :blink: )

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...

Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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... :rolleyes:

Anyway thanks for your help.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...