Physics simulation demo using Filament rendering engine and Bullet Physics SDK.
Physics simulation demo using Filament rendering engine and Bullet Physics SDK.
Cube Instancing | Constraints |
---|---|
CubeInstancingActivity.kt |
ConstraintsActivity.kt |
Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows, and WebGL. It is designed to be as small as possible and as efficient as possible on Android.
Bullet is a physics SDK for real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
This demo implements rudimentary instancing and rigid body simulations. Simply put😇, this demo loads a single glTF asset and creates copies of it, each attached with a rigid body from the physics engine that shares the transformation data of the rendering engine. The CubeInstancingActivity
creates a SurfaceView
and prepairs the rendering engine. The activity harnesses the ModelViewer
class to pipe down the boilerplating.
The CubeInstancingDemo
class initializes the physics world and performs the simulation. You can consult the manual for the details of the initialization phase. I have tried to keep it unopinionated as possible, it includes neither classes for node management nor interfaces that communicate with the physics engine, just so I have kept it simple.
You can tinker with the following constants in the CubeInstanceActivity.kt
:
// The number of concurrent rigid bodies
private const val INSTANCE_POOL_CAPACITY: Int = 100
// Feed rate
private const val CUBE_PER_SECOND: Int = 10
Most of the reasoning was from the links below. One may find them useful.
filament-physics is available under the MIT license. See the LICENSE file for more info.