Jump to content

VEX xyzdist function in HDK


Recommended Posts

Hello everyone! Inspired by this topic (http://forums.odforce.net/topic/12691-closest-point-on-the-primitive/) 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();
}
Edited by Dmitry Shurov
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...