JSim 2026.06.01-p(1)
Loading...
Searching...
No Matches
jsim.PhysicsWorld Class Reference
Inheritance diagram for jsim.PhysicsWorld:

Classes

enum  HitboxType

Public Member Functions

 PhysicsWorld (double fixedDtSeconds, boolean enableGravity)
double getFixedDtSeconds ()
long getNativeHandle ()
int getMaxBodies ()
PhysicsBody createBody (double massKg)
Gamepiece createGamepiece (double radiusMeters, double massKg, double restitution)
Gamepiece createGamepiece ()
Gamepiece createGamepiece (GamePieceType type, double radiusMeters, double massKg, double restitution)
Gamepiece createGamepiece (GamePieceType type)
Gamepiece createGamepiece (String typeName)
Gamepiece createGamepiece (String typeName, double radiusMeters, double massKg, double restitution)
List< Gamepiecegamepieces ()
void addStepListener (Runnable listener)
void setGamepiecePosition (int gamepieceIndex, double xMeters, double yMeters, double zMeters)
int pickGamepiece (int gamepieceIndex, double intakeX, double intakeY, double intakeZ, double captureRadius, double carryOffsetX, double carryOffsetY, double carryOffsetZ)
void placeGamepiece (int gamepieceIndex, double xMeters, double yMeters, double zMeters)
void outtakeGamepiece (int gamepieceIndex, double px, double py, double pz, double vx, double vy, double vz)
void setGamepieceLinearVelocity (int gamepieceIndex, double vxMetersPerSecond, double vyMetersPerSecond, double vzMetersPerSecond)
Pose3d getBodyPosition (int bodyIndex)
LinearVelocity3d getBodyLinearVelocity (int bodyIndex)
Rotation3d getBodyOrientation (int bodyIndex)
int getBodyState13Array (double[] outState13)
Pose3d getGamepiecePosition (int gamepieceIndex)
String getGamepieceTypeName (int gamepieceIndex)
LinearVelocity3d getGamepieceLinearVelocity (int gamepieceIndex)
void step ()
void step (int steps)
void setGravity (Translation3d gravity)
void setGravity (double gxMetersPerSecondSquared, double gyMetersPerSecondSquared, double gzMetersPerSecondSquared)
void close ()

Detailed Description

Thin Java wrapper around the native physics world implementation.

Constructor & Destructor Documentation

◆ PhysicsWorld()

jsim.PhysicsWorld.PhysicsWorld ( double fixedDtSeconds,
boolean enableGravity )
inline

Creates a native physics world.

Parameters
fixedDtSecondsfixed simulation timestep in seconds
enableGravitywhether gravity is enabled for newly created bodies

Member Function Documentation

◆ addStepListener()

void jsim.PhysicsWorld.addStepListener ( Runnable listener)
inline

Registers a callback that runs after each successful physics step.

Parameters
listenercallback invoked after step() completes

◆ close()

void jsim.PhysicsWorld.close ( )
inline

◆ createBody()

PhysicsBody jsim.PhysicsWorld.createBody ( double massKg)
inline

Creates a new body with the provided mass in kilograms.

Parameters
massKgthe body mass in kilograms
Returns
the created body handle

◆ createGamepiece() [1/6]

Gamepiece jsim.PhysicsWorld.createGamepiece ( )
inline

Creates a spherical gamepiece with default physical parameters.

Returns
the created gamepiece handle

◆ createGamepiece() [2/6]

Gamepiece jsim.PhysicsWorld.createGamepiece ( double radiusMeters,
double massKg,
double restitution )
inline

Creates a new generic gamepiece in the world.

Current native support is spherical hitboxes. Additional hitbox types can be added without changing the top-level gamepiece abstraction.

Parameters
radiusMeterssphere radius in meters
massKggamepiece mass in kilograms
restitutioncoefficient of restitution in [0, 1]
Returns
the created gamepiece handle

◆ createGamepiece() [3/6]

