Dmitry Shurov

Dmitry Shurov

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

random UV transform Oct. 26, 2014, 1:23 p.m.

Actually, rand(1) will always return you the same value because of its deterministic nature. To get different random values you must use different seeds. In your case, something like rand(a*u) and rand(b*v) may be reasonable, where a and b are any real numbers of your choice, except zero. You can try a=b=1 as a starting point.

VEX xyzdist function in HDK Oct. 26, 2014, 7:40 a.m.

Hello everyone!

Inspired by this topic (http://forums.odforce.net/topic/12691-closest-point-on-the-primitive/ [forums.odforce.net]) I've been trying to implement HDK function similar to VEX xyzdist using GU_RayIntersect class and its minumumPoint() method. Unfortunately, it always gives me zero values for uv. Tried it with different objects, no luck. Does anyone know how to make it right?

OP_ERROR
SOP_xyzdist::cookMySop(OP_Context &context)
{
if (lockInputs(context) >= UT_ERROR_ABORT)
return error();

duplicateSource(0, context);

UT_Vector3 pos(0,0,0); // just for testing
GA_PrimitiveGroup* grp = 0; // Searching the whole geometry, I suppose
GU_MinInfo mininfo(0, 100000, 1);
GU_RayIntersect near(gdp, grp, 1);
near.minimumPoint(pos, mininfo);

float u = mininfo.u1;
float v = mininfo.v1;
std::cout << u << “ ” << v << std::endl;

unlockInputs();
return error();
}

Wrapping my head around adding points using HDK..... June 23, 2014, 7:51 a.m.

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));