Jump to content

offset copied geo to points?


Recommended Posts

Hi,

I`m trying to create a SOP node, that basically does the same thing as the copytopoints SOP in Houdini but with a Box deformation added to it.
Now I was able to copy the detail from the second Input into the gdp, but I find myself unable to access the newly added geo to actually offset it to the corresponding point in the first input.
I want to add that I am a noobie when it comes to HDK (as you can probably see) 
and any help is much appreciated and thanks in advance. :)
 

OP_ERROR SOP_copyPTs::cookMySop(OP_Context &context)
{
	OP_AutoLockInputs inputs(this);

	if (inputs.lock(context) >= UT_ERROR_ABORT)
		return error();

	const GU_Detail *firstGDP = inputGeo(0, context);
	const GU_Detail *secondGDP = inputGeo(1, context);



	UT_AutoInterrupt progress("still copying...");

	duplicateSource(0, context);

	GA_RWHandleV3 Phandle(gdp->findAttribute(GA_ATTRIB_POINT, "P"));

    GA_Offset firstPToff;

	GEO_CopyMethod copymethod = GEO_COPY_ADD;


    GA_FOR_ALL_PTOFF(firstGDP, firstPToff)
    {

		if (progress.wasInterrupted())
			break;

		gdp->copy(*secondGDP, copymethod, true, false, GA_DATA_ID_CLONE);
	    UT_Vector3 Pvalue = Phandle.get(firstPToff);

    }

	Phandle.bumpDataId();


	return error();

}

i got it to work! :D (propably a pretty bad way to do it but it works)
(orientation is working as well now but its not in the code down below)
I am still very interested how experienced users would have written it. :S

    GA_FOR_ALL_PTOFF(firstGDP, gridPoints)
    {
		if (progress.wasInterrupted())
			break;

		GU_Detail *newgdp = new GU_Detail();
		GA_RWHandleV3 newPhandle(newgdp->findAttribute(GA_ATTRIB_POINT, "P"));



		newgdp->copy(*secondGDP, copymethod, true, false, GA_DATA_ID_CLONE);
		GA_Offset spherePoint;

	    UT_Vector3 pointPos = Phandle.get(gridPoints);

		GA_FOR_ALL_PTOFF(newgdp, spherePoint)
		{
			UT_Vector3 spherePos = newPhandle.get(spherePoint);

			UT_Vector3 addedPos = spherePos + pointPos;

			newPhandle.set(spherePoint, addedPos);

		}
		gdp->copy(*newgdp, copymethod, true, false, GA_DATA_ID_CLONE);

    }
Edited by Ninjakeks
wrote the post at 2am and didnt frase the question right
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...