MAXScript Cloth Simulator

22 votes
Date Updated: 
Author Name: 
Markus Boos

Inspired by Skeel Keng-Siang Lee's fantastic tutorial on soft body physics (
and for the sake of learning I wrote a little MAXScript that can
simulate cloth. It is pretty much hacked together, basic and very
limited, meaning there is no UI, you have to know what you are doing
and there is no collision detection. It is pretty slow too but it was
more for looking into new algorithms than using it for actual
production. Who knows, maybe it will evolve into something better and a
more universal thing for little simulations in character / vehicle rigs

There is a preview on youtube:

In case anyone wants to check it out, I uploaded the script and max
files (2010) here (just run the script and it will start simulating).

It uses Verlet integration without velocities and a simple spring
model. There are three types of springs (structural, shear and bend)
and the two corner points are constraint to helper objects. There is
gravity and a very simple wind force to add some randomness. But I am
planning to write a real wind function with better turbulence.

Have fun !

Version Requirement: 
MAX 2010
Video URL: 
VerletClothSim.ms15.56 KB
VerletClothSim.max224 KB
VerletClothSimDone.max1.32 MB
cloth_sim.jpg67.51 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ruoyu1's picture

looks cheesy, lol like a

looks cheesy, lol like a piece of cheese flying around

relief7's picture

Solozar, glad you figured it

Solozar, glad you figured it out. :-) I am sorry but since it is just a little experiment I don't plan on creating a UI unless I turn it into something that is more universally applicable. For now I leave the UI to somebody else who wants to play with it. :-)

solozar's picture

Has understood. But it is

Has understood.
But it is difficult to understand a script and to change tinctures.
In the future will be UI and so on?

solozar's picture

In advance sorry for my

In advance sorry for my English.

I had a problem. In any way load the script also writes:
Unknoun property:"numverts" in undefined
How it is possible to avoid the given prolemma?

relief7's picture

Martin: You are right, the

Martin: You are right, the dummies have to be created as well. I missed that one.

Jeff: Haha, good point ! Yes, I admit it !!! I toook Skeel's OOP concepts and transferred them 1:1 into MAXScript. Actually that was the first time I used structs which - compared to C++ - is kind of a mess right now (if you want to hear my opinion). It would be nice if MAXScript supported inheritance and polymorphism as well but maybe that comes later at some point... ;-)

Anyways, I can't give enough credit to this tutorial. He has structured it in a way that is very easy to understand and he explains everything in a simple way. And these concepts apply to rigid body simulatios as well. Sum up forces, integrate, done ! Pretty simple actually if we ignore collision detection for now... I can only highly recommend to look up his tutorial.

I am going to try the Runge-Kutta (RK4) integrator next which seems to be the industry standard in simulations. And my ultimate goal is a simple simulation system that I could use for characters, cars, planes or boats to automate certain things. I will keep you posted ! At some point I will have to convert to C++ though because MAXScript is just tooooo slow :-) Hehe !

Jeff Lim's picture

really cool script! it's

really cool script! it's also really interesting to see the transition/comparison of the XNA code to maxscript code. thank you very much for this script.

MarTroYx's picture

Thank, your explanation


your explanation worked perfectly , I'll also add that you have to create $dummy01 and $dummy02 at the vertex pos :-)

in fact , I like hard to use tool too :-)
nice work on this one :-P


relief7's picture

Hi Martin, thanks for

Hi Martin,

thanks for having a look ! :-) No plugins needed !

You should be able to get it to work by changing two things in the script under INITIALIZATION (line 531 - 561). You have to set iWidthSegments and iLengthSegments to 12 and in line 553, you have to put the name of your plane. The last thing is line 561/562 where you set the names of the dummies and the vertex number of the constrained vertices for attaching the corners (in your case probably 1 and 12). That should work. It is important to get those segment numbers right otherwise the springs between the vertices will not be initialized the correct way. If in doubt, try it on the max file I provided here and go from there.

Sorry for hardcoding all that stuff. I know it makes it hard to play around with. But my time is pretty limited right now so I had to focus and didnt have enough time to build a fancy UI :-) I hope you can understand ! :-)

MarTroYx's picture

I've got a simple 12x12

I've got a simple 12x12 editpoly plane and it crash at line 248 unknown pos in undefined , do I need special plugins installed ?

look very interesting by the way :-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.