6.8 Springs

Here we have a complex system to simulate springs and masses. It shows that even complex things can be done with Xpressionist if you have the theoretical background of the script you want to write. Please get the projects and play around with them. This is not a tutorial but should give you an idea how things like physics are approached with XP.

Click the image to get a larger view.

Each spring has two ends. One end is the Xpressionist group that keeps the expression for the spring (named spring1_xp and spring2_xp), the other end is the position of the attached mass, which is also an XP instance.

The expression of the spring1_xp group calculates how much force acts on its endings, and the expression of the mass_xp object calculates the resulting movement for the assigned mass.

Since this system is not visible we have attached a sphere to the mass_xp object and attached effectors - "position indicators" - to see where the ends of the springs are in our scene. The geometry of the spring is a deformed Ubershape group, that gets deformed by the distance of the spring_xp objects to the sphere/mass_xp object. To always make the spring model point to the sphere we have made the spring geometry a child of a simple IK chain with one bone that aligns the spring geometry.

The first project shows the use of one spring with one mass. To alter the behaviour of the system, change the values in the setup sections of the expressions. With this setup you can use as many spring_xp objects as you like in your scene.


Click on the image play the movie.


get project file one_spring.prj

The second project shows the system with two springs. It uses the same expressions as the one_spring project.




Click on the image play the movie.


get project file two_spring.prj

Here are three other renders of the system with different settings for the mass, the friction and the elasticity of the spring. Click on the images to play the movies.

Xpressionist 3.5