java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.PhysicsScene
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstPhysicsScene,RefTarget,AutoCloseable,Comparable<JoltPhysicsObject>
The creation settings of a set of bodies.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intbody index that denotes attachment to the fixed world -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the specified body to the scene.voidaddConstraint(TwoBodyConstraintSettings constraint, int body1, int body2) Add the specified constraint to the scene.voidaddSoftBody(ConstSoftBodyCreationSettings softBody) Add the specified soft body to the scene.booleancreateBodies(PhysicsSystem system) Instantiate the bodies in the scene.booleanCorrect any incorrectly scaled shapes in the scene.voidfromPhysicsSystem(ConstPhysicsSystem system) Load the current state of the specified physics system.Access the body-creation settings as a Java array.Access the constraints as a Java array.intCount the bodies in the scene.intCount the constraints in the scene.intCount the soft bodies in the scene.intCount the active references to the nativePhysicsScene.Access the soft-body creation settings as a Java array.voidsaveBinaryState(StreamOut stream, boolean saveShapes, boolean saveGroupFilter) Save the scene to the specified binary stream.voidMark the nativePhysicsSceneas embedded.static PhysicsSceneResultsRestoreFromBinaryState(StreamIn stream) Attempt to de-serialize a saved scene from the specified stream.toRef()Create a counted reference to the current scene.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, targetVaOrZero, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa, targetVaOrZero
-
Field Details
-
cFixedToWorld
public static final int cFixedToWorldbody index that denotes attachment to the fixed world- See Also:
-
-
Constructor Details
-
PhysicsScene
public PhysicsScene()Instantiate an empty scene.
-
-
Method Details
-
addBody
Add the specified body to the scene.- Parameters:
body- the body settings (notnull, unaffected)
-
addConstraint
Add the specified constraint to the scene.- Parameters:
constraint- the constraint settings (notnull, unaffected)body1- the index of the first body in the bodies listbody2- the index of the 2nd body in the bodies list
-
addSoftBody
Add the specified soft body to the scene.- Parameters:
softBody- the soft-body settings (notnull, unaffected)
-
createBodies
Instantiate the bodies in the scene.- Parameters:
system- where to add the bodies (notnull, modified)- Returns:
trueif successful, otherwisefalse
-
fixInvalidScales
public boolean fixInvalidScales()Correct any incorrectly scaled shapes in the scene.- Returns:
trueif successful, otherwisefalse
-
fromPhysicsSystem
Load the current state of the specified physics system.- Parameters:
system- the physics system to load from (notnull, unaffected)
-
sRestoreFromBinaryState
Attempt to de-serialize a saved scene from the specified stream.- Parameters:
stream- the stream to read (notnull)- Returns:
- a new object
-
getBodies
Access the body-creation settings as a Java array.- Specified by:
getBodiesin interfaceConstPhysicsScene- Returns:
- a new array of new JVM objects with the pre-existing native objects assigned
-
getConstraints
Access the constraints as a Java array.- Specified by:
getConstraintsin interfaceConstPhysicsScene- Returns:
- a new array of new JVM objects with the pre-existing native objects assigned
-
getNumBodies
public int getNumBodies()Count the bodies in the scene. The scene is unaffected.- Specified by:
getNumBodiesin interfaceConstPhysicsScene- Returns:
- the count (≥0)
-
getNumConstraints
public int getNumConstraints()Count the constraints in the scene. The scene is unaffected.- Specified by:
getNumConstraintsin interfaceConstPhysicsScene- Returns:
- the count (≥0)
-
getNumSoftBodies
public int getNumSoftBodies()Count the soft bodies in the scene. The scene is unaffected.- Specified by:
getNumSoftBodiesin interfaceConstPhysicsScene- Returns:
- the count (≥0)
-
getSoftBodies
Access the soft-body creation settings as a Java array.- Specified by:
getSoftBodiesin interfaceConstPhysicsScene- Returns:
- a new array of new JVM objects with pre-existing native objects assigned
-
saveBinaryState
Save the scene to the specified binary stream. The scene is unaffected.- Specified by:
saveBinaryStatein interfaceConstPhysicsScene- Parameters:
stream- the stream to write to (notnull)saveShapes- if true, save the shapessaveGroupFilter- if true, save the group filter
-
getRefCount
public int getRefCount()Count the active references to the nativePhysicsScene. The scene is unaffected.- Specified by:
getRefCountin interfaceRefTarget- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativePhysicsSceneas embedded.- Specified by:
setEmbeddedin interfaceRefTarget
-
toRef
Create a counted reference to the current scene.
-