summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-10 20:32:35 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-10 20:32:35 +0000
commit13375822869fa3fa8e061d1f00904222006793e8 (patch)
tree05fedbadeafda5e36ab03dfb54fba1e9bca67923 /legacy/ephysics
parent36553725716404611f29a0621c7b97ce4f03867d (diff)
ephysics: add test for light
SVN revision: 77805
Diffstat (limited to 'legacy/ephysics')
-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_light.c82
3 files changed, 85 insertions, 0 deletions
diff --git a/legacy/ephysics/src/bin/Makefile.am b/legacy/ephysics/src/bin/Makefile.am
index e3196e566e..bcae613a23 100644
--- a/legacy/ephysics/src/bin/Makefile.am
+++ b/legacy/ephysics/src/bin/Makefile.am
@@ -32,6 +32,7 @@ test_grab.c \
32test_growing_balls.c \ 32test_growing_balls.c \
33test_heavy.c \ 33test_heavy.c \
34test_jumping_balls.c \ 34test_jumping_balls.c \
35test_light.c \
35test_material.c \ 36test_material.c \
36test_no_gravity.c \ 37test_no_gravity.c \
37test_rotate.c \ 38test_rotate.c \
diff --git a/legacy/ephysics/src/bin/test.c b/legacy/ephysics/src/bin/test.c
index 50720405d8..36f75e4675 100644
--- a/legacy/ephysics/src/bin/test.c
+++ b/legacy/ephysics/src/bin/test.c
@@ -32,6 +32,7 @@ void test_grab(void *data, Evas_Object *obj, void *event_info);
32void test_growing_balls(void *data, Evas_Object *obj, void *event_info); 32void test_growing_balls(void *data, Evas_Object *obj, void *event_info);
33void test_heavy(void *data, Evas_Object *obj, void *event_info); 33void test_heavy(void *data, Evas_Object *obj, void *event_info);
34void test_jumping_balls(void *data, Evas_Object *obj, void *event_info); 34void test_jumping_balls(void *data, Evas_Object *obj, void *event_info);
35void test_light(void *data, Evas_Object *obj, void *event_info);
35void test_material(void *data, Evas_Object *obj, void *event_info); 36void test_material(void *data, Evas_Object *obj, void *event_info);
36void test_no_gravity(void *data, Evas_Object *obj, void *event_info); 37void test_no_gravity(void *data, Evas_Object *obj, void *event_info);
37void test_rotate(void *data, Evas_Object *obj, void *event_info); 38void test_rotate(void *data, Evas_Object *obj, void *event_info);
@@ -61,6 +62,7 @@ static const EPhysics_Test tests[] = {
61 {"Growing Balls", test_growing_balls}, 62 {"Growing Balls", test_growing_balls},
62 {"Heavy", test_heavy}, 63 {"Heavy", test_heavy},
63 {"Jumping Balls", test_jumping_balls}, 64 {"Jumping Balls", test_jumping_balls},
65 {"Light", test_light},
64 {"Material", test_material}, 66 {"Material", test_material},
65 {"No Gravity", test_no_gravity}, 67 {"No Gravity", test_no_gravity},
66 {"Rotate", test_rotate}, 68 {"Rotate", test_rotate},
diff --git a/legacy/ephysics/src/bin/test_light.c b/legacy/ephysics/src/bin/test_light.c
new file mode 100644
index 0000000000..b0a829a9a1
--- /dev/null
+++ b/legacy/ephysics/src/bin/test_light.c
@@ -0,0 +1,82 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ephysics_test.h"
6
7static void
8_ball_add(Test_Data *test_data, int x)
9{
10 Evas_Object *sphere, *shadow;
11 EPhysics_Body *ball;
12
13 shadow = elm_layout_add(test_data->win);
14 elm_layout_file_set(
15 shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
16 evas_object_move(shadow, WIDTH / 3, FLOOR_Y);
17 evas_object_resize(shadow, 70, 3);
18 evas_object_show(shadow);
19 test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
20
21 sphere = elm_image_add(test_data->win);
22 elm_image_file_set(
23 sphere, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "big-blue-ball");
24 evas_object_move(sphere, x, HEIGHT / 8);
25 evas_object_resize(sphere, 70, 70);
26 evas_object_show(sphere);
27 test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
28
29 ball = ephysics_body_circle_add(test_data->world);
30 ephysics_body_evas_object_set(ball, sphere, EINA_TRUE);
31 ephysics_body_restitution_set(ball, 0.95);
32 ephysics_body_friction_set(ball, 0.1);
33 ephysics_body_event_callback_add(ball, EPHYSICS_CALLBACK_BODY_UPDATE,
34 update_object_cb, shadow);
35 test_data->bodies = eina_list_append(test_data->bodies, ball);
36}
37
38static void
39_world_populate(Test_Data *test_data)
40{
41 _ball_add(test_data, WIDTH / 3);
42 _ball_add(test_data, WIDTH / 3 + 160);
43}
44
45static void
46_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
47{
48 test_clean(data);
49 _world_populate(data);
50}
51
52void
53test_light(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
54{
55 EPhysics_Body *boundary;
56 EPhysics_World *world;
57 Test_Data *test_data;
58
59 if (!ephysics_init())
60 return;
61
62 test_data = test_data_new();
63 test_win_add(test_data, "Light", EINA_TRUE);
64
65 elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
66 _restart, test_data);
67 elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
68
69 world = ephysics_world_new();
70 ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
71 test_data->world = world;
72
73 boundary = ephysics_body_bottom_boundary_add(test_data->world, 10);
74 ephysics_body_restitution_set(boundary, 0.65);
75 ephysics_body_friction_set(boundary, 4);
76
77 ephysics_world_light_set(world, 200, 300, -120, 255, 120, 120, 40, 40, 40);
78 ephysics_world_light_all_bodies_set(world, EINA_TRUE);
79
80 _world_populate(test_data);
81}
82