EPhysics Body
EPhysics

A body is a representation of an object inside a physics world. More...

## Macros

#define | EPHYSICS_BODY_MASS_STATIC (0.0)
| Mass amount used to makes a body static.
#define | EPHYSICS_BODY_DENSITY_WOOD (680.0)
| Density of wood in kg / m ^ 3.
#define | EPHYSICS_BODY_DENSITY_IRON (7400.0)
| Density of iron in kg / m ^ 3.
#define | EPHYSICS_BODY_DENSITY_CONCRETE (2300.0)
| Density of concrete in kg / m ^ 3.
#define | EPHYSICS_BODY_DENSITY_RUBBER (920.0)
| Density of rubber in kg / m ^ 3.
#define | EPHYSICS_BODY_DENSITY_POLYSTYRENE (80.0)
| Density of polystyrene in kg / m ^ 3.
#define | EPHYSICS_BODY_DENSITY_PLASTIC (1300.0)
| Density of plastic in kg / m ^ 3.
#define | EPHYSICS_BODY_FRICTION_WOOD (0.4)
| Friction coefficient of wood.
#define | EPHYSICS_BODY_FRICTION_IRON (0.8)
| Friction coefficient of iron.
#define | EPHYSICS_BODY_FRICTION_CONCRETE (0.65)
| Friction coefficient of concrete.
#define | EPHYSICS_BODY_FRICTION_RUBBER (0.75)
| Friction coefficient of rubber.
#define | EPHYSICS_BODY_FRICTION_POLYSTYRENE (0.5)
| Friction coefficient of polystyrene.
#define | EPHYSICS_BODY_FRICTION_PLASTIC (0.35)
| Friction coefficient of plastic.
#define | EPHYSICS_BODY_RESTITUTION_WOOD (0.7)
| Restitution coefficient of wood.
#define | EPHYSICS_BODY_RESTITUTION_IRON (0.85)
| Restitution coefficient of iron.
#define | EPHYSICS_BODY_RESTITUTION_CONCRETE (0.75)
| Restitution coefficient of concrete.
#define | EPHYSICS_BODY_RESTITUTION_RUBBER (0.3)
| Restitution coefficient of rubber.
#define | EPHYSICS_BODY_RESTITUTION_POLYSTYRENE (0.5)
| Restitution coefficient of polystyrene.
#define | EPHYSICS_BODY_RESTITUTION_PLASTIC (0.6)
| Restitution coefficient of plastic.

## Typedefs

typedef enum _EPhysics_Body_Cloth_Anchor_Side | EPhysics_Body_Cloth_Anchor_Side
| Identifier of cloth anchor sides.
typedef enum _EPhysics_Body_Face | EPhysics_Body_Face
| Define in which body's face the evas object should be set.
typedef struct _EPhysics_Body_Collision | EPhysics_Body_Collision
| Body collision wraps collision informations.
typedef enum _EPhysics_Callback_Body_Type | EPhysics_Callback_Body_Type
| The types of events triggering a callback.
typedef enum _EPhysics_Body_Material | EPhysics_Body_Material
| The types of materials to be set on a body.
typedef void(* | EPhysics_Body_Event_Cb) (void *data, EPhysics_Body *body, void *event_info)
| EPhysics body event callback function signature.
typedef struct _EPhysics_Body | EPhysics_Body
| Body handle, represents an object on EPhysics world.

## Enumerations

enum | _EPhysics_Body_Cloth_Anchor_Side { EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_LEFT , EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_RIGHT , EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_TOP , EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_BOTTOM , EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_LAST }

enum

_EPhysics_Body_Face {
EPHYSICS_BODY_BOX_FACE_MIDDLE_FRONT ,
EPHYSICS_BODY_BOX_FACE_MIDDLE_BACK ,
EPHYSICS_BODY_BOX_FACE_FRONT ,
EPHYSICS_BODY_BOX_FACE_BACK ,
EPHYSICS_BODY_BOX_FACE_LEFT ,
EPHYSICS_BODY_BOX_FACE_RIGHT ,
EPHYSICS_BODY_BOX_FACE_TOP ,
EPHYSICS_BODY_BOX_FACE_BOTTOM ,
EPHYSICS_BODY_CLOTH_FACE_FRONT ,
EPHYSICS_BODY_CLOTH_FACE_BACK ,
EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT ,
EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_BACK ,
EPHYSICS_BODY_CYLINDER_FACE_FRONT ,
EPHYSICS_BODY_CYLINDER_FACE_BACK ,
EPHYSICS_BODY_CYLINDER_FACE_CURVED ,
EPHYSICS_BODY_SPHERE_FACE_FRONT ,
EPHYSICS_BODY_SPHERE_FACE_BACK ,
EPHYSICS_BODY_FACE_LAST
}

enum | _EPhysics_Callback_Body_Type { EPHYSICS_CALLBACK_BODY_UPDATE , EPHYSICS_CALLBACK_BODY_COLLISION , EPHYSICS_CALLBACK_BODY_DEL , EPHYSICS_CALLBACK_BODY_STOPPED , EPHYSICS_CALLBACK_BODY_LAST }
enum | _EPhysics_Body_Material { EPHYSICS_BODY_MATERIAL_CUSTOM , EPHYSICS_BODY_MATERIAL_CONCRETE , EPHYSICS_BODY_MATERIAL_IRON , EPHYSICS_BODY_MATERIAL_PLASTIC , EPHYSICS_BODY_MATERIAL_POLYSTYRENE , EPHYSICS_BODY_MATERIAL_RUBBER , EPHYSICS_BODY_MATERIAL_WOOD , EPHYSICS_BODY_MATERIAL_LAST }

## Functions

