aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-11-13 22:18:09 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-11-13 22:18:09 +0000
commitcbf0049a643860c0662d0e044219e53f44225b2b (patch)
treebfdce3e82121230289056c923441f107609eb633
parentephysics: fix body rotation set / get (diff)
downloadefl-cbf0049a643860c0662d0e044219e53f44225b2b.tar.gz
ephysics: add cube 3d test
spot issues on rotation based on euler angles SVN revision: 79251
-rw-r--r--legacy/ephysics/data/themes/Makefile.am6
-rw-r--r--legacy/ephysics/data/themes/cubes.edc6
-rw-r--r--legacy/ephysics/data/themes/images/cube_back.pngbin0 -> 1496 bytes
-rw-r--r--legacy/ephysics/data/themes/images/cube_bottom.pngbin0 -> 1560 bytes
-rw-r--r--legacy/ephysics/data/themes/images/cube_front.pngbin0 -> 1442 bytes
-rw-r--r--legacy/ephysics/data/themes/images/cube_left.pngbin0 -> 1166 bytes
-rw-r--r--legacy/ephysics/data/themes/images/cube_right.pngbin0 -> 1412 bytes
-rw-r--r--legacy/ephysics/data/themes/images/cube_top.pngbin0 -> 1351 bytes
-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_cube_3d.c116
11 files changed, 131 insertions, 0 deletions
diff --git a/legacy/ephysics/data/themes/Makefile.am b/legacy/ephysics/data/themes/Makefile.am
index 11d2fd2dff..6e0e7e10fd 100644
--- a/legacy/ephysics/data/themes/Makefile.am
+++ b/legacy/ephysics/data/themes/Makefile.am
@@ -48,6 +48,12 @@ TEST_FILES = \
images/collisionL.png \
images/cube-blue.png \
images/cube-purple.png \
+ images/cube_back.png \
+ images/cube_bottom.png \
+ images/cube_front.png \
+ images/cube_left.png \
+ images/cube_right.png \
+ images/cube_top.png \
images/dice1.png \
images/dice2.png \
images/dice3.png \
diff --git a/legacy/ephysics/data/themes/cubes.edc b/legacy/ephysics/data/themes/cubes.edc
index b2be72a289..f6d99b6180 100644
--- a/legacy/ephysics/data/themes/cubes.edc
+++ b/legacy/ephysics/data/themes/cubes.edc
@@ -20,6 +20,12 @@
ADD_CUBE(blue-cube, cube-blue);
ADD_CUBE(purple-cube, cube-purple);
+ADD_CUBE(cube_top, cube_top);
+ADD_CUBE(cube_bottom, cube_bottom);
+ADD_CUBE(cube_front, cube_front);
+ADD_CUBE(cube_back, cube_back);
+ADD_CUBE(cube_right, cube_right);
+ADD_CUBE(cube_left, cube_left);
ADD_CUBE(dice1, dice1);
ADD_CUBE(dice2, dice2);
diff --git a/legacy/ephysics/data/themes/images/cube_back.png b/legacy/ephysics/data/themes/images/cube_back.png
new file mode 100644
index 0000000000..c8da7d8157
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/cube_back.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/cube_bottom.png b/legacy/ephysics/data/themes/images/cube_bottom.png
new file mode 100644
index 0000000000..62ff8d2e92
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/cube_bottom.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/cube_front.png b/legacy/ephysics/data/themes/images/cube_front.png
new file mode 100644
index 0000000000..2c5f827162
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/cube_front.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/cube_left.png b/legacy/ephysics/data/themes/images/cube_left.png
new file mode 100644
index 0000000000..adbdcc38fe
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/cube_left.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/cube_right.png b/legacy/ephysics/data/themes/images/cube_right.png
new file mode 100644
index 0000000000..4d4e423bfa
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/cube_right.png
Binary files differ
diff --git a/legacy/ephysics/data/themes/images/cube_top.png b/legacy/ephysics/data/themes/images/cube_top.png
new file mode 100644
index 0000000000..dd981d7e93
--- /dev/null
+++ b/legacy/ephysics/data/themes/images/cube_top.png
Binary files differ
diff --git a/legacy/ephysics/src/bin/Makefile.am b/legacy/ephysics/src/bin/Makefile.am
index 54e7390e80..b25c909020 100644
--- a/legacy/ephysics/src/bin/Makefile.am
+++ b/legacy/ephysics/src/bin/Makefile.am
@@ -27,6 +27,7 @@ test_collision_detection.c \
test_collision_filter.c \
test_collision_speed.c \
test_constraint.c \
+test_cube_3d.c \
test_delete.c \
test_dices.c \
test_falling_letters.c \
diff --git a/legacy/ephysics/src/bin/test.c b/legacy/ephysics/src/bin/test.c
index 38b577ba34..6b409f578c 100644
--- a/legacy/ephysics/src/bin/test.c
+++ b/legacy/ephysics/src/bin/test.c
@@ -26,6 +26,7 @@ void test_collision(void *data, Evas_Object *obj, void *event_info);
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_cube_3d(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);
@@ -58,6 +59,7 @@ static const EPhysics_Test tests[] = {
{"Collision Filter", test_collision_filter},
{"Collision High Speed", test_collision_speed},
{"Constraint", test_constraint},
+ {"Cube 3D", test_cube_3d},
{"Dices", test_dices},
{"Delete Body", test_delete},
{"Falling Letters", test_falling_letters},
diff --git a/legacy/ephysics/src/bin/test_cube_3d.c b/legacy/ephysics/src/bin/test_cube_3d.c
new file mode 100644
index 0000000000..01bcf7f8bb
--- /dev/null
+++ b/legacy/ephysics/src/bin/test_cube_3d.c
@@ -0,0 +1,116 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ephysics_test.h"
+
+#define BOX_SIZE (70)
+
+static void
+_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+{
+ Evas_Event_Mouse_Move *mmove = event_info;
+ EPhysics_Body *body = data;
+ double rx, ry, rz;
+
+ if (mmove->buttons != 1) return;
+
+ ephysics_body_rotation_get(body, &rx, &ry, &rz);
+ rx += mmove->cur.output.y - mmove->prev.output.y;
+ ry += mmove->cur.output.x - mmove->prev.output.x;
+ ephysics_body_rotation_set(body, rx, ry, rz);
+}
+
+static void
+_obj_face_add(Test_Data *test_data, EPhysics_Body *body, EPhysics_Body_Face face, 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, BOX_SIZE, BOX_SIZE);
+ evas_object_show(obj);
+
+ ephysics_body_face_evas_object_set(body, face, obj, EINA_TRUE);
+
+ test_data->evas_objs = eina_list_append(test_data->evas_objs, obj);
+}
+
+static void
+_world_populate(Test_Data *test_data)
+{
+ EPhysics_Body *box;
+ Evas_Object *rect;
+ Evas_Coord x, y;
+ Evas *evas;
+
+ x = (WIDTH - BOX_SIZE) / 2;
+ y = (HEIGHT - BOX_SIZE) / 2;
+
+ box = ephysics_body_box_add(test_data->world);
+
+ _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_FRONT, "cube_front",
+ x, y);
+ _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_BACK, "cube_back",
+ x, y);
+ _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_TOP, "cube_top",
+ x, y);
+ _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_BOTTOM, "cube_bottom",
+ x, y);
+ _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_RIGHT, "cube_right",
+ x, y);
+ _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_LEFT, "cube_left",
+ x, y);
+
+ ephysics_body_damping_set(box, 0, 0.2);
+ ephysics_body_linear_movement_enable_set(box, EINA_FALSE, EINA_FALSE,
+ EINA_FALSE);
+ ephysics_body_angular_movement_enable_set(box, EINA_TRUE, EINA_TRUE,
+ EINA_TRUE);
+ test_data->bodies = eina_list_append(test_data->bodies, box);
+
+ evas = evas_object_evas_get(test_data->win);
+ rect = evas_object_rectangle_add(evas);
+ evas_object_resize(rect, 120, 120);
+ evas_object_move(rect, (WIDTH - 120) / 2, (HEIGHT - 120) / 2);
+ evas_object_color_set(rect, 0, 0, 0, 0);
+ evas_object_show(rect);
+ evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_MOVE,
+ _mouse_move_cb, box);
+}
+
+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_cube_3d(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ EPhysics_World *world;
+ Test_Data *test_data;
+
+ if (!ephysics_init())
+ return;
+
+ test_data = test_data_new();
+ test_win_add(test_data, "Cube 3D", 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_world_gravity_set(world, 0, 0, 0);
+ ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
+ EINA_TRUE);
+ test_data->world = world;
+
+ _world_populate(test_data);
+}