Jump to content

UV's similar to Max's Unfold Strip from Loop


Recommended Posts

I've laid out UV's procedurally in Houdini with the sweep or skin sop and using arclen on the input curves, but I'm wondering if there is a solution to straighten/unwrap geometry that is generated in ways other that using a sweep or skin SOP. 

If anyone is familiar with the Unfold Strip from Loop button in 3dsMax's Unwrap UV modifier it basically takes any edge or loop input and straightens out the geometry into a strip. It's super useful for cylinders and chamfered/extruded edges. I'm wondering if there is a workflow to do something similar in Houdini. I tried messing with the new FlattenUV node and I can get something kind of close with the enable loop straightening, but the UV's are still wobbly and not perfectly straight.

0lVIFQ0.png

 

Link to comment
Share on other sites

  • 2 years later...

Me too was looking yesterday something like this and came with my own solution that fit my needs.
Rules to work:
A. Object should be Closed Shape (Rings Like).
B. Object should have no Open Edges (be Closed like should be Thicken/Shell I mean).
C. Object should be on or around a ground space.
This rules can be improved by your needs just do some research ;) 


Need to feed with Two Seams, one edge loop horizontal seam_U second vertical edge loop seam_V.
Works on UV Flatten 3.0 (Houdini 17+ I Guess).

1. Group Create (Edges) with group name seam_U - Here, in Base Group you will later put your horizontal edge loop
2. Group Create (Edges) with group name seam_V - Here in Base Group you will later put your vertical edge loop
3. Attribute Wrange (Detail) with code:

int comparisonAxis = 0; // 0 for V seams | 1 for U seams
string _prefix = comparisonAxis ? 'U' : 'V';
string edgeGroup = 'seam_'+_prefix;
string _vertsAGroup = 'vertsA_'+_prefix;
string _vertsBGroup = 'vertsB_'+_prefix;
string _primAGroup = 'primsA_'+_prefix;
string _primBGroup = 'primsB_'+_prefix;

int edgePointPairsFlatArray[] = expandedgegroup(0, edgeGroup, 'ordered');
int edgePointPairsSize = len(edgePointPairsFlatArray);

for (int i = 0; i < edgePointPairsSize; i++){   
    int pointIndex = edgePointPairsFlatArray[i];
    int point_verts[] = pointvertices(0, pointIndex);
    int pointNextIndex = edgePointPairsFlatArray[i+1];
    vector pointPosition = point(0, 'P', pointIndex);
    vector pointPositionNext = point(0, 'P', pointNextIndex);
    vector pointCenter = (pointPosition+pointPositionNext)/(vector)2;
    int foundPrim = 0, primID_A = -1, primID_B = -1, done = 0;
    foreach (int i2; int primID; pointprims(0, pointIndex)){
        foreach (int i3; int primPointID; primpoints(0, primID)){
            if(primPointID == pointNextIndex){
                if(primID_A==-1){
                    primID_A = primID;
                } else {
                    primID_B = primID;
                    done = 1;
                    break;
                }
            } 
        }
        if(done) {
           vector primsCenter = (prim(0,'P', primID_A)+prim(0,'P', primID_B))/(vector)2;
           vector primAPos = prim(0,'P', primID_A);
           int isLess = primAPos[comparisonAxis] < primsCenter[comparisonAxis];
           int correctPrim_A = isLess ? primID_A : primID_B;
           int correctPrim_B = isLess ? primID_B : primID_A;
          
            int upper_verts[] = primvertices(0, correctPrim_A);
            int lower_verts[] = primvertices(0, correctPrim_B);
            foreach (int i4; int pointVertID; point_verts){
                foreach (int i5; int pointVertID_Upper; upper_verts){
                    if(pointVertID_Upper == pointVertID){
                        setvertexgroup(0, _vertsAGroup, pointVertID, -1, 1, 'set');
                        break;
                    }
                }
                foreach (int i5; int pointVertID_Lower; lower_verts){
                    if(pointVertID_Lower == pointVertID){
                        setvertexgroup(0, _vertsBGroup, pointVertID, -1, 1, 'set');
                        break;
                    }
                }

            }
           break;
        }
    }    
}

4. Attribute Wrange (Detail) with code same as previous Step 3 but change in first line comparisonAxis from 0 to 1
5. UV Flatten:
There inside Flattening Constraints:
Add our two groups (seam_U seam_V) to Seams group
Create/Add with + button 4 Aligned Groups in section Axis-Aligned Vertex Groups
Group 0 (U Axis) select our vertsA_U
Group 1 (U Axis) select our vertsB_U
Group 2 (V Axis) select our vertsA_V
Group 3 (V Axis) select our vertsA_V
6. UV Smooth (Optional): Strength 100; Filter Quality 1
7. UV Layout
(Optional)
8. Group Delete (Optional): seam_U seam_V vertsA_U vertsA_V vertsB_U vertsB_V

Edited by kodbitz
Link to comment
Share on other sites

  • 9 months later...
On 27/03/2018 at 9:55 AM, davpe said:

i dont think there is a straightforward way to do that right now, unfortunately. 

 

I will be interested to know as well how to procedural be able to build straight UV strip based on UV quad follow loop (like in Blender) to make smooth connection like below

@davpe @kodbitz@animatrix @anim

 

 

image.thumb.png.7bcf34fbf700deec00fa9ea9efe48578.png

image.thumb.png.af11be3a42ec8b8a2c22047a5a45c2dc.png

 

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...