EAPI void | ephysics_body_soft_body_hardness_set (EPhysics_Body *body, double hardness)
| Set the soft body hardness percentage.
EAPI double | ephysics_body_soft_body_hardness_get (const EPhysics_Body *body)
| Get the soft body hardness percentage.
EAPI void | ephysics_body_soft_body_anchor_hardness_set (EPhysics_Body *body, double hardness)
| Set the soft body anchor hardness percentage.
EAPI double | ephysics_body_soft_body_anchor_hardness_get (EPhysics_Body *body)
| Get the soft body anchor hardnees percentage.
EAPI void | ephysics_body_soft_body_drag_coefficient_set (EPhysics_Body *body, double coefficient)
| Set the drag coefficient of a soft body.
EAPI double | ephysics_body_soft_body_drag_coefficient_get (const EPhysics_Body *body)
| Get the drag coefficient of a soft body.
EAPI void | ephysics_body_soft_body_dragging_set (EPhysics_Body *body, int triangle)
| Set the soft body dragging status.
EAPI void | ephysics_body_soft_body_dragging_unset (EPhysics_Body *body)
| Unset the soft body dragging status.
EAPI int | ephysics_body_soft_body_triangle_index_get (EPhysics_Body *body, Evas_Coord x, Evas_Coord y)
| Get the triangle index of a soft body in `x` and `y`.
EAPI EPhysics_Body * | ephysics_body_soft_sphere_add (EPhysics_World *world, int granularity)
| Get the slice index of a soft body based on its slice`s Evas Object.
EAPI Eina_List * | ephysics_body_soft_body_triangles_inside_get (const EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d)
| Get a list of triangles indexes inside an area.
EAPI void | ephysics_body_soft_body_triangle_impulse_apply (EPhysics_Body *body, int idx, double x, double y, double z)
| Apply an impulse on a given soft body triangle.
EAPI void | ephysics_body_soft_body_triangle_list_impulse_apply (EPhysics_Body *body, Eina_List *triangles, double x, double y, double z)
| Apply impulse in a list of triangles.
EAPI void | ephysics_body_soft_body_position_iterations_set (EPhysics_Body *body, int iterations)
| Set the soft body number of position iterations.
EAPI int | ephysics_body_soft_body_position_iterations_get (EPhysics_Body *body)
| Get the soft body number of position iterations.
EAPI void | ephysics_body_soft_body_triangle_move (EPhysics_Body *body, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z)
| Move a body's triangle.
EAPI void | ephysics_body_soft_body_bending_constraints_add (EPhysics_Body *body, int number)
| Add new bending constraints to some `body`.
EAPI EPhysics_Body * | ephysics_body_cylinder_add (EPhysics_World *world)
| Create a new sphere physics body.
EAPI EPhysics_Body * | ephysics_body_soft_cylinder_add (EPhysics_World *world)
| Create a new deformable cylinder physics body.
EAPI EPhysics_Body * | ephysics_body_box_add (EPhysics_World *world)
| Create a new box physics body.
EAPI EPhysics_Body * | ephysics_body_soft_box_add (EPhysics_World *world)
| Create a new deformable box physics body.
EAPI EPhysics_Body * | ephysics_body_cloth_add (EPhysics_World *world, unsigned short rows, unsigned short columns)
| Create a new deformable cloth physics body.
EAPI void | ephysics_body_cloth_anchor_full_add (EPhysics_Body *body1, EPhysics_Body *body2, EPhysics_Body_Cloth_Anchor_Side side)
| Anchors a cloth with a rigid body.
EAPI void | ephysics_body_cloth_anchor_add (EPhysics_Body *body1, EPhysics_Body *body2, int node)
| Anchors an arbitrary cloth's node with a rigid body.
EAPI void | ephysics_body_cloth_anchor_del (EPhysics_Body *body)
| Removes the anchors in a cloth body.
EAPI EPhysics_Body * | ephysics_body_shape_add (EPhysics_World *world, EPhysics_Shape *shape)
| Create a new physics body using a custom shape.
EAPI EPhysics_Body * | ephysics_body_top_boundary_add (EPhysics_World *world)
| Create a physic top boundary.
EAPI EPhysics_Body * | ephysics_body_bottom_boundary_add (EPhysics_World *world)
| Create a physic bottom boundary.
EAPI EPhysics_Body * | ephysics_body_left_boundary_add (EPhysics_World *world)
| Create a physic left boundary.
EAPI EPhysics_Body * | ephysics_body_right_boundary_add (EPhysics_World *world)
| Create a physic right boundary.
EAPI EPhysics_Body * | ephysics_body_front_boundary_add (EPhysics_World *world)
| Create a physic front boundary.
EAPI EPhysics_Body * | ephysics_body_back_boundary_add (EPhysics_World *world)
| Create a physic back boundary.
EAPI void | ephysics_body_del (EPhysics_Body *body)
| Delete a physics body.
EAPI EPhysics_World * | ephysics_body_world_get (const EPhysics_Body *body)
| Get the world a body belongs to.
EAPI void | ephysics_body_evas_object_set (EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
| Set an evas object to a physics body.
EAPI Evas_Object * | ephysics_body_evas_object_unset (EPhysics_Body *body)
| Unset the evas object associated to a physics body.
EAPI Evas_Object * | ephysics_body_evas_object_get (const EPhysics_Body *body)
| Get the evas object associated to a physics body.
EAPI void | ephysics_body_face_evas_object_set (EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
| Set an evas object to a physics body face.
EAPI Evas_Object * | ephysics_body_face_evas_object_get (const EPhysics_Body *body, EPhysics_Body_Face face)
| Get the evas object associated to a physics body face.
EAPI Evas_Object * | ephysics_body_face_evas_object_unset (EPhysics_Body *body, EPhysics_Body_Face face)
| Unset the evas object associated to a physics body face.
EAPI void | ephysics_body_resize (EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d)
| Set physics body size.
EAPI void | ephysics_body_move (EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z)
| Set physics body position.
EAPI void | ephysics_body_geometry_set (EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d)
| Set physics body geometry.
EAPI void | ephysics_body_geometry_get (const EPhysics_Body *body, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d)
| Get physics body position.
EAPI void | ephysics_body_mass_set (EPhysics_Body *body, double mass)
| Set body's mass.
EAPI double | ephysics_body_mass_get (const EPhysics_Body *body)
| Get body's mass.
EAPI void | ephysics_body_linear_velocity_set (EPhysics_Body *body, double x, double y, double z)
| Set body's linear velocity on x, y and z axes.
EAPI void | ephysics_body_linear_velocity_get (const EPhysics_Body *body, double *x, double *y, double *z)
| Get body's linear velocity on x, y and z axes.
EAPI void | ephysics_body_angular_velocity_set (EPhysics_Body *body, double x, double y, double z)
| Set body's angular velocity on x, y and z axes.
EAPI void | ephysics_body_angular_velocity_get (const EPhysics_Body *body, double *x, double *y, double *z)
| Get body's angular velocity on x, y and z axes.
EAPI void | ephysics_body_sleeping_threshold_set (EPhysics_Body *body, double linear_threshold, double angular_threshold)
| Set the linear and angular sleeping threshold.
EAPI void | ephysics_body_sleeping_threshold_get (const EPhysics_Body *body, double *linear_threshold, double *angular_threshold)
| Get the linear sleeping threshold.
EAPI void | ephysics_body_stop (EPhysics_Body *body)
| Stop angular and linear body movement.
EAPI void | ephysics_body_damping_set (EPhysics_Body *body, double linear_damping, double angular_damping)
| Set the angular and linear damping values.
EAPI void | ephysics_body_damping_get (const EPhysics_Body *body, double *linear_damping, double *angular_damping)
| Get the angular and linear damping values.
EAPI Eina_Bool | ephysics_body_collision_group_add (EPhysics_Body *body, const char *group)
| Add a `body` to a given collision group.
EAPI Eina_Bool | ephysics_body_collision_group_del (EPhysics_Body *body, const char *group)
| Removes `body` from collision `group`.
EAPI const Eina_List * | ephysics_body_collision_group_list_get (const EPhysics_Body *body)
| Get the collision group list of `body`.
EAPI void | ephysics_body_evas_object_update (EPhysics_Body *body)
| Update the evas object associated to the body.
EAPI void | ephysics_body_event_callback_add (EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, const void *data)
| Register a callback to a type of physics body event.
EAPI void * | ephysics_body_event_callback_del (EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func)
| Unregister an ephysics body event callback.
EAPI void * | ephysics_body_event_callback_del_full (EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, void *data)
| Unregister an ephysics body event callback matching data pointer.
EAPI void | ephysics_body_collision_position_get (const EPhysics_Body_Collision *collision, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z)
| Get the position(x, y) of a body's collision.
EAPI EPhysics_Body * | ephysics_body_collision_contact_body_get (const EPhysics_Body_Collision *collision)
| Get the body's collision contact body.
EAPI void | ephysics_body_restitution_set (EPhysics_Body *body, double restitution)
| Set body's coefficient of restitution.
EAPI double | ephysics_body_restitution_get (const EPhysics_Body *body)
| Get body's restitution.
EAPI void | ephysics_body_friction_set (EPhysics_Body *body, double friction)
| Set body's friction.
EAPI double | ephysics_body_friction_get (const EPhysics_Body *body)
| Get body's friction.
EAPI void | ephysics_body_central_impulse_apply (EPhysics_Body *body, double x, double y, double z)
| Apply an impulse on the center of a body.
EAPI void | ephysics_body_torque_impulse_apply (EPhysics_Body *body, double pitch, double yaw, double roll)
| Apply a torque impulse over a body.
EAPI void | ephysics_body_impulse_apply (EPhysics_Body *body, double x, double y, double z, Evas_Coord pos_x, Evas_Coord pos_y, Evas_Coord pos_z)
| Apply an impulse over a body.
EAPI void | ephysics_body_angular_movement_enable_set (EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z)
| Enable or disable body's rotation on z axis.
EAPI void | ephysics_body_angular_movement_enable_get (const EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y, Eina_Bool *enable_z)
| Return body's rotation on z axis state.
EAPI void | ephysics_body_linear_movement_enable_set (EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z)
| Enable or disable body's movement on x, y and z axes.
EAPI void | ephysics_body_linear_movement_enable_get (const EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y, Eina_Bool *enable_z)
| Get body's movement on x, y and z axes behavior.
EAPI EPhysics_Quaternion * | ephysics_body_rotation_get (const EPhysics_Body *body, EPhysics_Quaternion *rotation)
| Get body's rotation quaternion.
EAPI void | ephysics_body_rotation_set (EPhysics_Body *body, EPhysics_Quaternion *quat)
| Set body's rotation.
EAPI void | ephysics_body_data_set (EPhysics_Body *body, void *data)
| Set data to `body`.
EAPI void * | ephysics_body_data_get (const EPhysics_Body *body)
| Return data previously set to body.
EAPI void | ephysics_body_central_force_apply (EPhysics_Body *body, double x, double y, double z)
| Apply a force on the center of a body.
EAPI void | ephysics_body_torque_apply (EPhysics_Body *body, double torque_x, double torque_y, double torque_z)
| Apply a torque over a body.
EAPI void | ephysics_body_force_apply (EPhysics_Body *body, double x, double y, double z, Evas_Coord pos_x, Evas_Coord pos_y, Evas_Coord pos_z)
| Apply a force over a body.
EAPI void | ephysics_body_forces_get (const EPhysics_Body *body, double *x, double *y, double *z)
| Get physics body forces.
EAPI void | ephysics_body_torques_get (const EPhysics_Body *body, double *x, double *y, double *z)
| Get physics body torques.
EAPI void | ephysics_body_forces_clear (EPhysics_Body *body)
| Clear all the forces applied to a body.
EAPI void | ephysics_body_center_mass_get (const EPhysics_Body *body, double *x, double *y, double *z)
| Get the center of mass of physics body.
EAPI void | ephysics_body_density_set (EPhysics_Body *body, double density)
| Set body's material density.
EAPI double | ephysics_body_density_get (const EPhysics_Body *body)
| Get body's material density.
EAPI double | ephysics_body_volume_get (const EPhysics_Body *body)
| Get body's volume.
EAPI void | ephysics_body_material_set (EPhysics_Body *body, EPhysics_Body_Material material)
| Set body's material.
EAPI EPhysics_Body_Material | ephysics_body_material_get (const EPhysics_Body *body)
| Get body's material.
EAPI void | ephysics_body_light_set (EPhysics_Body *body, Eina_Bool enable)
| Set light effect over body.
EAPI Eina_Bool | ephysics_body_light_get (const EPhysics_Body *body)
| Get light effect over body.
EAPI void | ephysics_body_back_face_culling_set (EPhysics_Body *body, Eina_Bool enable)
| Set body's evas object to be hidden when it is counter-clockwise.
EAPI Eina_Bool | ephysics_body_back_face_culling_get (const EPhysics_Body *body)
| Return if body's evas object will be hidden when it is counter-clockwise or not.
EAPI Eina_Bool | ephysics_body_clockwise_get (const EPhysics_Body *body)
| Get the clockwise state of a body.

## Detailed Description

A body is a representation of an object inside a physics world.

Bodies can have different shapes that can be created with:

- ephysics_body_cylinder_add();
- ephysics_body_box_add();
- or ephysics_body_shape_add().

Also they can be soft bodies, that won't act as rigid bodies. They will deform its shape under certain circumstances, like under collisions. Soft bodies can be created with:

- ephysics_body_soft_cylinder_add();
- ephysics_body_soft_box_add();

They can collide and have customizable properties, like:

- mass, set with ephysics_body_mass_set();
- coefficient of restitution, set with ephysics_body_restitution_set();
- and friction, set with ephysics_body_friction_set().

Bodies can have its position and size directly set by: ephysics_body_move(); ephysics_body_resize(); ephysics_body_geometry_set().

Their rotation can be set directly with ephysics_body_rotation_set().

Also, they can have an associated evas object, done with ephysics_body_evas_object_set() function, being responsible for updating its position and rotation, or letting a user callback be set for this task with ephysics_body_event_callback_add().

Bodies can have velocity set with ephysics_body_linear_velocity_set() and ephysics_body_angular_velocity_set().

Also, bodies can have forces and impulses applied over them, and they will be affected by gravity.

Forces will be acting while they're set, changing bodies velocity over time. Impulses are applied only once, modifying bodies velocity immediately to the new value.

Forces can be managed with:

- ephysics_body_central_force_apply();
- ephysics_body_torque_apply().
- ephysics_body_force_apply();
- ephysics_body_forces_clear();

Impulses can be applied with:

- ephysics_body_central_impulse_apply();
- ephysics_body_torque_impulse_apply().
- ephysics_body_impulse_apply();

Bodies can be removed from the world being directly deleted with ephysics_body_del() or when the world is deleted, case when all the bodies belonging to it will be deleted as well. Evas objects associated to these bodies won't be affected in any way, but they will stop being moved or rotated.

## Macro Definition Documentation

## EPHYSICS_BODY_MASS_STATIC

#define EPHYSICS_BODY_MASS_STATIC (0.0)

Mass amount used to makes a body static.

Body will be set with infinite mass, so it will be immovable.

See also
  ephysics_body_mass_set() for details.

Examples
  ephysics_logo.c.

## EPHYSICS_BODY_DENSITY_WOOD

#define EPHYSICS_BODY_DENSITY_WOOD (680.0)

Density of wood in kg / m ^ 3.

It can be set to a body with ephysics_body_density_set().

## EPHYSICS_BODY_DENSITY_IRON

#define EPHYSICS_BODY_DENSITY_IRON (7400.0)

Density of iron in kg / m ^ 3.

It can be set to a body with ephysics_body_density_set().

## EPHYSICS_BODY_DENSITY_CONCRETE

#define EPHYSICS_BODY_DENSITY_CONCRETE (2300.0)

Density of concrete in kg / m ^ 3.

It can be set to a body with ephysics_body_density_set().

## EPHYSICS_BODY_DENSITY_RUBBER

#define EPHYSICS_BODY_DENSITY_RUBBER (920.0)

Density of rubber in kg / m ^ 3.

It can be set to a body with ephysics_body_density_set().

## EPHYSICS_BODY_DENSITY_POLYSTYRENE

#define EPHYSICS_BODY_DENSITY_POLYSTYRENE (80.0)

Density of polystyrene in kg / m ^ 3.

It can be set to a body with ephysics_body_density_set().

## EPHYSICS_BODY_DENSITY_PLASTIC

#define EPHYSICS_BODY_DENSITY_PLASTIC (1300.0)

Density of plastic in kg / m ^ 3.

It can be set to a body with ephysics_body_density_set().

## EPHYSICS_BODY_FRICTION_WOOD

#define EPHYSICS_BODY_FRICTION_WOOD (0.4)

Friction coefficient of wood.

It can be set to a body with ephysics_body_friction_set().

## EPHYSICS_BODY_FRICTION_IRON

#define EPHYSICS_BODY_FRICTION_IRON (0.8)

Friction coefficient of iron.

It can be set to a body with ephysics_body_friction_set().

## EPHYSICS_BODY_FRICTION_CONCRETE

#define EPHYSICS_BODY_FRICTION_CONCRETE (0.65)

Friction coefficient of concrete.

It can be set to a body with ephysics_body_friction_set().

## EPHYSICS_BODY_FRICTION_RUBBER

#define EPHYSICS_BODY_FRICTION_RUBBER (0.75)

Friction coefficient of rubber.

It can be set to a body with ephysics_body_friction_set().

## EPHYSICS_BODY_FRICTION_POLYSTYRENE

#define EPHYSICS_BODY_FRICTION_POLYSTYRENE (0.5)

Friction coefficient of polystyrene.

It can be set to a body with ephysics_body_friction_set().

## EPHYSICS_BODY_FRICTION_PLASTIC

#define EPHYSICS_BODY_FRICTION_PLASTIC (0.35)

Friction coefficient of plastic.

It can be set to a body with ephysics_body_friction_set().

## EPHYSICS_BODY_RESTITUTION_WOOD

#define EPHYSICS_BODY_RESTITUTION_WOOD (0.7)

Restitution coefficient of wood.

It can be set to a body with ephysics_body_restitution_set().

## EPHYSICS_BODY_RESTITUTION_IRON

#define EPHYSICS_BODY_RESTITUTION_IRON (0.85)

Restitution coefficient of iron.

It can be set to a body with ephysics_body_restitution_set().

## EPHYSICS_BODY_RESTITUTION_CONCRETE

#define EPHYSICS_BODY_RESTITUTION_CONCRETE (0.75)

Restitution coefficient of concrete.

It can be set to a body with ephysics_body_restitution_set().

## EPHYSICS_BODY_RESTITUTION_RUBBER

#define EPHYSICS_BODY_RESTITUTION_RUBBER (0.3)

Restitution coefficient of rubber.

It can be set to a body with ephysics_body_restitution_set().

## EPHYSICS_BODY_RESTITUTION_POLYSTYRENE

#define EPHYSICS_BODY_RESTITUTION_POLYSTYRENE (0.5)

Restitution coefficient of polystyrene.

It can be set to a body with ephysics_body_restitution_set().

## EPHYSICS_BODY_RESTITUTION_PLASTIC

#define EPHYSICS_BODY_RESTITUTION_PLASTIC (0.6)

Restitution coefficient of plastic.

It can be set to a body with ephysics_body_restitution_set().

## Typedef Documentation

## EPhysics_Body_Cloth_Anchor_Side

typedef enum _EPhysics_Body_Cloth_Anchor_Side EPhysics_Body_Cloth_Anchor_Side

Identifier of cloth anchor sides.

See also
  ephysics_body_cloth_anchor_full_add()

## EPhysics_Body_Face

typedef enum _EPhysics_Body_Face EPhysics_Body_Face

Define in which body's face the evas object should be set.

See also
  ephysics_body_face_evas_object_set()
  ephysics_body_face_evas_object_unset()
  ephysics_body_face_evas_object_get()

## EPhysics_Body_Collision

typedef struct _EPhysics_Body_Collision EPhysics_Body_Collision

Body collision wraps collision informations.

EPhysics_Body_Collision is used on EPHYSICS_CALLBACK_BODY_COLLISION callback and is mostly interested to hold informations like:

- contact_body - the body which the collision occurred against;
- position - points the position where the collision happened;

See also
  ephysics_body_collision_position_get()
  ephysics_body_collision_contact_body_get()
  EPHYSICS_CALLBACK_BODY_COLLISION and ephysics_body_event_callback_add() for collision callback.

Examples
  test_collision_detection.c, and test_delete.c.

## EPhysics_Callback_Body_Type

typedef enum _EPhysics_Callback_Body_Type EPhysics_Callback_Body_Type

The types of events triggering a callback.

Identifier of callbacks to be set for EPhysics bodies.

See also
  ephysics_body_event_callback_add()
  ephysics_body_event_callback_del()
  ephysics_body_event_callback_del_full()

## EPhysics_Body_Material

typedef enum _EPhysics_Body_Material EPhysics_Body_Material

The types of materials to be set on a body.

EPhysics bodies materials.

Each material has specific properties to be applied on the body, as density, friction and restitution.

See also
  ephysics_body_material_set() for details.

## EPhysics_Body_Event_Cb

typedef void(* EPhysics_Body_Event_Cb) (void *data, EPhysics_Body *body, void *event_info)

EPhysics body event callback function signature.

Callbacks can be registered for events like body updating or deleting.

Parameters

  data | User data that will be set when registering the callback.
  body | Physics body.
  event_info | Data specific to a kind of event. Some types of events don't have `event_info`.

See also
  ephysics_body_event_callback_add() for more info.

## EPhysics_Body

typedef struct _EPhysics_Body EPhysics_Body

Body handle, represents an object on EPhysics world.

Many types of bodies can be created:

- ephysics_body_cylinder_add()
- ephysics_body_box_add()
- ephysics_body_shape_add()
- ephysics_body_soft_cylinder_add()
- ephysics_body_soft_box_add()

and it can be deleted with ephysics_body_del().

Examples
  ephysics_logo.c, test_bouncing_ball.c, test_bouncing_text.c, test_camera.c, test_camera_track.c, test_collision_detection.c, test_collision_filter.c, test_constraint.c, test_delete.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_rotating_forever.c, test_shapes.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

## Enumeration Type Documentation

## _EPhysics_Callback_Body_Type

enum _EPhysics_Callback_Body_Type

Enumerator
EPHYSICS_CALLBACK_BODY_UPDATE | Body being updated.
EPHYSICS_CALLBACK_BODY_COLLISION | Body collided with other body.
EPHYSICS_CALLBACK_BODY_DEL | Body being deleted (called before free).
EPHYSICS_CALLBACK_BODY_STOPPED | Body is not moving any more.
EPHYSICS_CALLBACK_BODY_LAST | kept as sentinel, not really an event

## _EPhysics_Body_Material

enum _EPhysics_Body_Material

Enumerator
EPHYSICS_BODY_MATERIAL_CUSTOM | Custom properties set by the user.
EPHYSICS_BODY_MATERIAL_CONCRETE | Density:2300,Fric:0.65,Rest:0.75.
EPHYSICS_BODY_MATERIAL_IRON | Density:7400,Fric:0.8,Rest:0.85.
EPHYSICS_BODY_MATERIAL_PLASTIC | Density:1300,Fric:0.35,Rest:0.6.
EPHYSICS_BODY_MATERIAL_POLYSTYRENE | Density:80,Fric:0.5,Rest:0.5.
EPHYSICS_BODY_MATERIAL_RUBBER | Density:920,Fric:0.75,Rest:0.3.
EPHYSICS_BODY_MATERIAL_WOOD | Density:680,Fric:0.4,Rest:0.7.
EPHYSICS_BODY_MATERIAL_LAST | kept as sentinel, not really a material

## Function Documentation

## ephysics_body_soft_body_hardness_set()

EAPI void ephysics_body_soft_body_hardness_set | ( | EPhysics_Body * | body,
|  | double | hardness )

Set the soft body hardness percentage.

The hardness percentage will define how the soft body is supposed to deform, its default is set to 100%. The soft body mass will also interfere on soft body deformation, so bare in mind that the bodies mass must also be changed to have different deformation results.

Valid values vary from 0 to 100.

Parameters

  body | The body to be set.
  hardness | The percentage of deformation.

See also
  ephysics_body_soft_body_hardness_get()
  ephysics_body_mass_set() form body mass changing.

## ephysics_body_soft_body_hardness_get()

EAPI double ephysics_body_soft_body_hardness_get | ( | const EPhysics_Body * | body | ) |

Get the soft body hardness percentage.

Parameters

  body | The body of interest.

Returns
  The deformation percentage.

See also
  ephysics_body_soft_body_hardness_set()

## ephysics_body_soft_body_anchor_hardness_set()

EAPI void ephysics_body_soft_body_anchor_hardness_set | ( | EPhysics_Body * | body,
|  | double | hardness )

Set the soft body anchor hardness percentage.

The anchor hardness percentage(together with general hardness settings set with ephysics_body_soft_body_hardness_set()) will define how the soft body is supposed to deform.

By default EPhysics will calculate the anchor hardness depending on the general hardness settings, by default it`s set to 70% of general hardness on soft body and a fixed 80% for cloths.

Anchor hardness will result on a contrary force to impulse and velocities applied to soft bodies. So it implies on force reduction.

Note
  Since it`s a percentage value `hardness` will range from 0 - 100.

Parameters

  body | The body to be set.
  hardness | The hardness to be set to `body`.

See also
  ephysics_body_soft_body_hardness_set() for general hardness.
  ephysics_body_soft_body_anchor_hardness_get().

## ephysics_body_soft_body_anchor_hardness_get()

EAPI double ephysics_body_soft_body_anchor_hardness_get | ( | EPhysics_Body * | body | ) |

Get the soft body anchor hardnees percentage.

Parameters

  body | The body to get the anchor hardness percentage from.

Returns
  The anchor hardness percentage on success -1 on failure.

See also
  ephysics_body_soft_body_anchor_hardness_set().

## ephysics_body_soft_body_drag_coefficient_set()

EAPI void ephysics_body_soft_body_drag_coefficient_set | ( | EPhysics_Body * | body,
|  | double | coefficient )

Set the drag coefficient of a soft body.

Drag coefficient is a dimensionless quantity used to quantify an objects drag or resistance in the environment - like air or water resistance. It is used in the drag equation, where a lower drag coefficient indicates the object will have less aerodynamic or hydrodynamic drag.

The drag coefficient is defined as:

cd = 2Fd / (pv ^ 2)A

Where:

- `Fd` is the drag force, which is by definition the force component in the direction of the flow velocity;
- `p` is the mass density;
- `v` is the speed;
- `A` is the reference area;

The reference area depends on what type of drag coefficient is being measured.

Note
  default value set to 0.

Parameters

  body | The body to be set.
  coefficient | The drag coefficient.

See also
  ephysics_body_soft_body_drag_coefficient_get().

## ephysics_body_soft_body_drag_coefficient_get()

EAPI double ephysics_body_soft_body_drag_coefficient_get | ( | const EPhysics_Body * | body | ) |

Get the drag coefficient of a soft body.

Parameters

  body | The body to get the drag coefficient from.

Returns
  The drag coefficient set to `body` on success, -1 on failure.

See also
  ephysics_body_soft_body_drag_coefficient_set().

## ephysics_body_soft_body_dragging_set()

EAPI void ephysics_body_soft_body_dragging_set | ( | EPhysics_Body * | body,
|  | int | triangle )

Set the soft body dragging status.

While dragging a soft body the user may want to freeze a specific trimesh face, after calling this function EPhysics will do freeze the `triangle` until it gets a call to unset it with ephysics_body_soft_body_dragging_unset().

Note
  Freezing a specific trimesh face means no forces are applied to it, no gravity enforced, that's `triangle` will have no mass until it dragging gets unset.

Parameters

  body | The body of interest.
  triangle | The triangle to freeze.

See also
  ephysics_body_soft_body_dragging_unset().
  ephysics_body_soft_body_triangle_index_get().

## ephysics_body_soft_body_dragging_unset()

EAPI void ephysics_body_soft_body_dragging_unset | ( | EPhysics_Body * | body | ) |

Unset the soft body dragging status.

This function will tell EPhysics to not freeze - the previously dragging triangle set - any more.

Parameters

  body | The body to unset the dragging status.

See also
  ephysics_body_soft_body_dragging_set() for dragging details.

## ephysics_body_soft_body_triangle_index_get()

EAPI int ephysics_body_soft_body_triangle_index_get | ( | EPhysics_Body * | body,
|  | Evas_Coord | x,
|  | Evas_Coord | y )

Get the triangle index of a soft body in `x` and `y`.

Given a point in `x` and `y` a ray cast is performed and if a triangle is found its index is returned.

Parameters

  body | The body to get the triangle index from.
  x | The x coord.
  y | The y coord.

Returns
  -1 If no triangle is found, a triangle index otherwise.

See also
  ephysics_body_soft_body_triangle_move().

## ephysics_body_soft_sphere_add()

EAPI EPhysics_Body * ephysics_body_soft_sphere_add | ( | EPhysics_World * | world,
|  | int | granularity )

Get the slice index of a soft body based on its slice`s Evas Object.

Registering a mouse event callback on an associated evas object one can get the clicked slice evas object. With that pointer the user can get the slice index based on its related evas object.

Parameters

  body | The body to get the slice index from.
  slice | The slice evas object.

Returns
  The slice index on success, -1 otherwise.

See also
  ephysics_body_soft_body_triangle_index_get().

*/ EAPI int ephysics_body_soft_body_slice_index_get(EPhysics_Body *body, Evas_Object *slice);

/**

Add a soft sphere.

Add a new soft 3d sphere to the simulation. The `granularity` defines how many triangles are to be added.

Note
  if no `granularity` is informed(i.e `granularity` = 0) the soft body will be created with a triangle mesh of 100.

Parameters

  world | The world the new soft sphere is to be added.
  granularity | How many triangles the soft body triangle mesh must have.

Returns
  a new body or `NULL` on errors.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().
  ephysics_body_face_evas_object_set().

## ephysics_body_soft_body_triangles_inside_get()

EAPI Eina_List * ephysics_body_soft_body_triangles_inside_get | ( | const EPhysics_Body * | body,
|  | Evas_Coord | x,
|  | Evas_Coord | y,
|  | Evas_Coord | z,
|  | Evas_Coord | w,
|  | Evas_Coord | h,
|  | Evas_Coord | d )

Get a list of triangles indexes inside an area.

Get a list of triangles indexes given an area defined by `x`, `y`, `z`, `w`, `h` and `d`, the z axis components are represented by `x` and `d` where all triangles between `z` and `d` are considered, that's triangles with their z component greater than `z` and smaller than `d`.

Note
  EPhysics will not free the returned list, remember to do so.

Parameters

  body | The body to get triangles indexes from.
  x | The x component.
  y | The y component.
  z | The z component.
  w | The w component.
  h | The h component.
  d | The d component.

Returns
  NULL on errors or no triangles found, a list of triangles indexes otherwhise.

See also
  ephysics_body_soft_body_triangle_index_get().
  ephysics_body_soft_body_slice_index_get().

## ephysics_body_soft_body_triangle_impulse_apply()

EAPI void ephysics_body_soft_body_triangle_impulse_apply | ( | EPhysics_Body * | body,
|  | int | idx,
|  | double | x,
|  | double | y,
|  | double | z )

Apply an impulse on a given soft body triangle.

The impulse is equal to the change of momentum of the body. Impulse is the product of the force over the time this force is applied. In ephysics case, it would be the time of a tick, so it behaves just summing current linear velocity to impulse per mass(per triangle mass).

When a impulse is applied over a body, it will have its velocity changed. This impulse will be applied on body's specified triangle `idx`, so it won't imply in rotating the body.

Note
  Impulse is measured in kg * p / s.

Parameters

  body | The body to apply impulse to.
  idx | The soft body triangle index.
  x | The axis `x` component of impulse.
  y | The axis `y` component of impulse
  z | The axis `z` component of impulse

See also
  ephysics_body_soft_body_triangle_index_get().

## ephysics_body_soft_body_triangle_list_impulse_apply()

EAPI void ephysics_body_soft_body_triangle_list_impulse_apply | ( | EPhysics_Body * | body,
|  | Eina_List * | triangles,
|  | double | x,
|  | double | y,
|  | double | z )

Apply impulse in a list of triangles.

Apply impulse in a list of triangles all at once considering the same impulse values on `x`, `y` and `z`.

Parameters

  body | The body to apply impulse.
  triangles | A list of triangles indexes.
  x | The axis `x` component of impulse.
  y | The axis `y` component of impulse.
  z | The axis `z` component of impulse.

See also
  ephysics_body_soft_body_triangle_impulse_apply() to see about impulse applying on soft bodies.
  ephysics_body_soft_body_triangles_inside_get().

## ephysics_body_soft_body_position_iterations_set()

EAPI void ephysics_body_soft_body_position_iterations_set | ( | EPhysics_Body * | body,
|  | int | iterations )

Set the soft body number of position iterations.

Both soft body and cloth can have its number of position iterations changed. The number of position iterations will change how many time the physics engine will iterate the position solver, a greater value will change deformation behaves and how hard the soft body looks like. The greater position iterations the harder the soft body will be.

Note
  For soft bodies the default value is set to 1, and for cloth it's set to the number of rows / 5;

Parameters

  body | The body to be set.
  iterations | The number of iterations.

See also
  ephysics_body_cloth_add() for more informations about cloth.
  ephysics_body_soft_body_position_iterations_get().

## ephysics_body_soft_body_position_iterations_get()

EAPI int ephysics_body_soft_body_position_iterations_get | ( | EPhysics_Body * | body | ) |

Get the soft body number of position iterations.

Parameters

  body | The body to get the number os position iterations from.

Returns
  The number of position solver iterations of a soft `body`.

See also
  ephysics_body_soft_body_position_iterations_set().

## ephysics_body_soft_body_triangle_move()

EAPI void ephysics_body_soft_body_triangle_move | ( | EPhysics_Body * | body,
|  | int | idx,
|  | Evas_Coord | x,
|  | Evas_Coord | y,
|  | Evas_Coord | z )

Move a body's triangle.

Move the triangle of `idx` of `body` to `x`, `y` and `z`.

Parameters

  body | The body of interest.
  idx | The triangle index.
  x | The x coordinate.
  y | The y coordinate.
  z | The z coordinate.

See also
  ephysics_body_soft_body_triangle_index_get().

## ephysics_body_soft_body_bending_constraints_add()

EAPI void ephysics_body_soft_body_bending_constraints_add | ( | EPhysics_Body * | body,
|  | int | number )

Add new bending constraints to some `body`.

Bending constraints define how a soft body is to be deformeable. In fact a bending constraints represents a link between a soft body mesh triangle and other. The hardness property is used to define the bending constraint of those new links.

By default EPhysics create a new soft body or cloth with a single bending constraint.

Parameters

  body | The body to add bending constraints to.
  number | The number of bending constraints to be added, it must be greater than 0.

See also
  ephysics_body_soft_body_hardness_set().

## ephysics_body_cylinder_add()

EAPI EPhysics_Body * ephysics_body_cylinder_add | ( | EPhysics_World * | world | ) |

Create a new sphere physics body.

Its collision shape will be a sphere of diameter 1. To change its size ephysics_body_geometry_set(), `ephysics_body_resize()` should be used.

Any evas object can be associated to it with `ephysics_body_evas_object_set()`, and it will collid as a sphere(even if you`ve associated an evas rectangle).

For deformable sphere use `ephysics_body_soft_sphere_add()` instead.

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL`, on errors.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().
  ephysics_body_face_evas_object_set().

*/ EAPI EPhysics_Body *ephysics_body_sphere_add(EPhysics_World *world);

