nphysics is a 2 and 3-dimensional physics engine for games and animations. It uses ncollide for collision detection, and nalgebra for vector/matrix math.
Its most distinctive feature is its genericity wrt the simulation dimension. That means you can use it for both 2-dimensional physics and 3-dimensional physics. Higher dimensions could be possible, but nphysics has not be written/tested with those in thought.
Examples are available on the examples
directory.
There is also a short (outdated) demonstration video.
An on-line version of this documentation is available here.
There are a lot of physics engine out there. However having a physics engine written in rust is much more fun than writing bindings and has several advantages:
You will need the last nightly build of the rust compiler and the official package manager: cargo.
Simply add the following to your Cargo.toml
file if you want the 3d version
of nphysics, using 32-bits foalting point numbers:
[dependencies.nphysics3df32]
git = "https://github.com/sebcrozet/nphysics"
Depending on the accuracy or the dimension that you need, nphysics3df32
may
be replaced by:
nphysics2df32
− for 2d collision detection and 32 bits precision.nphysics3df32
− for 3d collision detection and 32 bits precision.nphysics2df64
− for 2d collision detection and 64 bits precision.nphysics3df64
− for 3d collision detection and 64 bits precision.Use make examples
to build the demos and execute ./your_favorite_example_here --help
to see all the cool stuffs you can do.
nphysics is a very young library and needs to learn a lot of things to become a grown up. Many missing features are because of missing features on ncollide. Features missing from nphysics itself include:
All dependencies are automatically cloned with a recursive clone. The libraries needed to compile the physics engine are:
The libraries needed to compile the examples are: