ephysics: add cube 3d test
spot issues on rotation based on euler angles SVN revision: 79251
This commit is contained in:
parent
c1e3f6a574
commit
cbf0049a64
|
@ -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 \
|
||||
|
|
|
@ -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);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -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 \
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue