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. More... | |
#define | EPHYSICS_BODY_DENSITY_WOOD (680.0) |
Density of wood in kg / m ^ 3. More... | |
#define | EPHYSICS_BODY_DENSITY_IRON (7400.0) |
Density of iron in kg / m ^ 3. More... | |
#define | EPHYSICS_BODY_DENSITY_CONCRETE (2300.0) |
Density of concrete in kg / m ^ 3. More... | |
#define | EPHYSICS_BODY_DENSITY_RUBBER (920.0) |
Density of rubber in kg / m ^ 3. More... | |
#define | EPHYSICS_BODY_DENSITY_POLYSTYRENE (80.0) |
Density of polystyrene in kg / m ^ 3. More... | |
#define | EPHYSICS_BODY_DENSITY_PLASTIC (1300.0) |
Density of plastic in kg / m ^ 3. More... | |
#define | EPHYSICS_BODY_FRICTION_WOOD (0.4) |
Friction coefficient of wood. More... | |
#define | EPHYSICS_BODY_FRICTION_IRON (0.8) |
Friction coefficient of iron. More... | |
#define | EPHYSICS_BODY_FRICTION_CONCRETE (0.65) |
Friction coefficient of concrete. More... | |
#define | EPHYSICS_BODY_FRICTION_RUBBER (0.75) |
Friction coefficient of rubber. More... | |
#define | EPHYSICS_BODY_FRICTION_POLYSTYRENE (0.5) |
Friction coefficient of polystyrene. More... | |
#define | EPHYSICS_BODY_FRICTION_PLASTIC (0.35) |
Friction coefficient of plastic. More... | |
#define | EPHYSICS_BODY_RESTITUTION_WOOD (0.7) |
Restitution coefficient of wood. More... | |
#define | EPHYSICS_BODY_RESTITUTION_IRON (0.85) |
Restitution coefficient of iron. More... | |
#define | EPHYSICS_BODY_RESTITUTION_CONCRETE (0.75) |
Restitution coefficient of concrete. More... | |
#define | EPHYSICS_BODY_RESTITUTION_RUBBER (0.3) |
Restitution coefficient of rubber. More... | |
#define | EPHYSICS_BODY_RESTITUTION_POLYSTYRENE (0.5) |
Restitution coefficient of polystyrene. More... | |
#define | EPHYSICS_BODY_RESTITUTION_PLASTIC (0.6) |
Restitution coefficient of plastic. More... | |
Typedefs | |
typedef enum _EPhysics_Body_Cloth_Anchor_Side | EPhysics_Body_Cloth_Anchor_Side |
Identifier of cloth anchor sides. More... | |
typedef enum _EPhysics_Body_Face | EPhysics_Body_Face |
Define in which body's face the evas object should be set. More... | |
typedef struct _EPhysics_Body_Collision | EPhysics_Body_Collision |
Body collision wraps collision informations. More... | |
typedef enum _EPhysics_Callback_Body_Type | EPhysics_Callback_Body_Type |
The types of events triggering a callback. More... | |
typedef enum _EPhysics_Body_Material | EPhysics_Body_Material |
The types of materials to be set on a body. More... | |
typedef void(* | EPhysics_Body_Event_Cb) (void *data, EPhysics_Body *body, void *event_info) |
EPhysics body event callback function signature. More... | |
typedef struct _EPhysics_Body | EPhysics_Body |
Body handle, represents an object on EPhysics world. More... | |
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. More... | |
EAPI double | ephysics_body_soft_body_hardness_get (const EPhysics_Body *body) |
Get the soft body hardness percentage. More... | |
EAPI void | ephysics_body_soft_body_anchor_hardness_set (EPhysics_Body *body, double hardness) |
Set the soft body anchor hardness percentage. More... | |
EAPI double | ephysics_body_soft_body_anchor_hardness_get (EPhysics_Body *body) |
Get the soft body anchor hardnees percentage. More... | |
EAPI void | ephysics_body_soft_body_drag_coefficient_set (EPhysics_Body *body, double coefficient) |
Set the drag coefficient of a soft body. More... | |
EAPI double | ephysics_body_soft_body_drag_coefficient_get (const EPhysics_Body *body) |
Get the drag coefficient of a soft body. More... | |
EAPI void | ephysics_body_soft_body_dragging_set (EPhysics_Body *body, int triangle) |
Set the soft body dragging status. More... | |
EAPI void | ephysics_body_soft_body_dragging_unset (EPhysics_Body *body) |
Unset the soft body dragging status. More... | |
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 . More... | |
EAPI int | ephysics_body_soft_body_slice_index_get (EPhysics_Body *body, Evas_Object *slice) |
Get the slice index of a soft body based on its slice`s Evas Object. More... | |
EAPI EPhysics_Body * | ephysics_body_soft_sphere_add (EPhysics_World *world, int granularity) |
Add a soft sphere. More... | |
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. More... | |
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. More... | |
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. More... | |
EAPI void | ephysics_body_soft_body_position_iterations_set (EPhysics_Body *body, int iterations) |
Set the soft body number of position iterations. More... | |
EAPI int | ephysics_body_soft_body_position_iterations_get (EPhysics_Body *body) |
Get the soft body number of position iterations. More... | |
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. More... | |
EAPI void | ephysics_body_soft_body_bending_constraints_add (EPhysics_Body *body, int number) |
Add new bending constraints to some body . More... | |
EAPI EPhysics_Body * | ephysics_body_sphere_add (EPhysics_World *world) |
Create a new sphere physics body. More... | |
EAPI EPhysics_Body * | ephysics_body_cylinder_add (EPhysics_World *world) |
Create a new cylinder physics body. More... | |
EAPI EPhysics_Body * | ephysics_body_soft_cylinder_add (EPhysics_World *world) |
Create a new deformable cylinder physics body. More... | |
EAPI EPhysics_Body * | ephysics_body_box_add (EPhysics_World *world) |
Create a new box physics body. More... | |
EAPI EPhysics_Body * | ephysics_body_soft_box_add (EPhysics_World *world) |
Create a new deformable box physics body. More... | |
EAPI EPhysics_Body * | ephysics_body_cloth_add (EPhysics_World *world, unsigned short rows, unsigned short columns) |
Create a new deformable cloth physics body. More... | |
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. More... | |
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. More... | |
EAPI void | ephysics_body_cloth_anchor_del (EPhysics_Body *body) |
Removes the anchors in a cloth body. More... | |
EAPI EPhysics_Body * | ephysics_body_shape_add (EPhysics_World *world, EPhysics_Shape *shape) |
Create a new physics body using a custom shape. More... | |
EAPI EPhysics_Body * | ephysics_body_top_boundary_add (EPhysics_World *world) |
Create a physic top boundary. More... | |
EAPI EPhysics_Body * | ephysics_body_bottom_boundary_add (EPhysics_World *world) |
Create a physic bottom boundary. More... | |
EAPI EPhysics_Body * | ephysics_body_left_boundary_add (EPhysics_World *world) |
Create a physic left boundary. More... | |
EAPI EPhysics_Body * | ephysics_body_right_boundary_add (EPhysics_World *world) |
Create a physic right boundary. More... | |
EAPI EPhysics_Body * | ephysics_body_front_boundary_add (EPhysics_World *world) |
Create a physic front boundary. More... | |
EAPI EPhysics_Body * | ephysics_body_back_boundary_add (EPhysics_World *world) |
Create a physic back boundary. More... | |
EAPI void | ephysics_body_del (EPhysics_Body *body) |
Delete a physics body. More... | |
EAPI EPhysics_World * | ephysics_body_world_get (const EPhysics_Body *body) |
Get the world a body belongs to. More... | |
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. More... | |
EAPI Evas_Object * | ephysics_body_evas_object_unset (EPhysics_Body *body) |
Unset the evas object associated to a physics body. More... | |
EAPI Evas_Object * | ephysics_body_evas_object_get (const EPhysics_Body *body) |
Get the evas object associated to a physics body. More... | |
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. More... | |
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. More... | |
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. More... | |
EAPI void | ephysics_body_resize (EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d) |
Set physics body size. More... | |
EAPI void | ephysics_body_move (EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z) |
Set physics body position. More... | |
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. More... | |
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. More... | |
EAPI void | ephysics_body_mass_set (EPhysics_Body *body, double mass) |
Set body's mass. More... | |
EAPI double | ephysics_body_mass_get (const EPhysics_Body *body) |
Get body's mass. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
EAPI void | ephysics_body_sleeping_threshold_set (EPhysics_Body *body, double linear_threshold, double angular_threshold) |
Set the linear and angular sleeping threshold. More... | |
EAPI void | ephysics_body_sleeping_threshold_get (const EPhysics_Body *body, double *linear_threshold, double *angular_threshold) |
Get the linear sleeping threshold. More... | |
EAPI void | ephysics_body_stop (EPhysics_Body *body) |
Stop angular and linear body movement. More... | |
EAPI void | ephysics_body_damping_set (EPhysics_Body *body, double linear_damping, double angular_damping) |
Set the angular and linear damping values. More... | |
EAPI void | ephysics_body_damping_get (const EPhysics_Body *body, double *linear_damping, double *angular_damping) |
Get the angular and linear damping values. More... | |
EAPI Eina_Bool | ephysics_body_collision_group_add (EPhysics_Body *body, const char *group) |
Add a body to a given collision group. More... | |
EAPI Eina_Bool | ephysics_body_collision_group_del (EPhysics_Body *body, const char *group) |
Removes body from collision group . More... | |
EAPI const Eina_List * | ephysics_body_collision_group_list_get (const EPhysics_Body *body) |
Get the collision group list of body . More... | |
EAPI void | ephysics_body_evas_object_update (EPhysics_Body *body) |
Update the evas object associated to the body. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
EAPI EPhysics_Body * | ephysics_body_collision_contact_body_get (const EPhysics_Body_Collision *collision) |
Get the body's collision contact body. More... | |
EAPI void | ephysics_body_restitution_set (EPhysics_Body *body, double restitution) |
Set body's coefficient of restitution. More... | |
EAPI double | ephysics_body_restitution_get (const EPhysics_Body *body) |
Get body's restitution. More... | |
EAPI void | ephysics_body_friction_set (EPhysics_Body *body, double friction) |
Set body's friction. More... | |
EAPI double | ephysics_body_friction_get (const EPhysics_Body *body) |
Get body's friction. More... | |
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. More... | |
EAPI void | ephysics_body_torque_impulse_apply (EPhysics_Body *body, double pitch, double yaw, double roll) |
Apply a torque impulse over a body. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
EAPI EPhysics_Quaternion * | ephysics_body_rotation_get (const EPhysics_Body *body, EPhysics_Quaternion *rotation) |
Get body's rotation quaternion. More... | |
EAPI void | ephysics_body_rotation_set (EPhysics_Body *body, EPhysics_Quaternion *quat) |
Set body's rotation. More... | |
EAPI void | ephysics_body_data_set (EPhysics_Body *body, void *data) |
Set data to body . More... | |
EAPI void * | ephysics_body_data_get (const EPhysics_Body *body) |
Return data previously set to body. More... | |
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. More... | |
EAPI void | ephysics_body_torque_apply (EPhysics_Body *body, double torque_x, double torque_y, double torque_z) |
Apply a torque over a body. More... | |
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. More... | |
EAPI void | ephysics_body_forces_get (const EPhysics_Body *body, double *x, double *y, double *z) |
Get physics body forces. More... | |
EAPI void | ephysics_body_torques_get (const EPhysics_Body *body, double *x, double *y, double *z) |
Get physics body torques. More... | |
EAPI void | ephysics_body_forces_clear (EPhysics_Body *body) |
Clear all the forces applied to a body. More... | |
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. More... | |
EAPI void | ephysics_body_density_set (EPhysics_Body *body, double density) |
Set body's material density. More... | |
EAPI double | ephysics_body_density_get (const EPhysics_Body *body) |
Get body's material density. More... | |
EAPI double | ephysics_body_volume_get (const EPhysics_Body *body) |
Get body's volume. More... | |
EAPI void | ephysics_body_material_set (EPhysics_Body *body, EPhysics_Body_Material material) |
Set body's material. More... | |
EAPI EPhysics_Body_Material | ephysics_body_material_get (const EPhysics_Body *body) |
Get body's material. More... | |
EAPI void | ephysics_body_light_set (EPhysics_Body *body, Eina_Bool enable) |
Set light effect over body. More... | |
EAPI Eina_Bool | ephysics_body_light_get (const EPhysics_Body *body) |
Get light effect over body. More... | |
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. More... | |
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. More... | |
EAPI Eina_Bool | ephysics_body_clockwise_get (const EPhysics_Body *body) |
Get the clockwise state of a body. More... | |
A body is a representation of an object inside a physics world.
Bodies can have different shapes that can be created with:
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:
They can collide and have customizable properties, like:
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:
Impulses can be applied with:
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.
#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.
#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().
#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().
#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().
#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().
#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().
#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().
#define EPHYSICS_BODY_FRICTION_WOOD (0.4) |
Friction coefficient of wood.
It can be set to a body with ephysics_body_friction_set().
#define EPHYSICS_BODY_FRICTION_IRON (0.8) |
Friction coefficient of iron.
It can be set to a body with ephysics_body_friction_set().
#define EPHYSICS_BODY_FRICTION_CONCRETE (0.65) |
Friction coefficient of concrete.
It can be set to a body with ephysics_body_friction_set().
#define EPHYSICS_BODY_FRICTION_RUBBER (0.75) |
Friction coefficient of rubber.
It can be set to a body with ephysics_body_friction_set().
#define EPHYSICS_BODY_FRICTION_POLYSTYRENE (0.5) |
Friction coefficient of polystyrene.
It can be set to a body with ephysics_body_friction_set().
#define EPHYSICS_BODY_FRICTION_PLASTIC (0.35) |
Friction coefficient of plastic.
It can be set to a body with ephysics_body_friction_set().
#define EPHYSICS_BODY_RESTITUTION_WOOD (0.7) |
Restitution coefficient of wood.
It can be set to a body with ephysics_body_restitution_set().
#define EPHYSICS_BODY_RESTITUTION_IRON (0.85) |
Restitution coefficient of iron.
It can be set to a body with ephysics_body_restitution_set().
#define EPHYSICS_BODY_RESTITUTION_CONCRETE (0.75) |
Restitution coefficient of concrete.
It can be set to a body with ephysics_body_restitution_set().
#define EPHYSICS_BODY_RESTITUTION_RUBBER (0.3) |
Restitution coefficient of rubber.
It can be set to a body with ephysics_body_restitution_set().
#define EPHYSICS_BODY_RESTITUTION_POLYSTYRENE (0.5) |
Restitution coefficient of polystyrene.
It can be set to a body with ephysics_body_restitution_set().
#define EPHYSICS_BODY_RESTITUTION_PLASTIC (0.6) |
Restitution coefficient of plastic.
It can be set to a body with ephysics_body_restitution_set().
Identifier of cloth anchor sides.
Define in which body's face the evas object should be set.
Body collision wraps collision informations.
EPhysics_Body_Collision is used on EPHYSICS_CALLBACK_BODY_COLLISION callback and is mostly interested to hold informations like:
The types of events triggering a callback.
Identifier of callbacks to be set for EPhysics bodies.
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.
EPhysics_Body_Event_Cb |
EPhysics body event callback function signature.
Callbacks can be registered for events like body updating or deleting.
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 . |
Body handle, represents an object on EPhysics world.
Many types of bodies can be created:
and it can be deleted with ephysics_body_del().
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.
body | The body to be set. |
hardness | The percentage of deformation. |
EAPI double ephysics_body_soft_body_hardness_get | ( | const EPhysics_Body * | body | ) |
Get the soft body hardness percentage.
body | The body of interest. |
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.
hardness
will range from 0 - 100.body | The body to be set. |
hardness | The hardness to be set to body . |
EAPI double ephysics_body_soft_body_anchor_hardness_get | ( | EPhysics_Body * | body | ) |
Get the soft body anchor hardnees percentage.
body | The body to get the anchor hardness percentage from. |
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.
body | The body to be set. |
coefficient | The drag coefficient. |
EAPI double ephysics_body_soft_body_drag_coefficient_get | ( | const EPhysics_Body * | body | ) |
Get the drag coefficient of a soft body.
body | The body to get the drag coefficient from. |
body
on success, -1 on failure.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().
triangle
will have no mass until it dragging gets unset.body | The body of interest. |
triangle | The triangle to freeze. |
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.
body | The body to unset the 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
.
Given a point in x
and y
a ray cast is performed and if a triangle is found its index is returned.
body | The body to get the triangle index from. |
x | The x coord. |
y | The y coord. |
EAPI int ephysics_body_soft_body_slice_index_get | ( | EPhysics_Body * | body, |
Evas_Object * | slice | ||
) |
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.
body | The body to get the slice index from. |
slice | The slice evas object. |
EAPI EPhysics_Body * ephysics_body_soft_sphere_add | ( | EPhysics_World * | world, |
int | granularity | ||
) |
Add a soft sphere.
Add a new soft 3d sphere to the simulation. The granularity
defines how many triangles are to be added.
granularity
is informed(i.e granularity
= 0) the soft body will be created with a triangle mesh of 100.world | The world the new soft sphere is to be added. |
granularity | How many triangles the soft body triangle mesh must have. |
NULL
on errors.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
.
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. |
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.
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 |
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
.
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. |
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.
body | The body to be set. |
iterations | The number of iterations. |
EAPI int ephysics_body_soft_body_position_iterations_get | ( | EPhysics_Body * | body | ) |
Get the soft body number of position iterations.
body | The body to get the number os position iterations from. |
body
.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
.
body | The body of interest. |
idx | The triangle index. |
x | The x coordinate. |
y | The y coordinate. |
z | The z coordinate. |
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.
body | The body to add bending constraints to. |
number | The number of bending constraints to be added, it must be greater than 0. |
EAPI EPhysics_Body * ephysics_body_sphere_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.
world | The world this body will belong to. |
NULL
, on errors.EAPI EPhysics_Body * ephysics_body_cylinder_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().
world | The world this body will belongs to. |
NULL
, on errors.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.
For a rigid cylinder, check ephysics_body_cylinder_add().
world | The world this body will belongs to. |
NULL
, on errors.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().
world | The world this body will belongs to. |
NULL
, on errors.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.
For a rigid cylinder, check ephysics_body_cylinder_add().
world | The world this body will belong to. |
NULL
on errors.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
.
world | The world this body will belong to. |
rows | The number os rows. |
columns | The number of columns. |
NULL
on erros.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.
body1 | The cloth body to be anchored. |
body2 | The body to be anchored to. |
side | The side to be anchored. |
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.
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.
body1 | The cloth body to be anchored. |
body2 | The body to be anchored to. |
node | The node index to be anchored. |
EAPI void ephysics_body_cloth_anchor_del | ( | EPhysics_Body * | body | ) |
Removes the anchors in a cloth body.
body | The body to delete anchors from. |
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().
world | The world this body will belongs to. |
shape | The custom shape to be used. |
NULL
, on errors.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().
world | The world this body will belong to. |
NULL
, on erros. 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().
world | The world this body will belong to. |
NULL
, on erros. 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().
world | The world this body will belong to. |
NULL
, on erros. 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().
world | The world this body will belong to. |
NULL
, on erros. 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.
world | The world this body will belong to. |
NULL
, on erros. 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.
world | The world this body will belong to. |
NULL
, on erros. 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.
body | The body to be deleted. |
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.
body | The physics body. |
NULL
on error. 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.
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. |
EAPI Evas_Object * ephysics_body_evas_object_unset | ( | EPhysics_Body * | body | ) |
Unset the evas object associated to a physics body.
body | The body to unset an evas object from. |
NULL
if no object is associated or on error.EAPI Evas_Object * ephysics_body_evas_object_get | ( | const EPhysics_Body * | body | ) |
Get the evas object associated to a physics body.
body | The body to get an evas object from. |
NULL
if no object is associated or on error.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
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. |
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.
body | The body to get an evas object from. |
face | The specific face of body where the evas object was placed. |
NULL
if no object is associated or on error.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.
body | The body to unset an evas object from. |
face | The specific face of body where the evas object was placed. |
NULL
if no object is associated or on error.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:
body | The body to be resized. |
w | The body width, in pixels. |
h | The body height, in pixels. |
d | The body depth, in pixels. |
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:
When the world is simulated forces will be applied on objects with mass and position will be modified too.
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. |
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:
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.
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. |
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.
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. |
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.
body | The body to has its mass set. |
mass | The body's mass, in kilograms. |
EAPI double ephysics_body_mass_get | ( | const EPhysics_Body * | body | ) |
Get body's mass.
It will get inertial mass of the body.
body | The physics body. |
body
mass, in kilograms.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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
linear_threshold
is the body's speed. It is measured in Evas coordinates per second.angular_threshold
is measured in degrees per second.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). |
EAPI void ephysics_body_sleeping_threshold_get | ( | const EPhysics_Body * | body, |
double * | linear_threshold, | ||
double * | angular_threshold | ||
) |
Get the linear sleeping threshold.
body | The body to get the linear sleeping threshold from. |
linear_threshold | The linear sleeping threshold factor. |
angular_threshold | The angular sleeping threshold factor. |
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.
body | The physics body. |
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.
body | The physics body. |
linear_damping | The linear damping factor to apply on body . |
angular_damping | The angular damping factor to apply on body . |
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.
body | The physics body. |
linear_damping | The linear damping factor applied over body . |
angular_damping | The angular damping factor applied over body . |
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.
body | The body to be added to group . |
group | The group the body will belong to. |
EINA_TRUE
if body is added to group, or EINA_FALSE
on error.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.
body | The body to be removed from group . |
group | The group body must be removed from. |
EINA_TRUE
if body is removed from group, or EINA_FALSE
on error.EAPI const Eina_List * ephysics_body_collision_group_list_get | ( | const EPhysics_Body * | body | ) |
Get the collision group list of body
.
body | The body of interest. |
body
, NULL on failure or case no group has been added to body
.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.
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:
Update callbacks receives evas object set to body as event_info argument.
What follows is a list of details about each callback type:
body
points to the EPhysics_Body itself and event_info
points to the evas object associated to the body.body
argument. event_info
is a pointer to EPhysics_Body_Collision - note, this structure(event_info
) is discarded/freed right after callback returns.body
points to the body being deleted and event_info
is a pointer to the evas object associated to it.body
points to the body of interest and event_info
is a pointer to the evas object associated to it.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. |
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.
body | The physics body. |
type | The type of callback to be unregistered. |
func | The callback function to be unregistered. |
NULL
on error.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.
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. |
NULL
on error.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.
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. |
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.
collision | The body collision of interest. |
collision
.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:
By default restitution coefficient of each body is 0.
EPhysics has some pre-defined restitution coefficients for materials:
body | The body to has its restitution coefficient set. |
restitution | The new body's restitution coefficient. |
EAPI double ephysics_body_restitution_get | ( | const EPhysics_Body * | body | ) |
Get body's restitution.
body | The physics body. |
body's
restitution value.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:
body | The body to has its friction set. |
friction | The new body's friction value. |
EAPI double ephysics_body_friction_get | ( | const EPhysics_Body * | body | ) |
Get body's friction.
body | The physics body. |
body's
friction value.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().
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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).
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). |
NULL
on error.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.
body | The physics body. |
quat | Quaternion representing the rotation. |
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.
body | The physics body. |
data | The data to be set. |
EAPI void * ephysics_body_data_get | ( | const EPhysics_Body * | body | ) |
Return data previously set to body.
body | The physics body. |
NULL
on error.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().
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. |
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.
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. |
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.
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. |
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.
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. |
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.
body | The physics body. |
x | The torque on x axis. |
y | The torque on y axis. |
z | The torque on z axis. |
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.
body | The physics body that will have applied forces set to 0. |
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.
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. |
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:
body | The body to has its material density set. |
density | The body's material density, in kilograms / meters ^ 3. |
EAPI double ephysics_body_density_get | ( | const EPhysics_Body * | body | ) |
Get body's material density.
body | The physics body. |
body
material's density, in kilograms / meters ^ 3 or 0 if no density is set.EAPI double ephysics_body_volume_get | ( | const EPhysics_Body * | body | ) |
Get body's volume.
body | The physics body. |
body's
volume, in meters ^ 3 or -1 on error.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.
body | The body to has its material set. |
material | The material to be used by the body. |
EAPI EPhysics_Body_Material ephysics_body_material_get | ( | const EPhysics_Body * | body | ) |
Get body's material.
body | The physics body. |
material
used by the body.EAPI void ephysics_body_light_set | ( | EPhysics_Body * | body, |
Eina_Bool | enable | ||
) |
Set light effect over body.
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.
EAPI Eina_Bool ephysics_body_light_get | ( | const EPhysics_Body * | body | ) |
Get light effect over body.
body | The physics body. |
EINA_TRUE
if light is applied over this body
or EINA_FALSE
in the other case, or on error.EINA_FALSE
even if it's being affect by lights. This need to be checked with ephysics_world_light_all_bodies_get().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.
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.
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.
body | The physics body. |
EINA_TRUE
if evas object will be hidden, or EINA_FALSE
in the other case, or on error.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.
body | The physics body. |
EINA_TRUE
if clockwise, EINA_FALSE
otherwise or on error.