|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.emini.physics2D.Shape
public class Shape
The Shape class represents the shape and physical properties of a body.
The vertices of the shape are given as a convex polygon.
A single vertex is interpreted as a circle.
The physical properties are:
Field Summary | |
---|---|
static float |
MAX_MASS_FX
Infinity mass (FX). |
protected FXVector |
mCcentroid
Centroid of the shape. |
protected float |
mElasticityFX
Elasticity factor (FX) for bodies with this shape. |
protected float |
mFrictionFX
Friction factor (FX) for bodies with this shape. |
protected UserData |
mUserData
User data |
protected FXVector[] |
mVertices
Corners in clockwise direction (x to right, y up). |
Constructor Summary | |
---|---|
protected |
Shape()
Used for multi shape |
|
Shape(FXVector[] corners)
Constructor. |
|
Shape(Shape other)
Copy Constructor. |
Method Summary | |
---|---|
void |
correctCentroid()
Centers the shape. |
static Shape |
createCircle(int radius)
Creates a circle shape. |
static Shape |
createRectangle(int width,
int height)
Creates a rectangle shape. |
static Shape |
createRegularPolygon(int radius,
int vertices)
Creates a regular polygon shape. |
float |
getAreaFX()
Gets the area of the shape (FX). |
protected int |
getBoundingRadius()
Gets the bounding radius. |
float |
getBoundingRadiusFX()
Gets the bounding radius (FX). |
int |
getBoundingRadiusSquare()
Gets the square of the bounding radius. |
FXVector[] |
getCorners()
Gets the shape vertices. |
float |
getElasticityFX()
Gets the elasticity. |
float |
getFrictionFX()
Gets the friction (FX). |
int |
getId()
Get the shape id. |
int |
getMass()
Gets the mass. |
float |
getMassFX()
Gets the mass (FX). |
UserData |
getUserData()
Get user data. |
protected void |
getVerticesFX(FXVector pos,
FXMatrix rotation,
FXVector[] vertices)
Computes rotated and shifted vertices. |
static Shape |
loadShape(PhysicsFileReader reader,
UserData userData)
Loads a shape from a stream. |
void |
setElasticity(int elasticity)
Set the elasticity (in percent). |
void |
setElasticityFX(float elasticityFX)
Set the elasticity (FX). |
void |
setFriction(int friction)
Sets the friction (in percent). |
void |
setFrictionFX(float frictionFX)
Sets the friction of the shape (FX). |
void |
setMass(int mass)
Sets the mass. |
void |
setMassFX(float massFX)
Sets the mass (FX). |
void |
setUserData(UserData userData)
Set User data |
protected void |
updateInternals()
Computes internal values for fast access. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected FXVector[] mVertices
protected float mElasticityFX
protected float mFrictionFX
protected UserData mUserData
protected FXVector mCcentroid
public static final float MAX_MASS_FX
Constructor Detail |
---|
public Shape(FXVector[] corners)
correctCentroid()
.
corners
- the corners of the polygonpublic Shape(Shape other)
protected Shape()
Method Detail |
---|
public static Shape createRectangle(int width, int height)
width
- width of the rectangle.height
- height of the rectangle.
public static Shape createCircle(int radius)
radius
- radius of the circle.
public static Shape createRegularPolygon(int radius, int vertices)
radius
- radius of the polygon.vertices
- number of vertices (max. World.M_SHAPE_MAX_VERTICES
).
public static Shape loadShape(PhysicsFileReader reader, UserData userData)
reader
- a physics file reader.
protected void updateInternals()
public void correctCentroid()
public FXVector[] getCorners()
public int getBoundingRadiusSquare()
protected int getBoundingRadius()
public float getBoundingRadiusFX()
public void setFriction(int friction)
friction
- - 0 means no friction, 100 max. frictionmFrictionFX
public void setFrictionFX(float frictionFX)
frictionFX
- - 0 means no friction, ONE_FX max frictionmFrictionFX
public float getFrictionFX()
mFrictionFX
public void setElasticity(int elasticity)
elasticity
- - 0 all energy of the collision is lost (no bounce), 100 full energy conserved (high bounce).mElasticityFX
public void setElasticityFX(float elasticityFX)
elasticityFX
- - 0 all energy of the collision is lost (no bounce), ONE_FX full energy conserved (high bounce).mElasticityFX
public float getElasticityFX()
mElasticityFX
public final void setMass(int mass)
mass
- new mass of the body.public final void setMassFX(float massFX)
massFX
- new mass of the body (FX).public int getMass()
public float getMassFX()
public int getId()
ShapeSet
.
That can only happen if no body uses it and it was not registered manually.
public float getAreaFX()
protected final void getVerticesFX(FXVector pos, FXMatrix rotation, FXVector[] vertices)
pos
- the center position of the translated shaperotation
- the rotation matrix of the translationvertices
- - the vertices vector, where the vertices in world coordinates are written topublic UserData getUserData()
public void setUserData(UserData userData)
userData
- the user data
|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |