Jump to content
Sign in to follow this  
bbentley81

UV to mesh with matching prim area

Recommended Posts

Hello,

I am working on a marvelous designer to Houdini pipeline and I have hit a snag that I am hoping someone could help me with.

I am trying to take the draped model and flatten it to the uvs that come out of MD. This part I have working with a point wrangle with "@P = @uv;"

The part I am having trouble with is matching the area. I have tried: 

1. make a measure sop set to area on both the draped and flatted model

2. promote the area attribute to detail using sum to get the area for the entilre model

3 get a scale factor by drapeArea/uvArea

4. use this in a point wrangle to scale the @P by the scale factor.

float currScale = detail(0, "area", 0);
float targetScale = detail(1, "area",0);
float scaleFactor = targetScale/currScale;
@P *= scaleFactor/1000;

This, however, is not working. I am not sure if it is a problem with my math or my logic. If anyone can shed some light on this I would be greatly appreciative. I have attached an example hipnc file for reference.

Cheers,
B

 

matchArea.hipnc

Share this post


Link to post
Share on other sites
1 hour ago, bbentley81 said:

This, however, is not working. I am not sure if it is a problem with my math or my logic.

math, since you are dealing with areas, which are quadratic, to compute linear scale you need to do sqrt() 

float currScale = detail(0, "area", 0);
float targetScale = detail(1, "area",0);
float scaleFactor = sqrt(targetScale/currScale);
@P *= scaleFactor;

Share this post


Link to post
Share on other sites

@P *= sqrt(scaleFactor);

I think if you double the scale of something you quadruple its area...

Edit. As Tomas just said!

Edited by julian johnson

Share this post


Link to post
Share on other sites

YAAAASSSS!!

Thank you so much. This worked perfectly!! I've attached the working file for those few who are interested.

matchAreaSqrt.hipnc

Edited by bbentley81

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×