Typedefs | Functions
EPhysics Constraint

Constraints can be used to limit bodies movements, between bodies or between bodies and the world. More...

Typedefs

typedef struct _EPhysics_Constraint EPhysics_Constraint
 Constraint handle, used to limit bodies movements. More...
 

Functions

EAPI EPhysics_Constraintephysics_constraint_linked_add (EPhysics_Body *body1, EPhysics_Body *body2)
 Create a new constraint between 2 bodies(Point to Point constraint). More...
 
EAPI void ephysics_constraint_anchor_set (EPhysics_Constraint *constraint, Evas_Coord anchor_b1_x, Evas_Coord anchor_b1_y, Evas_Coord anchor_b1_z, Evas_Coord anchor_b2_x, Evas_Coord anchor_b2_y, Evas_Coord anchor_b2_z)
 Change the constraints anchors values on both constrained bodies. More...
 
EAPI void ephysics_constraint_anchor_get (const EPhysics_Constraint *constraint, Evas_Coord *anchor_b1_x, Evas_Coord *anchor_b1_y, Evas_Coord *anchor_b1_z, Evas_Coord *anchor_b2_x, Evas_Coord *anchor_b2_y, Evas_Coord *anchor_b2_z)
 Get the constraints anchors values on both constrained bodies. More...
 
EAPI EPhysics_Constraintephysics_constraint_add (EPhysics_Body *body)
 Create a new constraint. More...
 
EAPI void ephysics_constraint_linear_limit_set (EPhysics_Constraint *constraint, Evas_Coord lower_x, Evas_Coord upper_x, Evas_Coord lower_y, Evas_Coord upper_y, Evas_Coord lower_z, Evas_Coord upper_z)
 Define the linear moving limits of a constraint. More...
 
EAPI void ephysics_constraint_linear_limit_get (const EPhysics_Constraint *constraint, Evas_Coord *lower_x, Evas_Coord *upper_x, Evas_Coord *lower_y, Evas_Coord *upper_y, Evas_Coord *lower_z, Evas_Coord *upper_z)
 Get the linear moving limits of a constraint. More...
 
EAPI void ephysics_constraint_angular_limit_set (EPhysics_Constraint *constraint, double counter_clock_x, double clock_wise_x, double counter_clock_y, double clock_wise_y, double counter_clock_z, double clock_wise_z)
 Set the angular moving limits of a constraint. More...
 
EAPI void ephysics_constraint_angular_limit_get (const EPhysics_Constraint *constraint, double *counter_clock_x, double *clock_wise_x, double *counter_clock_y, double *clock_wise_y, double *counter_clock_z, double *clock_wise_z)
 Get the angular moving limits of a constraint. More...
 
EAPI void ephysics_constraint_del (EPhysics_Constraint *constraint)
 Deletes a physics constraint. More...
 

Detailed Description

Constraints can be used to limit bodies movements, between bodies or between bodies and the world.

Constraints can limit movement angle, translation, or work like a motor.

Constraints can be created with ephysics_constraint_linked_add() or ephysics_constraint_add() and removed with ephysics_constraint_del(). Can be applied between two bodies or between a body and the world.

Typedef Documentation

◆ EPhysics_Constraint

typedef struct _EPhysics_Constraint EPhysics_Constraint

Constraint handle, used to limit bodies movements.

Created with ephysics_constraint_linked_add() or ephysics_constraint_add() and deleted with ephysics_constraint_del().

Function Documentation

◆ ephysics_constraint_linked_add()

EAPI EPhysics_Constraint * ephysics_constraint_linked_add ( EPhysics_Body body1,
EPhysics_Body body2 
)

Create a new constraint between 2 bodies(Point to Point constraint).

The constraint will join two bodies(body1 and body2) with angular and linear movements limited by calling ephysics_constraint_linear_limit_set() and ephysics_constraint_angular_limit_set(). Anchors values can be defined with ephysics_constraint_anchor_set().

Parameters
body1The first body to apply the constraint.
body2The second body to apply the constraint.
Returns
A new linked(joining 2 bodies) constraint or NULL, on errors.
See also
ephysics_constraint_del().
Examples
test_constraint.c.

◆ ephysics_constraint_anchor_set()

EAPI void ephysics_constraint_anchor_set ( EPhysics_Constraint constraint,
Evas_Coord  anchor_b1_x,
Evas_Coord  anchor_b1_y,
Evas_Coord  anchor_b1_z,
Evas_Coord  anchor_b2_x,
Evas_Coord  anchor_b2_y,
Evas_Coord  anchor_b2_z 
)

Change the constraints anchors values on both constrained bodies.

Note
By default the anchors are in the middle of a body, if a body of 20, 20 is positioned at (10, 10) then its anchor is set to (20, 20).
There`s no need to inform anchor_b2_x, anchor_b2_y and anchor_b2_z if the constraint has been created using ephysics_constraint_add().
Parameters
constraintThe constraint to be set.
anchor_b1_xThe first body X anchor.
anchor_b1_yThe first body Y anchor.
anchor_b1_zThe first body Z anchor.
anchor_b2_xThe second body X anchor.
anchor_b2_yThe second body Y anchor.
anchor_b2_zThe second body Z anchor.
See also
ephysics_constraint_anchor_get().
ephysics_constraint_linked_add().
Examples
test_constraint.c.

◆ ephysics_constraint_anchor_get()

EAPI void ephysics_constraint_anchor_get ( const EPhysics_Constraint constraint,
Evas_Coord anchor_b1_x,
Evas_Coord anchor_b1_y,
Evas_Coord anchor_b1_z,
Evas_Coord anchor_b2_x,
Evas_Coord anchor_b2_y,
Evas_Coord anchor_b2_z 
)

Get the constraints anchors values on both constrained bodies.

Parameters
constraintThe constraint to get anchor values from.
anchor_b1_xPointer to an Evas_Coord in which to store the first body X anchor value.
anchor_b1_yPointer to an Evas_Coord in which to store the first body Y anchor value.
anchor_b1_zPointer to an Evas_Coord in which to store the first body Z anchor value.
anchor_b2_xPointer to an Evas_Coord in which to store the second body X anchor value.
anchor_b2_yPointer to an Evas_Coord in which to store the second body Y anchor value.
anchor_b2_zPointer to an Evas_Coord in which to store the second body Z anchor value.
See also
ephysics_constraint_anchor_set().
ephysics_constraint_linked_add().

◆ ephysics_constraint_add()

EAPI EPhysics_Constraint * ephysics_constraint_add ( EPhysics_Body body)

Create a new constraint.

The constraint will limit the linear and angular moving of a body. This simple constraint is designated to constraint a single body.

Parameters
bodyThe body to apply the constraint.
See also
ephysics_constraint_linear_limit_set() for linear moving limit configuration.
ephysics_constraint_angular_limit_set() for angular moving limit configuration.
Returns
A new constraint or NULL on erros.
See also
ephysics_constraint_del().
Examples
test_slider.c.

◆ ephysics_constraint_linear_limit_set()

EAPI void ephysics_constraint_linear_limit_set ( EPhysics_Constraint constraint,
Evas_Coord  lower_x,
Evas_Coord  upper_x,
Evas_Coord  lower_y,
Evas_Coord  upper_y,
Evas_Coord  lower_z,
Evas_Coord  upper_z 
)

Define the linear moving limits of a constraint.

The linear limits are defined from the body's position on. The user will want to limit the movements on X, Y and Z axis where lower == upper axis will be locked, lower > upper axis is free, lower < upper axis is limited to the range.

The unit for every limits are defined on Evas coordinates.

Parameters
constraintThe constraint to be set.
lower_xThe lower linear moving limit on X axis.
upper_xThe upper linear moving limit on X axis.
lower_yThe lower linear moving limit on Y axis.
upper_yThe upper linear moving limit on Y axis.
lower_zThe lower linear moving limit on Z axis.
upper_zThe upper linear moving limit on Z axis.
See also
ephysics_constraint_linear_limit_get()
Examples
test_slider.c.

◆ ephysics_constraint_linear_limit_get()

EAPI void ephysics_constraint_linear_limit_get ( const EPhysics_Constraint constraint,
Evas_Coord lower_x,
Evas_Coord upper_x,
Evas_Coord lower_y,
Evas_Coord upper_y,
Evas_Coord lower_z,
Evas_Coord upper_z 
)

Get the linear moving limits of a constraint.

Parameters
constraintThe constraint to get linear limits from.
lower_xPointer to set with the lower limit to the X axis.
upper_xPointer to set with the upper limit to the X axis.
lower_yPointer to set with the lower limit to the Y axis.
upper_yPointer to set with the upper limit to the Y axis.
lower_zPointer to set with the lower limit to the Z axis.
upper_zPointer to set with the upper limit to the Z axis.
See also
ephysics_constraint_linear_limit_set()

◆ ephysics_constraint_angular_limit_set()

EAPI void ephysics_constraint_angular_limit_set ( EPhysics_Constraint constraint,
double  counter_clock_x,
double  clock_wise_x,
double  counter_clock_y,
double  clock_wise_y,
double  counter_clock_z,
double  clock_wise_z 
)

Set the angular moving limits of a constraint.

The angular moving limits is defined in degrees and will limit the moving on Z axis - counter clockwise and clockwise directions.

Parameters
constraintThe constraint to be set.
counter_clock_xAmount of degrees from 0.0 to 360.0 to limit counter clockwise rotation on X axis.
clock_wise_xAmount of degrees from 0.0 to 360.0 to limit clockwise rotation on X axis.
counter_clock_yAmount of degrees from 0.0 to 360.0 to limit counter clockwise rotation o Y axis.
clock_wise_yAmount of degrees from 0.0 to 360.0 to limit clockwise rotation on Y axis.
counter_clock_zAmount of degrees from 0.0 to 360.0 to limit counter clockwise rotation on Z axis.
clock_wise_zAmount of degrees from 0.0 to 360.0 to limit clockwise rotation on Z axis.
See also
ephysics_constraint_angular_limit_get()
Examples
test_slider.c.

◆ ephysics_constraint_angular_limit_get()

EAPI void ephysics_constraint_angular_limit_get ( const EPhysics_Constraint constraint,
double *  counter_clock_x,
double *  clock_wise_x,
double *  counter_clock_y,
double *  clock_wise_y,
double *  counter_clock_z,
double *  clock_wise_z 
)

Get the angular moving limits of a constraint.

Parameters
constraintThe constraint to get the angular limits from.
counter_clock_xPointer to set with the counter clockwise limmit degrees on X axis.
clock_wise_xPointer to set with the clockwise limit degrees on X axis.
counter_clock_yPointer to set with the counter clockwise limit degrees on Y axis.
clock_wise_yPointer to set with the clockwise limit degrees on Y axis.
counter_clock_zPointer to set with the counter clockwise limit degrees on Z axis.
clock_wise_zPointer to set with the clockwise limit degrees on Z axis.
See also
ephysics_constraint_angular_limit_set()

◆ ephysics_constraint_del()

EAPI void ephysics_constraint_del ( EPhysics_Constraint constraint)

Deletes a physics constraint.

Parameters
constraintThe constraint to be deleted.
See also
ephysics_constraint_linked_add() for more details.
ephysics_constraint_slider_add() for more details.