Itoo Software Forum

Author Topic: scale along path  (Read 5305 times)

eqko

  • Jr. Member
  • **
  • Posts: 96
scale along path
« on: March 15, 2016, 11:54:16 AM »
I read a thread from 2013 where it wasn't possible.

Is it currently possible to have a segment scale smaller along the path.
so lets say the 1st segment at the start is 100% and the one on the end is 50% gradually getting smaller along the path.

Paul Roberts

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2991
Re: scale along path
« Reply #1 on: March 15, 2016, 01:02:34 PM »
Hi,

This is now possible using Expressions. RailClone has a function called XSplinePosition that returns the segments position along the spline. 0.0 represents a segment at the start of the spline and 1.0 a segment at the end. Using this we can control the scale of an object based on it's current position in the array. To do that:

- Wire the Segment to a Transform operator.
- Right click on the Transform operator and export the Z, Y and Z Fixed Scale parameters, or a whichever you wish to control.
- Create two new Numeric nodes, call the first Scale Start and the second Scale End.
- Wire them to a new Arithmetic node and set the operation to Subtract. This will give you the total amount the segments changes between the start and end of the spline.
- Create a second Arithmetic note and wire Scale Start to the first input. Wire the Arithmetic node created in the previous step to the second input.

- Change the mode of the new Arithmetic node to Expression, click Edit Expression and enter

Input1-(XSplinePosition*Input2)

Where Input1 is the starting scale and and Input2 is the total scale change between the start and end of the spline.
- Wire the arithmetic node to the Transform operator's scale inputs. The final graph will look like this:


I've also attached a file with this example so you can try it out. If you'd like to know more about expressions, parameters and attributes then this chapter of the Next Steps with RailClone guide can be useful.  I hope that helps, please let me know if you have any further questions.

Many Thanks!

Paul
Paul Roberts
iToo Software

eqko

  • Jr. Member
  • **
  • Posts: 96
Re: scale along path
« Reply #2 on: March 15, 2016, 01:57:02 PM »
thanks for the fast reply, works like a charm !

RC2463

  • Newbie
  • *
  • Posts: 2
Re: scale along path
« Reply #3 on: February 06, 2018, 10:21:00 AM »
Hey,

Is there anyway to add 3rd input to control the mid scale of the spline object? Because now it goes from Scale Input1 to Input2. but is there anyway to have it Input1 to Input2 to Input3.

I got reply from Itoo if anyone needs in the future:

""... is there any way to add 3rd input to control the mid scale of the spline object?"

By adding a Conditional Operator (optionally by adding the condition directly in the Arithmetic Operator Expression) you can "split" it and add a third value in the middle based on the same principals. To "remap" the spline position (XSplinePosition values) on these parts, expressions should be adapted in the following way:

return Input1-((XSplinePosition*2)*Input2); for the first part

return Input1-((XSplinePosition-0.5)*2*Input2); for the second part"


Bests
« Last Edit: February 06, 2018, 11:04:39 AM by RC2463 »

grue

  • Full Member
  • ***
  • Posts: 100
Re: scale along path
« Reply #4 on: February 28, 2020, 05:44:26 PM »
so to add a middle portion... you would set it up like this diagram.  my expression is telling me there are errors.  also, where do you end up actually changing the scale settings.  in my case, i wish to only make the z-axis or height of the windows taller in the middle of the path and shorter on both ends.  100% - 200% - 100% start-middle-end.  thank you!

the expression i have typed in:

Input1-(XSplinePosition*Input2);
return Input1-((XSplinePosition*2)*Input2);
return Input1-((XSplinePosition-0.5)*2*Input2);


screen shot attached.

===================================================
EDIT: Ah, i just noticed the attached max file for a guide.

The "return" was missing on the first line.  i see now.  oh, i keep forgetting about the railclone rollouts - that's where the parameters are.  cool!  thanks for posting this!
« Last Edit: February 28, 2020, 06:14:52 PM by grue »

grue

  • Full Member
  • ***
  • Posts: 100
Re: scale along path
« Reply #5 on: February 28, 2020, 06:35:45 PM »
ok i'm setup and able to produce the scaling on the z-axis from beginning to end of the spline.

however i'm having trouble adapting the "middle" part. so that i can do 100-200-100 percent scale.  i do have 3 input parameters in my RailClone object roll-outs.

here is my expression.

return Input1-(XSplinePosition*Input2);

return Input1-((XSplinePosition*2)*Input2);

return Input1-((XSplinePosition-0.5)*2*Input2);

thanks agaiN!

Dragan

  • Hero Member
  • *****
  • Posts: 1419