/**

Create a new cylinder physics body.

Its collision shape will be a cylinder of diameter 1. To change it's size ephysics_body_geometry_set() should be used.

Any evas object can be associated to it with ephysics_body_evas_object_set(), and it will collide as a cylinder (even if you have an evas rectangle).

If a cylinder that could have its shape deformed is required, use ephysics_body_soft_cylinder_add().

Parameters

  world | The world this body will belongs to.

Returns
  a new body or `NULL`, on errors.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().
  ephysics_body_face_evas_object_set().

Examples
  ephysics_logo.c.

## ephysics_body_soft_cylinder_add()

EAPI EPhysics_Body * ephysics_body_soft_cylinder_add | ( | EPhysics_World * | world | ) |

Create a new deformable cylinder physics body.

Its collision shape will be a cylinder of diameter 1. To change it's size ephysics_body_geometry_set() should be used.

Any evas object can be associated to it with ephysics_body_evas_object_set(), and it will collide and deform as a cylinder (even if you have an evas rectangle).

Just like rotation, deformation will be applied on associated evas object using evas map.

Note
  When working with soft bodies it's importante to adjust the simulation's fixed time step due its multi point nature.

For a rigid cylinder, check ephysics_body_cylinder_add().

Parameters

  world | The world this body will belongs to.

Returns
  a new body or `NULL`, on errors.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().
  ephysics_body_face_evas_object_set().
  ephysics_world_simulation_set().

## ephysics_body_box_add()

EAPI EPhysics_Body * ephysics_body_box_add | ( | EPhysics_World * | world | ) |

Create a new box physics body.

Its collision shape will be a box of dimensions 1 on all the axes. To change it's size ephysics_body_geometry_set() should be used.

If a box that could have its shape deformed is required, use ephysics_body_soft_box_add().

Parameters

  world | The world this body will belongs to.

Returns
  a new body or `NULL`, on errors.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().
  ephysics_body_face_evas_object_set().

Examples
  ephysics_logo.c, test_bouncing_text.c, test_camera.c, test_camera_track.c, test_collision_filter.c, test_constraint.c, test_forces.c, test_no_gravity.c, test_rotating_forever.c, and test_slider.c.

## ephysics_body_soft_box_add()

EAPI EPhysics_Body * ephysics_body_soft_box_add | ( | EPhysics_World * | world | ) |

Create a new deformable box physics body.

Its collision shape will be a box of dimensions 1 on all the axes. To change it's size ephysics_body_geometry_set() should be used.

Just like rotation, deformation will be applied on associated evas object using evas map.

Note
  When working with soft bodies it's importante to adjust the simulation's fixed time step due its multi point nature.

For a rigid cylinder, check ephysics_body_cylinder_add().

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL` on errors.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().
  ephysics_body_face_evas_object_set().
  ephysics_world_simulation_set().

## ephysics_body_cloth_add()

EAPI EPhysics_Body * ephysics_body_cloth_add | ( | EPhysics_World * | world,
|  | unsigned short | rows,
|  | unsigned short | columns )

Create a new deformable cloth physics body.

A cloth has its points of deformation conceptually split into rows and columns where every square is also split into two triangles - afore named nodes. To fine tune the deformation one can increase this granularity by increasing the number of `rows` and `columns`.

By default - if passed 0 as `rows` and `columns` - EPhysics creates a cloth with 15 rows and 15 columns, these default values will generally fit the most common scenarios.

If the informed `rows` is of 0 then the default value - of 15 - is assumed. The same is true for `columns`.

Parameters

  world | The world this body will belong to.
  rows | The number os rows.
  columns | The number of columns.

Returns
  a new body or `NULL` on erros.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().
  ephysics_body_face_evas_object_set().
  ephysics_world_simulation_set().
  ephysics_body_cloth_anchor_add().
  ephysics_body_cloth_anchor_full_add().

## ephysics_body_cloth_anchor_full_add()

EAPI void ephysics_body_cloth_anchor_full_add | ( | EPhysics_Body * | body1,
|  | EPhysics_Body * | body2,
|  | EPhysics_Body_Cloth_Anchor_Side | side )

Anchors a cloth with a rigid body.

All the informed `side` of `body1` will be anchored to `body2` wherever it's in time of anchoring. That is, all the nodes in the informed "edge".

An anchor assumes the `body1` positions, if it's 20px far from `body2` then this distance is always kept, moving `body1` or `body2` will respect a 20px difference.

Parameters

  body1 | The cloth body to be anchored.
  body2 | The body to be anchored to.
  side | The side to be anchored.

See also
  ephysics_body_cloth_anchor_add().
  ephysics_body_cloth_anchor_del().
  ephysics_body_cloth_add() to know more about the cloth physics representation.

## ephysics_body_cloth_anchor_add()

EAPI void ephysics_body_cloth_anchor_add | ( | EPhysics_Body * | body1,
|  | EPhysics_Body * | body2,
|  | int | node )

Anchors an arbitrary cloth's node with a rigid body.

The informed `node` of `body1` will be anchored to `body2` wherever it's in time of anchoring.

See also
  ephysics_body_cloth_add() to know more about the cloth physics representation, nodes and so on.

An anchor assumes the `body1` positions, if it's 20px far from `body2` then this distance is always kept, moving `body1` or `body2` will respect a 20px difference.

Parameters

  body1 | The cloth body to be anchored.
  body2 | The body to be anchored to.
  node | The node index to be anchored.

See also
  ephysics_body_cloth_anchor_full_add().
  ephysics_body_cloth_anchor_del().

## ephysics_body_cloth_anchor_del()

EAPI void ephysics_body_cloth_anchor_del | ( | EPhysics_Body * | body | ) |

Removes the anchors in a cloth body.

Parameters

  body | The body to delete anchors from.

See also
  ephysics_body_cloth_anchor_full_add().
  ephysics_body_cloth_anchor_add().

## ephysics_body_shape_add()

EAPI EPhysics_Body * ephysics_body_shape_add | ( | EPhysics_World * | world,
|  | EPhysics_Shape * | shape )

Create a new physics body using a custom shape.

Its collision shape will be a convex shape that has all the points added to this `shape`. A shape can be created with ephysics_shape_new().

To change it's size ephysics_body_geometry_set() should be used, so it can be deformed on x, y and z axes.

The center of mass of this body can be get with ephysics_body_center_mass_get().

Parameters

  world | The world this body will belongs to.
  shape | The custom shape to be used.

Returns
  a new body or `NULL`, on errors.

See also
  ephysics_body_del().
  ephysics_body_evas_object_set().

Examples
  test_shapes.c.

## ephysics_body_top_boundary_add()

EAPI EPhysics_Body * ephysics_body_top_boundary_add | ( | EPhysics_World * | world | ) |

Create a physic top boundary.

A physic top boundary will limit the bodies area and placed on top edge of worlds render geometry - defined with ephysics_world_render_geometry_set().

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL`, on erros.

See also
  ephysics_world_render_geometry_set()

Examples
  test_bouncing_ball.c, test_collision_detection.c, test_collision_filter.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_shapes.c, test_sleeping_threshold.c, and test_velocity.c.

## ephysics_body_bottom_boundary_add()

EAPI EPhysics_Body * ephysics_body_bottom_boundary_add | ( | EPhysics_World * | world | ) |

Create a physic bottom boundary.

A physic bottom boundary will limit the bodies area and placed on bottom edge of worlds render geometry - defined with ephysics_world_render_geometry_set().

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL`, on erros.

See also
  ephysics_world_render_geometry_set()

Examples
  test_bouncing_ball.c, test_bouncing_text.c, test_collision_detection.c, test_collision_filter.c, test_constraint.c, test_delete.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_shapes.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

## ephysics_body_left_boundary_add()

EAPI EPhysics_Body * ephysics_body_left_boundary_add | ( | EPhysics_World * | world | ) |

Create a physic left boundary.

A physic left boundary will limit the bodies area and placed right o the left edge of worlds render geometry - defined with ephysics_world_render_geometry_set().

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL`, on erros.

See also
  ephysics_world_render_geometry_set()

Examples
  test_bouncing_ball.c, test_collision_detection.c, test_collision_filter.c, test_delete.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_shapes.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

## ephysics_body_right_boundary_add()

EAPI EPhysics_Body * ephysics_body_right_boundary_add | ( | EPhysics_World * | world | ) |

Create a physic right boundary.

A physic right boundary will limit the bodies area and placed right o the right edge of worlds render geometry - defined with ephysics_world_render_geometry_set().

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL`, on erros.

See also
  ephysics_world_render_geometry_set()

Examples
  test_bouncing_ball.c, test_collision_detection.c, test_collision_filter.c, test_delete.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_shapes.c, test_sleeping_threshold.c, and test_velocity.c.

## ephysics_body_front_boundary_add()

EAPI EPhysics_Body * ephysics_body_front_boundary_add | ( | EPhysics_World * | world | ) |

Create a physic front boundary.

A physic front boundary will limit the bodies area and placed on the front of worlds render geometry - defined with ephysics_world_render_geometry_set(). It is placed on x-y plane, from x to x + width, from y to y + height.

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL`, on erros.

See also
  ephysics_world_render_geometry_set()

## ephysics_body_back_boundary_add()

EAPI EPhysics_Body * ephysics_body_back_boundary_add | ( | EPhysics_World * | world | ) |

Create a physic back boundary.

A physic front boundary will limit the bodies area and placed on the back of worlds render geometry - defined with ephysics_world_render_geometry_set(). It is placed on x-y plane, from x to x + width, from y to y + height.

Parameters

  world | The world this body will belong to.

Returns
  a new body or `NULL`, on erros.

See also
  ephysics_world_render_geometry_set()

## ephysics_body_del()

EAPI void ephysics_body_del | ( | EPhysics_Body * | body | ) |

Delete a physics body.

This function will remove this body from its world and will free all the memory used. It won't delete or modify an associated evas object, what can be done with ephysics_body_evas_object_set(). So after it is removed the evas object will stop being updated, but will continue to be rendered on canvas.

Parameters

  body | The body to be deleted.

See also
  ephysics_body_box_add().
  ephysics_body_cylinder_add().

Examples
  test_delete.c.

## ephysics_body_world_get()

EAPI EPhysics_World * ephysics_body_world_get | ( | const EPhysics_Body * | body | ) |

Get the world a body belongs to.

It will return the world where the body was added to.

Parameters

  body | The physics body.

Returns
  The world, or `NULL` on error.

## ephysics_body_evas_object_set()

EAPI void ephysics_body_evas_object_set | ( | EPhysics_Body * | body,
|  | Evas_Object * | evas_obj,
|  | Eina_Bool | use_obj_pos )

Set an evas object to a physics body.

It will create a direct association between a physics body and an evas object. With that EPhysics will be able to update evas object position and rotation automatically.

This association should be 1:1. You can have physics bodies without evas objects, but you can't have more than an evas object directly associated to this body. If you want more, you can use ephysics_body_event_callback_add() to register a callback that will update the other evas objects. This function can be used to disable updates of associated evas objects, or complement updates, like changing evas objects properties under certain conditions of position or rotation.

If it's required to associate evas object to specific faces of the body, function ephysics_body_face_evas_object_set() could be used.

Parameters

  body | The body to associate to an evas object.
  evas_obj | The evas object that will be associated to this `body`.
  use_obj_pos | If `EINA_TRUE` it will set the physics body position to match evas object position taking world rate on consideration.

See also
  ephysics_body_box_add().
  ephysics_body_soft_box_add().
  ephysics_body_cylinder_add().
  ephysics_body_soft_cylinder_add().
  ephysics_body_evas_object_unset().
  ephysics_world_rate_set().

Examples
  ephysics_logo.c, test_bouncing_ball.c, test_bouncing_text.c, test_camera.c, test_camera_track.c, test_collision_detection.c, test_collision_filter.c, test_constraint.c, test_delete.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_rotating_forever.c, test_shapes.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

## ephysics_body_evas_object_unset()

EAPI Evas_Object * ephysics_body_evas_object_unset | ( | EPhysics_Body * | body | ) |

Unset the evas object associated to a physics body.

Parameters

  body | The body to unset an evas object from.

Returns
  The associated evas object, or `NULL` if no object is associated or on error.

See also
  ephysics_body_evas_object_set() for more details.

## ephysics_body_evas_object_get()

EAPI Evas_Object * ephysics_body_evas_object_get | ( | const EPhysics_Body * | body | ) |

Get the evas object associated to a physics body.

Parameters

  body | The body to get an evas object from.

Returns
  The associated evas object, or `NULL` if no object is associated or on error.

See also
  ephysics_body_evas_object_set() for more details.

Examples
  test_delete.c, and test_rotating_forever.c.

## ephysics_body_face_evas_object_set()

EAPI void ephysics_body_face_evas_object_set | ( | EPhysics_Body * | body,
|  | EPhysics_Body_Face | face,
|  | Evas_Object * | evas_obj,
|  | Eina_Bool | use_obj_pos )

Set an evas object to a physics body face.

It will create a direct association between a specific face of the physics body and an evas object. With that EPhysics will be able to update evas object position and rotation automatically.

If it's required to associate only one evas object to this body, a more generic function

See also
  ephysics_body_evas_object_set() can be used.

Parameters

  body | The body to associate to an evas object.
  face | The specific face of `body` where the evas object will be placed.
  evas_obj | The evas object that will be associated to this `body`.
  use_obj_pos | If `EINA_TRUE` it will set the physics body position to match evas object position taking world rate on consideration.

See also
  ephysics_body_face_evas_object_unset().
  ephysics_body_face_evas_object_get().
  ephysics_body_evas_object_set().
  ephysics_world_rate_set().

## ephysics_body_face_evas_object_get()

EAPI Evas_Object * ephysics_body_face_evas_object_get | ( | const EPhysics_Body * | body,
|  | EPhysics_Body_Face | face )

Get the evas object associated to a physics body face.

Parameters

  body | The body to get an evas object from.
  face | The specific face of `body` where the evas object was placed.

Returns
  The associated evas object, or `NULL` if no object is associated or on error.

See also
  ephysics_body_face_evas_object_set() for more details.

## ephysics_body_face_evas_object_unset()

EAPI Evas_Object * ephysics_body_face_evas_object_unset | ( | EPhysics_Body * | body,
|  | EPhysics_Body_Face | face )

Unset the evas object associated to a physics body face.

Parameters

  body | The body to unset an evas object from.
  face | The specific face of `body` where the evas object was placed.

Returns
  The associated evas object, or `NULL` if no object is associated or on error.

See also
  ephysics_body_face_evas_object_set() for more details.

## ephysics_body_resize()

EAPI void ephysics_body_resize | ( | EPhysics_Body * | body,
|  | Evas_Coord | w,
|  | Evas_Coord | h,
|  | Evas_Coord | d )

Set physics body size.

By default cylinders have diameter equal to 1 meter * rate, boxes have dimensions 1 meter * rate on all the axes.

There are three direct ways of modifying it's size:

- With ephysics_body_resize();
- With ephysics_body_geometry_set();
- When associating an evas object with ephysics_body_evas_object_set().

Note
  The unit used for size is Evas coordinates.

Parameters

  body | The body to be resized.
  w | The body width, in pixels.
  h | The body height, in pixels.
  d | The body depth, in pixels.

See also
  ephysics_body_geometry_get().
  ephysics_body_geometry_set().
  ephysics_body_move().

## ephysics_body_move()

EAPI void ephysics_body_move | ( | EPhysics_Body * | body,
|  | Evas_Coord | x,
|  | Evas_Coord | y,
|  | Evas_Coord | z )

Set physics body position.

All the physics bodies are created centered on origin (0, 0, 0).

There are three direct ways of modifying this position:

- With ephysics_body_move();
- With ephysics_body_geometry_set();
- When associating an evas object with ephysics_body_evas_object_set().

When the world is simulated forces will be applied on objects with mass and position will be modified too.

Note
  The unit used for position is Evas coordinates.

Parameters

  body | The body to be positioned.
  x | The position on axis x, in pixels.
  y | The position on axis y, in pixels.
  z | The position on axis z, in pixels.

See also
  ephysics_body_geometry_get().
  ephysics_body_geometry_set().
  ephysics_body_resize().

Examples
  ephysics_logo.c.

## ephysics_body_geometry_set()

EAPI void ephysics_body_geometry_set | ( | EPhysics_Body * | body,
|  | Evas_Coord | x,
|  | Evas_Coord | y,
|  | Evas_Coord | z,
|  | Evas_Coord | w,
|  | Evas_Coord | h,
|  | Evas_Coord | d )

Set physics body geometry.

All the physics bodies are created centered on origin (0, 0) and with canonical dimensions. Cylinder have diameter 1, boxes have dimensions 1 on all the axes.

There are four direct ways of modifying this geometry:

- With ephysics_body_geometry_set();
- With ephysics_body_move();
- With ephysics_body_resize();
- When associating an evas object with ephysics_body_evas_object_set().

If you just need to move the body, no changes are required to it's size, use ephysics_body_move(). If you just need to modify the size of `body` use ephysics_body_resize().

When the world is simulated forces will be applied on objects with mass and position will be modified too.

Note
  The unit used for geometry is Evas coordinates.

Parameters

  body | The body to be modified.
  x | The position on axis x, in pixels.
  y | The position on axis y, in pixels.
  z | The position on axis z, in pixels.
  w | The body width, in pixels.
  h | The body height, in pixels.
  d | The body depth, in pixels.

See also
  ephysics_body_geometry_get().
  ephysics_body_move().
  ephysics_body_resize().

Examples
  ephysics_logo.c, test_bouncing_text.c, test_camera.c, test_camera_track.c, and test_collision_filter.c.

## ephysics_body_geometry_get()

EAPI void ephysics_body_geometry_get | ( | const EPhysics_Body * | body,
|  | Evas_Coord * | x,
|  | Evas_Coord * | y,
|  | Evas_Coord * | z,
|  | Evas_Coord * | w,
|  | Evas_Coord * | h,
|  | Evas_Coord * | d )

Get physics body position.

Parameters

  body | The physics body.
  x | The position on axis x, in pixels.
  y | The position on axis y, in pixels.
  z | The position on axis z, in pixels.
  w | The body width, in pixels.
  h | The body height, in pixels.
  d | The body depth, in pixels.

See also
  ephysics_body_geometry_set() for more details.
  ephysics_body_move().
  ephysics_body_resize().

Examples
  test_constraint.c.

## ephysics_body_mass_set()

EAPI void ephysics_body_mass_set | ( | EPhysics_Body * | body,
|  | double | mass )

Set body's mass.

It will set inertial mass of the body. It is a quantitative measure of an object's resistance to the change of its speed. It's required to apply more force on objects with more mass to increase its speed.

If mass is set to 0 the body will have infinite mass, so it will be immovable, static. EPHYSICS_BODY_MASS_STATIC can be used too.

Negative mass is not allowed.

By default, a body is created with 1 kg.

Note
  The unit used for mass is kilograms.

Parameters

  body | The body to has its mass set.
  mass | The `body's` mass, in kilograms.

See also
  ephysics_body_mass_get().

Examples
  ephysics_logo.c, test_camera.c, test_camera_track.c, test_collision_filter.c, test_constraint.c, and test_slider.c.

## ephysics_body_mass_get()

EAPI double ephysics_body_mass_get | ( | const EPhysics_Body * | body | ) |

Get body's mass.

It will get inertial mass of the body.

Parameters

  body | The physics body.

Returns
  the `body` mass, in kilograms.

See also
  ephysics_body_mass_set() for details.

## ephysics_body_linear_velocity_set()

EAPI void ephysics_body_linear_velocity_set | ( | EPhysics_Body * | body,
|  | double | x,
|  | double | y,
|  | double | z )

Set body's linear velocity on x, y and z axes.

Parameters

  body | The physics body.
  x | The linear velocity on axis x.
  y | The linear velocity on axis y.
  z | The linear velocity on axis z.

Note
  EPhysics unit for linear velocity is Evas coordinates per second.

See also
  ephysics_body_linear_velocity_get().
  ephysics_body_angular_velocity_set().

Examples
  test_no_gravity.c, and test_sleeping_threshold.c.

## ephysics_body_linear_velocity_get()

EAPI void ephysics_body_linear_velocity_get | ( | const EPhysics_Body * | body,
|  | double * | x,
|  | double * | y,
|  | double * | z )

Get body's linear velocity on x, y and z axes.

Parameters

  body | The physics body.
  x | The linear velocity on axis x.
  y | The linear velocity on axis y.
  z | The linear velocity on axis z.

Note
  EPhysics unit for linear velocity is Evas coordinates per second.
  For cloth bodies the returned value is a velocity average of nodes velocities.

See also
  ephysics_body_linear_velocity_set().
  ephysics_body_angular_velocity_get().

Examples
  test_forces.c, and test_velocity.c.

## ephysics_body_angular_velocity_set()

EAPI void ephysics_body_angular_velocity_set | ( | EPhysics_Body * | body,
|  | double | x,
|  | double | y,
|  | double | z )

Set body's angular velocity on x, y and z axes.

Parameters

  body | The physics body.
  x | The angular velocity on axis x.
  y | The angular velocity on axis y.
  z | The angular velocity on axis z.

Note
  EPhysics unit for angular velocity is degrees per second.

See also
  ephysics_body_angular_velocity_get().
  ephysics_body_linear_velocity_set().

Examples
  test_no_gravity.c.

## ephysics_body_angular_velocity_get()

EAPI void ephysics_body_angular_velocity_get | ( | const EPhysics_Body * | body,
|  | double * | x,
|  | double * | y,
|  | double * | z )

Get body's angular velocity on x, y and z axes.

Parameters

  body | The physics body.
  x | The angular velocity on axis x.
  y | The angular velocity on axis y.
  z | The angular velocity on axis z.

Note
  EPhysics unit for angular velocity is degrees per second.

See also
  ephysics_body_angular_velocity_set().
  ephysics_body_linear_velocity_get().

Examples
  test_forces.c, test_rotating_forever.c, and test_velocity.c.

## ephysics_body_sleeping_threshold_set()

EAPI void ephysics_body_sleeping_threshold_set | ( | EPhysics_Body * | body,
|  | double | linear_threshold,
|  | double | angular_threshold )

Set the linear and angular sleeping threshold.

These factors are used to determine whenever a rigid body is supposed to increment the sleeping time.

After every tick the sleeping time is incremented, if the body's linear and angular speed is less than the respective thresholds the sleeping time is incremented by the current time step (delta time).

After reaching the max sleeping time the body is marked to sleep, that means the rigid body is to be deactivated.

Note
  The expected value to be informed as `linear_threshold` is the body's speed. It is measured in Evas coordinates per second.
  The expected angular velocity to be informed as `angular_threshold` is measured in degrees per second.

Parameters

  body | The body to be set.
  linear_threshold | The linear sleeping threshold factor, default value is 24.
  angular_threshold | The angular sleeping threshold factor, default value is 57.29 (1 rad).

See also
  ephysics_body_sleeping_threshold_get().
  ephysics_world_max_sleeping_time_set() for sleeping time details.

Examples
  test_no_gravity.c, test_sleeping_threshold.c, and test_velocity.c.

## ephysics_body_sleeping_threshold_get()

EAPI void ephysics_body_sleeping_threshold_get | ( | const EPhysics_Body * | body,
|  | double * | linear_threshold,
|  | double * | angular_threshold )

Get the linear sleeping threshold.

Note
  The linear sleeping threshold is measured in Evas coordinates per second and the angular sleeping threshold is measured in degrees per second.

Parameters

  body | The body to get the linear sleeping threshold from.
  linear_threshold | The linear sleeping threshold factor.
  angular_threshold | The angular sleeping threshold factor.

See also
  ephysics_body_sleeping_threshold_set() for more details.

Examples
  test_sleeping_threshold.c.

## ephysics_body_stop()

EAPI void ephysics_body_stop | ( | EPhysics_Body * | body | ) |

Stop angular and linear body movement.

It's equivalent to set linear velocity to 0 on both axis and angular velocity to 0 as well.

It's a momentary situation. If it receives impulse, directly or by collision, if gravity acts over this body, it will stop but it will accelerate again.

Parameters

  body | The physics body.

See also
  ephysics_body_angular_velocity_set().
  ephysics_body_linear_velocity_set().

Examples
  test_no_gravity.c.

## ephysics_body_damping_set()

EAPI void ephysics_body_damping_set | ( | EPhysics_Body * | body,
|  | double | linear_damping,
|  | double | angular_damping )

Set the angular and linear damping values.

Damping(linear and angular) values are applied to body's linear and angular velocity.

By applying a bodies damping factor the user will face a velocity reduction, with a force applied to it - like air resistance. The force is applied to slow it down. Different factors can be applied to angular and linear velocity to fine tune translation and rotation.

The damping is a force synchronous with the velocity of the object but in opposite direction.

Damping is specified as a value between 0 and 1, which is the proportion of velocity lost per second. If specified damping value - either for angular or linear - is greater or equal to 1, velocities are nulled(that means, will become 0 on every axis), resulting on a frozen body.

Default linear damping is set to 0. The same is true for angular damping factor.

Parameters

  body | The physics body.
  linear_damping | The linear damping factor to apply on `body`.
  angular_damping | The angular damping factor to apply on `body`.

See also
  ephysics_body_damping_get().

Examples
  test_camera_track.c, test_sleeping_threshold.c, and test_velocity.c.

## ephysics_body_damping_get()

EAPI void ephysics_body_damping_get | ( | const EPhysics_Body * | body,
|  | double * | linear_damping,
|  | double * | angular_damping )

Get the angular and linear damping values.

Damping(linear and angular) values are applied to body's linear and angular velocity.

Parameters

  body | The physics body.
  linear_damping | The linear damping factor applied over `body`.
  angular_damping | The angular damping factor applied over `body`.

See also
  ephysics_body_damping_set() for details.

## ephysics_body_collision_group_add()

EAPI Eina_Bool ephysics_body_collision_group_add | ( | EPhysics_Body * | body,
|  | const char * | group )

Add a `body` to a given collision group.

After calling this function the body is said to be added to collision `group`.

If not added to any group the body will collide against any other body. Otherwise this body will collide only against those in the same groups.

If `body` was already part of `group`, nothing will happen.

Parameters

  body | The body to be added to `group`.
  group | The group the `body` will belong to.

Returns
  `EINA_TRUE` if body is added to group, or `EINA_FALSE` on error.

See also
  ephysics_body_collision_group_del()
  ephysics_body_collision_group_list_get()

Examples
  test_collision_filter.c.

## ephysics_body_collision_group_del()

EAPI Eina_Bool ephysics_body_collision_group_del | ( | EPhysics_Body * | body,
|  | const char * | group )

Removes `body` from collision `group`.

This `body` will not belong to `group` any more and the collisions filter must take that on account.

If `body` wasn't part of `group` before, nothing will happen.

Parameters

  body | The body to be removed from `group`.
  group | The group `body` must be removed from.

Returns
  `EINA_TRUE` if body is removed from group, or `EINA_FALSE` on error.

See also
  ephysics_body_collision_group_add()

## ephysics_body_collision_group_list_get()

EAPI const Eina_List * ephysics_body_collision_group_list_get | ( | const EPhysics_Body * | body | ) |

Get the collision group list of `body`.

Parameters

  body | The body of interest.

Returns
  The collision group list of `body`, NULL on failure or case no group has been added to `body`.

Warning
  The collision group list is an EPhysics internal data structure and should never be modified by its callers.

See also
  ephysics_body_collision_group_add()

## ephysics_body_evas_object_update()

EAPI void ephysics_body_evas_object_update | ( | EPhysics_Body * | body | ) |

Update the evas object associated to the body.

This function should be called to update position and rotation of the evas object associated to the body with ephysics_body_evas_object_set(). It will take rate between pixels and meters set with ephysics_world_rate_set() in account.

If an update callback wasn't set with ephysics_body_event_callback_add(), this function will be executed after each physics simulation tick. If a callback was set, it won't be called automatically. So inside this callback it could be called, or a customized update could be implemented.

See also
  ephysics_body_event_callback_add() for more details.

Examples
  ephysics_logo.c, test_forces.c, and test_rotating_forever.c.

## ephysics_body_event_callback_add()

EAPI void ephysics_body_event_callback_add | ( | EPhysics_Body * | body,
|  | EPhysics_Callback_Body_Type | type,
|  | EPhysics_Body_Event_Cb | func,
|  | const void * | data )

Register a callback to a type of physics body event.

The registered callback will receives the body and extra user data that can be passed. From body it's possible to get the world it belongs to with ephysics_body_world_get(), the rate between pixels and meters with ephysics_world_rate_get() and the associated evas object with ephysics_body_evas_object_get().

So it's enough to do customized updates or fix pointers in your program.

Regarding EPHYSICS_CALLBACK_BODY_UPDATE:

This update event happens after each physics world tick. Its main use could be updating the evas object associated to a physics body.

If no callback is registered, the evas object associated to physics body will be automatically moved and rotated, taking rate between meters and pixels on account. This rate is set by ephysics_world_rate_set().

If callbacks are registered, these function will be called and will be responsible for updating the evas object. If the default update is wanted, function ephysics_body_evas_object_update() can be called inside the callback. So you could make changes before and after the evas object is updated.

A callback could be something like this:

static void
_update_cb(void *data, EPhysics_Body *body, void *event_info)
{
// Something you want to do before updating the evas object
ephysics_body_evas_object_update(body);
// Something to be done after the update, like checking the new position
// of the evas object to change a property.
}
ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_UPDATE,
_update_cb, NULL);
ephysics_body_evas_object_update
EAPI void ephysics_body_evas_object_update(EPhysics_Body *body)
Update the evas object associated to the body.
ephysics_body_event_callback_add
EAPI void ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, const void *data)
Register a callback to a type of physics body event.
EPhysics_Body
struct _EPhysics_Body EPhysics_Body
Body handle, represents an object on EPhysics world.
Definition EPhysics.h:655
EPHYSICS_CALLBACK_BODY_UPDATE
@ EPHYSICS_CALLBACK_BODY_UPDATE
Body being updated.
Definition EPhysics.h:2263

Update callbacks receives evas object set to body as event_info argument.

What follows is a list of details about each callback type:

- EPHYSICS_CALLBACK_BODY_UPDATE: Called after every physics iteration. `body` points to the EPhysics_Body itself and `event_info` points to the evas object associated to the body.
- EPHYSICS_CALLBACK_BODY_COLLISION: Called just after the collision has been actually processed by the physics engine. The body involved in the collision is passed as `body` argument. `event_info` is a pointer to EPhysics_Body_Collision - note, this structure(`event_info`) is discarded/freed right after callback returns.
- EPHYSICS_CALLBACK_BODY_DEL: Called when a body deletion has been issued and just before the deletion actually happens. `body` points to the body being deleted and `event_info` is a pointer to the evas object associated to it.
- EPHYSICS_CALLBACK_BODY_STOPPED: Called when a body is found to be stopped. `body` points to the body of interest and `event_info` is a pointer to the evas object associated to it.

Parameters

  body | The physics body.
  type | Type of callback to be listened by `func`.
  func | Callback function that will be called when event occurs.
  data | User data that will be passed to callback function. It won't be used by ephysics in any way.

Examples
  ephysics_logo.c, test_bouncing_ball.c, test_camera.c, test_collision_detection.c, test_constraint.c, test_delete.c, test_forces.c, test_no_gravity.c, test_rotating_forever.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

## ephysics_body_event_callback_del()

EAPI void * ephysics_body_event_callback_del | ( | EPhysics_Body * | body,
|  | EPhysics_Callback_Body_Type | type,
|  | EPhysics_Body_Event_Cb | func )

Unregister an ephysics body event callback.

A previously added callback that match `body`, `type` and `func` will be deleted.

Parameters

  body | The physics body.
  type | The type of callback to be unregistered.
  func | The callback function to be unregistered.

Returns
  The user data passed when the callback was registered, or `NULL` on error.

See also
  ephysics_body_event_callback_add() for details.
  ephysics_body_event_callback_del_full() if you need to match data pointer.

Examples
  test_collision_detection.c.

## ephysics_body_event_callback_del_full()

EAPI void * ephysics_body_event_callback_del_full | ( | EPhysics_Body * | body,
|  | EPhysics_Callback_Body_Type | type,
|  | EPhysics_Body_Event_Cb | func,
|  | void * | data )

Unregister an ephysics body event callback matching data pointer.

A previously added callback that match `body`, `type`, `func` and `data` will be deleted.

Parameters

  body | The physics body.
  type | The type of callback to be unregistered.
  func | The callback function to be unregistered.
  data | The data pointer that was passed to the callback.

Returns
  The user data passed when the callback was registered, or `NULL` on error.

See also
  ephysics_body_event_callback_add() for details.
  ephysics_body_event_callback_del() if you don't need to match data pointer.

## ephysics_body_collision_position_get()

EAPI void ephysics_body_collision_position_get | ( | const EPhysics_Body_Collision * | collision,
|  | Evas_Coord * | x,
|  | Evas_Coord * | y,
|  | Evas_Coord * | z )

Get the position(x, y) of a body's collision.

Given a body collision data, fills `x` and `y` pointers with the position where the collision occurred.

Parameters

  collision | The body collision data of interest.
  x | The x coordinate of collision point, in pixels.
  y | The y coordinate of collision point, in pixels.
  z | The z coordinate of collision point, in pixels.

See also
  EPHYSICS_CALLBACK_BODY_COLLISION and ephysics_body_event_callback_add() for collision callback.

Examples
  test_collision_detection.c.

## ephysics_body_collision_contact_body_get()

EAPI EPhysics_Body * ephysics_body_collision_contact_body_get | ( | const EPhysics_Body_Collision * | collision | ) |

Get the body's collision contact body.

Given a body collision data returns the contact body which a collision occurred against.

Parameters

  collision | The body collision of interest.

Returns
  The contact body of `collision`.

See also
  EPHYSICS_CALLBACK_BODY_COLLISION and ephysics_body_event_callback_add() for collision callback.

Examples
  test_collision_detection.c, and test_delete.c.

## ephysics_body_restitution_set()

EAPI void ephysics_body_restitution_set | ( | EPhysics_Body * | body,
|  | double | restitution )

Set body's coefficient of restitution.

The coefficient of restitution is proporcion between speed after and before a collision: COR = relative speed after collision / relative speed before collision

The body COR is the coefficient of restitution with respect to a perfectly rigid and elastic object. Bodies will collide between them with different behaviors depending on COR:

- they will elastically collide for COR == 1;
- they will inelastically collide for 0 < COR < 1;
- they will completelly stop (no bouncing at all) for COR == 0.

By default restitution coefficient of each body is 0.

EPhysics has some pre-defined restitution coefficients for materials:

- EPHYSICS_BODY_RESTITUTION_CONCRETE
- EPHYSICS_BODY_RESTITUTION_IRON
- EPHYSICS_BODY_RESTITUTION_PLASTIC
- EPHYSICS_BODY_RESTITUTION_POLYSTYRENE
- EPHYSICS_BODY_RESTITUTION_RUBBER
- EPHYSICS_BODY_RESTITUTION_WOOD

Parameters

  body | The body to has its restitution coefficient set.
  restitution | The new `body's` restitution coefficient.

See also
  ephysics_body_restitution_get().

Examples
  ephysics_logo.c, test_bouncing_ball.c, test_bouncing_text.c, test_camera.c, test_camera_track.c, test_collision_detection.c, test_collision_filter.c, test_constraint.c, test_delete.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_shapes.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

## ephysics_body_restitution_get()

EAPI double ephysics_body_restitution_get | ( | const EPhysics_Body * | body | ) |

Get body's restitution.

Parameters

  body | The physics body.

Returns
  the `body's` restitution value.

See also
  ephysics_body_restitution_set() for details.

## ephysics_body_friction_set()

EAPI void ephysics_body_friction_set | ( | EPhysics_Body * | body,
|  | double | friction )

Set body's friction.

Friction is used to make objects slide along each other realistically.

The friction parameter is usually set between 0 and 1, but can be any non-negative value. A friction value of 0 turns off friction and a value of 1 makes the friction strong.

By default friction value is 0.5 and simulation results will be better when friction in non-zero.

EPhysics has some pre-defined friction coefficients for materials:

- EPHYSICS_BODY_FRICTION_CONCRETE
- EPHYSICS_BODY_FRICTION_IRON
- EPHYSICS_BODY_FRICTION_PLASTIC
- EPHYSICS_BODY_FRICTION_POLYSTYRENE
- EPHYSICS_BODY_FRICTION_RUBBER
- EPHYSICS_BODY_FRICTION_WOOD

Parameters

  body | The body to has its friction set.
  friction | The new `body's` friction value.

See also
  ephysics_body_friction_get().

Examples
  ephysics_logo.c, test_bouncing_ball.c, test_bouncing_text.c, test_camera.c, test_camera_track.c, test_collision_detection.c, test_collision_filter.c, test_constraint.c, test_delete.c, test_forces.c, test_no_gravity.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

## ephysics_body_friction_get()

EAPI double ephysics_body_friction_get | ( | const EPhysics_Body * | body | ) |

Get body's friction.

Parameters

  body | The physics body.

Returns
  the `body's` friction value.

See also
  ephysics_body_friction_set() for details.

## ephysics_body_central_impulse_apply()

EAPI void ephysics_body_central_impulse_apply | ( | EPhysics_Body * | body,
|  | double | x,
|  | double | y,
|  | double | z )

Apply an impulse on the center of a body.

The impulse is equal to the change of momentum of the body.

Impulse is the product of the force over the time this force is applied. In ephysics case, it would be the time of a tick, so it behaves just summing current linear velocity to impulse per mass.

Example: A body of 2kg of mass has an initial velocity of 30 p/s. After a impulse of 30 kg * p / s in the same direction is applied, the velocity will be * 45 p/s.

(0, 30, 0) + (0, 300, 0) / 2 = (0, 30, 0) + (0, 15, 0) = (0, 45, 0)

When a impulse is applied over a body, it will has its velocity changed. This impulse will be applied on body's center, so it won't implies in rotating the body. For that is possible to apply a torque impulse with ephysics_body_torque_impulse_apply().

Note
  Impulse is measured in kg * p / s.

Parameters

  body | The physics body that will receive the impulse.
  x | The axis x component of impulse.
  y | The axis y component of impulse.
  z | The axis z component of impulse.

See also
  ephysics_body_torque_impulse_apply().
  ephysics_body_impulse_apply().

Examples
  ephysics_logo.c, test_bouncing_ball.c, test_camera.c, test_camera_track.c, test_collision_detection.c, test_collision_filter.c, test_delete.c, test_growing_balls.c, test_slider.c, and test_velocity.c.

## ephysics_body_torque_impulse_apply()

EAPI void ephysics_body_torque_impulse_apply | ( | EPhysics_Body * | body,
|  | double | pitch,
|  | double | yaw,
|  | double | roll )

Apply a torque impulse over a body.

An impulse will be applied over the body to make it rotate. Impulse is the product of the force over the time this force is applied. In ephysics case, it would be the time of a tick, so it behaves just summing current angular velocity to the result of a calculation involving torque impulse and body's inertia.

Parameters

  body | The physics body that will receive the impulse.
  pitch | Impulse to rotate body around X axis (rotate on y - z plane). Negative values will impulse body on counter clockwise rotation.
  yaw | Impulse to rotate body around Y axis (rotate on x - z plane). Negative values will impulse body on counter clockwise rotation.
  roll | Impulse to rotate body around Z axis (rotate on x - y plane). Negative values will impulse body on counter clockwise rotation.

See also
  ephysics_body_central_impulse_apply().
  ephysics_body_impulse_apply().

Examples
  test_rotating_forever.c.

## ephysics_body_impulse_apply()

EAPI void ephysics_body_impulse_apply | ( | EPhysics_Body * | body,
|  | double | x,
|  | double | y,
|  | double | z,
|  | Evas_Coord | pos_x,
|  | Evas_Coord | pos_y,
|  | Evas_Coord | pos_z )

Apply an impulse over a body.

An impulse will be applied over the body to make it move and rotate.

Impulse is the product of the force over the time this force is applied. It can be applied in the center of the body, avoiding rotating it, with ephysics_body_central_impulse_apply(), it can be applied only to make a body rotate, with ephysics_body_torque_impulse_apply(), or can be used to lead to both behaviors with ephysics_body_impulse_apply().

It will result in a central impulse with impulse (`x`, `y`, `z`) and a torque impulse that will be calculated as a cross product on impulse and relative position.

Parameters

  body | The physics body that will receive the impulse.
  x | The axis x component of impulse.
  y | The axis y component of impulse.
  z | The axis z component of impulse.
  pos_x | The axis x component of the relative position to apply impulse.
  pos_y | The axis y component of the relative position to apply impulse.
  pos_z | The axis z component of the relative position to apply impulse.

Note
  Impulse is measured in kg * p / s and position in pixels (Evas coordinates).

See also
  ephysics_body_central_impulse_apply().
  ephysics_body_torque_impulse_apply().

Examples
  test_rotating_forever.c.

## ephysics_body_angular_movement_enable_set()

EAPI void ephysics_body_angular_movement_enable_set | ( | EPhysics_Body * | body,
|  | Eina_Bool | enable_x,
|  | Eina_Bool | enable_y,
|  | Eina_Bool | enable_z )

Enable or disable body's rotation on z axis.

Enabled by default for z axis, so the body only will rotate on x-y plane.

Parameters

  body | The physics body.
  enable_x | If `EINA_TRUE` allow rotation on x axis (y-z plane), if `EINA_FALSE` disallow it.
  enable_y | If `EINA_TRUE` allow rotation on y axis (x-z plane), if `EINA_FALSE` disallow it.
  enable_z | If `EINA_TRUE` allow rotation on z axis (x-y plane), if `EINA_FALSE` disallow it.

See also
  ephysics_body_angular_movement_enable_get().

Examples
  ephysics_logo.c.

## ephysics_body_angular_movement_enable_get()

EAPI void ephysics_body_angular_movement_enable_get | ( | const EPhysics_Body * | body,
|  | Eina_Bool * | enable_x,
|  | Eina_Bool * | enable_y,
|  | Eina_Bool * | enable_z )

Return body's rotation on z axis state.

Parameters

  body | The physics body.
  enable_x | `EINA_TRUE` if rotation on x axis (y-z plane) is allowed, or `EINA_FALSE` if it's not.
  enable_y | `EINA_TRUE` if rotation on y axis (x-z plane) is allowed, or `EINA_FALSE` if it's not.
  enable_z | `EINA_TRUE` if rotation on z axis (x-y plane) is allowed, or `EINA_FALSE` if it's not.

See also
  ephysics_body_angular_movement_enable_set() for more details.

## ephysics_body_linear_movement_enable_set()

EAPI void ephysics_body_linear_movement_enable_set | ( | EPhysics_Body * | body,
|  | Eina_Bool | enable_x,
|  | Eina_Bool | enable_y,
|  | Eina_Bool | enable_z )

Enable or disable body's movement on x, y and z axes.

Enabled by default on x and y axes, disabled on z axis.

Parameters

  body | The physics body.
  enable_x | If `EINA_TRUE` allow movement on x axis, if `EINA_FALSE` disallow it.
  enable_y | If `EINA_TRUE` allow movement on y axis, if `EINA_FALSE` disallow it.
  enable_z | If `EINA_TRUE` allow movement on z axis, if `EINA_FALSE` disallow it.

See also
  ephysics_body_linear_movement_enable_get().
  ephysics_body_angular_movement_enable_set().

## ephysics_body_linear_movement_enable_get()

EAPI void ephysics_body_linear_movement_enable_get | ( | const EPhysics_Body * | body,
|  | Eina_Bool * | enable_x,
|  | Eina_Bool * | enable_y,
|  | Eina_Bool * | enable_z )

Get body's movement on x, y and z axes behavior.

Parameters

  body | The physics body.
  enable_x | `EINA_TRUE` if movement on x axis is allowed, or `EINA_FALSE` if it's not.
  enable_y | `EINA_TRUE` if movement on y axis is allowed, or `EINA_FALSE` if it's not.
  enable_z | `EINA_TRUE` if movement on z axis is allowed, or `EINA_FALSE` if it's not.

See also
  ephysics_body_linear_movement_enable_set().
  ephysics_body_angular_movement_enable_get().

## ephysics_body_rotation_get()

EAPI EPhysics_Quaternion * ephysics_body_rotation_get | ( | const EPhysics_Body * | body,
|  | EPhysics_Quaternion * | rotation )

Get body's rotation quaternion.

By default rotation is 0 degree on all axes (1, 0, 0, 0).

Parameters

  body | The physics body.
  rotation | Quaternion used to store the result. If it's `NULL`, a new quaternion will be allocated (and should be freed after usage).

Returns
  A quaternion or `NULL` on error.

See also
  ephysics_body_rotation_set()
  ephysics_quaternion_get()

Examples
  test_rotating_forever.c.

## ephysics_body_rotation_set()

EAPI void ephysics_body_rotation_set | ( | EPhysics_Body * | body,
|  | EPhysics_Quaternion * | quat )

Set body's rotation.

By default rotation is 0 degrees on all axes.

Parameters

  body | The physics body.
  quat | Quaternion representing the rotation.

See also
  ephysics_body_rotation_get()
  ephysics_quaternion_new()

Examples
  test_rotating_forever.c.

## ephysics_body_data_set()

EAPI void ephysics_body_data_set | ( | EPhysics_Body * | body,
|  | void * | data )

Set data to `body`.

If a previous data was set, it's reference will be lost and body will point to the new data.

It can be useful when you need to store a structure per body. For example, some values that must to be updated when a collision occurs between two bodies.

Note
  EPhysics won't handle this data, it won't be used in any way by the library. If it need to be freed when the body is deleted, a callback for EPHYSICS_CALLBACK_BODY_DEL can be added and data should be explicity freed.

Parameters

  body | The physics body.
  data | The data to be set.

See also
  ephysics_body_data_get()

## ephysics_body_data_get()

EAPI void * ephysics_body_data_get | ( | const EPhysics_Body * | body | ) |

Return data previously set to body.

Parameters

  body | The physics body.

Returns
  The data set or `NULL` on error.

See also
  ephysics_body_data_get() for more details

## ephysics_body_central_force_apply()

EAPI void ephysics_body_central_force_apply | ( | EPhysics_Body * | body,
|  | double | x,
|  | double | y,
|  | double | z )

Apply a force on the center of a body.

Applying a force to a body will lead it to change its velocity.

Force is the product of mass and acceleration. So, keeping the mass fixed, when force is applied acceleration will change, and consequently, velocity will gradually be changes.

Force = mass * acceleration

Final velocity = initial velocity + acceleration * time

While a force is applied, it will be acting over a body. It can be canceled by applying an inverse force, or just calling ephysics_body_forces_clear().

This force will be applied on body's center, so it won't implies in changing angular acceleration. For that, it is possible to apply a torque with ephysics_body_torque_apply().

If the force shouldn't be applied on body's center, it can be applied on a relative point with ephysics_body_force_apply().

Note
  Force is measured in kg * p / s / s.

Parameters

  body | The physics body which over the force will be applied.
  x | The axis x component of force.
  y | The axis y component of force.
  z | The axis z component of force.

See also
  ephysics_body_torque_apply().
  ephysics_body_force_apply().
  ephysics_body_forces_get().
  ephysics_body_torques_get().

Examples
  test_forces.c.

## ephysics_body_torque_apply()

EAPI void ephysics_body_torque_apply | ( | EPhysics_Body * | body,
|  | double | torque_x,
|  | double | torque_y,
|  | double | torque_z )

Apply a torque over a body.

A torque will be applied over the `body` to change the angular acceleration of this body. It will leads to a change on angular velocity over time.

Parameters

  body | The physics body that will receive the torque.
  torque_x | Torque to change angular acceleration of the body around X axis (rotate on y - z plane). Negative values will accelerate it on counter clockwise rotation.
  torque_y | Torque to change angular acceleration of the body around Y axis (rotate on x - z plane). Negative values will accelerate it on counter clockwise rotation.
  torque_z | Torque to change angular acceleration of the body around Z axis (rotate on x - y plane). Negative values will accelerate it on counter clockwise rotation.

See also
  ephysics_body_central_force_apply().
  ephysics_body_force_apply().
  ephysics_body_forces_get().
  ephysics_body_torques_get().

Examples
  test_rotating_forever.c, and test_shapes.c.

## ephysics_body_force_apply()

EAPI void ephysics_body_force_apply | ( | EPhysics_Body * | body,
|  | double | x,
|  | double | y,
|  | double | z,
|  | Evas_Coord | pos_x,
|  | Evas_Coord | pos_y,
|  | Evas_Coord | pos_z )

Apply a force over a body.

A force will be applied over the body to change it's linear and angular accelerations.

It can be applied in the center of the body, avoiding affecting angular acceleration, with ephysics_body_central_force_apply(), it can be applied only to change angular acceleration, with ephysics_body_torque_apply(), or can be used to lead to both behaviors with ephysics_body_force_apply().

It will result in a central force with force (`x`, `y`, `z`) and a torque that will be calculated as a cross product on force and relative position.

Parameters

  body | The physics body that will receive the impulse.
  x | The axis x component of force.
  y | The axis y component of force.
  z | The axis z component of force.
  pos_x | The axis x component of the relative position to apply force.
  pos_y | The axis y component of the relative position to apply force.
  pos_z | The axis z component of the relative position to apply force.

Note
  Force is measured in kg * p / s / s and position in p (pixels, or Evas coordinates).

See also
  ephysics_body_central_force_apply().
  ephysics_body_torque_apply().
  ephysics_body_forces_get().
  ephysics_body_torques_get().

Examples
  test_forces.c.

## ephysics_body_forces_get()

EAPI void ephysics_body_forces_get | ( | const EPhysics_Body * | body,
|  | double * | x,
|  | double * | y,
|  | double * | z )

Get physics body forces.

Get all the forces applied over a body, including gravity. Damping is not considered.

Parameters

  body | The physics body.
  x | The axis x component of total force.
  y | The axis y component of total force.
  z | The axis z component of total force.

See also
  ephysics_body_force_apply() for more details.
  ephysics_body_central_force_apply().
  ephysics_body_torque_apply().
  ephysics_body_torques_get().
  ephysics_body_forces_clear().
  ephysics_world_gravity_set().

Examples
  test_forces.c.

## ephysics_body_torques_get()

EAPI void ephysics_body_torques_get | ( | const EPhysics_Body * | body,
|  | double * | x,
|  | double * | y,
|  | double * | z )

Get physics body torques.

Get all the torques applied over a body. Damping is not considered.

Parameters

  body | The physics body.
  x | The torque on x axis.
  y | The torque on y axis.
  z | The torque on z axis.

See also
  ephysics_body_torque_apply() for more details.
  ephysics_body_force_apply().
  ephysics_body_forces_clear().

Examples
  test_forces.c, and test_rotating_forever.c.

## ephysics_body_forces_clear()

EAPI void ephysics_body_forces_clear | ( | EPhysics_Body * | body | ) |

Clear all the forces applied to a body.

It will remove all the forces previously applied. So linear acceleration and angular acceleration will be set to 0.

It won't interfere with world's gravity, the body will continue to be accelerated considering gravity.

It won't affect damping.

Parameters

  body | The physics body that will have applied forces set to 0.

See also
  ephysics_body_central_force_apply().
  ephysics_body_torque_apply().
  ephysics_body_force_apply().
  ephysics_body_forces_get().
  ephysics_body_torques_get().

Examples
  test_rotating_forever.c.

## ephysics_body_center_mass_get()

EAPI void ephysics_body_center_mass_get | ( | const EPhysics_Body * | body,
|  | double * | x,
|  | double * | y,
|  | double * | z )

Get the center of mass of physics body.

It returns a value from 0 to 1 representing where is the center of the mass considering the height, width and depth of the body.

If a body of width = 30, height = 20 and depth = 20, and has the center of mass at x component = 20, y component = 10 and z = 10, it will return `x` = 0.666, `y` = 0.5 and `z` = 0.5.

For primitive shapes, like box and cylinder, the center of mass is (0.5, 0.5, 0.5).

This function can be useful when updating evas objects for bodies with custom shapes.

Parameters

  body | The physics body.
  x | The axis x component of center of mass.
  y | The axis y component of center of mass.
  z | The axis z component of center of mass.

See also
  ephysics_body_shape_add().

## ephysics_body_density_set()

EAPI void ephysics_body_density_set | ( | EPhysics_Body * | body,
|  | double | density )

Set body's material density.

The density of a material is its mass per unit volume. It will set the body mass considering its volume. While a density is set, resizing a body will always recalculate its mass.

When a mass is explicitely set with ephysics_body_mass_set(), the density will be unset.

It's useful in cases where a specific material needs to be simulated, so its density can be set and ephysics will calcute the body's mass.

By default, no density is set.

EPhysics has some pre-defined density values for materials:

- EPHYSICS_BODY_DENSITY_CONCRETE
- EPHYSICS_BODY_DENSITY_IRON
- EPHYSICS_BODY_DENSITY_PLASTIC
- EPHYSICS_BODY_DENSITY_POLYSTYRENE
- EPHYSICS_BODY_DENSITY_RUBBER
- EPHYSICS_BODY_DENSITY_WOOD

Note
  The unit used for density is kilograms / meters ^ 3.

Parameters

  body | The body to has its material density set.
  density | The `body's` material density, in kilograms / meters ^ 3.

See also
  ephysics_body_density_get().

## ephysics_body_density_get()

EAPI double ephysics_body_density_get | ( | const EPhysics_Body * | body | ) |

Get body's material density.

Parameters

  body | The physics body.

Returns
  the `body` material's density, in kilograms / meters ^ 3 or 0 if no density is set.

See also
  ephysics_body_density_set() for details.

## ephysics_body_volume_get()

EAPI double ephysics_body_volume_get | ( | const EPhysics_Body * | body | ) |

Get body's volume.

Note
  The unit of the returned value is meters ^ 3. Not pixels. Useful for calculation with mass and density.

Parameters

  body | The physics body.

Returns
  the `body's` volume, in meters ^ 3 or -1 on error.

See also
  ephysics_body_geometry_set().
  ephysics_body_geometry_get().

## ephysics_body_material_set()

EAPI void ephysics_body_material_set | ( | EPhysics_Body * | body,
|  | EPhysics_Body_Material | material )

Set body's material.

This function makes properties setting easy. When a material is set to a body, it will update its friction, restitution and density, recalculating its mass.

EPhysics support some materials defined by EPhysics_Body_Material.

So, for example, if EPHYSICS_BODY_MATERIAL_WOOD is set, it will set body's density to EPHYSICS_BODY_DENSITY_WOOD, restitution to EPHYSICS_BODY_RESTITUTION_WOOD and friction to EPHYSICS_BODY_FRICTION_WOOD.

If any of these values are later explicitely set, the material will be set back to EPHYSICS_BODY_MATERIAL_CUSTOM, the default.

Parameters

  body | The body to has its material set.
  material | The `material` to be used by the body.

See also
  ephysics_body_material_get().

## ephysics_body_material_get()

EAPI EPhysics_Body_Material ephysics_body_material_get | ( | const EPhysics_Body * | body | ) |

Get body's material.

Parameters

  body | The physics body.

Returns
  the `material` used by the body.

See also
  ephysics_body_material_set() for more details.

## ephysics_body_light_set()

EAPI void ephysics_body_light_set | ( | EPhysics_Body * | body,
|  | Eina_Bool | enable )

Set light effect over body.

Parameters

  body | The physics body.
  enable | If `EINA_TRUE`, light will be applied over this `body`, otherwise it won't.

It's possible to set the light to apply over all the bodies with ephysics_world_light_all_bodies_set(). This will have priority over body's individual light settings.

So, if `body` is set to doesn't be affect by the light, but light is set to be applied over all the bodies, `body` will be displayed with light over it.

See also
  ephysics_body_light_get().
  ephysics_world_point_light_position_set() for more details regarding lighting.

## ephysics_body_light_get()

EAPI Eina_Bool ephysics_body_light_get | ( | const EPhysics_Body * | body | ) |

Get light effect over body.

Parameters

  body | The physics body.

Returns
  `EINA_TRUE` if light is applied over this `body` or `EINA_FALSE` in the other case, or on error.

Note
  If light is applied over all the bodies it may return `EINA_FALSE` even if it's being affect by lights. This need to be checked with ephysics_world_light_all_bodies_get().

See also
  ephysics_body_light_set() for more details.

## ephysics_body_back_face_culling_set()

EAPI void ephysics_body_back_face_culling_set | ( | EPhysics_Body * | body,
|  | Eina_Bool | enable )

Set body's evas object to be hidden when it is counter-clockwise.

Parameters

  body | The physics body.
  enable | If `EINA_TRUE`, evas object will be hidden, otherwise it will be visible, rotated.

An object is said to be facing the user when all its points are placed in a clockwise fashion.

Note
  When back-face culling is enabled, evas object visibility will be handled by ephysics_body_evas_object_update().

See also
  ephysics_body_back_face_culling_get().
  ephysics_body_clockwise_get().
  ephysics_body_evas_object_set().

## ephysics_body_back_face_culling_get()

EAPI Eina_Bool ephysics_body_back_face_culling_get | ( | const EPhysics_Body * | body | ) |

Return if body's evas object will be hidden when it is counter-clockwise or not.

Parameters

  body | The physics body.

Returns
  `EINA_TRUE` if evas object will be hidden, or `EINA_FALSE` in the other case, or on error.

See also
  ephysics_body_back_face_culling_set() for more details.
  ephysics_body_clockwise_get().

## ephysics_body_clockwise_get()

EAPI Eina_Bool ephysics_body_clockwise_get | ( | const EPhysics_Body * | body | ) |

Get the clockwise state of a body.

This determines if the points of the evas object associated to the `body` are clockwise or counter-clockwise. This can be used for "back-face culling". * This is where you hide objects that "face away" from you. In this case objects that are not clockwise.

It can be set with ephysics_body_back_face_culling_set(), so EPhysics will handle visibility automatically on evas object update.

Note
  This information only will be updated on ephysics_body_evas_object_update(). So if a custom rendering is being done, this function won't return the current value of the evas object.

Parameters

  body | The physics body.

Returns
  `EINA_TRUE` if clockwise, `EINA_FALSE` otherwise or on error.

See also
  ephysics_body_back_face_culling_set() for more details.