Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Cylinder, rotation and Float Expression
  RSS 2.0 ATOM  

Cylinder, rotation and Float Expression
Rate this thread
 
25803
 
Permlink of this thread  
avatar
  • Location: Quebec city
  • Total Posts: 32
  • Joined: 17 April 2009 09:02 PM

Hi,

First time here.

im a student in 3d animation in canada and found some explanation on a all purpose wheel posted here :

http://www.scriptspot.com/forums...-based-on-position-change

I am not sure about the ethiquette of transfering knowledge from forum to forum but i do this to get attention on a good idea wich i cant get more help So far. If the author happen to read this, understand that my intention are respectfull of your work and wish only to make it better whit help from the community.

It work flawlessly with a simple mouvement on the box so i decide to tried and apply it to my first school assignement, a train rolling in circle on a track.

Keep in mind that i dont NEED the wheel to follow the track, i just want them to roll as the train move along.

I follow everything and first found my first bug : My wheel were Tube instead of Cylinder and i had Radius 1 and Radius 2.

So i change my wheel to a Cylinder. and got the Radius.

Alas! it didnt work.

When i click Evaluate the a rotation on screen but that it. No others rotation on the wheel as i move the time bar.

So i am Asking a few question :

1. Can it be that the movement in circle confuse the expression which would want to work only in straight line ?

2. Could it be that my Path Constraint wich animate my train confuse the expression ?

Any input would be appreciate, im learning !

ty for any help.



Replies: 0
avatar

I remember writing a tutorial about this for Max 1.0 something like 13 years ago :)
http://www.scriptspot.com/bobo/rendfaq/RFAQ0066.HTM
The last paragraph of it says it “does not work with Path controller” (the original name of the Path Constraint before it was rewritten in Max 4).

That expression takes the X coordinate of the object, so it is only meant for a simple linear motion along one world axis.
It is possible to tweak it to respect two axes with a ball rolling (which was also an example of expressions in Max 1)
If your car is moving along a path, you would have to figure out the length of the path (which is 2*Pi*R in the case of a simple Circle) and how much you have traveled along it (which would be simple if using default linear Percentage in the Path Constraint). So the path traveled would be 2*Pi*PathR*CurrentFrame/AnimationLength/WheelR (where AnimationLength is the number of frames to do a full circle).

It is getting even simpler - the Expression Controller has a Range Bar seen in the Dope Sheet version of the TrackView.
The Animation Length of the controller is calculated within that interval, so the variable NT (Normalized Time) changes between 0 and 1 as the scene time changes from 0 to the last frame of the controller’s range. (The range is set when the controller is assigned, so if you want a scene with 500 frames, assign the controller after you extend the time, otherwise you will have to drag the ranges manually).

So your function can be then 2*Pi*PathR*NT/WheelR. PathR can be assigned to the Radius track of the Circle used as the path, and WheelR can be assigned to the Radius of the Cylinder (or outer Radius of a Tube) so changing these interactively would adjust the animation procedurally.

I went ahead and built a Max 2008 file with a “car” with 4 wheels running on a circle. Note that there is no differential calculation (in other words, all 4 wheel rotate at the same speed which is not the case on a real car where the inner wheels would spin faster). Also, it assumes no acceleration, just constant motion in circle.

See the file below:

http://www.scriptspot.com/bobo/stuff/forum/CarOnPath_v001.zip



Borislav “Bobo” Petrov

Replies: 0
avatar

Wow!

Ty so much for your time.

I must say that after only 1 month learning 3ds, this is overwhelming but i will read it again and again and i will learn from this.

Ty again !



Replies: 0
avatar
  • Ripley
  • Posted: 21 April 2009 09:35 AM

At PEN’s site there’s info about using scripted controllers with custom attributes. Well, maybe too much after 1 month learning, but in case you are interested in diving deeper :-)
A working file demoing that tech you’ll find at my blog , at the bottom of the page
-R



Replies: 0