SDL-Demos (mostly for developers)

In order to help Delphi and pascal developers getting started with the Newton Game Dynamics Engine I wrote some demos that come with full source code so you can see how different things can be achieved when using Newton. The demos use the Simple Direct Medialayer so that, when using a cross-platform pascal compiler, you can use Newton with all operating systems that are supported by Newton itself (currently Windows, Linux and Mac) . What you need to compile and run them :

  • A compatible pascal compiler, tested with Free Pascal 2.0.0 and Delphi
  • The Newton headers.  Choose the headers depending on which version of the demo you want to compile. The demos that use 2.00 work with the beta headers.
  • Pascal translation of the SDL-headers, called JEDI SDL
  • Newton’s shared library for your operating system, included in the Newton SDK, placed somewhere where the application can find it
  • SDL’s shared library for your operating system, placed somewhere where the application can find it
Newton SDL 01 01 – Basic Demo
This is as basic as it can get. If you want to get into the usage of Newton, take a look at this demo. It shows how to create some spinning boxes and also shows you how correct physics timing is done using “accumulative timeslicing”.

Newton SDL 02 02 – Joints Demo
This demo shows off all different joint types that Newton has to offer : Ball and Socket, Hinge, Slider, Corkscrew and the universal joint. It also shows how to use newton’s raycast-functions to grab and influence bodies. Also shows how to display debug lines for physics.

Newton SDL 03 03 – Vehicle Demo
This demo shows how to use the vehicle container in Newton. It isn’t looking pretty, but the source is fully documented and it should be easy to get vehicles to run in your own applications.

  • Source (Newton 1.53)
  • No Newton 2.00 source yet. Vehicle functions are missing from current NGD 2.xx beta!
Newton SDL 04 04 – Buoyancy Demo
This demonstration shows you how to implement fluids (and similar things) that bodies are immersed in using newton’s buoyancy features.

Newton SDL 05 05 – Ragdoll Demo
This demo shows the usage of NGD’s RagDoll-container to create humanoid ragdolls that bend and twist like real corpses do. The demo let’s you drop them down on an environment and also let’s you grab and throw them around with your mouse.

  • Source (Newton 1.53)
  • No Newton 2.00 source yet. Ragdoll functions are still subject to change in NGD 2.xx beta!
Newton SDL 06 06 – Character Controller
When pepople think of physics engines like NGD, they first think about throwing objects around. But that’s not the only thing such a physics engine can be used for. Modern FPS-games need to have robust collisions with realistic movement and collision reaction. This is usually a hard thing to code, but Newton can easily be used to implement such a character controller. This demo shows how to do this and let’s you run around in a small FPS environment where you can even interact with some dynamic objects.

Newton SDL 07 07 – Simple explosion
This demo shows how to create (simple explosions) by adding impulse to all bodies in an explosions perimeter depending on their distance to the explosions origin.

Newton SDL 08 08 – Contact process callback
Newton’s material system is very sophisticated and offers a lot possibilites. One of these is the contact process callback, a callback called from inside newton when two materials generate contacts. In this callback you can get the force of a contact and use it to apply damage, spawn particles, or play sounds depending on the strength of that contact, which is shown in this demo.

Newton SDL 09 09 – Moving static bodies
Sometimes it may be necessary to move a static body, for example if you have a scripted object that only moves when a certain action is triggered (think of an elevator for example). Just overriding the matrix of this body with animation information won’t work as interaction with rigid bodies won’t be correct. This demo shows how to move static objects the correct way.