JVM bindings for Jolt Physics
MIT License
The Jolt-jni Project provides JVM bindings for Jolt Physics, to facilitate physics simulation in JVM languages such as Java and Kotlin.
Source code is provided under an MIT license.
There’s close correspondence between the class/method names of Jolt Physics and jolt-jni. For example:
Body
class in jolt-jni will (eventually) provideBody
class in Jolt Physics.ConstBody
interface will include all the const
methodsBody
class, such as its GetPosition()
method,getPosition()
.Things become slightly more interesting when C++ templates and public member data are involved. For instance:
Array<BodyID>
in Jolt Physics;BodyIdVector
.mConvexRadius
member of the Jolt Physics BoxShapeSettings
classgetConvexRadius()
and setConvexRadius()
in jolt-jni.For a couple well-known Jolt Physics examples, line-for-line translations into Java are provided.
Jolt-jni comes pre-built as a platform-independent JVM library plus a set of native libraries, all downloadable from Maven Central.
Current jolt-jni releases provide the JVM library under 6 distinct names (artifact IDs). They also provide 24 native libraries, each specific to a particular platform, build type, and build flavor.
Your runtime classpath should include a JVM library plus 1-to-6 native libraries: a native library for each platform on which the code will run.
Add to the project’s "build.gradle" or "build.gradle.kts" file:
repositories {
mavenCentral()
}
dependencies {
implementation("com.github.stephengold:jolt-jni-Linux64:0.8.0") // JVM library
runtimeOnly("com.github.stephengold:jolt-jni-Linux64:0.8.0:DebugSp") // native library for Linux
// (Native libraries for other platforms could go here.)
}
JAVA_HOME
environment variable to your JDK installation:export JAVA_HOME="
path to installation "
set -g JAVA_HOME "
path to installation "
set JAVA_HOME="
path to installation "
$env:JAVA_HOME = '
path to installation '
git clone https://github.com/stephengold/jolt-jni.git
cd jolt-jni
git checkout -b latest 0.8.0
cd
to the extracted directory/folder./gradlew build
.\gradlew build
After a successful build, artifacts will be found in "build/libs".
You can run the "hello world" example app:
./gradlew runHelloWorld
.\gradlew runHelloWorld
You can run various scenes in the "performance test" example app:
./gradlew runConvexVsMesh
.\gradlew runConvexVsMesh
./gradlew runPyramid
.\gradlew runPyramid
./gradlew runRagdoll
.\gradlew runRagdoll