-
- All Implemented Interfaces:
DataContainer
public class BodyFixture extends Fixture implements DataContainer
Represents a piece of aPhysicsBody
.BodyFixture
extends theFixture
class, adding physical features like density and friction.- Since:
- 2.0.0
- Version:
- 5.0.0
- Author:
- William Bittle
- See Also:
Fixture
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_DENSITY
The default density in kg/m2; value =DEFAULT_DENSITY
static double
DEFAULT_FRICTION
The default coefficient of friction; value =DEFAULT_FRICTION
static double
DEFAULT_RESTITUTION
The default coefficient of restitution; value =DEFAULT_RESTITUTION
static double
DEFAULT_RESTITUTION_VELOCITY
The default restitution velocity; in meters/secondprotected double
density
The density in kg/m2protected double
friction
The coefficient of frictionprotected double
restitution
The coefficient of restitutionprotected double
restitutionVelocity
The minimum velocity to apply restitution
-
Constructor Summary
Constructors Constructor Description BodyFixture(Convex shape)
Minimal constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mass
createMass()
Creates a newMass
object using the set density and shape.double
getDensity()
Returns the density of this shape in kg/m2.double
getFriction()
Returns the coefficient of friction.double
getRestitution()
Returns the coefficient of restitution.double
getRestitutionVelocity()
Returns the minimum velocity required to apply restitution.void
setDensity(double density)
Sets the density of this shape in kg/m2.void
setFriction(double friction)
Sets the coefficient of friction.void
setRestitution(double restitution)
Sets the coefficient of restitution.void
setRestitutionVelocity(double restitutionVelocity)
Sets the minimum velocity required to apply restitution.String
toString()
-
Methods inherited from class Fixture
getFilter, getShape, getUserData, isSensor, setFilter, setSensor, setUserData
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface DataContainer
getUserData, setUserData
-
-
-
-
Field Detail
-
DEFAULT_FRICTION
public static final double DEFAULT_FRICTION
The default coefficient of friction; value =DEFAULT_FRICTION
- See Also:
- Constant Field Values
-
DEFAULT_RESTITUTION
public static final double DEFAULT_RESTITUTION
The default coefficient of restitution; value =DEFAULT_RESTITUTION
- See Also:
- Constant Field Values
-
DEFAULT_DENSITY
public static final double DEFAULT_DENSITY
The default density in kg/m2; value =DEFAULT_DENSITY
- See Also:
- Constant Field Values
-
DEFAULT_RESTITUTION_VELOCITY
public static final double DEFAULT_RESTITUTION_VELOCITY
The default restitution velocity; in meters/second- Since:
- 4.2.0
- See Also:
- Constant Field Values
-
density
protected double density
The density in kg/m2
-
friction
protected double friction
The coefficient of friction
-
restitution
protected double restitution
The coefficient of restitution
-
restitutionVelocity
protected double restitutionVelocity
The minimum velocity to apply restitution- Since:
- 4.2.0
-
-
Method Detail
-
setDensity
public void setDensity(double density)
Sets the density of this shape in kg/m2.The density of an object is a number that represent how much matter is contained in a given space. Larger density values indicate a more massive object. Larger density objects resist changes in motion more than smaller objects.
A density equal to zero will make this shape participate in collision detection and resolution, but will it will not contribute to the total mass of the body.
- Parameters:
density
- the density in kg/m2- Throws:
IllegalArgumentException
- if density is less than zero
-
getDensity
public double getDensity()
Returns the density of this shape in kg/m2.- Returns:
- double the density in kg/m2
- See Also:
setDensity(double)
-
getFriction
public double getFriction()
Returns the coefficient of friction.- Returns:
- double
- See Also:
setFriction(double)
-
setFriction
public void setFriction(double friction)
Sets the coefficient of friction.The coefficient of friction is a number that represents how rough a material is. Friction between surfaces converts the kinetic (motion) energy into heat, thereby slowing the objects in contact down.
A higher value of friction will slow the object down faster. A friction value of zero represents no friction.
- Parameters:
friction
- the coefficient of friction; must be greater than zero- Throws:
IllegalArgumentException
- if friction is less than zero
-
getRestitution
public double getRestitution()
Returns the coefficient of restitution.- Returns:
- double
- See Also:
setRestitution(double)
-
setRestitution
public void setRestitution(double restitution)
Sets the coefficient of restitution.The coefficient of restitution is a number that represents the bounciness of a material. Larger values produce more bounce and smaller values produce less bounce. A value of 1.0 indicates that an object would retain all of its velocity after bouncing. The value can be higher than 1 to increase the velocity after bouncing.
Due to floating point precision and accuracy, a value of 1.0 may not produce a fully ellastic bounce (all the velocity is retained).
- Parameters:
restitution
- the coefficient of restitution; must be greater than zero- Throws:
IllegalArgumentException
- if restitution is less than zero
-
getRestitutionVelocity
public double getRestitutionVelocity()
Returns the minimum velocity required to apply restitution.- Returns:
- double
- Since:
- 4.2.0
-
setRestitutionVelocity
public void setRestitutionVelocity(double restitutionVelocity)
Sets the minimum velocity required to apply restitution.- Parameters:
restitutionVelocity
- the velocity- Since:
- 4.2.0
-
-