[Sidefx-houdini-list] HDK: How to get nth point attrib value in H16?

Pradeep Barua pradeepbarua at live.com
Wed Mar 15 15:20:35 EDT 2017


I haven't used HDK for a long time. Now I'm a little rusty while using new classes.

I wrote a tool a long back which was using GEO_Point and GEO_PointList. Until H12(since then I was in Python and VEX world) it worked fine but now I get more lines of errors than my code :S

At 51 and 59 I need nth point position inside for loop(// create connections).

I'm going through the documentation and I think it's a lot to cover. Any help(or alternative) is highly appreciated!

My old code:
//----------------------------------------------------------------
OP_ERROR pbConnections::cookMySop(OP_Context &context)
{
// lock input
if (lockInputs(context) >= UT_ERROR_ABORT)
return error();

// clean the geometry
gdp->clearAndDestroy();

    // inputs
const GU_Detail *source = inputGeo(0);
const GU_Detail *target = inputGeo(1);

float t = context.getTime();

    // get user input parameter values
unsigned int maxConnections = evalInt("maxConnections", 0, t);
int curveSamples = evalInt("curveSamples", 0, t);
int maxConnectionsClamp = evalInt("maxConnectionsClamp", 0, t);

    // number of points in source and target
    int sourceNumPoints{0}, targetNumPoints{0};

// number of connections
unsigned int connections{0};
connections > maxConnections ? connections = maxConnections : 0;

//GEO_PointList sourceNumPoints; // old
if (source != NULL)
{
//sourceNumPoints = source->points().entries(); // old H12
        sourceNumPoints = source->getNumPoints(); // new H16
connections = sourceNumPoints;
}

//GEO_PointList targetNumPoints; // old
if (target != NULL)
{
//targetNumPoints = target->points().entries(); // old H12
        targetNumPoints = target->getNumPoints(); // new H16
        if (maxConnectionsClamp == 1)
connections > targetNumPoints ? connections = targetNumPoints : 0;
}

// create connections
for (int i = 0; i < connections; i++)
{

// get the start position
const GEO_Point *sourceCurPoint = source->points().entry(i); // old H12
UT_Vector3 startPos = sourceCurPoint->getPos(); // how to get nth point pos in H16?

// set the end position
UT_Vector3 endPos = startPos; // initial endPos

if (targetNumPoints > 0)
{
const GEO_Point *targetCurPoint = target->points().entry(i % targetNumPoints); // old H12
endPos = targetCurPoint->getPos(); // how to get nth point pos in H16?
}

        // some other code
        // .......

    }

    // .........
    // .........

unlockInputs();

return error();
}
//----------------------------------------------------------------


Thank you!



-Pradeep Barua


More information about the Sidefx-houdini-list mailing list