summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-12-03 21:29:42 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-12-03 21:29:42 +0000
commit7df4546acfec629552459f114e8b1f159e2cca47 (patch)
tree959213ae6a2c4b6e50e47b85e119f353a6f8b9b9 /legacy/ephysics
parentd449396bed3023de121a581397cc21ea0481e4e5 (diff)
EPhysics: soft button improvements
Use a bigger image to soft button tests, add light on/off button, use of anchor hardness API. --This line, and those below, will be ignored-- SVN revision: 80108
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/data/themes/Makefile.am1
-rw-r--r--legacy/ephysics/data/themes/cubes.edc1
-rw-r--r--legacy/ephysics/data/themes/images/cube-purple420.pngbin0 -> 25498 bytes
-rw-r--r--legacy/ephysics/src/bin/test_soft_button.c58
4 files changed, 45 insertions, 15 deletions
diff --git a/legacy/ephysics/data/themes/Makefile.am b/legacy/ephysics/data/themes/Makefile.am
index bfd6505990..f25c080875 100644
--- a/legacy/ephysics/data/themes/Makefile.am
+++ b/legacy/ephysics/data/themes/Makefile.am
@@ -52,6 +52,7 @@ TEST_FILES = \
52 images/collisionL.png \ 52 images/collisionL.png \
53 images/cube-blue.png \ 53 images/cube-blue.png \
54 images/cube-purple.png \ 54 images/cube-purple.png \
55 images/cube-purple420.png \
55 images/cube_back.png \ 56 images/cube_back.png \
56 images/cube_bottom.png \ 57 images/cube_bottom.png \
57 images/cube_front.png \ 58 images/cube_front.png \
diff --git a/legacy/ephysics/data/themes/cubes.edc b/legacy/ephysics/data/themes/cubes.edc
index f6d99b6180..83540c253a 100644
--- a/legacy/ephysics/data/themes/cubes.edc
+++ b/legacy/ephysics/data/themes/cubes.edc
@@ -20,6 +20,7 @@
20 20
21ADD_CUBE(blue-cube, cube-blue); 21ADD_CUBE(blue-cube, cube-blue);
22ADD_CUBE(purple-cube, cube-purple); 22ADD_CUBE(purple-cube, cube-purple);
23ADD_CUBE(purple-cube420, cube-purple420);
23ADD_CUBE(cube_top, cube_top); 24ADD_CUBE(cube_top, cube_top);
24ADD_CUBE(cube_bottom, cube_bottom); 25ADD_CUBE(cube_bottom, cube_bottom);
25ADD_CUBE(cube_front, cube_front); 26ADD_CUBE(cube_front, cube_front);
diff --git a/legacy/ephysics/data/themes/images/cube-purple420.png b/legacy/ephysics/data/themes/images/cube-purple420.png
new file mode 100644
index 0000000000..ac153afe1b
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/cube-purple420.png
Binary files differ
diff --git a/legacy/ephysics/src/bin/test_soft_button.c b/legacy/ephysics/src/bin/test_soft_button.c
index 645f0817b1..93fbc63c6c 100644
--- a/legacy/ephysics/src/bin/test_soft_button.c
+++ b/legacy/ephysics/src/bin/test_soft_button.c
@@ -15,17 +15,17 @@ _mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, v
15 15
16 ephysics_body_geometry_get(body, NULL, NULL, &z, NULL, NULL, &d); 16 ephysics_body_geometry_get(body, NULL, NULL, &z, NULL, NULL, &d);
17 17
18 w = 70; 18 w = 80;
19 h = 70; 19 h = 80;
20 x = mdown->output.x - (w / 2); 20 x = mdown->output.x - (w / 2);
21 y = mdown->output.y - (h / 2); 21 y = mdown->output.y - (h / 2);
22 zz = z + (d / 2); 22 zz = z + (d / 2);
23 d = z; 23 d = d / 2;
24 24
25 triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, zz, 25 triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, zz,
26 w, h, d); 26 w, h, d);
27 ephysics_body_soft_body_triangle_list_impulse_apply(body, triangles, 0, 0, 27 ephysics_body_soft_body_triangle_list_impulse_apply(body, triangles, 0, 0,
28 -100); 28 200);
29 EINA_LIST_FREE(triangles, ldata) 29 EINA_LIST_FREE(triangles, ldata)
30 free(ldata); 30 free(ldata);
31} 31}
@@ -37,23 +37,30 @@ _soft_ellipsoid_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *
37 Evas_Coord w, h; 37 Evas_Coord w, h;
38 38
39 39
40 body = ephysics_body_soft_ellipsoid_add(test_data->world, 100); 40 body = ephysics_body_soft_ellipsoid_add(test_data->world, 500);
41
42 ephysics_body_soft_body_position_iterations_set(body, 16);
43 ephysics_body_soft_body_anchor_hardness_set(body, 0);
44 ephysics_body_soft_body_hardness_set(body, 3);
41 45
42 ephysics_body_face_evas_object_set(body, 46 ephysics_body_face_evas_object_set(body,
43 EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT, front_face, EINA_TRUE); 47 EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT,
48 front_face, EINA_TRUE);
44 49
45 ephysics_body_face_evas_object_set(body, 50 ephysics_body_face_evas_object_set(body,
46 EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK, back_face, EINA_TRUE); 51 EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK,
52 back_face, EINA_TRUE);
47 53
48 ephysics_body_geometry_get(body, NULL, NULL, NULL, &w, &h, NULL); 54 ephysics_body_geometry_get(body, NULL, NULL, NULL, &w, &h, NULL);
49 ephysics_body_resize(body, w, h, h); 55 ephysics_body_resize(body, w, h, h);
50 test_data->bodies = eina_list_append(test_data->bodies, body);
51 56
52 ephysics_body_linear_movement_enable_set(body, EINA_FALSE, EINA_FALSE, 57 ephysics_body_linear_movement_enable_set(body, EINA_FALSE, EINA_FALSE,
53 EINA_FALSE); 58 EINA_FALSE);
54 ephysics_body_angular_movement_enable_set(body, EINA_FALSE, EINA_FALSE, 59 ephysics_body_angular_movement_enable_set(body, EINA_FALSE, EINA_FALSE,
55 EINA_FALSE); 60 EINA_FALSE);
56 61
62 test_data->bodies = eina_list_append(test_data->bodies, body);
63
57 evas_object_event_callback_add(front_face, EVAS_CALLBACK_MOUSE_DOWN, 64 evas_object_event_callback_add(front_face, EVAS_CALLBACK_MOUSE_DOWN,
58 _mouse_down_cb, body); 65 _mouse_down_cb, body);
59 66
@@ -68,17 +75,19 @@ _world_populate(Test_Data *test_data)
68 75
69 front_face = elm_image_add(test_data->win); 76 front_face = elm_image_add(test_data->win);
70 elm_image_file_set( 77 elm_image_file_set(
71 front_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "blue-cube"); 78 front_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
72 evas_object_move(front_face, WIDTH / 2 - 35, HEIGHT / 2 - 35); 79 "purple-cube420");
73 evas_object_resize(front_face, 70, 70); 80 evas_object_move(front_face, WIDTH / 4, HEIGHT / 4);
81 evas_object_resize(front_face, 280, 280);
74 evas_object_show(front_face); 82 evas_object_show(front_face);
75 test_data->evas_objs = eina_list_append(test_data->evas_objs, front_face); 83 test_data->evas_objs = eina_list_append(test_data->evas_objs, front_face);
76 84
77 back_face = elm_image_add(test_data->win); 85 back_face = elm_image_add(test_data->win);
78 elm_image_file_set( 86 elm_image_file_set(
79 back_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "blue-cube"); 87 back_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
80 evas_object_move(back_face, WIDTH / 2 - 35, HEIGHT / 2 - 35); 88 "purple-cube420");
81 evas_object_resize(back_face, 70, 70); 89 evas_object_move(back_face, WIDTH / 4, HEIGHT / 4);
90 evas_object_resize(back_face, 280, 280);
82 evas_object_show(back_face); 91 evas_object_show(back_face);
83 test_data->evas_objs = eina_list_append(test_data->evas_objs, back_face); 92 test_data->evas_objs = eina_list_append(test_data->evas_objs, back_face);
84 93
@@ -95,11 +104,19 @@ _restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED_
95 _world_populate(test_data); 104 _world_populate(test_data);
96} 105}
97 106
107static void
108_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
109{
110 EPhysics_World *world = data;
111 ephysics_world_light_all_bodies_set(world, elm_check_state_get(obj));
112}
113
98void 114void
99test_soft_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 115test_soft_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
100{ 116{
101 EPhysics_World *world; 117 EPhysics_World *world;
102 Test_Data *test_data; 118 Test_Data *test_data;
119 Evas_Object *tg;
103 120
104 if (!ephysics_init()) 121 if (!ephysics_init())
105 return; 122 return;
@@ -111,13 +128,24 @@ test_soft_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event
111 _restart, test_data); 128 _restart, test_data);
112 elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test"); 129 elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
113 130
131 tg = elm_check_add(test_data->win);
132 elm_object_style_set(tg, "ephysics-test");
133 evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
134 evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, 0.5);
135 elm_check_state_set(tg, EINA_FALSE);
136 evas_object_show(tg);
137 elm_layout_content_set(test_data->layout, "extra_input", tg);
138
114 world = ephysics_world_new(); 139 world = ephysics_world_new();
115 ephysics_world_simulation_set(world, 1/150.f, 5); 140 ephysics_world_simulation_set(world, 1/260.f, 5);
116 ephysics_world_render_geometry_set(world, 50, 40, -50, 141 ephysics_world_render_geometry_set(world, 50, 40, -50,
117 WIDTH - 100, FLOOR_Y - 40, DEPTH); 142 WIDTH - 100, FLOOR_Y - 40, DEPTH);
118 test_data->world = world; 143 test_data->world = world;
119 144
120 ephysics_world_point_light_position_set(world, 300, 50, -200); 145 ephysics_world_point_light_position_set(world, 300, 50, -200);
146 ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
147 EINA_TRUE);
121 148
149 evas_object_smart_callback_add(tg, "changed", _changed_cb, world);
122 _world_populate(test_data); 150 _world_populate(test_data);
123} 151}