Jump to content

# how to get edge length for tension map ?

## Recommended Posts

Hi Guys !

I would like to know what would be the most straightforward way to compute  the edge length of a mesh in houdini

to compute a tension map beetween a rest mesh and a deform mesh.

Thanks for your advise.

Cheers

E

#### Share this post

##### Share on other sites

You mean something like this?

PS. I'm not the author of the technique. I just modified file to more current standards + rig. I stole it from Werner Ziemerink, one of the Softimage guys that you can find on odForce too.

tension_map-mantragora,rigging.hip

Edited by mantragora
• 1

#### Share this post

##### Share on other sites

that's great , i'm very close to what i need , i just need to remap correctly positive and negative value !

i'll post a hip when it will be ok !

Thanks a lot for your help Mantragora !

#### Share this post

##### Share on other sites

i post my test scene.

The bad point is that we are using primitive area. maybe using edge length would be even more accurate ?

I would still be curious to know how we can get the length of an edge in H if it's possible !

tension_map.hip

Edited by sebkaine

#### Share this post

##### Share on other sites

this looks cool , but i would like to be able to understand and reproduce the process by myself if it's possible.

i don't know if we can access edge info in Vex.  maybe

- evaluating each connecting point to the current point

- getting the distance beetween each connected point

- average this distance

could give more accurate result ?

#### Share this post

##### Share on other sites

not tested but something like that ?

```int neighbournum;
vector nextp;
float currdist = 0;
int ncount = neighbourcount(0, @ptnum);

for (int i=0; i<ncount; i++) {
neighbournum = neighbour(0, @ptnum, i);
nextp = point(0, "P", neighbournum);
currdist += distance(@P, nextp);
}

@Cd = currdist;```

currdist to be fitted properly of course

• 1

#### Share this post

##### Share on other sites

Thanks a lot for your help Anthony i'm gonna test this tommorrow and see how it works compare to the previous solution.

What would be cool with tension map base on edge would be to have more options.

for exemple evaluating only tension in U direction or in V direction .

Because in certain case some edge are extremely stretch in U but very compress in V and thus it compensate volume.

So at the end by using primitive area you ended with a not very stretch primitive which is not accurate enough.

Maybe by using a rest pose i could be able to modify your code to be able to isolate

neighbour that go along U and those that go along V. That could work,especially that i am evaluating cloth sheets with clean topo.

But it would be cool if a VEX expert could confirm if it is possible or not to evaluate edge length with a simple vex command.

Edited by sebkaine

#### Share this post

##### Share on other sites

i have test with edge length average value, but the result are very close to the primitive area methods.

so it doen't bring any precision.

but i think that with the edge method and some extra work it could be possible to sort U / V edge and get tension

- along U

- along V

- along UV

seperatly.

tension_map_edge.hip

#### Share this post

##### Share on other sites

i have test with edge length average value, but the result are very close to the primitive area methods.

You should store the rest edge lengths in an attribute and then determine the tension from the combined absolute differences in edge lengths.

• 1

#### Share this post

##### Share on other sites

thanks a lot for your help eetu !

i am not sure i have perfectly understand what you mean :

- i already store the average rest length in the @edge_rest is that ok ?

- "combined absolute difference" is not crystal sharp in my mind ?

#### Share this post

##### Share on other sites

Ok, maybe it was unwarranted, but it sounded like you had problems with edge compressions canceling out edge stretches - and that sounds like you are accumulating the negative differences (compression) with positive differences (stretch) together. In that case you should add the absolute differences, so they don't cancel out. You need to both save the edge lengths and do the comparisons separately for each edge, and not do it after you have averaged the edge lengths together.

In iamyogs code it could look something like

for (int i=0; i<ncount; i++) {
neighbournum = neighbour(0, @ptnum, i);
nextp = point(0, "P", neighbournum);
currdist += abs(distance(@P, nextp) - @edge_rest);
}

You might even want to accumulate the negative and positive differences in separate attributes, so you can handle compression and stretching separately down the line.

#### Share this post

##### Share on other sites

http://www.sidefx.com/docs/houdini14.0/nodes/sop/convertline

May be this node will be of some use.

Convert Line surface node

Converts the input geometry into line segments.

Unlike the Convert SOP, this node will not copy the unconverted geometry. Primitive attributes and groups are not preserved.

This replaces the incoming primitives with two-point line segments. Each segment connects any point connected in the source.

Note

Two points will only be connected by a single segment, regardless of the number of connections in the source.

Parameters Compute Length

Computes the length of each resulting line segment and stores it in the given attribute.

• 2

#### Share this post

##### Share on other sites

@eetu

Thanks for precision !

well i have divided the stretch and the compression as 2 separate things stretch is display as blue , compression as red.

for compression i did use the absolute value. but i could have done mistakes anyway.

@Sandeep

Thanks for the links ! i have never use this convert line node , but it's very interesting , i 'm gonna try to see if it open new possibilities.

I have implement a U / V stretch implementation. it looks to work , but if you find any error in the code i would be glad to see your corrections !

cheers

E

tension_map_uv.hip

Edited by sebkaine

#### Share this post

##### Share on other sites

Well i have the time to put some more love into this .

Here is a Hip with tension map node with

- UV, U, V stretch map

- RG / Luminance map

- Smooth map

It's pretty complete now, but if you have any idea to enhance it feel free to share !

Cheers

E

tension_map_uv_ok.hip

Edited by sebkaine
• 6

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

×
• Donations

• Leaderboard