summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-08-10 21:05:28 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-08-10 21:05:28 +0000
commit5088b6bb930e904a1a292b6078955553163a1379 (patch)
tree66c3e842c0a124f0c8a871d0a07d12a9e52ae18a
parent031d47d1a963639fe4d8e46dae28dd4e42c55912 (diff)
EPhysics: add test using different shapes
Position / size looks buggy. Need to be fixed. SVN revision: 75153
-rw-r--r--legacy/ephysics/COPYING_ARTS3
-rw-r--r--legacy/ephysics/data/themes/Makefile.am4
-rw-r--r--legacy/ephysics/data/themes/ephysics_test.edc1
-rw-r--r--legacy/ephysics/data/themes/images/hexagon.pngbin0 -> 4502 bytes
-rw-r--r--legacy/ephysics/data/themes/images/hexagonal.pngbin4430 -> 0 bytes
-rw-r--r--legacy/ephysics/data/themes/images/pentagon.pngbin0 -> 3248 bytes
-rw-r--r--legacy/ephysics/data/themes/shapes.edc24
-rw-r--r--legacy/ephysics/src/bin/Makefile.am1
-rw-r--r--legacy/ephysics/src/bin/test.c2
-rw-r--r--legacy/ephysics/src/bin/test_shapes.c106
10 files changed, 139 insertions, 2 deletions
diff --git a/legacy/ephysics/COPYING_ARTS b/legacy/ephysics/COPYING_ARTS
index 5deb831ff7..0c2551d6f5 100644
--- a/legacy/ephysics/COPYING_ARTS
+++ b/legacy/ephysics/COPYING_ARTS
@@ -22,12 +22,13 @@ Unported License:
22 collisionL.png 22 collisionL.png
23 cube-blue.png 23 cube-blue.png
24 cube-purple.png 24 cube-purple.png
25 hexagonal.png 25 hexagon.png
26 list-item-corner.png 26 list-item-corner.png
27 list-item-corner-pressed.png 27 list-item-corner-pressed.png
28 list-item.png 28 list-item.png
29 list-item-pressed.png 29 list-item-pressed.png
30 list.png 30 list.png
31 pentagon.png
31 shadow-ball.png 32 shadow-ball.png
32 shadow-cube.png 33 shadow-cube.png
33 spinner_base.png 34 spinner_base.png
diff --git a/legacy/ephysics/data/themes/Makefile.am b/legacy/ephysics/data/themes/Makefile.am
index 8dba4d887c..c7e2001a44 100644
--- a/legacy/ephysics/data/themes/Makefile.am
+++ b/legacy/ephysics/data/themes/Makefile.am
@@ -20,6 +20,7 @@ EXTRA_DIST = \
20 frame.edc \ 20 frame.edc \
21 list.edc \ 21 list.edc \
22 shadows.edc \ 22 shadows.edc \
23 shapes.edc \
23 spinner.edc \ 24 spinner.edc \
24 images/arrows.png \ 25 images/arrows.png \
25 images/background.jpg \ 26 images/background.jpg \
@@ -41,11 +42,12 @@ EXTRA_DIST = \
41 images/collisionL.png \ 42 images/collisionL.png \
42 images/cube-blue.png \ 43 images/cube-blue.png \
43 images/cube-purple.png \ 44 images/cube-purple.png \
44 images/hexagonal.png \ 45 images/hexagon.png \
45 images/list-item.png \ 46 images/list-item.png \
46 images/list-item-corner.png \ 47 images/list-item-corner.png \
47 images/list-item-corner-pressed.png \ 48 images/list-item-corner-pressed.png \
48 images/list-item-pressed.png \ 49 images/list-item-pressed.png \
50 images/pentagon.png \
49 images/shadow-ball.png \ 51 images/shadow-ball.png \
50 images/shadow-cube.png \ 52 images/shadow-cube.png \
51 images/spinner_base.png \ 53 images/spinner_base.png \
diff --git a/legacy/ephysics/data/themes/ephysics_test.edc b/legacy/ephysics/data/themes/ephysics_test.edc
index 0fda97d64e..4d7a02be0e 100644
--- a/legacy/ephysics/data/themes/ephysics_test.edc
+++ b/legacy/ephysics/data/themes/ephysics_test.edc
@@ -10,5 +10,6 @@ collections {
10#include "frame.edc" 10#include "frame.edc"
11#include "list.edc" 11#include "list.edc"
12#include "shadows.edc" 12#include "shadows.edc"
13#include "shapes.edc"
13#include "spinner.edc" 14#include "spinner.edc"
14} 15}
diff --git a/legacy/ephysics/data/themes/images/hexagon.png b/legacy/ephysics/data/themes/images/hexagon.png
new file mode 100644
index 0000000000..75a5ffd9ad
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/hexagon.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/hexagonal.png b/legacy/ephysics/data/themes/images/hexagonal.png
deleted file mode 100644
index 6079691a4c..0000000000
--- a/legacy/ephysics/data/themes/images/hexagonal.png
+++ /dev/null
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/pentagon.png b/legacy/ephysics/data/themes/images/pentagon.png
new file mode 100644
index 0000000000..2bf8723578
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/pentagon.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/shapes.edc b/legacy/ephysics/data/themes/shapes.edc
new file mode 100644
index 0000000000..ec98b69b1e
--- /dev/null
+++ b/legacy/ephysics/data/themes/shapes.edc
@@ -0,0 +1,24 @@
1#define ADD_SHAPE(_name) \
2 images { \
3 image: #_name##".png" COMP; \
4 } \
5 group { \
6 name: #_name; \
7 parts { \
8 part { \
9 name: #_name; \
10 mouse_events: 0; \
11 type: IMAGE; \
12 description { \
13 state: "default" 0.0; \
14 image.normal: #_name##".png"; \
15 } \
16 } \
17 } \
18 }
19
20ADD_SHAPE(hexagon)
21ADD_SHAPE(pentagon)
22ADD_SHAPE(star)
23
24#undef ADD_SHAPE
diff --git a/legacy/ephysics/src/bin/Makefile.am b/legacy/ephysics/src/bin/Makefile.am
index b2350ca8e3..ad1c081148 100644
--- a/legacy/ephysics/src/bin/Makefile.am
+++ b/legacy/ephysics/src/bin/Makefile.am
@@ -31,6 +31,7 @@ test_jumping_balls.c \
31test_no_gravity.c \ 31test_no_gravity.c \
32test_rotate.c \ 32test_rotate.c \
33test_velocity.c \ 33test_velocity.c \
34test_shapes.c \
34test_sleeping_threshold.c \ 35test_sleeping_threshold.c \
35test_slider.c 36test_slider.c
36 37
diff --git a/legacy/ephysics/src/bin/test.c b/legacy/ephysics/src/bin/test.c
index 89d87939cc..74877f1152 100644
--- a/legacy/ephysics/src/bin/test.c
+++ b/legacy/ephysics/src/bin/test.c
@@ -24,6 +24,7 @@ void test_jumping_balls(void *data, Evas_Object *obj, void *event_info);
24void test_no_gravity(void *data, Evas_Object *obj, void *event_info); 24void test_no_gravity(void *data, Evas_Object *obj, void *event_info);
25void test_rotate(void *data, Evas_Object *obj, void *event_info); 25void test_rotate(void *data, Evas_Object *obj, void *event_info);
26void test_velocity(void *data, Evas_Object *obj, void *event_info); 26void test_velocity(void *data, Evas_Object *obj, void *event_info);
27void test_shapes(void *data, Evas_Object *obj, void *event_info);
27void test_sleeping(void *data, Evas_Object *obj, void *event_info); 28void test_sleeping(void *data, Evas_Object *obj, void *event_info);
28void test_slider(void *data, Evas_Object *obj, void *event_info); 29void test_slider(void *data, Evas_Object *obj, void *event_info);
29 30
@@ -168,6 +169,7 @@ _main_win_add(char *autorun __UNUSED__, Eina_Bool test_win_only __UNUSED__)
168 ADD_TEST("NO GRAVITY", test_no_gravity); 169 ADD_TEST("NO GRAVITY", test_no_gravity);
169 ADD_TEST("ROTATE", test_rotate); 170 ADD_TEST("ROTATE", test_rotate);
170 ADD_TEST("VELOCITY", test_velocity); 171 ADD_TEST("VELOCITY", test_velocity);
172 ADD_TEST("SHAPES", test_shapes);
171 ADD_TEST("SLEEPING THRESHOLD", test_sleeping); 173 ADD_TEST("SLEEPING THRESHOLD", test_sleeping);
172 ADD_TEST("SLIDER", test_slider); 174 ADD_TEST("SLIDER", test_slider);
173 175
diff --git a/legacy/ephysics/src/bin/test_shapes.c b/legacy/ephysics/src/bin/test_shapes.c
new file mode 100644
index 0000000000..4e00b5aafd
--- /dev/null
+++ b/legacy/ephysics/src/bin/test_shapes.c
@@ -0,0 +1,106 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ephysics_test.h"
6
7static void
8_world_populate(Test_Data *test_data)
9{
10 EPhysics_Shape *pentagon_shape, *hexagon_shape;
11 EPhysics_Body *pentagon_body, *hexagon_body;
12 EPhysics_Constraint *constraint;
13 Evas_Object *pentagon, *hexagon;
14
15 pentagon = elm_image_add(test_data->win);
16 elm_image_file_set(
17 pentagon, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "pentagon");
18 evas_object_move(pentagon, WIDTH / 3, HEIGHT / 2 - 30);
19 evas_object_resize(pentagon, 70, 66);
20 evas_object_show(pentagon);
21 test_data->evas_objs = eina_list_append(test_data->evas_objs, pentagon);
22
23 pentagon_shape = ephysics_shape_new();
24 ephysics_shape_point_add(pentagon_shape, 0/70., 24/66.);
25 ephysics_shape_point_add(pentagon_shape, 35/70., 0/66.);
26 ephysics_shape_point_add(pentagon_shape, 70/70., 24/66.);
27 ephysics_shape_point_add(pentagon_shape, 56/70., 66/66.);
28 ephysics_shape_point_add(pentagon_shape, 14/70., 66/66.);
29
30 pentagon_body = ephysics_body_shape_add(test_data->world, pentagon_shape);
31 ephysics_body_evas_object_set(pentagon_body, pentagon, EINA_TRUE);
32 ephysics_body_restitution_set(pentagon_body, 1);
33 ephysics_body_friction_set(pentagon_body, 0);
34 test_data->bodies = eina_list_append(test_data->bodies, pentagon_body);
35
36 hexagon = elm_image_add(test_data->win);
37 elm_image_file_set(
38 hexagon, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "hexagon");
39 evas_object_move(hexagon, WIDTH / 3 + 80, HEIGHT / 2 - 30 + 35);
40 evas_object_resize(hexagon, 70, 60);
41 evas_object_show(hexagon);
42 test_data->evas_objs = eina_list_append(test_data->evas_objs, hexagon);
43
44 hexagon_shape = ephysics_shape_new();
45 ephysics_shape_point_add(hexagon_shape, 0, 0.5);
46 ephysics_shape_point_add(hexagon_shape, 18/70., 0);
47 ephysics_shape_point_add(hexagon_shape, 52/70., 0);
48 ephysics_shape_point_add(hexagon_shape, 1, 0.5);
49 ephysics_shape_point_add(hexagon_shape, 52/70., 1);
50 ephysics_shape_point_add(hexagon_shape, 18/70., 1);
51
52 hexagon_body = ephysics_body_shape_add(test_data->world, hexagon_shape);
53 ephysics_body_mass_set(hexagon_body, 5);
54 ephysics_body_evas_object_set(hexagon_body, hexagon, EINA_TRUE);
55 ephysics_body_restitution_set(hexagon_body, 1);
56 ephysics_body_friction_set(hexagon_body, 0);
57 test_data->bodies = eina_list_append(test_data->bodies, hexagon_body);
58
59 constraint = ephysics_constraint_p2p_add(pentagon_body, NULL, 8, 0,
60 0, 0);
61 test_data->constraints = eina_list_append(test_data->constraints,
62 constraint);
63
64 constraint = ephysics_constraint_p2p_add(hexagon_body, NULL, 0, 0, 0, 0);
65 test_data->constraints = eina_list_append(test_data->constraints,
66 constraint);
67
68 ephysics_body_torque_impulse_apply(pentagon_body, 2);
69
70 ephysics_shape_del(pentagon_shape);
71 ephysics_shape_del(hexagon_shape);
72
73 ephysics_world_serialize(test_data->world, "/tmp/test.bullet");
74}
75
76static void
77_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
78{
79 Test_Data *test_data = data;
80
81 DBG("Restart pressed");
82 test_clean(test_data);
83 _world_populate(test_data);
84}
85
86void
87test_shapes(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
88{
89 EPhysics_World *world;
90 Test_Data *test_data;
91
92 if (!ephysics_init())
93 return;
94
95 test_data = test_data_new();
96 test_win_add(test_data, "Shapes", EINA_TRUE);
97 elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
98 elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
99 _restart, test_data);
100
101 world = ephysics_world_new();
102 ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
103 test_data->world = world;
104
105 _world_populate(test_data);
106}