Jump to content

PointWrangle Runtime


Recommended Posts

I use PointWrangleSOP to place my geo on the floor via selected polygon. Code is:

vector center()
{
    float xx[];
    float yy[];
    float zz[];
    for (int i = 0; i < primvertexcount(geoself(), PRIM_NUMBER); i++)
    {
        int pt = vertexpoint( geoself(), vertexindex(geoself(),PRIM_NUMBER, i) );
        vector pt_pos = point(geoself(), "P", pt);
        xx[i] = pt_pos.x;
        yy[i] = pt_pos.y;
        zz[i] = pt_pos.z;
    }
    return set( avg(xx), avg(yy), avg(zz) );
}

vector prim_normal = prim_normal(geoself(), PRIM_NUMBER, 0, 0);
vector to_vector = { 0, -1, 0 };
matrix3 mat = dihedral(prim_normal, to_vector);
vector pos = @P - center();
@P = pos * mat;

Is it good to place user function that get static polygon center at runtime ?

Whether function will be defined on each iteration (through each point) or once ? Or maybe i need to add this center via expression to spare parm ?

Edited by Alexey Vanzhula
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...