Wrapping my head around adding points using HDK.....

   2107   2   0
User Avatar
Member
5 posts
Joined: June 2014
Offline
I'm quite new to the HDK, but I'm doing research for my professor and writing some micro-solvers to make some things work. I'm having trouble understanding some concepts. I've looked at relevant examples that others have mentioned in similar posts, but I still can't figure it out.

Basically, I want to add points to this fluid simulation object we have. Using the following code in my “solveGasSubclass”, I do get new points added, but I don't know how to set attributes besides the x,y,z position.

const SIM_Geometry* temp = fluidobj->getGeometry();
GU_ConstDetailHandle temp2 = temp->getOwnGeometry();
GU_DetailHandle temp3 = temp2.castAwayConst();

GU_DetailHandleAutoWriteLock gdl(temp3);
GU_Detail *gdp = gdl.getGdp();

GA_Offset newptoff = gdp->appendPointOffset();
UT_Vector3 v(1,3.5,1);
gdp->setPos3(newptoff, v);

How can I set other attributes? For example, I have an attribute called “pscale” which I'm pretty sure is causing the points I'm adding to be much larger than the other points. There is no setPScale function, so I'm kinda at a loss. Is there, perhaps, a “setAttribute(”pscale“,0.1)” type function?

Another question: Is there a way to have a new point inherit all the attribute values from other points already?
User Avatar
Member
3 posts
Joined: Jan. 2014
Offline
To add an attribute you can use:

gdp->addFloatTuple(GA_ATTRIB_POINT, GA_SCOPE_PUBLIC, “pscale”, 1, GA_Defaults(1.0));

The you can create a handle to write to this attribute:
GA_RWHandleF pscale_h(gdp, GA_ATTRIB_POINT, “pscale”);

float newValue = 2.0;
pscale_h.set(newptoff, newValue);


Or you can create an attribute and a handle in ine line:
GA_RWHandleF pscale_h(gdp->addFloatTuple(GA_ATTRIB_POINT, “pscale”, 1, GA_Defaults(1.0));
User Avatar
Member
5 posts
Joined: June 2014
Offline
Thank you so much, that really shed some light on things and worked great.
  • Quick Links