Re: scale along path
« Reply #6 on: February 29, 2020, 03:26:47 AM »
Hi.
First of all, there can be only one result of the arithmetic node so there is only one `RETURN` in expression. Some useful documentation:
https://docs.itoosoft.com/railclone/style-editor/operators#Operators-Arithmetic
I`m not very good at math but I think the solution is related to:
https://www.mathsisfun.com/algebra/line-equation-point-slope.html
I have tried to implement this to RC style and got some results. I notice some uneven distribution compare left>right size when I tested some simple values (100,50,100 at 50%). If you are in a hurry you can tweak it and eventually nail it.
I`m not sure what is wrong, my math or RC calculation.    ::)  :o  I guess my math.
Unfortunately, I don't have more time to deal with your problem since I have some deadlines project to finish.  :(
However, I hope this example could give you some ideas on how to approach the problem.

please check the parameters:
Start/Middle/End values for the scale ratio related to the original segment height.
Split Position is the value on the Spline 0-100% so you can have more variations and not just `middle point`
Beat Regards.



« Last Edit: February 29, 2020, 03:19:40 PM by Dragan »

grue

  • Full Member
  • ***
  • Posts: 100
Re: scale along path
« Reply #7 on: February 29, 2020, 06:29:41 PM »
thanks.  i started playing around and realized what you said ha, only one result can be in the expression!  i got to a point where it appeared to start at 100% then dip down to 0% then end back up at 100%.

i will look at the links you provided, but deadlines for other things loom so probably wont pick up again until next week.

thanks though!  this is a good starting point for me in terms of expressions and operators.  ive not really jumped in to this stuff yet.

Dragan

  • Hero Member
  • *****
  • Posts: 1419
Re: scale along path
« Reply #8 on: March 03, 2020, 02:04:04 PM »
I`m not very good at math but I think the solution is related to:
https://www.mathsisfun.com/algebra/line-equation-point-slope.html
I have tried to implement this to RC style and got some results. I notice some uneven distribution compare left>right size when I tested some simple values (100,50,100 at 50%). If you are in a hurry you can tweak it and eventually nail it.
I`m not sure what is wrong, my math or RC calculation.    ::)  :o  I guess my math.

#Itoo
Can you guys please check it out, just to complete this topic right to the point?

Rokas

  • Hero Member
  • *****
  • Posts: 3324
Re: scale along path
« Reply #9 on: March 03, 2020, 02:46:39 PM »
Hi Dragan

Your math seems correct.
Ok, I have made scene:

0.0 100%
0.5  2.5%
1.0 100%

Draw a line:


Unhide Your RC object:


Zoom to middle:


I think now You understand, but to illustrate, lets make segments shorter in X size:

Rokas

Dragan

  • Hero Member
  • *****
  • Posts: 1419
Re: scale along path
« Reply #10 on: March 03, 2020, 06:39:01 PM »
Hi Rokas.
Thank You for taking a look into this. Yes, I had similar testing too. I understand everything is driven by spline position and probably some correction factor related to Segment`s X-size should be considered. I'm kind of hoping that Adaptive mode will override and fit everything.
Either way, I think grue, RC2463 and eqko have some start point and I had fun with my son helping me solve this problem.
Best Regards
« Last Edit: March 03, 2020, 11:05:07 PM by Dragan »

Terri Brown

  • Full Member
  • ***
  • Posts: 114
    • Terri Brown 3D
Re: scale along path
« Reply #11 on: February 11, 2021, 01:50:37 PM »
Hi guys. Can this work with an A2S Generator, where you want your segment to scale smaller going up the YSpline? I followed all the steps exactly, but when I enter the expression you gave below I make it: Input1-(YSplinePosition*Input2) instead. It doesn't seem to work. Says "Expression has errors". This happens when I use the original expression too.

I have created a dome using this principles in this tutorial:
https://www.itoosoft.com/tutorials/using-railclones-gradient-probability-macro?back=page%3D2%26tag%3Drailclone

My dome is made up of tubes - some are solid and some have glass. As they go up to the point of the dome they overlap, so I want to decrease their size to compensate.

Please let me know if it's possible.

Thanks

Rokas

  • Hero Member
  • *****
  • Posts: 3324
Re: scale along path
« Reply #12 on: February 12, 2021, 09:27:48 AM »
Hi.

Please read this regarding how expression should be modified from old format to the new one.
Rokas

Terri Brown

  • Full Member
  • ***
  • Posts: 114
    • Terri Brown 3D
Re: scale along path
« Reply #13 on: February 12, 2021, 09:36:41 AM »
Thanks Rokas,

So after reading that I typed Return Input1-(YSplinePosition*Input2);
I'm assuming that the return property it mentions means pressing the enter key??

It still says that the expression has errors.

Rokas

  • Hero Member
  • *****
  • Posts: 3324
Re: scale along path
« Reply #14 on: February 12, 2021, 09:37:56 AM »
Thanks Rokas,

So after reading that I typed Return Input1-(YSplinePosition*Input2);
I'm assuming that the return property it mentions means pressing the enter key??

It still says that the expression has errors.

No. return is "return", not "Enter key"

Test expression "-1*(Input/4)" in v2 should be written in v3 and v4 like this:
return -1*(Input/4);

Basically all expressions should have "return" in start of "expression" and You should end them with ";"
« Last Edit: February 12, 2021, 09:41:51 AM by Rokas »
Rokas