/* Example:
*
* physics_impulse(PART:"logo", 0, 50.8, 0);
+ * physics_torque_impulse(PART:"logo", 0, 0, 3.4);
*/
native physics_impulse (part_id, Float:x, Float:y, Float:z);
+native physics_torque_impulse (part_id, Float:x, Float:y, Float:z);
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,
- PHYSICS_IMPULSE
+ PHYSICS_IMPULSE, PHYSICS_TORQUE_IMPULSE
Only one action can be specified per program. Examples:\n
action: STATE_SET "statename" 0.5;\n
action: ACTION_STOP;\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
+ action: PHYSICS_TORQUE_IMPULSE 0 2.1 0.95;\n
@endproperty
*/
static void
"PLAY_SAMPLE", EDJE_ACTION_TYPE_SOUND_SAMPLE,
"PLAY_TONE", EDJE_ACTION_TYPE_SOUND_TONE,
"PHYSICS_IMPULSE", EDJE_ACTION_TYPE_PHYSICS_IMPULSE,
+ "PHYSICS_TORQUE_IMPULSE",
+ EDJE_ACTION_TYPE_PHYSICS_TORQUE_IMPULSE,
NULL);
if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
{
ep->physics.impulse.y = parse_float(2);
ep->physics.impulse.z = parse_float(3);
}
+ else if (ep->action == EDJE_ACTION_TYPE_PHYSICS_TORQUE_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)
check_arg_count(3);
break;
case EDJE_ACTION_TYPE_PHYSICS_IMPULSE:
+ case EDJE_ACTION_TYPE_PHYSICS_TORQUE_IMPULSE:
check_arg_count(4);
break;
default:
#ifdef HAVE_EPHYSICS
else if (ep->action == EDJE_ACTION_TYPE_PHYSICS_IMPULSE)
data_queue_part_lookup(pc, name, &(et->id));
+ else if (ep->action == EDJE_ACTION_TYPE_PHYSICS_TORQUE_IMPULSE)
+ data_queue_part_lookup(pc, name, &(et->id));
#endif
else
{
/* 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
+ * signal clockwise impulse -> will roll blue ball in clockwise
+ * signal counterclockwise impulse -> will roll blue ball in counterclockwise
+ *
* message 1 FLOAT_SET 3 50 -100 0 -> apply an impulse on blue ball with
* x = 50, y = -100, z = 0, for example
+ * message 2 FLOAT_SET 3 0 0 8.2 -> apply a torque impulse on blue ball with
+ * x = 4, y = 0, z = 0.8, for example
*/
#define ID_IMPULSE (1)
+#define ID_TORQUE_IMPULSE (2)
collections {
z = getfarg(4);
physics_impulse(PART:"blue_circle", x, y, z);
}
+ else if ((id == ID_TORQUE_IMPULSE) && (type == MSG_FLOAT_SET)) {
+ new Float:x, Float:y, Float:z;
+ new n = numargs();
+ if (n < 5) return;
+ x = getfarg(2);
+ y = getfarg(3);
+ z = getfarg(4);
+ physics_torque_impulse(PART:"blue_circle", x, y, z);
+ }
}
}
target: "red_circle";
}
+ program {
+ name: "impulse_clockwise";
+ signal: "clockwise";
+ source: "impulse";
+ action: PHYSICS_TORQUE_IMPULSE 0 0 4;
+ target: "blue_circle";
+ }
+
+ program {
+ name: "impulse_counterclockwise";
+ signal: "counterclockwise";
+ source: "impulse";
+ action: PHYSICS_TORQUE_IMPULSE 0 0 -4;
+ target: "blue_circle";
+ }
+
}
}
typedef enum _Edje_Action_Type
{
- EDJE_ACTION_TYPE_NONE = 0,
- EDJE_ACTION_TYPE_STATE_SET = 1,
- EDJE_ACTION_TYPE_ACTION_STOP = 2,
- EDJE_ACTION_TYPE_SIGNAL_EMIT = 3,
- EDJE_ACTION_TYPE_DRAG_VAL_SET = 4,
- EDJE_ACTION_TYPE_DRAG_VAL_STEP = 5,
- EDJE_ACTION_TYPE_DRAG_VAL_PAGE = 6,
- EDJE_ACTION_TYPE_SCRIPT = 7,
- EDJE_ACTION_TYPE_FOCUS_SET = 8,
- EDJE_ACTION_TYPE_RESERVED00 = 9,
- EDJE_ACTION_TYPE_FOCUS_OBJECT = 10,
- EDJE_ACTION_TYPE_PARAM_COPY = 11,
- 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_PHYSICS_IMPULSE = 15, /**< @since 1.8 */
- EDJE_ACTION_TYPE_LAST = 16
+ EDJE_ACTION_TYPE_NONE = 0,
+ EDJE_ACTION_TYPE_STATE_SET = 1,
+ EDJE_ACTION_TYPE_ACTION_STOP = 2,
+ EDJE_ACTION_TYPE_SIGNAL_EMIT = 3,
+ EDJE_ACTION_TYPE_DRAG_VAL_SET = 4,
+ EDJE_ACTION_TYPE_DRAG_VAL_STEP = 5,
+ EDJE_ACTION_TYPE_DRAG_VAL_PAGE = 6,
+ EDJE_ACTION_TYPE_SCRIPT = 7,
+ EDJE_ACTION_TYPE_FOCUS_SET = 8,
+ EDJE_ACTION_TYPE_RESERVED00 = 9,
+ EDJE_ACTION_TYPE_FOCUS_OBJECT = 10,
+ EDJE_ACTION_TYPE_PARAM_COPY = 11,
+ 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_PHYSICS_IMPULSE = 15, /**< @since 1.8 */
+ EDJE_ACTION_TYPE_PHYSICS_TORQUE_IMPULSE = 16, /**< @since 1.8 */
+ EDJE_ACTION_TYPE_LAST = 17
} Edje_Action_Type;
/**
* external_param_set_bool(id, param_name[], value)
*
* physics_impulse(part_id, Float:x, Float:y, Float:z)
+ * physics_torque_impulse(part_id, Float:x, Float:y, Float:z)
*
* ADD/DEL CUSTOM OBJECTS UNDER SOLE EMBRYO SCRIPT CONTROL
*
}
return 0;
}
+
+/* physics_torque_impulse(part_id, Float:x, Float:y, Float:z) */
+static Embryo_Cell
+_edje_embryo_fn_physics_torque_impulse(Embryo_Program *ep, Embryo_Cell *params)
+{
+ Edje_Real_Part *rp;
+ int part_id = 0;
+ Edje *ed;
+
+ CHKPARAM(4);
+
+ ed = embryo_program_data_get(ep);
+ part_id = params[1];
+ if (part_id < 0) return 0;
+
+ rp = ed->table_parts[part_id % ed->table_parts_size];
+ if (rp)
+ {
+ if (rp->body)
+ {
+ double x, y, z;
+
+ x = (double) EMBRYO_CELL_TO_FLOAT(params[2]);
+ y = (double) EMBRYO_CELL_TO_FLOAT(params[3]);
+ z = (double) EMBRYO_CELL_TO_FLOAT(params[4]);
+
+ ephysics_body_torque_impulse_apply(rp->body, x, y, z);
+ }
+ }
+ return 0;
+}
#endif
void
#ifdef HAVE_EPHYSICS
embryo_program_native_call_add(ep, "physics_impulse", _edje_embryo_fn_physics_impulse);
+ embryo_program_native_call_add(ep, "physics_torque_impulse", _edje_embryo_fn_physics_torque_impulse);
#endif
}
}
}
break;
+ case EDJE_ACTION_TYPE_PHYSICS_TORQUE_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_torque_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);