diff --git a/legacy/ephysics/data/themes/Makefile.am b/legacy/ephysics/data/themes/Makefile.am index ff2baecd90..8bc5c6a869 100644 --- a/legacy/ephysics/data/themes/Makefile.am +++ b/legacy/ephysics/data/themes/Makefile.am @@ -45,6 +45,12 @@ TEST_FILES = \ images/collisionL.png \ images/cube-blue.png \ images/cube-purple.png \ + images/dice1.png \ + images/dice2.png \ + images/dice3.png \ + images/dice4.png \ + images/dice5.png \ + images/dice6.png \ images/green-flag.png \ images/hexagon.png \ images/list-item.png \ diff --git a/legacy/ephysics/data/themes/cubes.edc b/legacy/ephysics/data/themes/cubes.edc index f5d1fb17b5..b2be72a289 100644 --- a/legacy/ephysics/data/themes/cubes.edc +++ b/legacy/ephysics/data/themes/cubes.edc @@ -21,4 +21,11 @@ ADD_CUBE(blue-cube, cube-blue); ADD_CUBE(purple-cube, cube-purple); +ADD_CUBE(dice1, dice1); +ADD_CUBE(dice2, dice2); +ADD_CUBE(dice3, dice3); +ADD_CUBE(dice4, dice4); +ADD_CUBE(dice5, dice5); +ADD_CUBE(dice6, dice6); + #undef ADD_CUBE diff --git a/legacy/ephysics/data/themes/images/dice1.png b/legacy/ephysics/data/themes/images/dice1.png new file mode 100644 index 0000000000..ae88d4a1f5 Binary files /dev/null and b/legacy/ephysics/data/themes/images/dice1.png differ diff --git a/legacy/ephysics/data/themes/images/dice2.png b/legacy/ephysics/data/themes/images/dice2.png new file mode 100644 index 0000000000..194e916ace Binary files /dev/null and b/legacy/ephysics/data/themes/images/dice2.png differ diff --git a/legacy/ephysics/data/themes/images/dice3.png b/legacy/ephysics/data/themes/images/dice3.png new file mode 100644 index 0000000000..317c7d90cb Binary files /dev/null and b/legacy/ephysics/data/themes/images/dice3.png differ diff --git a/legacy/ephysics/data/themes/images/dice4.png b/legacy/ephysics/data/themes/images/dice4.png new file mode 100644 index 0000000000..feb12a5e15 Binary files /dev/null and b/legacy/ephysics/data/themes/images/dice4.png differ diff --git a/legacy/ephysics/data/themes/images/dice5.png b/legacy/ephysics/data/themes/images/dice5.png new file mode 100644 index 0000000000..f830667fd0 Binary files /dev/null and b/legacy/ephysics/data/themes/images/dice5.png differ diff --git a/legacy/ephysics/data/themes/images/dice6.png b/legacy/ephysics/data/themes/images/dice6.png new file mode 100644 index 0000000000..aa8963e11c Binary files /dev/null and b/legacy/ephysics/data/themes/images/dice6.png differ diff --git a/legacy/ephysics/src/bin/Makefile.am b/legacy/ephysics/src/bin/Makefile.am index 46fa4db14e..4448576c1e 100644 --- a/legacy/ephysics/src/bin/Makefile.am +++ b/legacy/ephysics/src/bin/Makefile.am @@ -27,6 +27,7 @@ test_collision_filter.c \ test_collision_speed.c \ test_constraint.c \ test_delete.c \ +test_dices.c \ test_falling_letters.c \ test_forces.c \ test_grab.c \ diff --git a/legacy/ephysics/src/bin/test.c b/legacy/ephysics/src/bin/test.c index 96660e85da..646f230d12 100644 --- a/legacy/ephysics/src/bin/test.c +++ b/legacy/ephysics/src/bin/test.c @@ -26,6 +26,7 @@ void test_collision_filter(void *data, Evas_Object *obj, void *event_info); void test_collision_speed(void *data, Evas_Object *obj, void *event_info); void test_constraint(void *data, Evas_Object *obj, void *event_info); void test_delete(void *data, Evas_Object *obj, void *event_info); +void test_dices(void *data, Evas_Object *obj, void *event_info); void test_falling_letters(void *data, Evas_Object *obj, void *event_info); void test_flag(void *data, Evas_Object *obj, void *event_info); void test_forces(void *data, Evas_Object *obj, void *event_info); @@ -56,6 +57,7 @@ static const EPhysics_Test tests[] = { {"Collision Filter", test_collision_filter}, {"Collision High Speed", test_collision_speed}, {"Constraint", test_constraint}, + {"Dices", test_dices}, {"Delete Body", test_delete}, {"Falling Letters", test_falling_letters}, {"Flag - Cloth", test_flag}, diff --git a/legacy/ephysics/src/bin/test_bouncing_3d.c b/legacy/ephysics/src/bin/test_bouncing_3d.c index e0d6758e5c..2012b70cb8 100644 --- a/legacy/ephysics/src/bin/test_bouncing_3d.c +++ b/legacy/ephysics/src/bin/test_bouncing_3d.c @@ -4,7 +4,7 @@ #include "ephysics_test.h" -void +static void _pos_print_cb(void *data __UNUSED__, EPhysics_Body *body, void *event_info __UNUSED__) { Evas_Coord x, y, z; diff --git a/legacy/ephysics/src/bin/test_dices.c b/legacy/ephysics/src/bin/test_dices.c new file mode 100644 index 0000000000..725096fe38 --- /dev/null +++ b/legacy/ephysics/src/bin/test_dices.c @@ -0,0 +1,128 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "ephysics_test.h" + +static Evas_Object * +_obj_face_add(Test_Data *test_data, const char *group, Evas_Coord x, Evas_Coord y) +{ + Evas_Object *obj; + + obj = elm_image_add(test_data->win); + elm_image_file_set(obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", + group); + evas_object_move(obj, x, y); + evas_object_resize(obj, 70, 70); + evas_object_show(obj); + test_data->evas_objs = eina_list_append(test_data->evas_objs, obj); + + return obj; +} + +static EPhysics_Body * +_box_add(Test_Data *test_data, Evas_Coord x, Evas_Coord y) +{ + Evas_Object *front, *back, *top, *bottom, *right, *left, *shadow; + EPhysics_Body *box; + + shadow = elm_layout_add(test_data->win); + elm_layout_file_set( + shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball"); + evas_object_move(shadow, x, FLOOR_Y); + evas_object_resize(shadow, 70, 3); + evas_object_show(shadow); + test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow); + + front = _obj_face_add(test_data, "dice1", x, y); + back = _obj_face_add(test_data, "dice6", x, y); + top = _obj_face_add(test_data, "dice2", x, y); + bottom = _obj_face_add(test_data, "dice5", x, y); + right = _obj_face_add(test_data, "dice3", x, y); + left = _obj_face_add(test_data, "dice4", x, y); + + box = ephysics_body_box_add(test_data->world); + ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_FRONT, + front, EINA_TRUE); + ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_BACK, + back, EINA_TRUE); + ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_TOP, + top, EINA_TRUE); + ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_BOTTOM, + bottom, EINA_TRUE); + ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_RIGHT, + right, EINA_TRUE); + ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_LEFT, + left, EINA_TRUE); + ephysics_body_restitution_set(box, 0.7); + ephysics_body_sleeping_threshold_set(box, 0, 0); + ephysics_body_damping_set(box, 0, 0); + ephysics_body_linear_movement_enable_set(box, EINA_TRUE, EINA_TRUE, + EINA_TRUE); + ephysics_body_angular_movement_enable_set(box, EINA_TRUE, EINA_TRUE, + EINA_TRUE); + ephysics_body_event_callback_add(box, EPHYSICS_CALLBACK_BODY_UPDATE, + update_object_cb, shadow); + test_data->bodies = eina_list_append(test_data->bodies, box); + + return box; +} + +static void +_world_populate(Test_Data *test_data) +{ + EPhysics_Body *box; + + box = _box_add(test_data, WIDTH / 2, HEIGHT / 4); + ephysics_body_torque_impulse_apply(box, 6, -2, 0); + box = _box_add(test_data, 80, 80); + ephysics_body_torque_impulse_apply(box, 0, 0, 3); + ephysics_body_central_impulse_apply(box, 80, 0, 0); +} + +static void +_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +{ + test_clean(data); + _world_populate(data); +} + +void +test_dices(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + EPhysics_Body *boundary; + EPhysics_World *world; + Test_Data *test_data; + + if (!ephysics_init()) + return; + + test_data = test_data_new(); + test_win_add(test_data, "Dices", EINA_TRUE); + + elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme", + _restart, test_data); + elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test"); + + world = ephysics_world_new(); + ephysics_world_render_geometry_set(world, 50, 40, -50, + WIDTH - 100, FLOOR_Y - 40, DEPTH * 2); + ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world), + EINA_TRUE); + + ephysics_world_point_light_position_set(world, 0, 100, -400); + ephysics_world_ambient_light_color_set(world, 60, 60, 60); + ephysics_world_light_all_bodies_set(world, EINA_TRUE); + + test_data->world = world; + + boundary = ephysics_body_bottom_boundary_add(test_data->world); + ephysics_body_restitution_set(boundary, 0.7); + + ephysics_body_right_boundary_add(test_data->world); + ephysics_body_left_boundary_add(test_data->world); + ephysics_body_back_boundary_add(test_data->world); + ephysics_body_top_boundary_add(test_data->world); + + _world_populate(test_data); +}