Object scaling based on distance between points

   10851   4   0
User Avatar
Member
26 posts
Joined: Sept. 2010
Offline
Hey Guys,

I'm quite a beginner at Houdini so bear with me if there is a super simple solution to my issue;

What I have is a line made up of several points which I will want to be able to deform freely in the X axis…

What I want is to copy an object onto each point, and have this object scale dependent on the distance of the point it's on to the point in the line before and after it.

I was thinking about measuring each segment of the line between each two points and using that to determine the proper scaling…but I have no idea ops:

Thanks in advance
User Avatar
Member
512 posts
Joined: July 2009
Offline
you can use the distance() expression to calculate the distance between point A and point B, something like this:

distance to next point:

if( $PT < $NPT -1, distance($TX, $TY, $TZ,
point(opinputpath(“.”, 0), ($PT+1), “P”, 0),
point(opinputpath(“.”, 0), ($PT+1), “P”, 1),
point(opinputpath(“.”, 0), ($PT+1), “P”, 0) ), 0 )


distance to previous point:

if( $PT > 0, distance($TX, $TY, $TZ,
point(opinputpath(“.”, 0), ($PT-1), “P”, 0),
point(opinputpath(“.”, 0), ($PT-1), “P”, 1),
point(opinputpath(“.”, 0), ($PT-1), “P”, 0) ), 0 )


once you have those 2 attributes you can add them together to get a scale attribute. But be aware, if you're going to move your points it's not going to be that easy, you're going to have to move the pivot as well (posA+posB)/2 in order to place the objects correctly!

cheers,

Manu
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
26 posts
Joined: Sept. 2010
Offline
I never got around to thanking you for your answer Thanks!

I decided to stick with a much simpler solution for my problem then, although your expression works amazingly for scaling objects on a straight line!

One problem though, for some reason the scaling factor on objects closer to the center is smaller?

User Avatar
Member
26 posts
Joined: Sept. 2010
Offline
After some brain teasing, I came up with this =

if($PT == 0,

distance($TX, $TY, $TZ,

point(opinputpath(“.”, 1), ($PT + 1), “P”, 0),
point(opinputpath(“.”, 1), ($PT + 1), “P”, 1),
point(opinputpath(“.”, 1), ($PT + 1), “P”, 2)),

if(($PT > 0) || ($PT == $NPT - 1),

distance($TX, $TY, $TZ,
point(opinputpath(“.”, 1), ($PT - 1), “P”, 0),
point(opinputpath(“.”, 1), ($PT - 1), “P”, 1),
point(opinputpath(“.”, 1), ($PT - 1), “P”, 2))

,0)
)


For scaling objects along a straight line I found this to be easier to understand
User Avatar
Member
7733 posts
Joined: July 2005
Online
Maybe I'm not understanding. This is a problem that the traditional “copy stamping” technique solves? I've attached a contrived example.

Attachments:
copyStampScale.hipnc (61.5 KB)

  • Quick Links