About Me

Not Specified
Not Specified


Recent Forum Posts

vex levels with midpoint 2023年5月26日20:32

I'm trying to create a levels control out of an attribute wrangle. I have code that's doing something close to what I'm looking for but the midpoint isn't behaving right. I'm not really clear on what the math should be. Can anyone here help out?

Here's my existing code:

f@levelsResult = pow(fit(@attribute, chf("inMin"), chf("inMax"), chf("outMin"), chf("outMax")), 1.0 / chf("midPoint"));

UPDATE: I've a better, though not yet perfect, solution now. Unfortunately, the default values are a little more contrasty than they should be and it kicks out values above 1. Other than that though, the following code provides a tool that functions as I expect. That said, if any of you are able to provide me with a solution that works better, I'd really rather use that.

NOTE: I left in the esoteric naming this time.

float levelsMidpoint_rootToTip = 1 - chf("rootToTip_midPoint");
@stiffnessProfilePerFeatherRootToTip = pow(fit(@distanceFromRoot, chf("rootToTip_inMin"), chf("rootToTip_inMax"), chf("rootToTip_outMin"), chf("rootToTip_outMax")) + levelsMidpoint_rootToTip, (1.0 / levelsMidpoint_rootToTip)) * (levelsMidpoint_rootToTip);

rivet deformer for multiple objects etc 2023年5月26日13:53

I'm working in houdini 18. I have multiple objects merged together. Each object has a single point that is in the point group "rootPoint". each point of each object has a string attribute, "feaInstanceId", that identifies which object it belongs to. The merged geometry has a detail string array attribute, "allFeaInstanceIds", that lists every unique value of the "feaInstanceId" point attribute.

Given the above information, I want to create a rivet deformer that will cause each object in input 0 to stick to the target geometry at input 1. The location on the surface of the target geometry that each object should follow, I'll call this the "targetLocation", is that location which is closest to the location of each object's "rootPoint" point and the starting offset between each object's "rootPoint" and the "targetLocation" should be maintained, as should the orientation of the object, relative to the normal of the "targetLocation".

That's how I posed my situation to chatGPT. chatGPT's response was logical but insufficient.

Note that the "objects" are feathers.

I already have part of the problem worked out. With the VEX code below, running in detail mode, I've obtained the skin location that is closest to the root of each feather and stored that in a point attribute, "feaRootPositionOnSkin". I've done this prior to any animation and in reference to the rest skin, so those values shouldn't change. I've done the same for the offset between each point's location and the "feaRootPositionOnSkin" and stored that as the point attribute "feaRootPositionOnSkinOffset".

I'm stuck on how to proceed from here and am hoping one of the fine folks here will be able to help.

string feaInstanceIdsList[] = detail(0,"allFeaInstanceIds");

int numberOfFeathers = len(feaInstanceIdsList);

//run through one feather at a time
foreach (string fea; feaInstanceIdsList){
    int feaPnts[] = {}; 
    vector skinPos;
    int j = 0;
    int rootPointID;
    vector rootPos;
    //get pointNum of all points belonging to current feather
    //when the rootPoint is encountered, get its location on the skin
    for (int pnt = 0; pnt < @numpt; pnt++) {
        if (point(0, "feaInstanceId", pnt) == fea) {
            feaPnts[j] = pnt;

                rootPointID = pnt;
                // Get the world coordinate position of the current point in the "rootPoint" group
                rootPos = point(0, "P", pnt);
                // Get the closest skin location to the position of the rootPoint
                int skinPrim = -1;
                vector skinParamUV;
                float maxDist = 1.0;
                float dist = xyzdist(1,rootPos, skinPrim, skinParamUV, maxDist);
                skinPos = primuv(1,"P",skinPrim,skinParamUV); 
    //store the closest skin location and the offset between it and each point's position
    foreach(int pnt; feaPnts){      
        vector pntPos = point(0, "P", pnt);
        vector skinPosOffset = pntPos - skinPos;
        setpointattrib(0, "feaRootPositionOnSkin", pnt, skinPos, "set");
        setpointattrib(0, "feaRootPositionOnSkinOffset", pnt, skinPosOffset, "set");

Code runs without error but doesn't produce expected result 2023年5月20日11:40

@tamte - thank you so much for those insights. I can see how the first one would work. I'll try out the second option when I'm back at work.