# Building my own Delphi Physics Engine part V

Today I felt inspired (after parts I, II, III and IV) and I tried to do a cloth simulation in the Thundax Physics Engine. There are a lot of things to do, but at least I can start simulating different components very fast without too much implementation. I saw one amazing implementation of the "processing cloth" in JRC313.com. Even though the applet is written in JavaScript, the performance is quite impressive and it's a nice work.

but, How it works?
"Every line in the cloth simulation is technically called a constraint and every point is a point mass (an object with no dimension, just location and mass). All the constraints do is control the distance between each point mass. If two points move too far apart, it will pull them closer. If two points are too close together, it will push them apart. The cloth is really then just a collection of constraints and point masses in a never ending struggle."

using Relaxation in simple linear systems:
In the case of this cloth simulation all I needed to do was try satisfying the constraints as fast as I can. For things like simple rope simulations it may be necessary to satisfy several times (maybe 4 or 5). The more times you satisfy, the more rigid the constraint becomes. This process is known as relaxation and is amazing!. The displacement will then be of the form y(t) = Ae − t / Tcos(μt − δ). The constant T is called the relaxation time of the system and the constant μ is the quasi-frequency. (Wikipedia).

In the following videos you'll be able to check the performance of the simulated cloth. I took advantage of my previous bridge (spring + particles) and I've concatenated a series of bridges to set up a virtual cloth. Now the movement is quite astonishing:

In the second video I'm showing one of the new features for the next release: "the cutting tool". I still need to think about it, but for simple objects it could be simple to cut an object and see its reaction, like in the next video:

You can download the last version of the executable file here: thundax Balls demo v1.52. And maybe in a near future you'll be able to see something similar to the Puzzler for iPhone.

Other interesting video about physics and games is Crayon Physics from Petri Purho:

I hope you enjoy the videos!

# Building my own Delphi Physics Engine part IV

I'm still working on my solution, but I can advance you a preview of the smoothness of the application. I have improved the bridge particle and its interaction with external events. I'm working on a TStyle class that will enhance the GDIRender allowing the different particles to have a custom style on the screen and refactor all the classes to improve the scalability and interoperability of the Engine. If you are interested on testing the application, you can get the latest version of it from here: Thundax Ball Demo v1.1. In this version you will notice the improved interaction with the mouse and the circle particles. I have to work out a solution for the other particles, but I'm still designing the whole product and I need to test some of the features that I want to release in the next version. Once the version is ready, I will upload it on Sourceforge just in case you feel the urge to play with it!.
Here you can see the new performance:

# Building my own Delphi Physics Engine part III

Now I'm working on the interactive part (Controller). Since now I only have developed the model and the view section of the MVC pattern and I'm implementing and testing the controller part. The main problem is that the Engine is quite simple to implement and use until the visual control appears. Now I have to take into account all the events that come from the outside (mouse, keyboard) and add subscribers to the object particles. With the design that I've implemented it is easy to make extensible the model and the view section because the Engine follows the "low cohesion high coupling" principle. My sister challenged me by trying to do something similar to the ruicode project, where its ofxRuiPhysics2d project (Simple 2d physics addon for OF (OpenFrameworks) using the Verlet integrator where it includes particles, collisions and springs) is quite astonishing. Here you can see one of its videos:

And here is my project: Thundax balls demo.exe, a Delphi win32 application that will start a demo with balls, springs and collisions. In the following videos you'll see different performances of my tests. In the first video I'm trying to simulate the environment with all the forces playing at the same time, and in the second video you can see myself using the mouse interacting with the balls and the springs.

I hope you enjoy the videos!.

Related frameworks:
It's amazing the large amount of physics Engine that are available on the net. I just google the words "Physics Engine" and here are the results:
Javascript, C, and Java Frameworks:
ActionScript Frameworks:

3D and Realistic Frameworks:

# Netscape Mozilla Documentary 1998 - 2000 ProJect Code Rush

Now you can see the very inspiring and must-see film from Code Rush

The year is early 1998, at the height of dot-com era, and a small team of Netscape code writers frantically works to reconstruct the company's Internet browser. In doing so they will rewrite the rules of software development by giving away the recipe for its browser in exchange for integrating improvements created by outside unpaid developers.   The fate of the entire company may well rest on their shoulders.   Broadcast on PBS, the film capture the human and technological dramas that unfold in the collision between science, engineering, code, and commerce.
Source: Code Rush.