summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-11-29 18:53:56 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-11-29 18:53:56 +0000
commit9e76f59766a386613dec6512cc7a2469f1a5dc41 (patch)
treee207de0579fa5f379b1ca308cf73808ffc7a703d /legacy/ephysics
parent0b558bc80ce7c6ed4bae0c64fd0c37cd0c8a1fab (diff)
EPhysics: add hinge test
Add a test to simulate a hinge constraint using the generic constraint API's. --This line, and those below, will be ignored-- SVN revision: 79849
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/data/themes/Makefile.am3
-rw-r--r--legacy/ephysics/data/themes/images/door-back.pngbin0 -> 5116 bytes
-rw-r--r--legacy/ephysics/data/themes/images/door-front.pngbin0 -> 5103 bytes
-rw-r--r--legacy/ephysics/data/themes/images/door-post.pngbin0 -> 1933 bytes
-rw-r--r--legacy/ephysics/data/themes/others.edc60
-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_hinge.c142
8 files changed, 208 insertions, 0 deletions
diff --git a/legacy/ephysics/data/themes/Makefile.am b/legacy/ephysics/data/themes/Makefile.am
index cbce0fdd42..bfd6505990 100644
--- a/legacy/ephysics/data/themes/Makefile.am
+++ b/legacy/ephysics/data/themes/Makefile.am
@@ -34,6 +34,9 @@ TEST_FILES = \
34 images/ball-green70.png \ 34 images/ball-green70.png \
35 images/ball-red.png \ 35 images/ball-red.png \
36 images/ball-red70.png \ 36 images/ball-red70.png \
37 images/door-back.png \
38 images/door-front.png \
39 images/door-post.png \
37 images/bg_floor.jpg \ 40 images/bg_floor.jpg \
38 images/brown-pole.png \ 41 images/brown-pole.png \
39 images/bt_jump.png \ 42 images/bt_jump.png \
diff --git a/legacy/ephysics/data/themes/images/door-back.png b/legacy/ephysics/data/themes/images/door-back.png
new file mode 100644
index 0000000000..b00a7fe5c5
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/door-back.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/door-front.png b/legacy/ephysics/data/themes/images/door-front.png
new file mode 100644
index 0000000000..770bb481ca
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/door-front.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/door-post.png b/legacy/ephysics/data/themes/images/door-post.png
new file mode 100644
index 0000000000..f1ca119401
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/door-post.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/others.edc b/legacy/ephysics/data/themes/others.edc
index 7cd31bcb98..54ac54fe68 100644
--- a/legacy/ephysics/data/themes/others.edc
+++ b/legacy/ephysics/data/themes/others.edc
@@ -1,6 +1,9 @@
1 images { 1 images {
2 image: "green-flag.png" COMP; 2 image: "green-flag.png" COMP;
3 image: "brown-pole.png" COMP; 3 image: "brown-pole.png" COMP;
4 image: "door-front.png" COMP;
5 image: "door-back.png" COMP;
6 image: "door-post.png" COMP;
4 } 7 }
5 8
6 group { 9 group {
@@ -40,4 +43,61 @@
40 43
41 } 44 }
42 45
46 }
47
48 group {
49 name: "door-front";
50
51 parts {
52
53 part {
54 name: "door-front";
55 mouse_events: 0;
56 type: IMAGE;
57 description {
58 state: "default" 0.0;
59 image.normal: "door-front.png";
60 }
61 }
62
63 }
64
65 }
66
67 group {
68 name: "door-back";
69
70 parts {
71
72 part {
73 name: "door-back";
74 mouse_events: 0;
75 type: IMAGE;
76 description {
77 state: "default" 0.0;
78 image.normal: "door-back.png";
79 }
80 }
81
82 }
83
84 }
85
86 group {
87 name: "door-post";
88
89 parts {
90
91 part {
92 name: "door-post";
93 mouse_events: 0;
94 type: IMAGE;
95 description {
96 state: "default" 0.0;
97 image.normal: "door-post.png";
98 }
99 }
100
101 }
102
43 } \ No newline at end of file 103 } \ No newline at end of file
diff --git a/legacy/ephysics/src/bin/Makefile.am b/legacy/ephysics/src/bin/Makefile.am
index 5808d7a5d8..6d93e3dd64 100644
--- a/legacy/ephysics/src/bin/Makefile.am
+++ b/legacy/ephysics/src/bin/Makefile.am
@@ -37,6 +37,7 @@ test_forces.c \
37test_grab.c \ 37test_grab.c \
38test_growing_balls.c \ 38test_growing_balls.c \
39test_heavy.c \ 39test_heavy.c \
40test_hinge.c \
40test_jumping_balls.c \ 41test_jumping_balls.c \
41test_light.c \ 42test_light.c \
42test_material.c \ 43test_material.c \
diff --git a/legacy/ephysics/src/bin/test.c b/legacy/ephysics/src/bin/test.c
index d2d49cb592..8f55489150 100644
--- a/legacy/ephysics/src/bin/test.c
+++ b/legacy/ephysics/src/bin/test.c
@@ -36,6 +36,7 @@ void test_forces(void *data, Evas_Object *obj, void *event_info);
36void test_grab(void *data, Evas_Object *obj, void *event_info); 36void test_grab(void *data, Evas_Object *obj, void *event_info);
37void test_growing_balls(void *data, Evas_Object *obj, void *event_info); 37void test_growing_balls(void *data, Evas_Object *obj, void *event_info);
38void test_heavy(void *data, Evas_Object *obj, void *event_info); 38void test_heavy(void *data, Evas_Object *obj, void *event_info);
39void test_hinge(void *data, Evas_Object *obj, void *event_info);
39void test_jumping_balls(void *data, Evas_Object *obj, void *event_info); 40void test_jumping_balls(void *data, Evas_Object *obj, void *event_info);
40void test_light(void *data, Evas_Object *obj, void *event_info); 41void test_light(void *data, Evas_Object *obj, void *event_info);
41void test_material(void *data, Evas_Object *obj, void *event_info); 42void test_material(void *data, Evas_Object *obj, void *event_info);
@@ -72,6 +73,7 @@ static const EPhysics_Test tests[] = {
72 {"Grab", test_grab}, 73 {"Grab", test_grab},
73 {"Growing Balls", test_growing_balls}, 74 {"Growing Balls", test_growing_balls},
74 {"Heavy", test_heavy}, 75 {"Heavy", test_heavy},
76 {"Hinge", test_hinge},
75 {"Jumping Balls", test_jumping_balls}, 77 {"Jumping Balls", test_jumping_balls},
76 {"Light", test_light}, 78 {"Light", test_light},
77 {"Material", test_material}, 79 {"Material", test_material},
diff --git a/legacy/ephysics/src/bin/test_hinge.c b/legacy/ephysics/src/bin/test_hinge.c
new file mode 100644
index 0000000000..0136f7872a
--- /dev/null
+++ b/legacy/ephysics/src/bin/test_hinge.c
@@ -0,0 +1,142 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ephysics_test.h"
6
7static void
8_door_create(Test_Data *test_data, Evas_Object *front, Evas_Object *back, Evas_Object *right, Evas_Object *left, Evas_Object *top)
9{
10 EPhysics_Body *body;
11 EPhysics_Constraint *constraint;
12 Evas_Coord x, y, z, w, h, d;
13
14 body = ephysics_body_box_add(test_data->world);
15 test_data->bodies = eina_list_append(test_data->bodies, body);
16
17 ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_TOP, top,
18 EINA_TRUE);
19
20 ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_RIGHT, right,
21 EINA_TRUE);
22
23 ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_LEFT, left,
24 EINA_TRUE);
25
26 ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_FRONT, front,
27 EINA_TRUE);
28
29 ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_BACK, back,
30 EINA_TRUE);
31
32 ephysics_body_angular_movement_enable_set(body, EINA_FALSE, EINA_TRUE,
33 EINA_FALSE);
34
35 ephysics_body_linear_movement_enable_set(body, EINA_TRUE, EINA_TRUE,
36 EINA_TRUE);
37
38 ephysics_body_geometry_get(body, &x, &y, &z, &w, &h, &d);
39 ephysics_body_resize(body, w, h, 6);
40 ephysics_body_move(body, x, y, 150);
41 ephysics_body_geometry_get(body, &x, &y, &z, &w, &h, &d);
42
43 constraint = ephysics_constraint_add(body);
44 ephysics_constraint_angular_limit_set(constraint, 0, 0, 90, 0, 0, 0);
45 ephysics_constraint_anchor_set(constraint, x - 2, y + h / 2, z + d / 2, 0, 0,
46 0);
47 test_data->constraints = eina_list_append(test_data->constraints, constraint);
48 ephysics_body_impulse_apply(body, 0, 0, -10, x + w, y + h / 2, z);
49}
50
51static void
52_world_populate(Test_Data *test_data)
53{
54 Evas_Object *front, *back, *right, *left, *top;
55
56 front = elm_image_add(test_data->win);
57 elm_image_file_set(
58 front, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "door-front");
59 evas_object_resize(front, 139, 270);
60 evas_object_move(front, WIDTH / 3, FLOOR_Y - 290);
61 test_data->evas_objs = eina_list_append(test_data->evas_objs, front);
62
63 back = elm_image_add(test_data->win);
64 elm_image_file_set(
65 back, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "door-back");
66 evas_object_resize(back, 139, 270);
67 evas_object_move(back, WIDTH / 3, FLOOR_Y - 290);
68 test_data->evas_objs = eina_list_append(test_data->evas_objs, back);
69
70 right = evas_object_rectangle_add(evas_object_evas_get(test_data->win));
71 evas_object_color_set(right, 117, 75, 35, 255);
72 evas_object_resize(right, 6, 270);
73 test_data->evas_objs = eina_list_append(test_data->evas_objs, right);
74
75 left = evas_object_rectangle_add(evas_object_evas_get(test_data->win));
76 evas_object_color_set(left, 117, 75, 35, 255);
77 evas_object_resize(left, 6, 270);
78 test_data->evas_objs = eina_list_append(test_data->evas_objs, left);
79
80 top = evas_object_rectangle_add(evas_object_evas_get(test_data->win));
81 evas_object_color_set(top, 117, 75, 35, 255);
82 evas_object_resize(top, 139, 6);
83 test_data->evas_objs = eina_list_append(test_data->evas_objs, top);
84
85 _door_create(test_data, front, back, right, left, top);
86
87 evas_object_show(front);
88 evas_object_show(back);
89 evas_object_show(right);
90 evas_object_show(left);
91 evas_object_show(top);
92}
93
94static void
95_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
96{
97 Test_Data *test_data = data;
98
99 DBG("Restart pressed");
100 test_clean(test_data);
101 _world_populate(test_data);
102}
103
104void
105test_hinge(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
106{
107 EPhysics_Camera *cam;
108 EPhysics_World *world;
109 Test_Data *test_data;
110 Evas_Object *floor_obj, *door_post;
111
112 if (!ephysics_init())
113 return;
114
115 test_data = test_data_new();
116 test_win_add(test_data, "Hinge", EINA_TRUE);
117 elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
118 _restart, test_data);
119
120 floor_obj = elm_image_add(test_data->win);
121 elm_image_file_set(
122 floor_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "floor");
123 evas_object_move(floor_obj, 0, FLOOR_Y - 20);
124 evas_object_resize(floor_obj, FLOOR_WIDTH, 224);
125 evas_object_show(floor_obj);
126
127 door_post = elm_image_add(test_data->win);
128 elm_image_file_set(
129 door_post, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "door-post");
130 evas_object_resize(door_post, 147, 278);
131 evas_object_move(door_post, WIDTH / 3 - 5, FLOOR_Y - 295);
132 evas_object_show(door_post);
133
134 world = ephysics_world_new();
135 cam = ephysics_world_camera_get(world);
136 ephysics_world_render_geometry_set(world, 0, 0, 0, WIDTH - 100, FLOOR_Y - 300,
137 300);
138 ephysics_camera_perspective_enabled_set(cam, EINA_TRUE);
139
140 test_data->world = world;
141 _world_populate(test_data);
142}