Gamepiece jsim.PhysicsWorld.createGamepiece ( GamePieceType type)
inline

Convenience overload for creating a typed gamepiece with default physical parameters.

Parameters
typethe gamepiece type to create
Returns
created gamepiece

◆ createGamepiece() [4/6]

Gamepiece jsim.PhysicsWorld.createGamepiece ( GamePieceType type,
double radiusMeters,
double massKg,
double restitution )
inline

Creates a new gamepiece with an explicit type tag.

Parameters
typegamepiece type enum
radiusMeterssphere radius in meters
massKgmass in kilograms
restitutioncoefficient of restitution
Returns
created gamepiece

◆ createGamepiece() [5/6]

Gamepiece jsim.PhysicsWorld.createGamepiece ( String typeName)
inline

Convenience overload for creating a named gamepiece type with default physical parameters.

Parameters
typeNamehuman readable type name (e.g. "generic_sphere", "fuel_rebuilt_2026")
Returns
created gamepiece

◆ createGamepiece() [6/6]

Gamepiece jsim.PhysicsWorld.createGamepiece ( String typeName,
double radiusMeters,
double massKg,
double restitution )
inline

Creates a new named gamepiece type (useful for season definitions or CAD-imported types).

Parameters
typeNamehuman readable type name (e.g. "generic_sphere", "fuel_rebuilt_2026")
radiusMeterssphere radius in meters
massKgmass in kilograms
restitutioncoefficient of restitution
Returns
created gamepiece

◆ gamepieces()

List< Gamepiece > jsim.PhysicsWorld.gamepieces ( )
inline

Returns gamepieces created through this world wrapper in insertion order.

Returns
live list of created gamepieces

◆ getBodyLinearVelocity()

LinearVelocity3d jsim.PhysicsWorld.getBodyLinearVelocity ( int bodyIndex)
inline

Gets the world linear velocity for the given body.

Parameters
bodyIndexnative body index
Returns
body linear velocity

◆ getBodyOrientation()

Rotation3d jsim.PhysicsWorld.getBodyOrientation ( int bodyIndex)
inline

Gets the world orientation for the given body.

Parameters
bodyIndexnative body index
Returns
body orientation

◆ getBodyPosition()

Pose3d jsim.PhysicsWorld.getBodyPosition ( int bodyIndex)
inline

Gets the world position for the given body.

Parameters
bodyIndexnative body index
Returns
body position

◆ getBodyState13Array()

int jsim.PhysicsWorld.getBodyState13Array ( double[] outState13)
inline

Exports full body state blocks.

Layout per body is: [x, y, z, qw, qx, qy, qz, vx, vy, vz, wx, wy, wz].

Parameters
outState13destination array sized for N*13 entries
Returns
number of body blocks written

◆ getFixedDtSeconds()

double jsim.PhysicsWorld.getFixedDtSeconds ( )
inline

Returns the fixed timestep configured for this world.

Returns
fixed timestep in seconds

◆ getGamepieceLinearVelocity()

LinearVelocity3d jsim.PhysicsWorld.getGamepieceLinearVelocity ( int gamepieceIndex)
inline

Gets the world linear velocity for the given gamepiece.

Parameters
gamepieceIndexnative gamepiece index
Returns
gamepiece linear velocity as a LinearVelocity3d

◆ getGamepiecePosition()

Pose3d jsim.PhysicsWorld.getGamepiecePosition ( int gamepieceIndex)
inline

Gets the world position for the given gamepiece.

Parameters
gamepieceIndexnative gamepiece index
Returns
gamepiece position as a Pose3d with zero rotation

◆ getGamepieceTypeName()

String jsim.PhysicsWorld.getGamepieceTypeName ( int gamepieceIndex)
inline

Returns the registered type name for the given gamepiece.

Parameters
gamepieceIndexnative gamepiece index
Returns
human-readable type name or null if none

◆ getMaxBodies()

