forge2d_browser library

Classes

AABB
An axis-aligned bounding box.
Body
A rigid body. These are created via World.createBody.
BodyDef
Holds all the data needed to construct a Body.
BodyMeta
BroadPhase
BroadPhaseStrategy
CanvasDraw
CanvasViewportTransform
Transform for drawing using a canvas context. Y-flip is permanently set to true.
ChainAndCircleContact
ChainAndPolygonContact
ChainShape
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside and outside collision. Therefore, you may use any winding order. Connectivity information is used to create smooth collisions. WARNING: The chain will not collide properly if there are self-intersections.
CircleContact
CircleShape
A circle shape.
ClipVertex
Used for computing contact manifolds.
Collision
Functions used for computing contact points, distance queries, and TOI queries. Collision methods are non-static for pooling speed, retrieve a collision object from the SingletonPool. Should not be finalructed.
Color3i
ConstantVolumeJoint
ConstantVolumeJointDef<A extends Body>
Definition for a {@link ConstantVolumeJoint}, which connects a group a bodies together so they maintain a constant volume within them.
Contact
The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.
ContactFilter
Implement this class to provide collision filtering. In other words, you can implement this class if you want finer control over contact creation.
ContactID
ContactImpulse
Contact impulses for reporting. Impulses are used instead of forces because sub-step forces may approach infinity for rigid body collisions. These match up one-to-one with the contact points in b2Manifold.
ContactListener
Implement this class to get contact information. You can use these results for things like sounds and game logic. You can also get contact results by traversing the contact lists after the time step. However, you might miss some contacts because continuous physics leads to sub-stepping. Additionally you may receive multiple callbacks for the same contact in a single time step. You should strive to make your callbacks efficient because there may be many callbacks per time step. Warning: You cannot create/destroy Forge2D entities inside these callbacks.
ContactManager
Delegate of World.
ContactPositionConstraint
ContactSolver
ContactSolverDef
ContactVelocityConstraint
CreateParticleGroupCallback
DebugDraw
Implement this abstract class to allow Forge2d to automatically draw your physics for debugging purposes.
DefaultBroadPhaseBuffer
The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent overlap.
DestroyListener
Joints and fixtures are destroyed when their associated body is destroyed. Implement this listener so that you may remove references to these joints and shapes.
DestroyParticlesInShapeCallback
Distance
DistanceInput
Input for Distance. You have to option to use the shape radii in the computation.
DistanceJoint
A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.
DistanceJointDef<A extends Body, B extends Body>
Distance joint definition. This requires defining an anchor point on both bodies and the non-zero length of the distance joint. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game.
DistanceOutput
Output for Distance.
DistanceProxy
DynamicTree
A dynamic tree arranges data in a binary tree to accelerate queries such as volume queries and ray casts. Leaves are proxies with an AABB. In the tree we expand the proxy AABB by _fatAABBFactor so that the proxy AABB is bigger than the client object. This allows the client object to move by small amounts without triggering a tree update.
DynamicTreeNode
EdgeAndCircleContact
EdgeAndPolygonContact
EdgePolygonCollider
This class collides an edge and a polygon, taking into account edge adjacency.
EdgeResults
Java-specific class for returning edge results
EdgeShape
A line segment (edge) shape. These can be connected in chains or loops to other edge shapes. The connectivity information is used to ensure correct contact normals.
EPAxis
Filter
This holds contact filtering data.
Fixture
A fixture is used to attach a Shape to a Body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as friction, collision filters, etc. Fixtures are created via body.createFixture.
FixtureDef
Used to create a Fixture.
FixtureProxy
This proxy is used internally to connect fixtures to the broad-phase.
FrictionJoint
FrictionJointDef<A extends Body, B extends Body>
Friction joint definition.
GearJoint
A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motion together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length.
GearJointDef<A extends Body, B extends Body>
Gear joint definition. This definition requires two existing revolute or prismatic joints (any combination will work). The provided joints must attach a dynamic body to a static body.
Island
This is an internal class.
Jacobian
JoinParticleGroupsCallback
Joint
The base joint class. Joints are used to constrain two bodies together in various fashions. Some joints also feature limits and motors.
JointDef<A extends Body, B extends Body>
JointDefs are used to construct Joints.
Manifold
ManifoldPoint
A manifold point is a contact point belonging to a contact manifold. It holds details related to the geometry and dynamics of the contact points. The local point usage depends on the manifold type:
MassData
This holds the mass data computed for a shape.
Matrix2
2D Matrix. Values are stored in column major order.
Matrix3
3D Matrix. Values are stored in column major order.
MotorJoint
A motor joint is used to control the relative motion between two bodies. A typical usage is to control the movement of a dynamic body with respect to the ground.
MotorJointDef<A extends Body, B extends Body>
Motor joint definition.
MouseJoint
A mouse joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces. NOTE: this joint is not documented in the manual because it was developed to be used in the testbed. If you want to learn how to use the mouse joint, look at the testbed.
MouseJointDef<A extends Body, B extends Body>
Mouse joint definition. This requires a world target point, tuning parameters, and the time step.
NewIndices
Pair
PairCallback
Particle
ParticleBodyContact
ParticleContact
ParticleDestroyListener
ParticleGroup
ParticleGroupDef
A particle group definition holds all the data needed to construct a particle group. You can safely re-use these definitions.
ParticleGroupType
ParticleQueryCallback
Callback class for AABB queries. See World.queryAABB.
ParticleRaycastCallback
ParticleSystem
ParticleType
The particle type. Can be combined with | operator. Zero means liquid.
PolygonAndCircleContact
PolygonContact
PolygonShape
A convex polygon shape. Polygons have a maximum number of vertices equal to _maxPolygonVertices. In most cases you should not need many vertices for a convex polygon.
Position
PositionSolverManifold
PrismaticJoint
A prismatic joint. This joint provides one degree of freedom: translation along an axis fixed in bodyA. Relative rotation is prevented. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction.
PrismaticJointDef<A extends Body, B extends Body>
Prismatic joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
Profile
ProfileEntry
PsPair
Connection between two particles
PsProxy
Used for detecting particle contacts
PsTriad
Connection between three particles
PulleyJoint
The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio * length2 <= constant Yes, the force transmitted is scaled by the ratio. Warning: the pulley joint can get a bit squirrelly by itself. They often work better when combined with prismatic joints. You should also cover the anchor points with static shapes to prevent one side from going to zero length.
PulleyJointDef<A extends Body, B extends Body>
Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, and a pulley ratio.
QueryCallback
Callback class for AABB queries. See World.queryAABB.
RayCastCallback
Callback class for ray casts. See World.raycast.
RayCastInput
Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
RayCastOutput
Ray-cast output data. The ray hits at p1 + fraction * (p2 - p1), where p1 and p2 come from RayCastInput.
RaycastResult
RevoluteJoint
A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.
RevoluteJointDef<A extends Body, B extends Body>
Revolute joint definition. This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from the body's origin rather than the center of mass because:
RopeJoint
A rope joint enforces a maximum distance between two points on two bodies. It has no other effect. Warning: if you attempt to change the maximum length during the simulation you will get some non-physical behavior. A model that would allow you to dynamically modify the length would have some sponginess, so I chose not to implement it that way. See DistanceJoint if you want to dynamically control length.
RopeJointDef<A extends Body, B extends Body>
Rope joint definition. This requires two body anchor points and a maximum lengths.
Rot
SeparationFunction
Shape
A shape is used for collision detection. You can create a shape however you like. Shapes used for simulation in World are created automatically when a Fixture is created. Shapes may encapsulate a one or more child shapes.
SimplexCache
SolveCollisionCallback
SolverData
Sweep
This describes the motion of a body/shape for TOI computation. Shapes are defined with respect to the body origin, which may not coincide with the center of mass. However, to support dynamics we must interpolate the center of mass position.
TempPolygon
This holds polygon B expressed in frame A.
TimeOfImpact
Class used for computing the time of impact. This class should not be constructed usually, just retrieve from the {@link SingletonPool#getTOI()}.
TimeStep
This is an internal structure.
TOIInput
Input parameters for TOI
TOIOutput
Output parameters for TimeOfImpact
Transform
A transform contains translation and rotation. It is used to represent the position and orientation of rigid frames.
TreeCallback
Callback for DynamicTree
TreeRayCastCallback
Callback for {@link DynamicTree}
UpdateBodyContactsCallback
Vector2
2D column vector.
Vector3
3D column vector.
Velocity
VelocityConstraintPoint
ViewportTransform
VoronoiDiagram
VoronoiDiagramCallback
VoronoiDiagramTask
VoronoiGenerator
WeldJoint
A weld joint essentially glues two bodies together. A weld joint may distort somewhat because the island constraint solver is approximate.
WeldJointDef<A extends Body, B extends Body>
WheelJoint
A wheel joint. This joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. You can use a joint limit to restrict the range of motion and a joint motor to drive the rotation or to model rotational friction. This joint is designed for vehicle suspensions.
WheelJointDef<A extends Body, B extends Body>
Wheel joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
World
The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.
WorldManifold
This is used to compute the current state of a contact manifold.
WorldQueryWrapper
WorldRayCastWrapper

Enums

BodyType
Defines the type of a Body.
ContactIDType
EPAxisType
This structure is used to keep track of the best separating axis.
LimitState
ManifoldType
A manifold for two touching convex shapes. Forge2D supports multiple types of contact:
PointState
This is used for determining the state of contact points.
SeparationFunctionType
ShapeType
Types of shapes
TOIOutputState
VertexType

Properties

aabbExtension double
This is used to fatten AABBs in the dynamic tree. This allows proxies to move by a small amount without triggering a tree adjustment. This is in meters.
getter/setter pair
aabbMultiplier double
This is used to fatten AABBs in the dynamic tree. This is used to predict the future position based on the current displacement. This is a dimensionless multiplier.
getter/setter pair
angularSleepTolerance double
A body cannot sleep if its angular velocity is above this tolerance.
getter/setter pair
angularSlop double
A small angle used as a collision and constraint tolerance. Usually it is chosen to be numerically significant, but visually insignificant.
getter/setter pair
baumgarte double
This scale factor controls how fast overlap is resolved. Ideally this would be 1 so that overlap is removed in one time step. However using values close to 1 often lead to overshoot.
getter/setter pair
epsilon double
A "close to zero" float epsilon value for use
getter/setter pair
intMaxValue int
NOTE: If you change any of these values, do make sure that you know what you are doing. Don't change these because your bodies are moving to slowly, then you have done something else that is wrong, like setting the scale too low.
getter/setter pair
invalidParticleIndex int
A symbolic constant that stands for particle allocation error.
getter/setter pair
linearSleepTolerance double
A body cannot sleep if its linear velocity is above this tolerance.
getter/setter pair
linearSlop double
A small length used as a collision and constraint tolerance. Usually it is chosen to be numerically significant, but visually insignificant.
getter/setter pair
maxAngularCorrection double
The maximum angular position correction used when solving constraints. This helps to prevent overshoot.
getter/setter pair
maxLinearCorrection double
The maximum linear position correction used when solving constraints. This helps to prevent overshoot.
getter/setter pair
maxManifoldPoints int
The maximum number of contact points between two convex shapes.
getter/setter pair
maxParticleWeight double
The upper limit for particle weight used in pressure calculation.
getter/setter pair
maxPolygonVertices int
The maximum number of vertices on a convex polygon.
getter/setter pair
maxRotation double
The maximum angular velocity of a body. This limit is very large and is used to prevent numerical problems. You shouldn't need to adjust this.
getter/setter pair
maxRotationSquared double
getter/setter pair
maxSubSteps int
Maximum number of sub-steps per contact in continuous physics simulation.
getter/setter pair
maxTOIContacts int
Maximum number of contacts to be handled to solve a TOI island.
getter/setter pair
maxTranslation double
The maximum linear velocity of a body. This limit is very large and is used to prevent numerical problems. You shouldn't need to adjust this.
getter/setter pair
maxTranslationSquared double
getter/setter pair
maxTriadDistance int
The maximum distance between particles in a triad, divided by the particle radius.
getter/setter pair
maxTriadDistanceSquared int
getter/setter pair
minParticleBufferCapacity int
The initial size of particle data buffers.
getter/setter pair
minParticleWeight double
The minimum particle weight that produces pressure.
getter/setter pair
particleStride double
The standard distance between particles, divided by the particle radius.
getter/setter pair
polygonRadius double
The radius of the polygon/edge shape skin. This should not be modified. Making this smaller means polygons will have and insufficient for continuous collision. Making it larger may create artifacts for vertex collision.
getter/setter pair
positionIterations int
The amount of iterations for positions that should be done in the solver.
getter/setter pair
timeToSleep double
The time that a body must be still before it will go to sleep.
getter/setter pair
velocityIterations int
The amount of iterations for velocities that should be done in the solver.
getter/setter pair
velocityThreshold double
A velocity threshold for elastic collisions. Any collision with a relative linear velocity below this threshold will be treated as inelastic.
getter/setter pair