Need help wiring parameter linked to Percent

Need help wiring parameter linked to Percent

RobH2
Advisor Advisor
1,787 Views
1 Reply
Message 1 of 2

Need help wiring parameter linked to Percent

RobH2
Advisor
Advisor

I've rigged a bike and a rider. The wheels of the bike are wired to the position of a point helper I have (brown point in attached image). When I constrain that brown point to a spline the wheels turn based on the position of the brown point. However, I've learned that if I move that spline around in the world,  things, timing, ect., move around and get offset in an undesirable way. 

 

I've provided a photo that shows my wiring of the wheel to the position of my brown point. 

 

I've learned that if I remove the path constraint from that brown point that the bike wheels are linked to and attach the brown point to a helper, I can then path constrain that helper and can now move the spline around without messing up anything. 

 

However, now my wheels don't turn because the brown point now has no position data to pass along to the wheel rotation. I need to wire the 'Percent' of the new helper on the spline so that it drives the wheels. 

 

I'm not a programmer and have tried creating the math to wire this but can't figure it out. 

 

How can I wire the 'Percent' position of a helper to the rotation of a wheel?

 

BikeRig.jpg


Rob Holmes

EESignature

------------------------------------------------------------------------------------------------------------------------------------------
3ds Max (2023-2026), V-Ray 7, Ryzen 9 9950X3D Processor, DDR5 128MB, Gigabyte Aorus X870E Master motherboard, Sabrent Rocket NVMe Gen5 M.2 drives, NVidia RTX 4090, Space Pilot Pro, Windows 11 Pro x64, Tri-Monitor, Cintiq 13HD, Windows 11 x64
------------------------------------------------------------------------------------------------------------------------------------------
0 Likes
1,788 Views
1 Reply
Reply (1)
Message 2 of 2

ads_royje
Alumni
Alumni

Hi @RobH2,

 

to get a rotation (of a wheel) from a distance, you'd need : Circumference = 2*Pi*SqrRadius.

The formula you are looking for uses that Circumference equation.

 

You need the Radius of your rotating object.

You'll need to convert the percent of the spline into a measured distance, for that you need to get the length of the spline.

To get the Spline length you may use :

getSegLengths <splineShape> <spline_index> [****:<boolean>]

 

 

This outputs the lengths of all the segments of the spline into an array, the last element of the array is the total length of the spline.

The code would look like : 

((getSegLengths $Line001 1 ****:true)[(getSegLengths $Line001 1 ****:true).count])

 

 

Then you'd need to multiply by the Percent and then divide by the Circumference (in example below, the Circumference is 25.0) :

((getSegLengths $Line001 1 ****:true)[(getSegLengths $Line001 1 ****:true).count]) *  Percent / (2*pi*(pow 25.0 2)

 

This will output a rotation value in Radian, now just need to convert the Radian to Degrees: " RadToDeg "

 

The finale formula would look like :

radToDeg((getSegLengths $Line001 1 ****:true)[(getSegLengths $Line001 1 ****:true).count]) *  Percent / (2*pi*(pow 25.0 2))

 

WireParam.jpg

That is a screenshot of the final formula, and I've attached a little video that demonstrate that working in Max.

 

I hope this can help! 🙂

 

Edits:

Sorry for the code looks strange ... the "****" are not as intended ... 😞 the formatting of the site converts "c u m" (with no spaces) for cumulative as a "bad" word 😞

Please read "c u m" where **** are shown 

0 Likes