Jump to content


Stalkerx777

Member Since 09 Jun 2008
Offline Last Active Apr 19 2013 02:18 PM
-----

Topics I've Started

SOHO - modify geometry?

11 November 2012 - 12:24 PM

Hi guys! So here is the problem. I need to compute some data and store it as primitive attributes.The simplest solution would be to put digital asset in each geometry object, but i want this to be done at IFD export time. So in the end, every geometry object should have this data in IFD.
I started with writing IFDHook function ("pre_geometry"), where i get access to geometry, and compute my stuff. But after some research, i figure out, that there is no way to modify SohoGeometry, it has read only access.
SohoGeometry.save(), emits original houdini geometry into stdout stream.
Then, in IFDgeo.py in method saveRetained() there is a call to objectWragler, and there is a NOTE:

"Call the object wranglers 'retainGeometry', skip inbuilt soho code if  it returns True. Note. It's the responsibility of object wrangler to emit IFD correctly."

So, i can write my wrangler, and emit data to IFD by myself, but I think it is not a very good idea to implement such a thing in python. There should be a performance hit.
Any help on this? Maybe i do something wrong, and there are more elegant solutions.... !?

Best regards.
Alex

Store Computed GDP

09 September 2012 - 08:17 AM

Hi guys. I' looking for solution how to add some functionality similar to capture sop. There is Capture Frame parameter in this sop, which allows to compute capture weights data in specified frame, while reuse this data in other frames. I'd like to add this functionality into my sop. I think it should look something like this (in pseudo code):
class MySopClass
{
.
.
	GU_Detail *initGDP;
.
.
}

cookMySop(....)
{
.
.
	if(frame != initFrame && initGDP.isValid())
	{
		gdp->copy(*initGDP);
	}
	else
	{
		//Compute things
		initGDP = gdp;
	}
}

So, basically i need to recompute gdp only in initFrame (frame 1 for example), store this gdp in initGDP, and reuse it in other frames. Of course there is no isValid() method in gdp. So i can't be sure is my gdp "isValid". Is this a right approach?:unsure:
Any help? Thx!

HDK - Iterating vertecies

21 August 2012 - 11:39 AM

Hi. :)  I have a little experiense in pre H12 geometry library, but i completely lost in new GA library. I'm trying to iterate over all vertices of each primitive.... here' is how my code looks like, it compiles fine, but crash, right on display flag set:
.
.
.
GA_ROAttributeRef uv_ref = gdp->findVertexAttribute("uv");
GA_ROHandleV3 uv_h(uv_ref.getAttribute());
if (! uv_h.isInvalid())
   return error();
	
	const GA_Primitive *prim;
	const GA_PrimitiveList &primList = gdp->getPrimitiveList();
		GA_Range vtx_range;
	

	for (GA_Iterator pr_it(gdp->getPrimitiveRange()); !pr_it.atEnd(); ++pr_it)
	{
		GA_Offset prim_offset = pr_it.getOffset();
		prim = primList.get(prim_offset);
		vtx_range = prim->getVertexRange();
		for (GA_Iterator vtx_it(vtx_range.begin()); !vtx_it.atEnd(); ++vtx_it)
		{
			GA_Offset vtx_offset = vtx_it.getOffset()
			UT_Vector3 uv(uv_h.get(vtx_offset));
						// Do something with uv.......

		}
		

	}
.
.
.

If i remove UT_Vector3 uv(uv_h.get(vtx_offset)), houdini doesn't crash anymore. Can you please tell me where i'm wrong. And is this a right approach for iterating over vertices? Strictly speaking, i need only one vertex from each primitive, how can i get it?
Thx!