int jsim.PhysicsWorld.getMaxBodies ( )
inline

Returns a reasonable default maximum number of bodies to export for telemetry.

Callers may use this value when constructing publishers that snapshot world state.

Returns
default max bodies for telemetry (units: count)

◆ getNativeHandle()

long jsim.PhysicsWorld.getNativeHandle ( )
inline

Returns the native world handle for interop (primarily for publishers).

This is intentionally provided so callers can create native-backed helpers like telemetry publishers that require the raw handle.

Returns
native world handle (non-zero while world is valid)

◆ outtakeGamepiece()

void jsim.PhysicsWorld.outtakeGamepiece ( int gamepieceIndex,
double px,
double py,
double pz,
double vx,
double vy,
double vz )
inline

Outtakes a gamepiece from a pose with a linear velocity.

Parameters
gamepieceIndexnative gamepiece index
pxlaunch x position in meters
pylaunch y position in meters
pzlaunch z position in meters
vxlaunch x velocity in meters per second
vylaunch y velocity in meters per second
vzlaunch z velocity in meters per second

◆ pickGamepiece()

int jsim.PhysicsWorld.pickGamepiece ( int gamepieceIndex,
double intakeX,
double intakeY,
double intakeZ,
double captureRadius,
double carryOffsetX,
double carryOffsetY,
double carryOffsetZ )
inline

Requests pickup of a gamepiece into a carrier.

Parameters
gamepieceIndexnative gamepiece index
intakeXintake world x position
intakeYintake world y position
intakeZintake world z position
captureRadiuspickup radius in meters
carryOffsetXcarry offset x in meters
carryOffsetYcarry offset y in meters
carryOffsetZcarry offset z in meters
Returns
zero on success

◆ placeGamepiece()

void jsim.PhysicsWorld.placeGamepiece ( int gamepieceIndex,
double xMeters,
double yMeters,
double zMeters )
inline

Places a gamepiece at the given world position and marks it grounded.

Parameters
gamepieceIndexnative gamepiece index
xMetersx position in meters
yMetersy position in meters
zMetersz position in meters

◆ setGamepieceLinearVelocity()

void jsim.PhysicsWorld.setGamepieceLinearVelocity ( int gamepieceIndex,
double vxMetersPerSecond,
double vyMetersPerSecond,
double vzMetersPerSecond )
inline

Sets the gamepiece's world-space linear velocity in meters per second.

Parameters
gamepieceIndexnative gamepiece index
vxMetersPerSecondx velocity in meters per second
vyMetersPerSecondy velocity in meters per second
vzMetersPerSecondz velocity in meters per second

◆ setGamepiecePosition()

void jsim.PhysicsWorld.setGamepiecePosition ( int gamepieceIndex,
double xMeters,
double yMeters,
double zMeters )
inline

Sets the gamepiece's world-space position in meters.

Parameters
gamepieceIndexnative gamepiece index
xMetersx position in meters
yMetersy position in meters
zMetersz position in meters

◆ setGravity() [1/2]

void jsim.PhysicsWorld.setGravity ( double gxMetersPerSecondSquared,
double gyMetersPerSecondSquared,
double gzMetersPerSecondSquared )
inline

Applies gravity components to the world.

Parameters
gxMetersPerSecondSquaredx gravity in meters per second squared
gyMetersPerSecondSquaredy gravity in meters per second squared
gzMetersPerSecondSquaredz gravity in meters per second squared

◆ setGravity() [2/2]

void jsim.PhysicsWorld.setGravity ( Translation3d gravity)
inline

Applies a gravity vector to the world.

Parameters
gravitygravity vector in meters per second squared

◆ step() [1/2]

void jsim.PhysicsWorld.step ( )
inline

Advances the simulation by one step.

◆ step() [2/2]

void jsim.PhysicsWorld.step ( int steps)
inline

Advances the simulation by the requested number of steps.

Parameters
stepsnumber of steps to advance

The documentation for this class was generated from the following file: