It will apply a central impulse over a body's part.
SVN revision: 80278
@effect
Action to be performed by the program. Valid actions are: STATE_SET,
ACTION_STOP, SIGNAL_EMIT, DRAG_VAL_SET, DRAG_VAL_STEP, DRAG_VAL_PAGE,
- FOCUS_SET, PARAM_COPY, PARAM_SET, PLAY_SAMPLE, PLAY_TONE
+ FOCUS_SET, PARAM_COPY, PARAM_SET, PLAY_SAMPLE, PLAY_TONE,
+ PHYSICS_IMPULSE
Only one action can be specified per program. Examples:\n
action: STATE_SET "statename" 0.5;\n
action: ACTION_STOP;\n
action: PARAM_SET "part" "param" "value";\n
action: PLAY_SAMPLE "sample name";\n
action: PLAY_TONE "tone name" duration in seconds ( Range 0.1 to 10.0 );\n
+ action: PHYSICS_IMPULSE 10 -23.4 0;\n
@endproperty
*/
static void
"PARAM_SET", EDJE_ACTION_TYPE_PARAM_SET,
"PLAY_SAMPLE", EDJE_ACTION_TYPE_SOUND_SAMPLE,
"PLAY_TONE", EDJE_ACTION_TYPE_SOUND_TONE,
+ "PHYSICS_IMPULSE", EDJE_ACTION_TYPE_PHYSICS_IMPULSE,
NULL);
if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
{
data_queue_part_lookup(pc, part, &(ep->param.dst));
free(part);
}
-
+#ifdef HAVE_EPHYSICS
+ else if (ep->action == EDJE_ACTION_TYPE_PHYSICS_IMPULSE)
+ {
+ ep->physics.impulse.x = parse_float(1);
+ ep->physics.impulse.y = parse_float(2);
+ ep->physics.impulse.z = parse_float(3);
+ }
+#endif
+
switch (ep->action)
{
case EDJE_ACTION_TYPE_ACTION_STOP:
case EDJE_ACTION_TYPE_SOUND_TONE:
check_arg_count(3);
break;
+ case EDJE_ACTION_TYPE_PHYSICS_IMPULSE:
+ check_arg_count(4);
+ break;
default:
check_arg_count(3);
}
data_queue_part_lookup(pc, name, &(et->id));
else if (ep->action == EDJE_ACTION_TYPE_FOCUS_OBJECT)
data_queue_part_lookup(pc, name, &(et->id));
+#ifdef HAVE_EPHYSICS
+ else if (ep->action == EDJE_ACTION_TYPE_PHYSICS_IMPULSE)
+ data_queue_part_lookup(pc, name, &(et->id));
+#endif
else
{
ERR("parse error %s:%i. target may only be used after action",
if ENABLE_EPHYSICS
EDCS += \
+physics_actions.edc \
physics_basic.edc \
physics_complex.edc
endif
--- /dev/null
+/* It can be tested with edje_player slave mode
+ * $ edje_player -S physics_actions.edj
+ * signal up impulse -> will throw both balls up
+ * signal left impulse -> will throw blue ball to the left
+ */
+
+collections {
+
+ images {
+ image: "bubble-blue.png" COMP;
+ }
+
+ group {
+ name: "example_group";
+
+ parts {
+ part {
+ name: "background";
+ type: RECT;
+ physics_body: NONE;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 255; /* white */
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 1.0 1.0;
+ }
+ }
+
+ part {
+ name: "blue_circle";
+ type: IMAGE;
+ physics_body: RIGID_CIRCLE;
+ description {
+ state: "default" 0.0;
+ rel1.relative: 0.35 0.1;
+ rel2.relative: 0.55 0.2;
+ aspect: 1 1;
+ image {
+ normal: "bubble-blue.png";
+ }
+ physics {
+ restitution: 0.85;
+ friction: 1.0;
+ }
+ }
+ }
+
+ part {
+ name: "red_circle";
+ type: IMAGE;
+ physics_body: RIGID_CIRCLE;
+ description {
+ state: "default" 0.0;
+ color: 255 0 0 255; /* light red */
+ rel1.relative: 0.65 0.1;
+ rel2.relative: 0.85 0.2;
+ aspect: 1 1;
+ image {
+ normal: "bubble-blue.png";
+ }
+ physics {
+ restitution: 0.85;
+ friction: 1.0;
+ }
+ }
+ }
+
+ part {
+ name: "floor";
+ type: RECT;
+ physics_body: BOUNDARY_BOTTOM;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ physics {
+ restitution: 0.6;
+ friction: 1.0;
+ }
+ }
+ }
+
+ part {
+ name: "right_wall";
+ type: RECT;
+ physics_body: BOUNDARY_RIGHT;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ physics {
+ restitution: 0.3;
+ }
+ }
+ }
+
+ part {
+ name: "left_wall";
+ type: RECT;
+ physics_body: BOUNDARY_LEFT;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ physics {
+ restitution: 0.3;
+ }
+ }
+ }
+
+ part {
+ name: "roof";
+ type: RECT;
+ physics_body: BOUNDARY_TOP;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ physics {
+ restitution: 0.2;
+ }
+ }
+ }
+ }
+
+ programs {
+
+ program {
+ name: "impulse_up";
+ signal: "up";
+ source: "impulse";
+ action: PHYSICS_IMPULSE 0 -300 0;
+ target: "blue_circle";
+ target: "red_circle";
+ }
+
+ program {
+ name: "impulse_down";
+ signal: "down";
+ source: "impulse";
+ action: PHYSICS_IMPULSE 0 300 0;
+ target: "red_circle";
+ target: "blue_circle";
+ }
+
+ program {
+ name: "impulse_left";
+ signal: "left";
+ source: "impulse";
+ action: PHYSICS_IMPULSE -300 0 0;
+ target: "blue_circle";
+ }
+
+ program {
+ name: "impulse_right";
+ signal: "right";
+ source: "impulse";
+ action: PHYSICS_IMPULSE 300 0 0;
+ target: "red_circle";
+ }
+
+ }
+
+ }
+}
EDJE_ACTION_TYPE_PARAM_SET = 12,
EDJE_ACTION_TYPE_SOUND_SAMPLE = 13, /**< @since 1.1 */
EDJE_ACTION_TYPE_SOUND_TONE = 14, /**< @since 1.1 */
- EDJE_ACTION_TYPE_LAST = 15
+ EDJE_ACTION_TYPE_PHYSICS_IMPULSE = 15, /**< @since 1.8 */
+ EDJE_ACTION_TYPE_LAST = 16
} Edje_Action_Type;
/**
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "param.src", param.src, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "param.dst", param.dst, EET_T_INT);
+#ifdef HAVE_EPHYSICS
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "physics.impulse.x", physics.impulse.x, EET_T_DOUBLE);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "physics.impulse.y", physics.impulse.y, EET_T_DOUBLE);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "physics.impulse.z", physics.impulse.z, EET_T_DOUBLE);
+#endif
+
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id);
_edje_edd_edje_part_image_id =
eet_data_descriptor_file_new(&eddc);
int dst; /* part where parameter is being stored */
} param;
+#ifdef HAVE_EPHYSICS
+ /* used for actions related to physics, as PHYSICS_IMPULSE */
+ struct {
+ struct {
+ double x;
+ double y;
+ double z;
+ } impulse;
+ } physics;
+#endif
+
Eina_Bool exec : 1;
};
if (_edje_block_break(ed)) goto break_prog;
}
break;
+#ifdef HAVE_EPHYSICS
+ case EDJE_ACTION_TYPE_PHYSICS_IMPULSE:
+ if (_edje_block_break(ed))
+ goto break_prog;
+ EINA_LIST_FOREACH(pr->targets, l, pt)
+ {
+ if (pt->id >= 0)
+ {
+ rp = ed->table_parts[pt->id % ed->table_parts_size];
+ if ((rp) && (rp->body))
+ ephysics_body_central_impulse_apply(
+ rp->body, pr->physics.impulse.x, pr->physics.impulse.y,
+ pr->physics.impulse.z);
+ }
+ }
+ break;
+#endif
default:
// _edje_emit(ed, "program,start", pr->name);
// _edje_emit(ed, "program,stop", pr->name);