summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <chuneon.park@samsung.com>2020-03-19 11:59:31 +0900
committerHermet Park <chuneon.park@samsung.com>2020-03-19 11:59:31 +0900
commitb2e56fd9d8ae8a57a31ea7b27d9679d28d08ad19 (patch)
treef24d5fc4f4351216b162aa78341b605d09176fb6
parent466471e5e81fa0b8c08bd039bcd669ceba889e82 (diff)
parentc4fad77ae3d1e2acbc8d0876edb614d861051dc8 (diff)
Merge branch 'master' into devs/hermet/lottie
-rw-r--r--src/bin/elementary/test.c3
-rw-r--r--src/bin/elementary/test_ui_spotlight.c115
-rw-r--r--src/examples/elementary/evas3d_map_example.c1211
-rw-r--r--src/examples/elementary/evas3d_map_example.edc964
-rw-r--r--src/examples/elementary/evas3d_object_on_button_example.c288
-rw-r--r--src/examples/elementary/evas3d_scene_on_button_example.c280
-rw-r--r--src/examples/elementary/meson.build6
-rw-r--r--src/examples/elementary/performance/HowTo13
-rw-r--r--src/examples/elementary/performance/Tools.h19
-rw-r--r--src/examples/elementary/performance/background.pngbin177255 -> 0 bytes
-rw-r--r--src/examples/elementary/performance/camera_light.c354
-rw-r--r--src/examples/elementary/performance/graphical.c622
-rw-r--r--src/examples/elementary/performance/graphical_struct.h90
-rw-r--r--src/examples/elementary/performance/initial_config.xml11
-rw-r--r--src/examples/elementary/performance/layout.edc170
-rw-r--r--src/examples/elementary/performance/meson.build31
-rw-r--r--src/examples/elementary/performance/performance.c953
-rw-r--r--src/examples/elementary/performance/target_texture.pngbin2123166 -> 0 bytes
-rw-r--r--src/examples/elementary/performance/tools_private.h51
-rw-r--r--src/examples/elementary/sphere_hunter/EFL_defeat.pngbin88373 -> 0 bytes
-rw-r--r--src/examples/elementary/sphere_hunter/EFL_victory.pngbin108064 -> 0 bytes
-rw-r--r--src/examples/elementary/sphere_hunter/evas_3d_sphere_hunter.c858
-rw-r--r--src/examples/elementary/sphere_hunter/meson.build31
-rw-r--r--src/examples/elementary/sphere_hunter/score.jpgbin51305 -> 0 bytes
-rw-r--r--src/examples/elementary/sphere_hunter/sphere_hunter.edc251
-rw-r--r--src/examples/evas/README32
-rw-r--r--src/examples/evas/evas-3d-aabb.c237
-rw-r--r--src/examples/evas/evas-3d-blending.c312
-rw-r--r--src/examples/evas/evas-3d-colorpick.c415
-rw-r--r--src/examples/evas/evas-3d-cube-rotate.c285
-rw-r--r--src/examples/evas/evas-3d-cube.c262
-rw-r--r--src/examples/evas/evas-3d-cube2.c258
-rw-r--r--src/examples/evas/evas-3d-eet.c210
-rw-r--r--src/examples/evas/evas-3d-fog.c238
-rw-r--r--src/examples/evas/evas-3d-frustum.c446
-rw-r--r--src/examples/evas/evas-3d-hull.c465
-rw-r--r--src/examples/evas/evas-3d-md2.c176
-rw-r--r--src/examples/evas/evas-3d-mmap-set.c260
-rw-r--r--src/examples/evas/evas-3d-obj.c239
-rw-r--r--src/examples/evas/evas-3d-parallax-occlusion.c264
-rw-r--r--src/examples/evas/evas-3d-pick.c189
-rw-r--r--src/examples/evas/evas-3d-ply.c235
-rw-r--r--src/examples/evas/evas-3d-proxy.c262
-rw-r--r--src/examples/evas/evas-3d-shadows.c689
-rw-r--r--src/examples/evas/evas-3d-static-lod.c280
-rw-r--r--src/examples/evas/meson.build21
-rw-r--r--src/examples/evas/resources/models/NoNormal_NoUVs_Colors.ply67
-rw-r--r--src/examples/evas/resources/models/NoNormal_NoUVs_NoColors.ply60
-rw-r--r--src/examples/evas/resources/models/NoNormal_UVs_Colors.ply143
-rw-r--r--src/examples/evas/resources/models/NoNormal_UVs_NoColors.ply140
-rw-r--r--src/examples/evas/resources/models/Normal_NoUVs_Colors.ply144
-rw-r--r--src/examples/evas/resources/models/Normal_NoUVs_NoColors.ply141
-rw-r--r--src/examples/evas/resources/models/Normal_UVs_Colors.ply146
-rw-r--r--src/examples/evas/resources/models/Normal_UVs_NoColors.ply143
-rw-r--r--src/examples/evas/resources/models/convex_hull/column.ply521
-rw-r--r--src/examples/evas/resources/models/convex_hull/column_blender_ch.ply295
-rw-r--r--src/examples/evas/resources/models/convex_hull/column_blender_ch_test.ply164
-rw-r--r--src/examples/evas/resources/models/convex_hull/cube_blender_ch.ply43
-rw-r--r--src/examples/evas/resources/models/convex_hull/cube_blender_ch_test.ply24
-rw-r--r--src/examples/evas/resources/models/convex_hull/eagle_blender_ch.ply306
-rw-r--r--src/examples/evas/resources/models/convex_hull/eagle_blender_ch_test.ply124
-rw-r--r--src/examples/evas/resources/models/convex_hull/home_blender_ch.obj40
-rw-r--r--src/examples/evas/resources/models/convex_hull/home_blender_ch_test.ply35
-rw-r--r--src/examples/evas/resources/models/convex_hull/plain.ply846
-rw-r--r--src/examples/evas/resources/models/convex_hull/plain_blender_ch.ply18
-rw-r--r--src/examples/evas/resources/models/convex_hull/plain_blender_ch_test.ply15
-rw-r--r--src/examples/evas/resources/models/convex_hull/sonic_blender_ch.ply659
-rw-r--r--src/examples/evas/resources/models/convex_hull/sonic_blender_ch_test.ply260
-rw-r--r--src/examples/evas/resources/models/convex_hull/sphere_blender_ch.ply469
-rw-r--r--src/examples/evas/resources/models/convex_hull/sphere_blender_ch_test.ply194
-rw-r--r--src/examples/evas/resources/models/convex_hull/torus_blender_ch.ply12313
-rw-r--r--src/examples/evas/resources/models/convex_hull/torus_blender_ch_test.ply2556
-rw-r--r--src/examples/evas/resources/models/lod/iso_sphere0.obj3208
-rw-r--r--src/examples/evas/resources/models/lod/iso_sphere1.obj1608
-rw-r--r--src/examples/evas/resources/models/lod/iso_sphere2.obj808
-rw-r--r--src/examples/evas/resources/models/mesh_for_mmap.eetbin19495 -> 0 bytes
-rw-r--r--src/examples/evas/resources/models/mesh_for_mmap.md2bin3400 -> 0 bytes
-rw-r--r--src/examples/evas/resources/models/mesh_for_mmap.obj639
-rw-r--r--src/examples/evas/resources/models/mesh_for_mmap.ply401
-rw-r--r--src/examples/evas/resources/models/sonic.md2bin660576 -> 0 bytes
-rw-r--r--src/examples/evas/resources/models/sweet_home.obj107
-rw-r--r--src/examples/evas/resources/models/sweet_home_only_vertex_coords.obj40
-rw-r--r--src/examples/evas/resources/models/sweet_home_without_normals.obj96
-rw-r--r--src/examples/evas/resources/models/sweet_home_without_tex_coords.obj55
-rw-r--r--src/examples/evas/shooter/assets/images/brick-stone.jpgbin30416 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/brick-stone_n.jpgbin23490 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/bricks.jpgbin90039 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/bricks_n.jpgbin34584 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/eagle.pngbin35011 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/gazebo.pngbin113938 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/gazebo_b_n.pngbin148096 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/gazebo_t.pngbin119501 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/gazebo_t_n.pngbin128640 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/gazebo_t_t.pngbin121842 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/snake.pngbin76100 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/snake_n.pngbin79061 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/soldier.pngbin113272 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/images/warrior.pngbin118574 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/models/eagle.md2bin196728 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/models/gazebo_b.md2bin153476 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/models/gazebo_t.md2bin154756 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/models/snake.md2bin270584 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/models/soldier.md2bin591280 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/models/soldier_jump.md2bin518676 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/assets/models/tommy.ply3558
-rw-r--r--src/examples/evas/shooter/assets/models/warrior.md2bin130276 -> 0 bytes
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter-header.c359
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter-header.h196
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter-macros.h242
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter.c1186
-rw-r--r--src/examples/evas/shooter/meson.build5
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa.h4
-rw-r--r--src/lib/ecore_input_evas/ecore_input_evas.c4
-rw-r--r--src/lib/edje/Edje_Eo.h1
-rw-r--r--src/lib/edje/Efl_Layout.h1
-rw-r--r--src/lib/edje/edje_message_queue.c1
-rw-r--r--src/lib/edje/edje_part.c3
-rw-r--r--src/lib/edje/edje_part_invalid.c2
-rw-r--r--src/lib/edje/efl_canvas_layout_part.eo12
-rw-r--r--src/lib/edje/efl_canvas_layout_part_invalid.eo2
-rw-r--r--src/lib/edje/efl_canvas_layout_part_type_provider.eo20
-rw-r--r--src/lib/edje/efl_layout_group.eo2
-rw-r--r--src/lib/edje/meson.build1
-rw-r--r--src/lib/efl/interfaces/efl_gfx_types.eot6
-rw-r--r--src/lib/efl/interfaces/efl_input_text.eo35
-rw-r--r--src/lib/eina/eina_file.c2
-rw-r--r--src/lib/eina/eina_promise.c4
-rw-r--r--src/lib/eina/eina_promise.h506
-rw-r--r--src/lib/eina/eina_quadtree.h12
-rw-r--r--src/lib/eina/eina_vector.h8
-rw-r--r--src/lib/elementary/Efl_Ui.h1
-rw-r--r--src/lib/elementary/efl_ui_spotlight_animation_manager.c268
-rw-r--r--src/lib/elementary/efl_ui_spotlight_animation_manager.eo75
-rw-r--r--src/lib/elementary/efl_ui_spotlight_container.c22
-rw-r--r--src/lib/elementary/efl_ui_spotlight_fade_manager.c213
-rw-r--r--src/lib/elementary/efl_ui_spotlight_fade_manager.eo10
-rw-r--r--src/lib/elementary/efl_ui_spotlight_manager.eo8
-rw-r--r--src/lib/elementary/efl_ui_spotlight_plain_manager.c2
-rw-r--r--src/lib/elementary/efl_ui_spotlight_scroll_manager.c2
-rw-r--r--src/lib/elementary/efl_ui_textbox.eo5
-rw-r--r--src/lib/elementary/efl_ui_widget.c10
-rw-r--r--src/lib/elementary/efl_ui_widget_part.eo3
-rw-r--r--src/lib/elementary/efl_ui_win.c3
-rw-r--r--src/lib/elementary/meson.build4
-rw-r--r--src/lib/evas/Evas_Legacy.h884
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_container.c4
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_container_eo.legacy.c6
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_container_eo.legacy.h32
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_gradient.c14
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_gradient_eo.legacy.h21
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_gradient_linear.c12
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_gradient_radial.c16
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_node.c20
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_node_eo.legacy.c10
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_node_eo.legacy.h31
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object.c6
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object_eo.legacy.c12
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object_eo.legacy.h29
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_shape.c82
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_shape_eo.legacy.h54
-rw-r--r--src/lib/evas/canvas/evas_grid_eo.c2
-rw-r--r--src/lib/evas/canvas/evas_table_eo.c2
-rw-r--r--src/lib/evas/canvas/meson.build1
-rw-r--r--src/modules/ecore_evas/engines/x/ecore_evas_x.c7
164 files changed, 1632 insertions, 45335 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index d52240011b..bfb505e4a3 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -398,7 +398,7 @@ void test_ui_tab_pager(void *data, Evas_Object *obj, void *event_info);
398void test_ui_spotlight_stack(void *data, Evas_Object *obj, void *event_info); 398void test_ui_spotlight_stack(void *data, Evas_Object *obj, void *event_info);
399void test_ui_spotlight_plain(void *data, Evas_Object *obj, void *event_info); 399void test_ui_spotlight_plain(void *data, Evas_Object *obj, void *event_info);
400void test_ui_spotlight_scroll(void *data, Evas_Object *obj, void *event_info); 400void test_ui_spotlight_scroll(void *data, Evas_Object *obj, void *event_info);
401 401void test_ui_spotlight_animation(void *data, Evas_Object *obj, void *event_info);
402void test_ui_relative_container(void *data, Evas_Object *obj, void *event_info); 402void test_ui_relative_container(void *data, Evas_Object *obj, void *event_info);
403void test_efl_ui_radio(void *data, Evas_Object *obj, void *event_info); 403void test_efl_ui_radio(void *data, Evas_Object *obj, void *event_info);
404void test_efl_ui_collection_list(void *data, Evas_Object *obj, void *event_info); 404void test_efl_ui_collection_list(void *data, Evas_Object *obj, void *event_info);
@@ -1173,6 +1173,7 @@ add_tests:
1173 ADD_TEST_EO(NULL, "Spotlight", "Efl.Ui.Spotlight Plain", test_ui_spotlight_plain); 1173 ADD_TEST_EO(NULL, "Spotlight", "Efl.Ui.Spotlight Plain", test_ui_spotlight_plain);
1174 ADD_TEST_EO(NULL, "Spotlight", "Efl.Ui.Spotlight Scroll", test_ui_spotlight_scroll); 1174 ADD_TEST_EO(NULL, "Spotlight", "Efl.Ui.Spotlight Scroll", test_ui_spotlight_scroll);
1175 ADD_TEST_EO(NULL, "Spotlight", "Efl.Ui.Spotlight Stack", test_ui_spotlight_stack); 1175 ADD_TEST_EO(NULL, "Spotlight", "Efl.Ui.Spotlight Stack", test_ui_spotlight_stack);
1176 ADD_TEST_EO(NULL, "Spotlight", "Efl.Ui.Spotlight Custom animation", test_ui_spotlight_animation);
1176 ADD_TEST_EO(NULL, "Spotlight", "Navigation stack", test_ui_stack); 1177 ADD_TEST_EO(NULL, "Spotlight", "Navigation stack", test_ui_stack);
1177 //------------------------------// 1178 //------------------------------//
1178 ADD_TEST(NULL, "Popups", "Ctxpopup", test_ctxpopup); 1179 ADD_TEST(NULL, "Popups", "Ctxpopup", test_ctxpopup);
diff --git a/src/bin/elementary/test_ui_spotlight.c b/src/bin/elementary/test_ui_spotlight.c
index 1d0837d9db..a5c8d141e3 100644
--- a/src/bin/elementary/test_ui_spotlight.c
+++ b/src/bin/elementary/test_ui_spotlight.c
@@ -1129,3 +1129,118 @@ test_ui_spotlight_scroll(void *data EINA_UNUSED,
1129 efl_gfx_entity_size_set(win, EINA_SIZE2D(580, 320)); 1129 efl_gfx_entity_size_set(win, EINA_SIZE2D(580, 320));
1130} 1130}
1131 1131
1132
1133void
1134test_ui_spotlight_animation(void *data EINA_UNUSED,
1135 Evas_Object *obj EINA_UNUSED,
1136 void *event_info EINA_UNUSED)
1137{
1138 Eo *win, *panes, *navi, *list, *layout, *spotlight, *view, *custom_animation_manager;
1139 Efl_Canvas_Animation *jump_animation, *push_animation, *pop_animation;
1140 Params *params = NULL;
1141 char buf[PATH_MAX];
1142 int i;
1143
1144 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
1145 efl_text_set(efl_added, "Efl.Ui.Spotlight Scroll"),
1146 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
1147
1148 panes = efl_add(EFL_UI_PANES_CLASS, win,
1149 efl_gfx_hint_weight_set(efl_added, 1, 1),
1150 efl_ui_panes_split_ratio_set(efl_added, 0.3),
1151 efl_content_set(win, efl_added));
1152
1153 navi = elm_naviframe_add(panes);
1154 evas_object_show(navi);
1155 efl_content_set(efl_part(panes, "first"), navi);
1156
1157 list = elm_list_add(navi);
1158 elm_list_horizontal_set(list, EINA_FALSE);
1159 elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
1160 elm_naviframe_item_push(navi, "Properties", NULL, NULL, list, NULL);
1161 evas_object_show(list);
1162
1163 snprintf(buf, sizeof(buf), "%s/objects/test_pager.edj",
1164 elm_app_data_dir_get());
1165 layout = efl_add(EFL_UI_LAYOUT_CLASS, panes,
1166 efl_file_set(efl_added, buf),
1167 efl_file_key_set(efl_added, "pager"),
1168 efl_file_load(efl_added),
1169 efl_content_set(efl_part(panes, "second"), efl_added));
1170
1171
1172 jump_animation = efl_new(EFL_CANVAS_ALPHA_ANIMATION_CLASS);
1173 efl_animation_alpha_set(jump_animation, 0.0, 1.0);
1174 efl_animation_duration_set(jump_animation, 0.5);
1175
1176 push_animation = efl_new(EFL_CANVAS_TRANSLATE_ANIMATION_CLASS);
1177 efl_animation_translate_set(push_animation, EINA_POSITION2D(0, 100), EINA_POSITION2D(0, 0));
1178 efl_animation_duration_set(push_animation, 0.5);
1179
1180 pop_animation = efl_new(EFL_CANVAS_TRANSLATE_ANIMATION_CLASS);
1181 efl_animation_translate_set(pop_animation, EINA_POSITION2D(0, -100), EINA_POSITION2D(0, 0));
1182 efl_animation_duration_set(pop_animation, 0.5);
1183
1184 custom_animation_manager = efl_new(EFL_UI_SPOTLIGHT_ANIMATION_MANAGER_CLASS,
1185 efl_ui_spotlight_manager_animation_push_setup_set(efl_added, push_animation, jump_animation),
1186 efl_ui_spotlight_manager_animation_pop_setup_set(efl_added, jump_animation, pop_animation),
1187 efl_ui_spotlight_manager_animation_jump_setup_set(efl_added, jump_animation, jump_animation));
1188
1189 spotlight = efl_add(EFL_UI_SPOTLIGHT_CONTAINER_CLASS, layout,
1190 efl_ui_spotlight_manager_set(efl_added, custom_animation_manager),
1191 efl_content_set(efl_part(layout, "pager"), efl_added),
1192 efl_ui_spotlight_size_set(efl_added, EINA_SIZE2D(200, 300)));
1193
1194 efl_add(EFL_UI_BUTTON_CLASS, layout,
1195 efl_text_set(efl_added, "Pop"),
1196 efl_event_callback_add(efl_added,
1197 EFL_INPUT_EVENT_CLICKED, pop_btn_cb, spotlight),
1198 efl_content_set(efl_part(layout, "prev_btn"), efl_added));
1199
1200 efl_add(EFL_UI_BUTTON_CLASS, layout,
1201 efl_text_set(efl_added, "Push"),
1202 efl_event_callback_add(efl_added,
1203 EFL_INPUT_EVENT_CLICKED, push_btn_cb, spotlight),
1204 efl_content_set(efl_part(layout, "next_btn"), efl_added));
1205
1206 params = calloc(1, sizeof(Params));
1207 if (!params) return;
1208
1209 params->navi = navi;
1210 params->spotlight = spotlight;
1211 params->indicator = NULL;
1212 params->w = 200;
1213 params->h = 300;
1214 params->wfill = EINA_FALSE;
1215 params->hfill = EINA_FALSE;
1216
1217 elm_list_item_append(list, "View Size", NULL, NULL, spotlight_size, params);
1218 elm_list_item_append(list, "Pack / Unpack", NULL, NULL, pack_cb, params);
1219 elm_list_item_append(list, "Active Index", NULL, NULL, active_index_cb, params);
1220 elm_list_item_append(list, "Indicator", NULL, NULL, indicator_cb, params);
1221 elm_list_item_append(list, "Animation", NULL, NULL, view_animation_cb, params);
1222 elm_list_item_append(list, "Scroll Block", NULL, NULL, scroll_block_cb, params);
1223 elm_list_go(list);
1224
1225 efl_event_callback_add(list, EFL_EVENT_DEL, list_del_cb, params);
1226
1227 for (i = 0; i < PAGE_NUM; i++) {
1228 switch (i % 3)
1229 {
1230 case 0:
1231 view = view_add(LAYOUT, spotlight);
1232 break;
1233
1234 case 1:
1235 view = view_add(LIST, spotlight);
1236 break;
1237
1238 case 2:
1239 view = view_add(BUTTON, spotlight);
1240 break;
1241 }
1242 efl_pack_end(spotlight, view);
1243 }
1244
1245 efl_gfx_entity_size_set(win, EINA_SIZE2D(580, 320));
1246}
diff --git a/src/examples/elementary/evas3d_map_example.c b/src/examples/elementary/evas3d_map_example.c
deleted file mode 100644
index f0859e30ac..0000000000
--- a/src/examples/elementary/evas3d_map_example.c
+++ /dev/null
@@ -1,1211 +0,0 @@
1#ifndef EFL_BETA_API_SUPPORT
2# define EFL_BETA_API_SUPPORT
3#endif
4
5#include <Elementary.h>
6
7#define WIDTH 1024
8#define HEIGHT 1024
9#define IMG_SIZE 1024
10#define SKYBOX_IMG_WIDTH 4096
11#define SKYBOX_IMG_HEIGHT 3072
12
13#define MIN_3D_ZOOM_FACTOR 1.0
14#define MAX_3D_ZOOM_FACTOR 4.9
15#define MIN_2D_ZOOM_FACTOR 5.0
16#define MAX_2D_ZOOM_FACTOR 16.0
17
18#define MAX_CAMERA_DISTANCE 10.0
19
20#define ROUND(a) ((a < 0) ? ((int)((a - 0.05) * 10) * 0.1) : ((int)((a + 0.05) * 10) * 0.1))
21
22typedef struct _mat3
23{
24 float m[9];
25} mat3;
26
27typedef struct _vec4
28{
29 float x;
30 float y;
31 float z;
32 float w;
33} vec4;
34
35typedef struct _vec2
36{
37 float x;
38 float y;
39} vec2;
40
41typedef struct _vec3
42{
43 float x;
44 float y;
45 float z;
46} vec3;
47
48typedef struct _vertex
49{
50 vec3 position;
51 vec3 normal;
52 vec3 tangent;
53 vec4 color;
54 vec3 texcoord;
55} vertex;
56
57typedef enum _Map_Dimension_State
58{
59 MAP_DIMENSION_STATE_2D = 0,
60 MAP_DIMENSION_STATE_3D
61} Map_Dimension_State;
62
63static Evas *evas = NULL;
64static Evas_Object *win = NULL;
65static Evas_Object *bg = NULL;
66static Evas_Object *image = NULL;
67static Evas_Object *map = NULL;
68static Evas_Object *normal_map = NULL;
69static Evas_Object *control_layout = NULL;
70static Evas_Object *hoversel = NULL;
71static Evas_Object *rotation_toggle = NULL;
72static Evas_Object *light_toggle = NULL;
73static Evas_Object *zoom_slider = NULL;
74static Evas_Object *menu = NULL;
75static Elm_Object_Item *menu_it = NULL;
76static Ecore_Animator *animator = NULL;
77
78static Evas_Canvas3D_Scene *scene = NULL;
79static Evas_Canvas3D_Node *root_node = NULL;
80static Evas_Canvas3D_Node *camera_node = NULL;
81static Evas_Canvas3D_Camera *camera = NULL;
82static Evas_Canvas3D_Node *light_node = NULL;
83static Evas_Canvas3D_Light *light = NULL;
84static Evas_Canvas3D_Node *mesh_node = NULL;
85static Evas_Canvas3D_Mesh *mesh = NULL;
86static Evas_Canvas3D_Material *material = NULL;
87static Evas_Canvas3D_Texture *texture_diffuse = NULL;
88static Evas_Canvas3D_Texture *texture_normal = NULL;
89
90static int vertex_count = 0;
91static int index_count = 0;
92static vertex *vertices = NULL;
93static unsigned short *indices = NULL;
94
95static vec2 mouse_down_pos;
96static vec3 camera_pos;
97static vec3 camera_up_vec;
98static vec3 camera_right_vec;
99static double zoom_factor = MIN_3D_ZOOM_FACTOR;
100static Eina_Bool is_mouse_pressed = EINA_FALSE;
101static Map_Dimension_State map_dimension_state = MAP_DIMENSION_STATE_3D;
102
103static const float skybox_vertices[] =
104{
105 /* Front */
106 -40.0, 40.0, 40.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.99, 0.334,
107 40.0, 40.0, 40.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.75, 0.334,
108 -40.0, -40.0, 40.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.99, 0.666,
109 40.0, -40.0, 40.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.75, 0.666,
110
111 /* Back */
112 40.0, 40.0, -40.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.50, 0.334,
113 -40.0, 40.0, -40.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.25, 0.334,
114 40.0, -40.0, -40.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.50, 0.666,
115 -40.0, -40.0, -40.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.25, 0.666,
116
117 /* Left */
118 -40.0, 40.0, -40.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.25, 0.334,
119 -40.0, 40.0, 40.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.01, 0.334,
120 -40.0, -40.0, -40.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.25, 0.666,
121 -40.0, -40.0, 40.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.01, 0.666,
122
123 /* Right */
124 40.0, 40.0, 40.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.75, 0.334,
125 40.0, 40.0, -40.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.50, 0.334,
126 40.0, -40.0, 40.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.75, 0.666,
127 40.0, -40.0, -40.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.50, 0.666,
128
129 /* Top */
130 -40.0, 40.0, -40.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.25, 0.334,
131 40.0, 40.0, -40.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.50, 0.334,
132 -40.0, 40.0, 40.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.25, 0.01,
133 40.0, 40.0, 40.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.50, 0.01,
134
135 /* Bottom */
136 40.0, -40.0, -40.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.50, 0.666,
137 -40.0, -40.0, -40.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.25, 0.666,
138 40.0, -40.0, 40.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.50, 0.99,
139 -40.0, -40.0, 40.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.25, 0.99,
140};
141
142static const unsigned short skybox_indices[] =
143{
144 /* Front */
145 0, 1, 2, 2, 1, 3,
146
147 /* Back */
148 4, 5, 6, 6, 5, 7,
149
150 /* Left */
151 8, 9, 10, 10, 9, 11,
152
153 /* Right */
154 12, 13, 14, 14, 13, 15,
155
156 /* Top */
157 16, 17, 18, 18, 17, 19,
158
159 /* Bottom */
160 20, 21, 22, 22, 21, 23
161};
162
163static void zoom_factor_set(double new_zoom_factor);
164
165static inline void
166vec3_scale(vec3 *out,
167 const vec3 *v,
168 const double scale)
169{
170 out->x = scale * v->x;
171 out->y = scale * v->y;
172 out->z = scale * v->z;
173}
174
175static inline void
176vec3_normalize(vec3 *out,
177 const vec3 *vec)
178{
179 double length = sqrt(vec->x * vec->x + vec->y * vec->y + vec->z * vec->z);
180
181 out->x = vec->x / length;
182 out->y = vec->y / length;
183 out->z = vec->z / length;
184}
185
186static inline void
187mat3_multiply_vec3(vec3 *out,
188 const mat3 *mat,
189 const vec3 *vec)
190{
191 out->x = mat->m[0] * vec->x + mat->m[1] * vec->y + mat->m[2] * vec->z;
192 out->y = mat->m[3] * vec->x + mat->m[4] * vec->y + mat->m[5] * vec->z;
193 out->z = mat->m[6] * vec->x + mat->m[7] * vec->y + mat->m[8] * vec->z;
194}
195
196static inline void
197vec3_rotate_angle_axis(vec3 *out,
198 const vec3 *vec,
199 const double radian,
200 const vec3 *axis)
201{
202 mat3 mat;
203 double cos_r = cos(radian);
204 double sin_r = sin(radian);
205 double one_minus_cos_r = 1.0 - cos_r;
206
207 mat.m[0] = cos_r + one_minus_cos_r * (axis->x * axis->x);
208 mat.m[1] = (-axis->z * sin_r) + one_minus_cos_r * (axis->x * axis->y);
209 mat.m[2] = (axis->y * sin_r) + one_minus_cos_r * (axis->x * axis->z);
210
211 mat.m[3] = (axis->z * sin_r) + one_minus_cos_r * (axis->x * axis->y);
212 mat.m[4] = cos_r + one_minus_cos_r * (axis->y * axis->y);
213 mat.m[5] = (-axis->x * sin_r) + one_minus_cos_r * (axis->y * axis->z);
214
215 mat.m[6] = (-axis->y * sin_r) + one_minus_cos_r * (axis->x * axis->z);
216 mat.m[7] = (axis->x * sin_r) + one_minus_cos_r * (axis->y * axis->z);
217 mat.m[8] = cos_r + one_minus_cos_r * (axis->z * axis->z);
218
219 mat3_multiply_vec3(out, &mat, vec);
220}
221
222static Eina_Bool
223animate_scene(void *data)
224{
225 static float angle = 0.0f;
226
227 angle += 0.05;
228
229 evas_canvas3d_node_orientation_angle_axis_set((Evas_Canvas3D_Node *)data, angle, 0.0, 1.0, 0.0);
230
231 /* Rotate */
232 if (angle > 360.0)
233 angle -= 360.0f;
234
235 return EINA_TRUE;
236}
237
238static void
239sphere_init(int precision)
240{
241 int i, j;
242 vertex *v;
243 unsigned short *idx;
244
245 vertex_count = (precision + 1) * (precision + 1);
246 index_count = precision * precision * 6;
247
248 /* Allocate buffer. */
249 vertices = malloc(sizeof(vertex) * vertex_count);
250 indices = malloc(sizeof(unsigned short) * index_count);
251
252 for (i = 0; i <= precision; i++)
253 {
254 double lati = M_PI * ((double)i / (double)precision);
255 double y = cos(lati);
256 double r = fabs(sin(lati));
257
258 for (j = 0; j <= precision; j++)
259 {
260 double longi = (M_PI * 2.0) * ((double)j / (double)precision);
261 v = &vertices[i * (precision + 1) + j];
262
263 if (j == 0 || j == precision) v->position.x = 0.0;
264 else v->position.x = r * sin(longi);
265
266 v->position.y = y;
267
268 if (j == 0 || j == precision) v->position.z = r;
269 else v->position.z = r * cos(longi);
270
271 v->normal = v->position;
272
273 if (v->position.x > 0.0)
274 {
275 v->tangent.x = -v->normal.y;
276 v->tangent.y = v->normal.x;
277 v->tangent.z = v->normal.z;
278 }
279 else
280 {
281 v->tangent.x = v->normal.y;
282 v->tangent.y = -v->normal.x;
283 v->tangent.z = v->normal.z;
284 }
285
286 v->color.x = 1.0;
287 v->color.y = 1.0;
288 v->color.z = 1.0;
289 v->color.w = 1.0;
290
291 if (j == precision) v->texcoord.x = 1.0;
292 else if (j == 0) v->texcoord.x = 0.0;
293 else v->texcoord.x = (double)j / (double)precision;
294
295 if (i == precision) v->texcoord.y = 1.0;
296 else if (i == 0) v->texcoord.y = 0.0;
297 else v->texcoord.y = (double)i / (double)precision;
298 }
299 }
300
301 idx = &indices[0];
302
303 for (i = 0; i < precision; i++)
304 {
305 for (j = 0; j < precision; j++)
306 {
307 *idx++ = i * (precision + 1) + j;
308 *idx++ = i * (precision + 1) + j + 1;
309 *idx++ = (i + 1) * (precision + 1) + j;
310
311 *idx++ = (i + 1) * (precision + 1) + j;
312 *idx++ = i * (precision + 1) + j + 1;
313 *idx++ = (i + 1) * (precision + 1) + j + 1;
314 }
315 }
316
317 for (i = 0; i < index_count; i += 3)
318 {
319 vertex *v0 = &vertices[indices[i + 0]];
320 vertex *v1 = &vertices[indices[i + 1]];
321 vertex *v2 = &vertices[indices[i + 2]];
322
323 vec3 e1, e2;
324 float du1, du2, dv1, dv2, f;
325 vec3 tangent;
326
327 e1.x = v1->position.x - v0->position.x;
328 e1.y = v1->position.y - v0->position.y;
329 e1.z = v1->position.z - v0->position.z;
330
331 e2.x = v2->position.x - v0->position.x;
332 e2.y = v2->position.y - v0->position.y;
333 e2.z = v2->position.z - v0->position.z;
334
335 du1 = v1->texcoord.x - v0->texcoord.x;
336 dv1 = v1->texcoord.y - v0->texcoord.y;
337
338 du2 = v2->texcoord.x - v0->texcoord.x;
339 dv2 = v2->texcoord.y - v0->texcoord.y;
340
341 f = 1.0 / (du1 * dv2 - du2 * dv1);
342
343 tangent.x = f * (dv2 * e1.x - dv1 * e2.x);
344 tangent.y = f * (dv2 * e1.y - dv1 * e2.y);
345 tangent.z = f * (dv2 * e1.z - dv1 * e2.z);
346
347 v0->tangent = tangent;
348 }
349
350 for (i = 0; i <= precision; i++)
351 {
352 for (j = 0; j <= precision; j++)
353 {
354 if (j == precision)
355 {
356 v = &vertices[i * (precision + 1) + j];
357 v->tangent = vertices[i * (precision + 1)].tangent;
358 }
359 }
360 }
361}
362
363static void
364sphere_fini(void)
365{
366 if (vertices)
367 free(vertices);
368
369 if (indices)
370 free(indices);
371}
372
373static void
374change_to_2d_map(void)
375{
376 if (map_dimension_state == MAP_DIMENSION_STATE_2D) return;
377 map_dimension_state = MAP_DIMENSION_STATE_2D;
378
379 elm_object_style_set(map, "default");
380 elm_scroller_policy_set
381 (map, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
382 elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_MANUAL);
383 elm_map_paused_set(map, EINA_TRUE);
384
385 evas_canvas3d_texture_source_visible_set(texture_diffuse, EINA_TRUE);
386
387 evas_object_hide(image);
388
389 elm_slider_unit_format_set(zoom_slider, "X%1.0f");
390 elm_slider_indicator_format_set(zoom_slider, "%1.0f");
391 elm_slider_min_max_set(zoom_slider, MIN_2D_ZOOM_FACTOR, MAX_2D_ZOOM_FACTOR);
392}
393
394static void
395change_to_3d_map(void)
396{
397 if (map_dimension_state == MAP_DIMENSION_STATE_3D) return;
398 map_dimension_state = MAP_DIMENSION_STATE_3D;
399
400 elm_object_style_set(map, "evas3d");
401 elm_scroller_policy_set
402 (map, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
403 elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_AUTO_FILL);
404
405 evas_object_show(image);
406
407 elm_slider_unit_format_set(zoom_slider, "X%1.1f");
408 elm_slider_indicator_format_set(zoom_slider, "%1.1f");
409 elm_slider_min_max_set(zoom_slider, MIN_3D_ZOOM_FACTOR, MAX_3D_ZOOM_FACTOR);
410}
411
412static void
413zoom_factor_set(double new_zoom_factor)
414{
415 double cur_zoom_factor;
416 double s, t;
417 double lon, lat;
418 vec3 camera_pos_unit_vec;
419 Evas_Canvas3D_Node *n;
420 Evas_Canvas3D_Mesh *m;
421 Evas_Coord src_x, src_y;
422 Evas_Coord src_size;
423
424 cur_zoom_factor = zoom_factor;
425 zoom_factor = ROUND(new_zoom_factor);
426
427 if (cur_zoom_factor == zoom_factor) return;
428
429 /* 2D Zoom */
430 if (zoom_factor >= MIN_2D_ZOOM_FACTOR)
431 {
432 /* Transition from 3D to 2D */
433 if (cur_zoom_factor < MIN_2D_ZOOM_FACTOR)
434 {
435 zoom_factor = MIN_2D_ZOOM_FACTOR;
436 evas_canvas3d_scene_pick(scene, IMG_SIZE / 2, IMG_SIZE / 2, &n, &m, &s, &t);
437 src_size = IMG_SIZE * cur_zoom_factor;
438 src_x = (Evas_Coord)(src_size * s);
439 src_y = (Evas_Coord)(src_size * t);
440 elm_map_canvas_to_region_convert(map, src_x, src_y, &lon, &lat);
441
442 change_to_2d_map();
443 evas_object_resize(map, IMG_SIZE, IMG_SIZE);
444 elm_map_zoom_set(map, (int)zoom_factor);
445 elm_map_region_show(map, lon, lat);
446 }
447 else
448 elm_map_zoom_set(map, (int)zoom_factor);
449 }
450 /* 3D Zoom */
451 else
452 {
453 if (zoom_factor < MIN_3D_ZOOM_FACTOR)
454 zoom_factor = MIN_3D_ZOOM_FACTOR;
455
456 /* Transition from 2D to 3D */
457 if (cur_zoom_factor >= MIN_2D_ZOOM_FACTOR)
458 {
459 change_to_3d_map();
460 }
461
462 /* Update texture source. */
463 src_size = IMG_SIZE * zoom_factor;
464 evas_object_resize(map, src_size, src_size);
465
466 /* Apply updated texture source. */
467 texture_diffuse = efl_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
468 evas_canvas3d_texture_source_set(texture_diffuse, map);
469 evas_canvas3d_texture_source_visible_set(texture_diffuse, EINA_FALSE);
470
471 evas_canvas3d_material_texture_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture_diffuse);
472
473 /* Update camera position. */
474 vec3_normalize(&camera_pos_unit_vec, &camera_pos);
475 camera_pos.x = (camera_pos_unit_vec.x * MAX_CAMERA_DISTANCE) / zoom_factor;
476 camera_pos.y = (camera_pos_unit_vec.y * MAX_CAMERA_DISTANCE) / zoom_factor;
477 camera_pos.z = (camera_pos_unit_vec.z * MAX_CAMERA_DISTANCE) / zoom_factor;
478
479 evas_canvas3d_node_position_set(camera_node, camera_pos.x, camera_pos.y, camera_pos.z);
480 }
481
482 /* Update zoom slider. */
483 elm_slider_value_set(zoom_slider, zoom_factor);
484}
485
486static void
487zoom_in_cb(void *data EINA_UNUSED,
488 Evas_Object *obj EINA_UNUSED,
489 void *event_info EINA_UNUSED)
490{
491 zoom_factor_set(zoom_factor + 1);
492}
493
494static void
495zoom_out_cb(void *data EINA_UNUSED,
496 Evas_Object *obj EINA_UNUSED,
497 void *event_info EINA_UNUSED)
498{
499 zoom_factor_set(zoom_factor - 1);
500}
501
502static void
503zoom_to_2d_map_cb(void *data EINA_UNUSED,
504 Evas_Object *obj EINA_UNUSED,
505 void *event_info EINA_UNUSED)
506{
507 double s, t;
508 double lon, lat;
509 Evas_Canvas3D_Node *n;
510 Evas_Canvas3D_Mesh *m;
511 Evas_Coord src_x, src_y;
512 Evas_Coord src_size;
513
514 if (map_dimension_state == MAP_DIMENSION_STATE_2D) return;
515
516 evas_canvas3d_scene_pick(scene, mouse_down_pos.x, mouse_down_pos.y, &n, &m, &s, &t);
517 src_size = (Evas_Coord)(IMG_SIZE * zoom_factor);
518 src_x = (Evas_Coord)(src_size * s);
519 src_y = (Evas_Coord)(src_size * t);
520 elm_map_canvas_to_region_convert(map, src_x, src_y, &lon, &lat);
521
522 zoom_factor_set(MIN_2D_ZOOM_FACTOR);
523
524 elm_map_region_show(map, lon, lat);
525}
526
527static void
528zoom_to_3d_map_cb(void *data EINA_UNUSED,
529 Evas_Object *obj EINA_UNUSED,
530 void *event_info EINA_UNUSED)
531{
532 if (map_dimension_state == MAP_DIMENSION_STATE_3D) return;
533
534 zoom_factor_set(MAX_3D_ZOOM_FACTOR);
535}
536
537static void
538submenu_zoom_add(Elm_Object_Item *parent)
539{
540 if (!parent) return;
541
542 elm_menu_item_add(menu, parent, NULL, "Zoom in", zoom_in_cb, NULL);
543 elm_menu_item_add(menu, parent, NULL, "Zoom out", zoom_out_cb, NULL);
544 elm_menu_item_add(menu, parent, NULL, "Zoom to 2D map", zoom_to_2d_map_cb, NULL);
545 elm_menu_item_add(menu, parent, NULL, "Zoom to 3D map", zoom_to_3d_map_cb, NULL);
546}
547
548static void
549submenu_info_add(Elm_Object_Item *parent)
550{
551 char buf[50];
552 double s, t;
553 double lon, lat;
554 Evas_Canvas3D_Node *n;
555 Evas_Canvas3D_Mesh *m;
556 Evas_Coord src_x, src_y;
557 Evas_Coord src_size;
558
559 if (!parent) return;
560
561 if (map_dimension_state == MAP_DIMENSION_STATE_3D)
562 {
563 evas_canvas3d_scene_pick(scene, mouse_down_pos.x, mouse_down_pos.y, &n, &m, &s, &t);
564 src_size = (Evas_Coord) (IMG_SIZE * zoom_factor);
565 src_x = (Evas_Coord)(src_size * s);
566 src_y = (Evas_Coord)(src_size * t);
567 elm_map_canvas_to_region_convert(map, src_x, src_y, &lon, &lat);
568 }
569 else
570 {
571 elm_map_canvas_to_region_convert(map, mouse_down_pos.x, mouse_down_pos.y, &lon, &lat);
572 }
573
574 snprintf(buf, sizeof(buf), "Longitude : %f", lon);
575 elm_menu_item_add(menu, parent, NULL, buf, NULL, NULL);
576
577 snprintf(buf, sizeof(buf), "Latitude : %f", lat);
578 elm_menu_item_add(menu, parent, NULL, buf, NULL, NULL);
579}
580
581static void
582map_zoom_change_cb(void *data EINA_UNUSED,
583 Evas_Object *obj EINA_UNUSED,
584 void *event_info EINA_UNUSED)
585{
586 int cur_zoom_factor;
587
588 if (map_dimension_state == MAP_DIMENSION_STATE_3D) return;
589
590 cur_zoom_factor = elm_map_zoom_get(map);
591
592 if (elm_map_paused_get(map))
593 elm_map_paused_set(map, EINA_FALSE);
594
595 zoom_factor_set(cur_zoom_factor);
596}
597
598static void
599map_mouse_down_cb(void *data EINA_UNUSED,
600 Evas *e EINA_UNUSED,
601 Evas_Object *o,
602 void *event_info)
603{
604 Evas_Event_Mouse_Down *ev = event_info;
605 Evas_Coord x, y, w, h;
606 Evas_Coord obj_x, obj_y;
607 int scene_w, scene_h;
608 double scene_x, scene_y;
609 double s, t;
610 Evas_Canvas3D_Node *n;
611 Evas_Canvas3D_Mesh *m;
612 Eina_Bool pick;
613
614 mouse_down_pos.x = ev->canvas.x;
615 mouse_down_pos.y = ev->canvas.y;
616
617 evas_object_geometry_get(o, &x, &y, &w, &h);
618
619 obj_x = ev->canvas.x - x;
620 obj_y = ev->canvas.y - y;
621
622 evas_canvas3d_scene_size_get(scene, &scene_w, &scene_h);
623
624 scene_x = obj_x * scene_w / (double)w;
625 scene_y = obj_y * scene_h / (double)h;
626
627 pick = evas_canvas3d_scene_pick(scene, scene_x, scene_y, &n, &m, &s, &t);
628 if (pick)
629 printf("Picked : ");
630 else
631 printf("Not picked : ");
632
633 printf("output(%d, %d) canvas(%d, %d) object(%d, %d) scene(%f, %f) texcoord(%f, %f) "
634 "node(%p) mesh(%p)\n",
635 ev->output.x, ev->output.y,
636 ev->canvas.x, ev->canvas.y,
637 obj_x, obj_y,
638 scene_x, scene_y,
639 s, t, n, m);
640
641 if (ev->button == 3)
642 {
643 if (!menu)
644 {
645 menu = elm_menu_add(o);
646 elm_menu_parent_set(menu, o);
647 menu_it = elm_menu_item_add(menu, NULL, "", "Zoom", NULL, NULL);
648 submenu_zoom_add(menu_it);
649 menu_it = elm_menu_item_add(menu, NULL, "", "Info", NULL, NULL);
650 }
651
652 elm_menu_item_subitems_clear(menu_it);
653 submenu_info_add(menu_it);
654
655 elm_menu_move(menu, ev->canvas.x, ev->canvas.y);
656 evas_object_show(menu);
657 }
658
659}
660
661static void
662mouse_down_cb(void *data EINA_UNUSED,
663 Evas *e EINA_UNUSED,
664 Evas_Object *o,
665 void *event_info)
666{
667 Evas_Event_Mouse_Down *ev = event_info;
668 Evas_Coord x, y, w, h;
669 Evas_Coord obj_x, obj_y;
670 int scene_w, scene_h;
671 double scene_x, scene_y;
672 double s, t;
673 Evas_Canvas3D_Node *n;
674 Evas_Canvas3D_Mesh *m;
675 Eina_Bool pick;
676
677 mouse_down_pos.x = ev->canvas.x;
678 mouse_down_pos.y = ev->canvas.y;
679
680 /* Stop rotating earth. */
681 if (animator)
682 {
683 ecore_animator_del(animator);
684 animator = NULL;
685 }
686
687 evas_object_geometry_get(o, &x, &y, &w, &h);
688
689 obj_x = ev->canvas.x - x;
690 obj_y = ev->canvas.y - y;
691
692 evas_canvas3d_scene_size_get(scene, &scene_w, &scene_h);
693
694 scene_x = obj_x * scene_w / (double)w;
695 scene_y = obj_y * scene_h / (double)h;
696
697 pick = evas_canvas3d_scene_pick(scene, scene_x, scene_y, &n, &m, &s, &t);
698 if (pick)
699 printf("Picked : ");
700 else
701 printf("Not picked : ");
702
703 printf("output(%d, %d) canvas(%d, %d) object(%d, %d) scene(%f, %f) texcoord(%f, %f) "
704 "node(%p) mesh(%p)\n",
705 ev->output.x, ev->output.y,
706 ev->canvas.x, ev->canvas.y,
707 obj_x, obj_y,
708 scene_x, scene_y,
709 s, t, n, m);
710
711 if (ev->button == 1)
712 is_mouse_pressed = EINA_TRUE;
713 else if (ev->button == 3)
714 {
715 elm_check_state_set(rotation_toggle, EINA_FALSE);
716 if (!menu)
717 {
718 menu = elm_menu_add(o);
719 elm_menu_parent_set(menu, o);
720 menu_it = elm_menu_item_add(menu, NULL, "", "Zoom", NULL, NULL);
721 submenu_zoom_add(menu_it);
722 menu_it = elm_menu_item_add(menu, NULL, "", "Info", NULL, NULL);
723 }
724
725 elm_menu_item_subitems_clear(menu_it);
726 submenu_info_add(menu_it);
727
728 elm_menu_move(menu, ev->canvas.x, ev->canvas.y);
729 evas_object_show(menu);
730 }
731}
732
733static void
734mouse_move_cb(void *data EINA_UNUSED,
735 Evas *e EINA_UNUSED,
736 Evas_Object *o EINA_UNUSED,
737 void *event_info)
738{
739 Evas_Event_Mouse_Move *ev = event_info;
740 double distance_to_origin;
741 double radian_camera_up_axis, radian_camera_right_axis;
742 vec3 camera_pos_unit_vec;
743
744 if ((ev->buttons == 1) && is_mouse_pressed)
745 {
746 radian_camera_up_axis = (ev->prev.canvas.x - ev->cur.canvas.x) * 0.01;
747 radian_camera_right_axis = (ev->prev.canvas.y - ev->cur.canvas.y) * 0.01;
748
749 distance_to_origin = sqrt(pow(camera_pos.x, 2) + pow(camera_pos.y, 2) + pow(camera_pos.z, 2));
750
751 /* Update camera position, up vector and right vector. */
752 vec3_rotate_angle_axis(&camera_pos, &camera_pos, radian_camera_up_axis, &camera_up_vec);
753 vec3_rotate_angle_axis(&camera_right_vec, &camera_right_vec, radian_camera_up_axis, &camera_up_vec);
754 vec3_normalize(&camera_right_vec, &camera_right_vec);
755
756 vec3_rotate_angle_axis(&camera_pos, &camera_pos, radian_camera_right_axis, &camera_right_vec);
757 vec3_rotate_angle_axis(&camera_up_vec, &camera_up_vec, radian_camera_right_axis, &camera_right_vec);
758 vec3_normalize(&camera_up_vec, &camera_up_vec);
759 vec3_normalize(&camera_pos_unit_vec, &camera_pos);
760 vec3_scale(&camera_pos, &camera_pos_unit_vec, distance_to_origin);
761
762 evas_canvas3d_node_position_set(camera_node, camera_pos.x, camera_pos.y, camera_pos.z);
763 evas_canvas3d_node_look_at_set(camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, camera_up_vec.x, camera_up_vec.y, camera_up_vec.z);
764
765 if (elm_check_state_get(light_toggle))
766 {
767 /* Update light position as the same as camera position. */
768 evas_canvas3d_node_position_set(light_node, camera_pos.x, camera_pos.y, camera_pos.z);
769 evas_canvas3d_node_look_at_set(light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, camera_up_vec.x, camera_up_vec.y, camera_up_vec.z);
770 }
771 }
772}
773
774static void
775mouse_up_cb(void *data EINA_UNUSED,
776 Evas *e EINA_UNUSED,
777 Evas_Object *o,
778 void *event_info)
779{
780 Evas_Event_Mouse_Up *ev = event_info;
781 Evas_Coord x, y, w, h;
782 Evas_Coord obj_x, obj_y;
783 int scene_w, scene_h;
784 double scene_x, scene_y;
785 double s, t;
786 Evas_Canvas3D_Node *n;
787 Evas_Canvas3D_Mesh *m;
788 Eina_Bool pick;
789
790 evas_object_geometry_get(o, &x, &y, &w, &h);
791
792 obj_x = ev->canvas.x - x;
793 obj_y = ev->canvas.y - y;
794
795 evas_canvas3d_scene_size_get(scene, &scene_w, &scene_h);
796
797 scene_x = obj_x * scene_w / (double)w;
798 scene_y = obj_y * scene_h / (double)h;
799
800 pick = evas_canvas3d_scene_pick(scene, scene_x, scene_y, &n, &m, &s, &t);
801 if (pick)
802 printf("Picked : ");
803 else
804 printf("Not picked : ");
805
806 printf("output(%d, %d) canvas(%d, %d) object(%d, %d) scene(%f, %f) texcoord(%f, %f) "
807 "node(%p) mesh(%p)\n",
808 ev->output.x, ev->output.y,
809 ev->canvas.x, ev->canvas.y,
810 obj_x, obj_y,
811 scene_x, scene_y,
812 s, t, n, m);
813
814 /* Move camera position. */
815 if (ev->button == 1)
816 is_mouse_pressed = EINA_FALSE;
817
818 if (elm_check_state_get(rotation_toggle))
819 {
820 /* Restart rotating earth. */
821 animator = ecore_animator_add(animate_scene, mesh_node);
822 }
823}
824
825static void
826mouse_wheel_cb(void *data EINA_UNUSED,
827 Evas *e EINA_UNUSED,
828 Evas_Object *o EINA_UNUSED,
829 void *event_info)
830{
831 Evas_Event_Mouse_Wheel *ev = event_info;
832 double new_zoom_factor;
833
834 if (map_dimension_state == MAP_DIMENSION_STATE_2D) return;
835
836 new_zoom_factor = zoom_factor - (ev->z * 0.1);
837 zoom_factor_set(new_zoom_factor);
838}
839
840static void
841skybox_setup(void)
842{
843 Evas_Canvas3D_Node *skybox_mesh_node;
844 Evas_Canvas3D_Mesh *skybox_mesh;
845 Evas_Canvas3D_Material *skybox_material;
846 Evas_Canvas3D_Texture *skybox_texture_diffuse;
847 Evas_Object *skybox_image;
848 char buf[PATH_MAX];
849
850 skybox_mesh = efl_add(EVAS_CANVAS3D_MESH_CLASS, evas);
851 evas_canvas3d_mesh_vertex_count_set(skybox_mesh, 24);
852 evas_canvas3d_mesh_frame_add(skybox_mesh, 0);
853 evas_canvas3d_mesh_frame_vertex_data_set(skybox_mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 12 * sizeof(float), &skybox_vertices[0]);
854 evas_canvas3d_mesh_frame_vertex_data_set(skybox_mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 12 * sizeof(float), &skybox_vertices[3]);
855 evas_canvas3d_mesh_frame_vertex_data_set(skybox_mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, 12 * sizeof(float), &skybox_vertices[6]);
856 evas_canvas3d_mesh_frame_vertex_data_set(skybox_mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 12 * sizeof(float), &skybox_vertices[10]);
857 evas_canvas3d_mesh_index_data_set(skybox_mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &skybox_indices[0]);
858 evas_canvas3d_mesh_vertex_assembly_set(skybox_mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
859
860 /* Set skybox texture source image. */
861 skybox_image = elm_image_add(win);
862 snprintf(buf, sizeof(buf), "%s/images/space.png", elm_app_data_dir_get());
863 elm_image_file_set(skybox_image, buf, NULL);
864 evas_object_resize(skybox_image, SKYBOX_IMG_WIDTH, SKYBOX_IMG_HEIGHT);
865 evas_object_show(skybox_image);
866
867 /* Set skybox texture material. */
868 skybox_material = efl_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
869 evas_canvas3d_mesh_frame_material_set(skybox_mesh, 0, skybox_material);
870
871 skybox_texture_diffuse = efl_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
872
873 evas_canvas3d_texture_source_set(skybox_texture_diffuse, skybox_image);
874 evas_canvas3d_texture_source_visible_set(skybox_texture_diffuse, EINA_FALSE);
875
876 evas_canvas3d_material_texture_set(skybox_material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, skybox_texture_diffuse);
877 evas_canvas3d_material_enable_set(skybox_material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
878 evas_canvas3d_material_enable_set(skybox_material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
879 evas_canvas3d_material_enable_set(skybox_material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
880 evas_canvas3d_material_color_set(skybox_material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.1, 0.1, 0.1, 1.0);
881 evas_canvas3d_material_color_set(skybox_material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0);
882 evas_canvas3d_material_color_set(skybox_material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 0.1, 0.1, 0.1, 1.0);
883 evas_canvas3d_material_shininess_set(skybox_material, 50.0);
884
885 skybox_mesh_node = efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_MESH));
886 evas_canvas3d_node_member_add(root_node, skybox_mesh_node);
887 evas_canvas3d_node_mesh_add(skybox_mesh_node, skybox_mesh);
888 evas_canvas3d_mesh_shader_mode_set(skybox_mesh, EVAS_CANVAS3D_SHADER_MODE_DIFFUSE);
889}
890
891static void
892texture_source_setup(void)
893{
894 char buf[PATH_MAX];
895
896 snprintf(buf, sizeof(buf), "%s/examples/evas3d_map_example.edj", elm_app_data_dir_get());
897 elm_theme_extension_add(NULL, buf);
898
899 /* Add a map object for the use of the texture source. */
900 map = elm_map_add(win);
901 elm_object_style_set(map, "evas3d");
902 elm_map_source_set(map, ELM_MAP_SOURCE_TYPE_TILE, "MapQuest");
903 elm_scroller_policy_set
904 (map, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
905 elm_map_zoom_mode_set(map, ELM_MAP_ZOOM_MODE_AUTO_FILL);
906 evas_object_resize(map, IMG_SIZE, IMG_SIZE);
907 evas_object_show(map);
908
909 evas_object_smart_callback_add(map, "zoom,change",
910 map_zoom_change_cb, NULL);
911 evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_DOWN,
912 map_mouse_down_cb, map);
913
914 /* Add a normal map object for the use of the normal texture source. */
915 normal_map = elm_image_add(win);
916 snprintf(buf, sizeof(buf), "%s/images/earth_normal.png", elm_app_data_dir_get());
917 elm_image_file_set(normal_map, buf, NULL);
918 evas_object_resize(normal_map, IMG_SIZE, IMG_SIZE);
919 evas_object_show(normal_map);
920}
921
922static void
923camera_setup(void)
924{
925 /* Add the camera. */
926 camera = efl_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
927 evas_canvas3d_camera_projection_perspective_set(camera, 60.0, 1.0, 1.0, 100.0);
928
929 /* Set camera position. */
930 camera_pos.x = 0.0;
931 camera_pos.y = 0.0;
932 camera_pos.z = MAX_CAMERA_DISTANCE;
933
934 /* Set camera up vector. */
935 camera_up_vec.x = 0.0;
936 camera_up_vec.y = 1.0;
937 camera_up_vec.z = 0.0;
938
939 /* Set camera right vector. */
940 camera_right_vec.x = 1.0;
941 camera_right_vec.y = 0.0;
942 camera_right_vec.z = 0.0;
943
944 camera_node = efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
945 evas_canvas3d_node_camera_set(camera_node, camera);
946 evas_canvas3d_node_position_set(camera_node, camera_pos.x, camera_pos.y, camera_pos.z);
947 evas_canvas3d_node_look_at_set(camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, camera_up_vec.x, camera_up_vec.y, camera_up_vec.z);
948 evas_canvas3d_node_member_add(root_node, camera_node);
949}
950
951static void
952light_setup(void)
953{
954 light = efl_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
955 evas_canvas3d_light_ambient_set(light, 0.2, 0.2, 0.2, 1.0);
956 evas_canvas3d_light_diffuse_set(light, 1.0, 1.0, 1.0, 1.0);
957 evas_canvas3d_light_specular_set(light, 0.2, 0.2, 0.2, 1.0);
958
959 light_node = efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
960 evas_canvas3d_node_light_set(light_node, light);
961 evas_canvas3d_node_position_set(light_node, 0.0, 0.0, MAX_CAMERA_DISTANCE);
962 evas_canvas3d_node_look_at_set(light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
963 evas_canvas3d_node_member_add(root_node, light_node);
964}
965
966static void
967mesh_setup(void)
968{
969 /* Create a sphere mesh. */
970 sphere_init(50);
971
972 mesh = efl_add(EVAS_CANVAS3D_MESH_CLASS, evas);
973 evas_canvas3d_mesh_vertex_count_set(mesh, vertex_count);
974 evas_canvas3d_mesh_frame_add(mesh, 0);
975 evas_canvas3d_mesh_frame_vertex_data_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, sizeof(vertex), &vertices[0].position);
976 evas_canvas3d_mesh_frame_vertex_data_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, sizeof(vertex), &vertices[0].normal);
977 evas_canvas3d_mesh_frame_vertex_data_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT, sizeof(vertex), &vertices[0].tangent);
978 evas_canvas3d_mesh_frame_vertex_data_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, sizeof(vertex), &vertices[0].color);
979 evas_canvas3d_mesh_frame_vertex_data_set(mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, sizeof(vertex), &vertices[0].texcoord);
980 evas_canvas3d_mesh_index_data_set(mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, index_count, &indices[0]);
981 evas_canvas3d_mesh_vertex_assembly_set(mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
982
983 material = efl_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
984 evas_canvas3d_mesh_frame_material_set(mesh, 0, material);
985
986 texture_diffuse = efl_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
987 evas_canvas3d_texture_source_set(texture_diffuse, map);
988 evas_canvas3d_texture_source_visible_set(texture_diffuse, EINA_FALSE);
989
990 texture_normal = efl_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
991 evas_canvas3d_texture_source_set(texture_normal, normal_map);
992 evas_canvas3d_texture_source_visible_set(texture_normal, EINA_FALSE);
993
994 evas_canvas3d_material_texture_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, texture_diffuse);
995 evas_canvas3d_material_texture_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, texture_normal);
996 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
997 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
998 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
999 evas_canvas3d_material_enable_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE);
1000 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.1, 0.1, 0.1, 1.0);
1001 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0);
1002 evas_canvas3d_material_color_set(material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 0.1, 0.1, 0.1, 1.0);
1003 evas_canvas3d_material_shininess_set(material, 50.0);
1004
1005 mesh_node = efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_MESH));
1006 evas_canvas3d_node_member_add(root_node, mesh_node);
1007 evas_canvas3d_node_mesh_add(mesh_node, mesh);
1008 evas_canvas3d_mesh_shader_mode_set(mesh, EVAS_CANVAS3D_SHADER_MODE_NORMAL_MAP);
1009}
1010
1011static void
1012hoversel_cb(void *data,
1013 Evas_Object *obj EINA_UNUSED,
1014 void *event_info EINA_UNUSED)
1015{
1016 elm_map_source_set(map, ELM_MAP_SOURCE_TYPE_TILE, (char *)data);
1017 zoom_factor_set(zoom_factor);
1018}
1019
1020static void
1021hoversel_setup(Evas_Object *parent)
1022{
1023 hoversel = elm_hoversel_add(parent);
1024
1025 elm_hoversel_hover_parent_set(hoversel, parent);
1026 elm_object_text_set(hoversel, "Map Sources");
1027 elm_hoversel_item_add(hoversel, "Mapnik", NULL, ELM_ICON_NONE, hoversel_cb, "Mapnik");
1028 elm_hoversel_item_add(hoversel, "CycleMap", NULL, ELM_ICON_NONE, hoversel_cb, "CycleMap");
1029 elm_hoversel_item_add(hoversel, "MapQuest", NULL, ELM_ICON_NONE, hoversel_cb, "MapQuest");
1030
1031 elm_object_part_content_set(parent, "elm.swallow.hoversel", hoversel);
1032 evas_object_show(hoversel);
1033}
1034
1035static void
1036rotation_toggle_changed_cb(void *data EINA_UNUSED,
1037 Evas_Object *obj,
1038 void *event_info EINA_UNUSED)
1039{
1040 /* Stop rotating earth. */
1041 if (animator)
1042 {
1043 ecore_animator_del(animator);
1044 animator = NULL;
1045 }
1046 if (elm_check_state_get(obj))
1047 {
1048 /* Restart rotating earth. */
1049 animator = ecore_animator_add(animate_scene, mesh_node);
1050 }
1051}
1052
1053static void
1054rotation_toggle_setup(Evas_Object *parent)
1055{
1056 rotation_toggle = elm_check_add(parent);
1057
1058 elm_object_style_set(rotation_toggle, "toggle");
1059 elm_object_text_set(rotation_toggle, "Earth Rotation");
1060 elm_object_part_text_set(rotation_toggle, "on", "ON");
1061 elm_object_part_text_set(rotation_toggle, "off", "OFF");
1062 elm_check_state_set(rotation_toggle, EINA_TRUE);
1063
1064 elm_object_part_content_set(parent, "elm.swallow.rotation_toggle", rotation_toggle);
1065 evas_object_show(rotation_toggle);
1066
1067 evas_object_smart_callback_add(rotation_toggle, "changed", rotation_toggle_changed_cb, NULL);
1068}
1069
1070static void
1071light_toggle_changed_cb(void *data EINA_UNUSED,
1072 Evas_Object *obj,
1073 void *event_info EINA_UNUSED)
1074{
1075 if (elm_check_state_get(obj))
1076 {
1077 /* Set light position as the same as camera position. */
1078 evas_canvas3d_node_position_set(light_node, camera_pos.x, camera_pos.y, camera_pos.z);
1079 evas_canvas3d_node_look_at_set(light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, camera_up_vec.x, camera_up_vec.y, camera_up_vec.z);
1080 }
1081 else
1082 {
1083 /* Set light position to default position. */
1084 evas_canvas3d_node_position_set(light_node, 0.0, 0.0, MAX_CAMERA_DISTANCE);
1085 evas_canvas3d_node_look_at_set(light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
1086 }
1087}
1088
1089static void
1090light_toggle_setup(Evas_Object *parent)
1091{
1092 light_toggle = elm_check_add(parent);
1093
1094 elm_object_style_set(light_toggle, "toggle");
1095 elm_object_text_set(light_toggle, "Light on Camera");
1096 elm_object_part_text_set(light_toggle, "on", "ON");
1097 elm_object_part_text_set(light_toggle, "off", "OFF");
1098 elm_check_state_set(light_toggle, EINA_FALSE);
1099
1100 elm_object_part_content_set(parent, "elm.swallow.light_toggle", light_toggle);
1101 evas_object_show(light_toggle);
1102
1103 evas_object_smart_callback_add(light_toggle, "changed", light_toggle_changed_cb, NULL);
1104}
1105
1106
1107static void
1108slider_changed_cb(void *data EINA_UNUSED,
1109 Evas_Object *obj,
1110 void *event_info EINA_UNUSED)
1111{
1112 double new_zoom_factor = ROUND(elm_slider_value_get(obj));
1113
1114 if (new_zoom_factor == zoom_factor) return;
1115
1116 zoom_factor_set(new_zoom_factor);
1117}
1118
1119static void
1120zoom_slider_setup(Evas_Object *parent)
1121{
1122 zoom_slider = elm_slider_add(parent);
1123
1124 elm_object_text_set(zoom_slider, "Zoom Factor");
1125 elm_slider_unit_format_set(zoom_slider, "X%1.1f");
1126 elm_slider_indicator_format_set(zoom_slider, "%1.1f");
1127 elm_slider_span_size_set(zoom_slider, 100);
1128 elm_slider_min_max_set(zoom_slider, MIN_3D_ZOOM_FACTOR, MAX_3D_ZOOM_FACTOR);
1129
1130 elm_object_part_content_set(parent, "elm.swallow.zoom_slider", zoom_slider);
1131 evas_object_show(zoom_slider);
1132
1133 evas_object_smart_callback_add(zoom_slider, "changed", slider_changed_cb, NULL);
1134}
1135
1136EAPI_MAIN int
1137elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
1138{
1139 char buf[PATH_MAX];
1140
1141 elm_app_info_set(elm_main, "elementary", "examples/evas3d_map_example.edj");
1142
1143 elm_config_accel_preference_set("3d");
1144
1145 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
1146
1147 /* Add a window. */
1148 win = elm_win_util_standard_add("elm_map_evas3d", "Elm_Map_Evas3d");
1149 elm_win_autodel_set(win, EINA_TRUE);
1150
1151 evas = evas_object_evas_get(win);
1152
1153 /* Add a background. */
1154 bg = evas_object_rectangle_add(evas);
1155 evas_object_color_set(bg, 0, 0, 0, 255);
1156 evas_object_resize(bg, WIDTH, HEIGHT);
1157 evas_object_show(bg);
1158
1159 /* Add an image which shows a scene. */
1160 image = efl_add(EFL_CANVAS_SCENE3D_CLASS, evas);
1161 evas_object_resize(image, WIDTH, HEIGHT);
1162 evas_object_show(image);
1163
1164 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_DOWN, mouse_down_cb, NULL);
1165 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_MOVE, mouse_move_cb, NULL);
1166 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_UP, mouse_up_cb, NULL);
1167 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_WHEEL, mouse_wheel_cb, NULL);
1168
1169 /* Add a scene object. */
1170 scene = efl_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
1171
1172 /* Add a root node for the scene. */
1173 root_node = efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_NODE));
1174
1175 skybox_setup();
1176 texture_source_setup();
1177 camera_setup();
1178 light_setup();
1179 mesh_setup();
1180
1181 /* Set up scene. */
1182 evas_canvas3d_scene_root_node_set(scene, root_node);
1183 evas_canvas3d_scene_camera_node_set(scene, camera_node);
1184 evas_canvas3d_scene_size_set(scene, WIDTH, HEIGHT);
1185 efl_canvas_scene3d_set(image, scene);
1186
1187 /* Add a layout for controlers. */
1188 control_layout = elm_layout_add(win);
1189 snprintf(buf, sizeof(buf), "%s/examples/evas3d_map_example.edj", elm_app_data_dir_get());
1190 elm_layout_file_set(control_layout, buf, "control_layout");
1191 evas_object_resize(control_layout, WIDTH, HEIGHT);
1192 evas_object_show(control_layout);
1193
1194 /* Set up controlers. */
1195 hoversel_setup(control_layout);
1196 rotation_toggle_setup(control_layout);
1197 light_toggle_setup(control_layout);
1198 zoom_slider_setup(control_layout);
1199
1200 /* Start rotating earth */
1201 animator = ecore_animator_add(animate_scene, mesh_node);
1202
1203 evas_object_resize(win, WIDTH, HEIGHT);
1204 evas_object_show(win);
1205
1206 elm_run();
1207 sphere_fini();
1208
1209 return 0;
1210}
1211ELM_MAIN();
diff --git a/src/examples/elementary/evas3d_map_example.edc b/src/examples/elementary/evas3d_map_example.edc
deleted file mode 100644
index 2d4573a788..0000000000
--- a/src/examples/elementary/evas3d_map_example.edc
+++ /dev/null
@@ -1,964 +0,0 @@
1#define FIXED_SIZE(_WIDTH, _HEIGHT) \
2 min: _WIDTH _HEIGHT; max: _WIDTH _HEIGHT; fixed: 1 1;
3
4collections {
5group { name: "control_layout";
6 parts {
7 part { name: "base"; type: SPACER;
8 scale: 1;
9 description { state: "default" 0.0;
10 }
11 }
12 part { name: "control_bg"; type: SPACER;
13 scale: 1;
14 description { state: "default" 0.0;
15 min: 220 150;
16 max: 220 150;
17 fixed: 1 1;
18 align: 1.0 1.0;
19 rel1 { to: "base"; relative: 1.0 1.0; }
20 rel2 { to: "base"; relative: 1.0 1.0; }
21 }
22 }
23 part { name: "elm.swallow.hoversel"; type: SWALLOW;
24 scale: 1;
25 description { state: "default" 0.0;
26 min: 200 20;
27 max: 200 20;
28 fixed: 1 1;
29 align: 0.0 0.0;
30 rel1 { to: "control_bg"; relative: 0.0 0.0; }
31 rel2 { to: "control_bg"; relative: 1.0 0.0; }
32 }
33 }
34 part { name: "hoversel_bottom_padding"; type: SPACER;
35 scale: 1;
36 description { state: "default" 0.0;
37 min: 200 10;
38 max: 200 10;
39 fixed: 1 1;
40 align: 0.0 0.0;
41 rel1 { to_x: "control_bg"; to_y: "elm.swallow.hoversel"; relative: 0.0 1.0; }
42 rel2 { to_x: "control_bg"; to_y: "elm.swallow.hoversel"; relative: 1.0 1.0; }
43 }
44 }
45 part { name: "elm.swallow.rotation_toggle"; type: SWALLOW;
46 scale: 1;
47 description { state: "default" 0.0;
48 min: 200 30;
49 max: 200 30;
50 fixed: 1 1;
51 align: 0.0 0.0;
52 rel1 { to_x: "control_bg"; to_y: "hoversel_bottom_padding"; relative: 0.0 1.0; }
53 rel2 { to_x: "control_bg"; to_y: "hoversel_bottom_padding"; relative: 1.0 1.0; }
54 }
55 }
56 part { name: "elm.swallow.light_toggle"; type: SWALLOW;
57 scale: 1;
58 description { state: "default" 0.0;
59 min: 200 30;
60 max: 200 30;
61 fixed: 1 1;
62 align: 0.0 0.0;
63 rel1 { to_x: "control_bg"; to_y: "elm.swallow.rotation_toggle"; relative: 0.0 1.0; }
64 rel2 { to_x: "control_bg"; to_y: "elm.swallow.rotation_toggle"; relative: 1.0 1.0; }
65 }
66 }
67 part { name: "elm.swallow.zoom_slider"; type: SWALLOW;
68 scale: 1;
69 description { state: "default" 0.0;
70 min: 200 30;
71 max: 200 30;
72 fixed: 1 1;
73 align: 0.0 0.0;
74 rel1 { to_x: "control_bg"; to_y: "elm.swallow.light_toggle"; relative: 0.0 1.0; }
75 rel2 { to_x: "control_bg"; to_y: "elm.swallow.light_toggle"; relative: 1.0 1.0; }
76 }
77 }
78 }
79}
80
81group { name: "elm/scroller/base/evas3d";
82 data.item: "focus_highlight" "on";
83
84 parts {
85 program {
86 signal: "load"; source: "";
87 script {
88 emit("reload", "elm");
89 }
90 }
91// vert bar ////////////////////////////////////////////////////////////////
92 part { name: "sb_vbar_show"; type: RECT;
93 description { state: "default" 0.0;
94 }
95 description { state: "hidden" 0.0;
96 inherit: "default" 0.0;
97 visible: 0;
98 }
99 }
100 part { name: "sb_vbar"; type: RECT;
101 scale: 1;
102 description { state: "default" 0.0;
103 fixed: 1 1;
104 min: 15 1;
105 align: 1.0 0.0;
106 rel1.relative: 1.0 0.0;
107 //rel1.offset: -1 0;
108 rel2.relative: 1.0 0.0;
109 rel2.to_y: "sb_hbar";
110 }
111 description { state: "hidden" 0.0;
112 inherit: "default" 0.0;
113 min: 0 0;
114 max: 0 99999;
115 }
116 }
117 part { name: "sb_vbar_base"; type: RECT;
118 clip_to: "sb_vbar";
119 description { state: "default" 0.0;
120 color: 0 0 0 0;
121 rel1.relative: 0.0 1.0;
122 rel1.to: "sb_vbar_a1";
123 rel2.relative: 1.0 0.0;
124 rel2.to: "sb_vbar_a2";
125 fixed: 1 1;
126 }
127 }
128 part { name: "sb_vbar_p1"; type: RECT;
129 clip_to: "sb_vbar";
130 description { state: "default" 0.0;
131 color: 0 0 0 0;
132 rel1.relative: 0.0 1.0;
133 rel1.to: "sb_vbar_a1";
134 rel2.relative: 1.0 0.0;
135 rel2.to: "elm.dragable.vbar";
136 fixed: 1 1;
137 }
138 }
139 part { name: "sb_vbar_p2"; type: RECT;
140 clip_to: "sb_vbar";
141 description { state: "default" 0.0;
142 color: 0 0 0 0;
143 rel1.relative: 0.0 1.0;
144 rel1.to: "elm.dragable.vbar";
145 rel2.relative: 1.0 0.0;
146 rel2.to: "sb_vbar_a2";
147 fixed: 1 1;
148 }
149 }
150 part { name: "elm.dragable.vbar"; type: RECT;
151 clip_to: "sb_vbar";
152 scale: 1;
153 dragable.x: 0 0 0;
154 dragable.y: 1 1 0;
155 dragable.confine: "sb_vbar_base";
156 description { state: "default" 0.0;
157 fixed: 1 1;
158 min: 15 13;
159 rel1.relative: 0.5 0.5;
160 rel1.to: "sb_vbar_base";
161 rel2.relative: 0.5 0.5;
162 rel2.to: "sb_vbar_base";
163 color: 0 0 0 0;
164 }
165 description { state: "hidden" 0.0;
166 inherit: "default" 0.0;
167 min: 0 0;
168 }
169 description { state: "clicked" 0.0;
170 inherit: "default" 0.0;
171 }
172 }
173 part { name: "sb_vbar_a1"; type: RECT;
174 clip_to: "sb_vbar";
175 description { state: "default" 0.0;
176 fixed: 1 1;
177 min: 15 15;
178 align: 0.5 0.0;
179 aspect: 1.0 1.0; aspect_preference: HORIZONTAL;
180 color: 0 0 0 0;
181 rel1.to: "sb_vbar";
182 rel2.to: "sb_vbar";
183 rel2.relative: 1.0 0.0;
184 //rel2.offset: -1 0;
185 }
186 description { state: "hidden" 0.0;
187 inherit: "default" 0.0;
188 min: 0 0;
189 }
190 }
191 part { name: "sb_vbar_a2"; type: RECT;
192 clip_to: "sb_vbar";
193 description { state: "default" 0.0;
194 fixed: 1 1;
195 min: 15 15;
196 align: 0.5 1.0;
197 aspect: 1.0 1.0; aspect_preference: HORIZONTAL;
198 color: 0 0 0 0;
199 rel1.to: "sb_vbar";
200 //rel1.offset: 0 -1;
201 rel1.relative: 0.0 1.0;
202 rel2.to: "sb_vbar";
203 }
204 description { state: "hidden" 0.0;
205 inherit: "default" 0.0;
206 min: 0 0;
207 }
208 }
209 program {
210 signal: "elm,action,show,vbar"; source: "elm";
211 action: STATE_SET "default" 0.0;
212 target: "sb_vbar";
213 target: "sb_vbar_show";
214 target: "elm.dragable.vbar";
215 target: "sb_vbar_a1";
216 target: "sb_vbar_a2";
217 }
218 program {
219 signal: "elm,action,hide,vbar"; source: "elm";
220 action: STATE_SET "hidden" 0.0;
221 target: "sb_vbar";
222 target: "sb_vbar_show";
223 target: "elm.dragable.vbar";
224 target: "sb_vbar_a1";
225 target: "sb_vbar_a2";
226 }
227 program {
228 signal: "mouse,down,1*"; source: "sb_vbar_a1";
229 action: STATE_SET "clicked" 0.0;
230 target: "arrow1_vbar";
231 }
232 program {
233 signal: "mouse,down,1*"; source: "sb_vbar_a1";
234 action: DRAG_VAL_STEP 0.0 -1.0;
235 target: "elm.dragable.vbar";
236 }
237 program {
238 signal: "mouse,up,1"; source: "sb_vbar_a1";
239 action: STATE_SET "default" 0.0;
240 target: "arrow1_vbar";
241 }
242 program {
243 signal: "mouse,down,1*"; source: "sb_vbar_a2";
244 action: STATE_SET "clicked" 0.0;
245 target: "arrow2_vbar";
246 }
247 program {
248 signal: "mouse,down,1*"; source: "sb_vbar_a2";
249 action: DRAG_VAL_STEP 0.0 1.0;
250 target: "elm.dragable.vbar";
251 }
252 program {
253 signal: "mouse,up,1"; source: "sb_vbar_a2";
254 action: STATE_SET "default" 0.0;
255 target: "arrow2_vbar";
256 }
257 program {
258 signal: "mouse,down,1*"; source: "sb_vbar_p1";
259 action: DRAG_VAL_PAGE 0.0 -1.0;
260 target: "elm.dragable.vbar";
261 }
262 program {
263 signal: "mouse,down,1*"; source: "sb_vbar_p2";
264 action: DRAG_VAL_PAGE 0.0 1.0;
265 target: "elm.dragable.vbar";
266 }
267
268// horiz bar /////////////////////////////////////////////////////////////
269 part { name: "sb_hbar_show"; type: RECT;
270 description { state: "default" 0.0;
271 }
272 description { state: "hidden" 0.0;
273 inherit: "default" 0.0;
274 visible: 0;
275 }
276 }
277 part { name: "sb_hbar"; type: RECT; mouse_events: 0;
278 scale: 1;
279 description { state: "default" 0.0;
280 fixed: 1 1;
281 min: 1 15;
282 align: 0.0 1.0;
283 rel1.relative: 0.0 1.0;
284 //rel1.offset: 0 -1;
285 rel2.relative: 0.0 1.0;
286 rel2.to_x: "sb_vbar";
287 }
288 description { state: "hidden" 0.0;
289 inherit: "default" 0.0;
290 min: 0 0;
291 max: 99999 0;
292 }
293 }
294 part { name: "sb_hbar_base"; type: RECT;
295 clip_to: "sb_hbar";
296 description { state: "default" 0.0;
297 color: 0 0 0 0;
298 rel1.relative: 1.0 0.0;
299 rel1.to: "sb_hbar_a1";
300 rel2.relative: 0.0 1.0;
301 rel2.to: "sb_hbar_a2";
302 fixed: 1 1;
303 }
304 }
305 part { name: "sb_hbar_p1"; type: RECT;
306 clip_to: "sb_hbar";
307 description { state: "default" 0.0;
308 color: 0 0 0 0;
309 rel1.relative: 1.0 0.0;
310 rel1.to: "sb_hbar_a1";
311 rel2.relative: 0.0 1.0;
312 rel2.to: "elm.dragable.hbar";
313 fixed: 1 1;
314 }
315 }
316 part { name: "sb_hbar_p2"; type: RECT;
317 clip_to: "sb_hbar";
318 description { state: "default" 0.0;
319 color: 0 0 0 0;
320 rel1.relative: 1.0 0.0;
321 rel1.to: "elm.dragable.hbar";
322 rel2.relative: 0.0 1.0;
323 rel2.to: "sb_hbar_a2";
324 fixed: 1 1;
325 }
326 }
327 part { name: "elm.dragable.hbar"; type: RECT;
328 clip_to: "sb_hbar";
329 scale: 1;
330 dragable.x: 1 1 0;
331 dragable.y: 0 0 0;
332 dragable.confine: "sb_hbar_base";
333 description { state: "default" 0.0;
334 fixed: 1 1;
335 min: 13 15;
336 rel1.relative: 0.5 0.5;
337 rel1.to: "sb_hbar_base";
338 rel2.relative: 0.5 0.5;
339 rel2.to: "sb_hbar_base";
340 color: 0 0 0 0;
341 }
342 description { state: "hidden" 0.0;
343 inherit: "default" 0.0;
344 min: 0 0;
345 }
346 description { state: "clicked" 0.0;
347 inherit: "default" 0.0;
348 }
349 }
350 part { name: "sb_hbar_a1"; type: RECT;
351 clip_to: "sb_hbar";
352 description { state: "default" 0.0;
353 fixed: 1 1;
354 min: 15 15;
355 align: 0.0 0.5;
356 aspect: 1.0 1.0; aspect_preference: VERTICAL;
357 color: 0 0 0 0;
358 rel1.to: "sb_hbar";
359 rel2.to: "sb_hbar";
360 rel2.relative: 0.0 1.0;
361 //rel2.offset: 0 -1;
362 }
363 description { state: "hidden" 0.0;
364 inherit: "default" 0.0;
365 min: 0 0;
366 }
367 }
368 part { name: "sb_hbar_a2"; type: RECT;
369 clip_to: "sb_hbar";
370 description { state: "default" 0.0;
371 fixed: 1 1;
372 min: 15 15;
373 align: 1.0 0.5;
374 aspect: 1.0 1.0; aspect_preference: VERTICAL;
375 color: 0 0 0 0;
376 rel1.to: "sb_hbar";
377 //rel1.offset: -1 0;
378 rel1.relative: 1.0 0.0;
379 rel2.to: "sb_hbar";
380 }
381 description { state: "hidden" 0.0;
382 inherit: "default" 0.0;
383 min: 0 0;
384 }
385 }
386 program {
387 signal: "elm,action,show,hbar"; source: "elm";
388 action: STATE_SET "default" 0.0;
389 target: "sb_hbar";
390 target: "sb_hbar_show";
391 target: "elm.dragable.hbar";
392 target: "sb_hbar_a1";
393 target: "sb_hbar_a2";
394 }
395 program {
396 signal: "elm,action,hide,hbar"; source: "elm";
397 action: STATE_SET "hidden" 0.0;
398 target: "sb_hbar";
399 target: "sb_hbar_show";
400 target: "elm.dragable.hbar";
401 target: "sb_hbar_a1";
402 target: "sb_hbar_a2";
403 }
404 program {
405 signal: "mouse,down,1*"; source: "sb_hbar_a1";
406 action: STATE_SET "clicked" 0.0;
407 target: "arrow1_hbar";
408 }
409 program {
410 signal: "mouse,down,1*"; source: "sb_hbar_a1";
411 action: DRAG_VAL_STEP -1.0 0.0;
412 target: "elm.dragable.hbar";
413 }
414 program {
415 signal: "mouse,up,1"; source: "sb_hbar_a1";
416 action: STATE_SET "default" 0.0;
417 target: "arrow1_hbar";
418 }
419 program {
420 signal: "mouse,down,1*"; source: "sb_hbar_a2";
421 action: STATE_SET "clicked" 0.0;
422 target: "arrow2_hbar";
423 }
424 program {
425 signal: "mouse,down,1*"; source: "sb_hbar_a2";
426 action: DRAG_VAL_STEP 1.0 0.0;
427 target: "elm.dragable.hbar";
428 }
429 program {
430 signal: "mouse,up,1"; source: "sb_hbar_a2";
431 action: STATE_SET "default" 0.0;
432 target: "arrow2_hbar";
433 }
434 program {
435 signal: "mouse,down,1*"; source: "sb_hbar_p1";
436 action: DRAG_VAL_PAGE -1.0 0.0;
437 target: "elm.dragable.hbar";
438 }
439 program {
440 signal: "mouse,down,1*"; source: "sb_hbar_p2";
441 action: DRAG_VAL_PAGE 1.0 0.0;
442 target: "elm.dragable.hbar";
443 }
444
445 part { name: "bg"; type: RECT;
446 description { state: "default" 0.0;
447 rel1.to: "elm.swallow.background";
448 rel2.to: "elm.swallow.background";
449// color: 64 64 64 200;
450 color: 0 0 0 0;
451 color_class: "scroller_bg";
452 }
453 }
454 part { name: "clipper"; type: RECT;
455 description { state: "default" 0.0;
456 rel1.to: "elm.swallow.background";
457 rel2.to: "elm.swallow.background";
458 }
459 }
460 part { name: "elm.swallow.background"; type: SWALLOW;
461 clip_to: "clipper";
462 description { state: "default" 0.0;
463 //rel1.offset: 1 1;
464 rel2.relative: 0.0 0.0;
465 //rel2.offset: -2 -2;
466 rel2.to_x: "sb_vbar";
467 rel2.to_y: "sb_hbar";
468 }
469 }
470 part { name: "elm.swallow.content"; type: SWALLOW;
471 clip_to: "clipper";
472 description { state: "default" 0.0;
473 //rel1.offset: 1 1;
474 rel2.relative: 0.0 0.0;
475 //rel2.offset: -2 -2;
476 rel2.to_x: "sb_vbar";
477 rel2.to_y: "sb_hbar";
478 }
479 }
480 part { name: "inset"; type: SPACER;
481 description { state: "default" 0.0;
482 rel1.to: "bg";
483 //rel1.offset: -1 -1;
484 rel2.to: "bg";
485 //rel2.offset: 0 0;
486 }
487 }
488 part { name: "shadow"; type: SPACER;
489 description { state: "default" 0.0;
490 rel1.to: "bg";
491 rel2.to: "bg";
492 }
493 }
494 part { name: "elm.swallow.overlay"; type: SWALLOW;
495 clip_to: "clipper";
496 description { state: "default" 0.0;
497 rel1.to: "elm.swallow.content";
498 rel2.to: "elm.swallow.content";
499 }
500 }
501 part { name: "runner_vbar"; type: SPACER;
502 clip_to: "sb_vbar_show";
503 description { state: "default" 0.0;
504 rel1.to: "sb_vbar_base";
505 rel2.to: "sb_vbar_base";
506 min: 3 4;
507 max: 3 99999;
508 fixed: 1 1;
509 }
510 }
511 part { name: "runner_hbar"; type: SPACER;
512 clip_to: "sb_hbar_show";
513 description { state: "default" 0.0;
514 rel1.to: "sb_hbar_base";
515 rel2.to: "sb_hbar_base";
516 min: 4 3;
517 max: 99999 3;
518 fixed: 1 1;
519 }
520 }
521 part { name: "runner_vbar_clip"; type: RECT;
522 clip_to: "sb_vbar_show";
523 description { state: "default" 0.0;
524 min: 1 1;
525 max: 1 99999;
526 rel1.to: "runner_vbar";
527 //rel1.offset: 0 1;
528 rel2.to: "runner_vbar";
529 //rel2.offset: -1 -2;
530 fixed: 1 1;
531 }
532 }
533 part { name: "runner_hbar_clip"; type: RECT;
534 clip_to: "sb_hbar_show";
535 description { state: "default" 0.0;
536 min: 1 1;
537 max: 99999 1;
538 rel1.to: "runner_hbar";
539 //rel1.offset: 1 0;
540 rel2.to: "runner_hbar";
541 //rel2.offset: -2 -1;
542 fixed: 1 1;
543 }
544 }
545
546 part { name: "arrow1_vbar"; type: SPACER;
547 clip_to: "sb_vbar_show";
548 description { state: "default" 0.0;
549 rel1.to: "sb_vbar_a1";
550 rel2.to: "sb_vbar_a1";
551 FIXED_SIZE(15, 15)
552 }
553 description { state: "clicked" 0.0;
554 inherit: "default" 0.0;
555 }
556 }
557 part { name: "arrow2_vbar"; type: SPACER;
558 clip_to: "sb_vbar_show";
559 description { state: "default" 0.0;
560 rel1.to: "sb_vbar_a2";
561 rel2.to: "sb_vbar_a2";
562 FIXED_SIZE(15, 15)
563 }
564 description { state: "clicked" 0.0;
565 inherit: "default" 0.0;
566 }
567 }
568 part { name: "shadow_vbar"; type: SPACER;
569 clip_to: "sb_vbar_show";
570 description { state: "default" 0.0;
571 //rel1.offset: -3 -2;
572 rel1.to: "base_vbar";
573 //rel2.offset: 2 4;
574 rel2.to: "base_vbar";
575 fixed: 1 1;
576 }
577 description { state: "clicked" 0.0;
578 inherit: "default" 0.0;
579 //rel1.offset: -2 -2;
580 //rel2.offset: 1 1;
581 }
582 }
583 part { name: "glow_vbar"; type: SPACER;
584 clip_to: "sb_vbar_show";
585 description { state: "default" 0.0;
586 //rel1.offset: -3 -3;
587 rel1.to: "base_vbar";
588 //rel2.offset: 2 2;
589 rel2.to: "base_vbar";
590 fixed: 1 1;
591 }
592 description { state: "clicked" 0.0;
593 inherit: "default" 0.0;
594 }
595 }
596 part { name: "runner_glow_vbar"; type: SPACER;
597 clip_to: "runner_vbar_clip";
598 description { state: "default" 0.0;
599 rel1.offset: 0 -30;
600 rel1.to_x: "runner_vbar_clip";
601 rel1.to_y: "base_vbar";
602 rel2.offset: -1 29;
603 rel2.to_x: "runner_vbar_clip";
604 rel2.to_y: "base_vbar";
605 fixed: 1 1;
606 }
607 }
608 part { name: "base_vbar"; type: SPACER;
609 clip_to: "sb_vbar_show";
610 description { state: "default" 0.0;
611 fixed: 1 1;
612 //rel1.offset: 2 0;
613 rel1.to: "elm.dragable.vbar";
614 //rel2.offset: -3 -1;
615 rel2.to: "elm.dragable.vbar";
616 min: 3 13;
617 fixed: 1 1;
618 }
619 }
620 part { name: "bevel_vbar"; type: SPACER;
621 clip_to: "sb_vbar_show";
622 description { state: "default" 0.0;
623 rel1.to: "base_vbar";
624 rel2.to: "base_vbar";
625 min: 3 3;
626 fixed: 1 1;
627 }
628 }
629 part { name: "center_vbar"; type: SPACER;
630 clip_to: "sb_vbar_show";
631 description { state: "default" 0.0;
632 rel1.to: "base_vbar";
633 rel2.to: "base_vbar";
634 FIXED_SIZE(3, 11)
635 }
636 }
637 part { name: "center_glow_vbar"; type: SPACER;
638 clip_to: "sb_vbar_show";
639 description { state: "default" 0.0;
640 rel1.to: "center_vbar";
641 rel2.to: "center_vbar";
642 FIXED_SIZE(11, 17)
643 }
644 description { state: "clicked" 0.0;
645 inherit: "default" 0.0;
646 }
647 }
648
649 part { name: "arrow1_hbar"; type: SPACER;
650 clip_to: "sb_hbar_show";
651 description { state: "default" 0.0;
652 rel1.to: "sb_hbar_a1";
653 rel2.to: "sb_hbar_a1";
654 FIXED_SIZE(15, 15)
655 }
656 description { state: "clicked" 0.0;
657 inherit: "default" 0.0;
658 }
659 }
660 part { name: "arrow2_hbar"; type: SPACER;
661 clip_to: "sb_hbar_show";
662 description { state: "default" 0.0;
663 rel1.to: "sb_hbar_a2";
664 rel2.to: "sb_hbar_a2";
665 FIXED_SIZE(15, 15)
666 }
667 description { state: "clicked" 0.0;
668 inherit: "default" 0.0;
669 }
670 }
671 part { name: "shadow_hbar"; type: SPACER;
672 clip_to: "sb_hbar_show";
673 description { state: "default" 0.0;
674 //rel1.offset: -3 -2;
675 rel1.to: "base_hbar";
676 //rel2.offset: 2 4;
677 rel2.to: "base_hbar";
678 fixed: 1 1;
679 }
680 description { state: "clicked" 0.0;
681 inherit: "default" 0.0;
682 //rel1.offset: -2 -2;
683 //rel2.offset: 1 1;
684 }
685 }
686 part { name: "glow_hbar"; type: SPACER;
687 clip_to: "sb_hbar_show";
688 description { state: "default" 0.0;
689 //rel1.offset: -3 -3;
690 rel1.to: "base_hbar";
691 //rel2.offset: 2 2;
692 rel2.to: "base_hbar";
693 fixed: 1 1;
694 }
695 description { state: "clicked" 0.0;
696 inherit: "default" 0.0;
697 }
698 }
699 part { name: "runner_glow_hbar"; type: SPACER;
700 clip_to: "runner_hbar_clip";
701 description { state: "default" 0.0;
702 rel1.offset: -30 0;
703 rel1.to_x: "base_hbar";
704 rel1.to_y: "runner_hbar_clip";
705 rel2.offset: 29 -1;
706 rel2.to_x: "base_hbar";
707 rel2.to_y: "runner_hbar_clip";
708 fixed: 1 1;
709 }
710 }
711 part { name: "base_hbar"; type: SPACER;
712 clip_to: "sb_hbar_show";
713 description { state: "default" 0.0;
714 fixed: 1 1;
715 //rel1.offset: 0 2;
716 rel1.to: "elm.dragable.hbar";
717 //rel2.offset: -1 -3;
718 rel2.to: "elm.dragable.hbar";
719 min: 13 3;
720 }
721 }
722 part { name: "bevel_hbar"; type: SPACER;
723 clip_to: "sb_hbar_show";
724 description { state: "default" 0.0;
725 rel1.to: "base_hbar";
726 rel2.to: "base_hbar";
727 min: 3 3;
728 fixed: 1 1;
729 }
730 }
731 part { name: "center_hbar"; type: SPACER;
732 clip_to: "sb_hbar_show";
733 description { state: "default" 0.0;
734 rel1.to: "base_hbar";
735 rel2.to: "base_hbar";
736 FIXED_SIZE(11, 3)
737 fixed: 1 1;
738 }
739 }
740 part { name: "center_glow_hbar"; type: SPACER;
741 clip_to: "sb_hbar_show";
742 description { state: "default" 0.0;
743 rel1.to: "center_hbar";
744 rel2.to: "center_hbar";
745 FIXED_SIZE(17, 11)
746 }
747 description { state: "clicked" 0.0;
748 inherit: "default" 0.0;
749 }
750 }
751 part { name: "dim_effect"; type: RECT; mouse_events: 0;
752 description { state: "default" 0.0;
753 color: 0 0 0 0;
754 }
755 description { state: "effect" 0.0;
756 color: 50 50 50 255;
757 }
758 }
759 }
760 programs {
761 program {
762 signal: "mouse,down,1*"; source: "elm.dragable.vbar";
763 action: STATE_SET "clicked" 0.0;
764 target: "elm.dragable.vbar";
765 target: "shadow_vbar";
766 target: "glow_vbar";
767 target: "center_glow_vbar";
768 }
769 program {
770 signal: "mouse,up,1"; source: "elm.dragable.vbar";
771 action: STATE_SET "default" 0.0;
772 target: "elm.dragable.vbar";
773 target: "shadow_vbar";
774 target: "glow_vbar";
775 target: "center_glow_vbar";
776 }
777 program {
778 signal: "mouse,down,1*"; source: "elm.dragable.hbar";
779 action: STATE_SET "clicked" 0.0;
780 target: "elm.dragable.hbar";
781 target: "shadow_hbar";
782 target: "glow_hbar";
783 target: "center_glow_hbar";
784 }
785 program {
786 signal: "mouse,up,1"; source: "elm.dragable.hbar";
787 action: STATE_SET "default" 0.0;
788 target: "elm.dragable.hbar";
789 target: "shadow_hbar";
790 target: "glow_hbar";
791 target: "center_glow_hbar";
792 }
793 program {
794 signal: "elm,action,looping,left"; source: "elm";
795 action: STATE_SET "effect" 0.0;
796 transition: LINEAR 0.3;
797 target: "dim_effect";
798 after: "looping,left,done";
799 }
800 program { name: "looping,left,done";
801 action: SIGNAL_EMIT "elm,looping,left,done" "elm";
802 }
803 program {
804 signal: "elm,action,looping,left,end"; source: "elm";
805 action: STATE_SET "default" 0.0;
806 transition: LINEAR 0.3;
807 target: "dim_effect";
808 }
809 program {
810 signal: "elm,action,looping,right"; source: "elm";
811 action: STATE_SET "effect" 0.0;
812 transition: LINEAR 0.3;
813 target: "dim_effect";
814 after: "looping,right,done";
815 }
816 program { name: "looping,right,done";
817 action: SIGNAL_EMIT "elm,looping,right,done" "elm";
818 }
819 program {
820 signal: "elm,action,looping,right,end"; source: "elm";
821 action: STATE_SET "default" 0.0;
822 transition: LINEAR 0.3;
823 target: "dim_effect";
824 }
825 program {
826 signal: "elm,action,looping,up"; source: "elm";
827 action: STATE_SET "effect" 0.0;
828 transition: LINEAR 0.3;
829 target: "dim_effect";
830 after: "looping,up,done";
831 }
832 program { name: "looping,up,done";
833 action: SIGNAL_EMIT "elm,looping,up,done" "elm";
834 }
835 program {
836 signal: "elm,action,looping,up,end"; source: "elm";
837 action: STATE_SET "default" 0.0;
838 transition: LINEAR 0.3;
839 target: "dim_effect";
840 }
841 program {
842 signal: "elm,action,looping,down"; source: "elm";
843 action: STATE_SET "effect" 0.0;
844 transition: LINEAR 0.3;
845 target: "dim_effect";
846 after: "looping,down,done";
847 }
848 program { name: "looping,down,done";
849 action: SIGNAL_EMIT "elm,looping,down,done" "elm";
850 }
851 program {
852 signal: "elm,action,looping,down,end"; source: "elm";
853 action: STATE_SET "default" 0.0;
854 transition: LINEAR 0.3;
855 target: "dim_effect";
856 }
857 }
858}
859
860group { name: "elm/photocam/base/evas3d";
861 inherit: "elm/scroller/base/evas3d";
862 parts {
863 part { name: "busy_clip"; type: RECT;
864 description { state: "default" 0.0;
865 visible: 0;
866 color: 255 255 255 0;
867 }
868 description { state: "active" 0.0;
869 visible: 1;
870 color: 255 255 255 255;
871 }
872 }
873 part { name: "knob"; type: RECT;
874 mouse_events: 0;
875 clip_to: "busy_clip";
876 scale: 1;
877 description { state: "default" 0.0;
878 min: 40 40;
879 max: 40 40;
880 align: 0.0 0.0;
881 rel1.offset: 3 3;
882 rel2.offset: 3 3;
883 fixed: 1 1;
884 visible: 0;
885 }
886 }
887 part { name: "knob_spinner"; type: RECT;
888 mouse_events: 0;
889 clip_to: "busy_clip";
890 description { state: "default" 0.0;
891 fixed: 1 1;
892 rel1.to: "knob";
893 rel2.to: "knob";
894 map.on: 1;
895 map.smooth: 1;
896 map.rotation.center: "knob";
897 visible: 0;
898 }
899 description { state: "spin" 0.0;
900 inherit: "default" 0.0;
901 map.rotation.z: 360;
902 }
903 }
904 }
905 programs {
906 program { name: "spin";
907 signal: "elm,state,busy,start"; source: "elm";
908 action: ACTION_STOP;
909 target: "spin";
910 target: "spin0";
911 target: "spin1";
912 target: "spin2";
913 target: "spin3";
914 target: "spin4";
915 after: "spin0";
916 }
917 program { name: "spin0";
918 action: STATE_SET "default" 0.0;
919 target: "knob_spinner";
920 after: "spin1";
921 }
922 program { name: "spin1";
923 action: STATE_SET "spin" 0.0;
924 transition: LINEAR 1.0;
925 target: "knob_spinner";
926 after: "spin2";
927 }
928 program { name: "spin2";
929 action: STATE_SET "default" 0.0;
930 target: "knob_spinner";
931 after: "spin1";
932 }
933
934 program {
935 signal: "elm,state,busy,start"; source: "elm";
936 action: STATE_SET "active" 0.0;
937 transition: SINUSOIDAL 0.25;
938 target: "busy_clip";
939 }
940
941 program {
942 signal: "elm,state,busy,stop"; source: "elm";
943 action: STATE_SET "default" 0.0;
944 transition: SINUSOIDAL 1.0;
945 target: "busy_clip";
946 after: "spin3";
947 }
948 program { name: "spin3";
949 action: ACTION_STOP;
950 target: "spin";
951 target: "spin2";
952 after: "spin4";
953 }
954 program { name: "spin4";
955 action: STATE_SET "default" 0.0;
956 target: "knob_spinner";
957 }
958 }
959}
960
961group { name: "elm/map/base/evas3d";
962 inherit: "elm/photocam/base/evas3d";
963}
964}
diff --git a/src/examples/elementary/evas3d_object_on_button_example.c b/src/examples/elementary/evas3d_object_on_button_example.c
deleted file mode 100644
index fe458eb454..0000000000
--- a/src/examples/elementary/evas3d_object_on_button_example.c
+++ /dev/null
@@ -1,288 +0,0 @@
1/*
2 * This example shows the mechanism of elementary widget adding (button) to the 3d scene object (cube) and
3 * illustrates the work of callback of event from mouse.
4 *
5 * Compile with:
6 * gcc -o evas3d_object_on_button_example evas3d_object_on_button_example.c -g `pkg-config --libs --cflags evas ecore eo elementary`
7 */
8#ifndef EFL_BETA_API_SUPPORT
9# define EFL_BETA_API_SUPPORT
10#endif
11
12#include <Eo.h>
13#include <Evas.h>
14#include <Ecore.h>
15#include <Elementary.h>
16
17#define WIDTH 400
18#define HEIGHT 400
19
20typedef struct _Scene_Data
21{
22 Eo *scene;
23 Eo *root_node;
24 Eo *camera_node;
25 Eo *light_node;
26 Eo *mesh_node;
27
28 Eo *camera;
29 Eo *light;
30 Eo *mesh;
31 Eo *material;
32 Eo *texture;
33} Scene_Data;
34
35Evas_Object *win = NULL;
36static Evas *evas = NULL;
37static Eo *image = NULL;
38static Eo *btn = NULL;
39static float d_angle = 0.5;
40
41static const float cube_vertices[] =
42{
43 /* Front */
44 -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0,
45 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
46 -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
47 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0,
48
49 /* Back */
50 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
51 -1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0,
52 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0,
53 -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0,
54
55 /* Left */
56 -1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0,
57 -1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0,
58 -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0,
59 -1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0,
60
61 /* Right */
62 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0,
63 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0,
64 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
65 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0,
66
67 /* Top */
68 -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
69 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
70 -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
71 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0,
72
73 /* Bottom */
74 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
75 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0,
76 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
77 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0,
78};
79
80static const unsigned short cube_indices[] =
81{
82 /* Front */
83 0, 1, 2, 2, 1, 3,
84
85 /* Back */
86 4, 5, 6, 6, 5, 7,
87
88 /* Left */
89 8, 9, 10, 10, 9, 11,
90
91 /* Right */
92 12, 13, 14, 14, 13, 15,
93
94 /* Top */
95 16, 17, 18, 18, 17, 19,
96
97 /* Bottom */
98 20, 21, 22, 22, 21, 23
99};
100
101static void
102_stop_scene(void *data,
103 Evas *e EINA_UNUSED,
104 Evas_Object *eo EINA_UNUSED,
105 void *event_info)
106{
107 Evas_Event_Mouse_Down *ev = event_info;
108 Evas_Canvas3D_Node *n;
109 Evas_Canvas3D_Mesh *m;
110 Evas_Real s, t;
111 Scene_Data *d = (Scene_Data *)data;
112
113 if (ev->button == 1)
114 {
115 Eina_Bool ret;
116
117 evas_canvas3d_scene_color_pick_enable_set(d->scene, EINA_TRUE);
118 ret = evas_canvas3d_scene_pick(d->scene, ev->canvas.x, ev->canvas.y, &n, &m, &s, &t);
119 if (ret)
120 {
121 d_angle = 0.0;
122 elm_object_signal_emit(btn, "mouse,down,1", "event");
123 evas_canvas3d_node_position_set(d->mesh_node, 0.0, 0.0, -0.2);
124 }
125 }
126}
127
128static void
129_play_scene(void *data,
130 Evas *e EINA_UNUSED,
131 Evas_Object *eo EINA_UNUSED,
132 void *event_info EINA_UNUSED)
133{
134 Scene_Data *d = (Scene_Data *)data;
135
136 d_angle = 0.5;
137 elm_object_signal_emit(btn, "mouse,up,1", "event");
138 evas_canvas3d_node_position_set(d->mesh_node, 0.0, 0.0, 0.0);
139}
140
141
142static Eina_Bool
143_animate_scene(void *data)
144{
145 static float angle = 0.0f;
146 Scene_Data *scene = (Scene_Data *)data;
147
148 angle += d_angle;
149
150 evas_canvas3d_node_orientation_angle_axis_set(scene->mesh_node, angle, 1.0, 1.0, 1.0);
151
152 /* Rotate */
153 if (angle > 360.0) angle -= 360.0f;
154
155 return EINA_TRUE;
156}
157
158static void
159_camera_setup(Scene_Data *data)
160{
161 data->camera = efl_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
162
163 evas_canvas3d_camera_projection_perspective_set(data->camera, 20.0, 1.0, 2.0, 50.0);
164
165 data->camera_node =
166 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
167 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
168 evas_canvas3d_node_position_set(data->camera_node, 0.0, 0.0, 15.0);
169 evas_canvas3d_node_look_at_set(data->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, -1.0, 0.0);
170 evas_canvas3d_node_member_add(data->root_node, data->camera_node);
171}
172
173static void
174_light_setup(Scene_Data *data)
175{
176 data->light = efl_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
177 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
178 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
179 evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
180
181 data->light_node =
182 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
183 evas_canvas3d_node_light_set(data->light_node, data->light);
184 evas_canvas3d_node_position_set(data->light_node, 0.0, 0.0, 10.0);
185 evas_canvas3d_node_look_at_set(data->light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
186 evas_canvas3d_node_member_add(data->root_node, data->light_node);
187}
188static void
189_mesh_setup(Scene_Data *data)
190{
191 /* Setup material and texture as widget button. */
192 data->material = efl_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
193 data->texture = efl_add(EVAS_CANVAS3D_TEXTURE_CLASS, evas);
194
195 evas_canvas3d_texture_source_set(data->texture, btn);
196 evas_canvas3d_texture_source_visible_set(data->texture, EINA_FALSE);
197
198 evas_canvas3d_material_texture_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, data->texture);
199 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
200 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
201 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
202 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0);
203 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0);
204 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
205 evas_canvas3d_material_shininess_set(data->material, 100.0);
206
207 /* Setup mesh. */
208 data->mesh = efl_add(EVAS_CANVAS3D_MESH_CLASS, evas);
209 evas_canvas3d_mesh_vertex_count_set(data->mesh, 24);
210 evas_canvas3d_mesh_frame_add(data->mesh, 0);
211 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 12 * sizeof(float), &cube_vertices[ 0]);
212 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 12 * sizeof(float), &cube_vertices[ 3]);
213 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, 12 * sizeof(float), &cube_vertices[ 6]);
214 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 12 * sizeof(float), &cube_vertices[10]);
215 evas_canvas3d_mesh_index_data_set(data->mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &cube_indices[0]);
216 evas_canvas3d_mesh_vertex_assembly_set(data->mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
217 evas_canvas3d_mesh_shader_mode_set(data->mesh, EVAS_CANVAS3D_SHADER_MODE_PHONG);
218 evas_canvas3d_mesh_frame_material_set(data->mesh, 0, data->material);
219 evas_canvas3d_mesh_color_pick_enable_set(data->mesh, EINA_TRUE);
220
221 data->mesh_node =
222 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_MESH));
223 evas_canvas3d_node_member_add(data->root_node, data->mesh_node);
224 evas_canvas3d_node_mesh_add(data->mesh_node, data->mesh);
225}
226
227static void
228_scene_setup(Scene_Data *data)
229{
230 data->scene = efl_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
231 evas_canvas3d_scene_size_set(data->scene, WIDTH, HEIGHT);
232 evas_canvas3d_scene_background_color_set(data->scene, 0.0, 0.0, 0.0, 0.0);
233
234 data->root_node =
235 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_NODE));
236
237 _camera_setup(data);
238 _light_setup(data);
239 _mesh_setup(data);
240
241 evas_canvas3d_scene_root_node_set(data->scene, data->root_node);
242 evas_canvas3d_scene_camera_node_set(data->scene, data->camera_node);
243}
244
245int
246elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
247{
248 Scene_Data data;
249
250 elm_config_accel_preference_set("3d");
251 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
252
253 win = elm_win_util_standard_add("evas3d-object-button", "A button on the 3d object");
254 elm_win_autodel_set(win, EINA_TRUE);
255
256 evas = evas_object_evas_get(win);
257
258 /* Add an image object for 3D scene rendering. */
259 image = efl_add(EFL_CANVAS_SCENE3D_CLASS, evas);
260 efl_gfx_entity_size_set(image, EINA_SIZE2D(WIDTH, HEIGHT));
261 efl_gfx_entity_visible_set(image, EINA_TRUE);
262
263 btn = elm_button_add(win);
264 evas_object_resize(btn, (WIDTH * 2) / 3, (HEIGHT * 2) / 3);
265 elm_object_text_set(btn, "3D Button");
266 elm_object_scale_set(btn, 3.0);
267 evas_object_show(btn);
268
269 /* Set the image object as render target for 3D scene. */
270 _scene_setup(&data);
271 evas_object_focus_set(image, EINA_TRUE);
272 efl_canvas_scene3d_set(image, data.scene);
273
274 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_DOWN, _stop_scene, &data);
275 evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_UP, _play_scene, &data);
276
277 /* Add animation timer callback. */
278 ecore_timer_add(0.016, _animate_scene, &data);
279
280 evas_object_resize(win, WIDTH, HEIGHT);
281 evas_object_show(win);
282
283 /* Enter main loop. */
284 elm_run();
285
286 return 0;
287}
288ELM_MAIN()
diff --git a/src/examples/elementary/evas3d_scene_on_button_example.c b/src/examples/elementary/evas3d_scene_on_button_example.c
deleted file mode 100644
index 267e45b7e9..0000000000
--- a/src/examples/elementary/evas3d_scene_on_button_example.c
+++ /dev/null
@@ -1,280 +0,0 @@
1/*
2* This example shows the mechanism of scene object adding (3D cube) to the widget button and
3* illustrates the work of callback of event from mouse.
4*
5* Compile with:
6* gcc -o evas3d_scene_on_button_example evas3d_scene_on_button_example.c -g `pkg-config --libs --cflags evas ecore eo elementary`
7*/
8#ifndef EFL_BETA_API_SUPPORT
9# define EFL_BETA_API_SUPPORT
10#endif
11
12#define WIDTH 500
13#define HEIGHT 500
14#define d_w 100
15#define d_h 100
16
17
18#include <Eo.h>
19#include <Evas.h>
20#include <Ecore.h>
21#include <Elementary.h>
22#include <stdio.h>
23
24typedef struct _Scene_Data
25{
26 Eo *scene;
27 Eo *root_node;
28 Eo *camera_node;
29 Eo *light_node;
30 Eo *mesh_node;
31
32 Eo *camera;
33 Eo *light;
34 Eo *mesh;
35 Eo *material;
36} Scene_Data;
37
38Evas_Object *win = NULL;
39Evas_Object *btn = NULL;
40float d_angle = 0.5;
41static Evas *evas = NULL;
42static Eo *image = NULL;
43
44static const float cube_vertices[] =
45{
46 /* Front */
47 -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0,
48 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
49 -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
50 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0,
51
52 /* Back */
53 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0,
54 -1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0,
55 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0,
56 -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0,
57
58 /* Left */
59 -1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0,
60 -1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0,
61 -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0,
62 -1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0,
63
64 /* Right */
65 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0,
66 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0,
67 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0,
68 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0,
69
70 /* Top */
71 -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
72 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
73 -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
74 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0,
75
76 /* Bottom */
77 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
78 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0,
79 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
80 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0,
81};
82
83static const unsigned short cube_indices[] =
84{
85 /* Front */
86 0, 1, 2, 2, 1, 3,
87
88 /* Back */
89 4, 5, 6, 6, 5, 7,
90
91 /* Left */
92 8, 9, 10, 10, 9, 11,
93
94 /* Right */
95 12, 13, 14, 14, 13, 15,
96
97 /* Top */
98 16, 17, 18, 18, 17, 19,
99
100 /* Bottom */
101 20, 21, 22, 22, 21, 23
102};
103
104static Eina_Bool
105_animate_scene(void *data)
106{
107 static float angle = 0.0f;
108 Scene_Data *scene = (Scene_Data *)data;
109
110 angle += d_angle;
111
112 evas_canvas3d_node_orientation_angle_axis_set(scene->mesh_node, angle, 1.0, 1.0, 1.0);
113
114 /* Rotate */
115 if (angle > 360.0) angle -= 360.0f;
116
117 return EINA_TRUE;
118}
119
120static void
121_camera_setup(Scene_Data *data)
122{
123 data->camera = efl_add(EVAS_CANVAS3D_CAMERA_CLASS, evas);
124
125 evas_canvas3d_camera_projection_perspective_set(data->camera, 60.0, 1.0, 2.0, 50.0);
126
127 data->camera_node =
128 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_CAMERA));
129 evas_canvas3d_node_camera_set(data->camera_node, data->camera);
130 evas_canvas3d_node_position_set(data->camera_node, 0.0, 0.0, 10.0);
131 evas_canvas3d_node_look_at_set(data->camera_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
132 evas_canvas3d_node_member_add(data->root_node, data->camera_node);
133}
134
135static void
136_light_setup(Scene_Data *data)
137{
138 data->light = efl_add(EVAS_CANVAS3D_LIGHT_CLASS, evas);
139 evas_canvas3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
140 evas_canvas3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
141 evas_canvas3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
142
143 data->light_node =
144 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_LIGHT));
145 evas_canvas3d_node_light_set(data->light_node, data->light);
146 evas_canvas3d_node_position_set(data->light_node, 0.0, 0.0, 10.0);
147 evas_canvas3d_node_look_at_set(data->light_node, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0);
148 evas_canvas3d_node_member_add(data->root_node, data->light_node);
149}
150static void
151_mesh_setup(Scene_Data *data)
152{
153 /* Setup material. */
154 data->material = efl_add(EVAS_CANVAS3D_MATERIAL_CLASS, evas);
155
156 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE);
157 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE);
158 evas_canvas3d_material_enable_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
159 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0);
160 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0);
161 evas_canvas3d_material_color_set(data->material, EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0);
162 evas_canvas3d_material_shininess_set(data->material, 100.0);
163
164 /* Setup mesh. */
165 data->mesh = efl_add(EVAS_CANVAS3D_MESH_CLASS, evas);
166 evas_canvas3d_mesh_vertex_count_set(data->mesh, 24);
167 evas_canvas3d_mesh_frame_add(data->mesh, 0);
168 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, 12 * sizeof(float), &cube_vertices[ 0]);
169 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL, 12 * sizeof(float), &cube_vertices[ 3]);
170 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR, 12 * sizeof(float), &cube_vertices[ 6]);
171 evas_canvas3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD, 12 * sizeof(float), &cube_vertices[10]);
172 evas_canvas3d_mesh_index_data_set(data->mesh, EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, 36, &cube_indices[0]);
173 evas_canvas3d_mesh_vertex_assembly_set(data->mesh, EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES);
174 evas_canvas3d_mesh_shader_mode_set(data->mesh, EVAS_CANVAS3D_SHADER_MODE_PHONG);
175 evas_canvas3d_mesh_frame_material_set(data->mesh, 0, data->material);
176
177 data->mesh_node =
178 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_MESH));
179 evas_canvas3d_node_member_add(data->root_node, data->mesh_node);
180 evas_canvas3d_node_mesh_add(data->mesh_node, data->mesh);
181}
182
183static void
184_scene_setup(Scene_Data *data)
185{
186 data->scene = efl_add(EVAS_CANVAS3D_SCENE_CLASS, evas);
187 evas_canvas3d_scene_size_set(data->scene, WIDTH - d_w, HEIGHT - d_h);
188 evas_canvas3d_scene_background_color_set(data->scene, 0.0, 0.0, 0.0, 0.0);
189
190 data->root_node =
191 efl_add(EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_type_set(efl_added, EVAS_CANVAS3D_NODE_TYPE_NODE));
192
193 _camera_setup(data);
194 _light_setup(data);
195 _mesh_setup(data);
196
197 evas_canvas3d_scene_root_node_set(data->scene, data->root_node);
198 evas_canvas3d_scene_camera_node_set(data->scene, data->camera_node);
199}
200
201static void
202_stop_scene(void *data,
203 Evas *e EINA_UNUSED,
204 Evas_Object *eo EINA_UNUSED,
205 void *event_info)
206{
207 Evas_Event_Mouse_Down *ev = event_info;
208 Scene_Data *d = (Scene_Data *)data;
209
210 evas_canvas3d_node_scale_set(d->mesh_node, 0.97, 0.97, 0.97);
211
212 if (ev->button == 1)
213 {
214 if (evas_canvas3d_scene_exist(d->scene, (ev->canvas.x - (d_w / 2)), (ev->canvas.y - (d_h / 2)), d->mesh_node))
215 {
216 d_angle = 0;
217 }
218 }
219}
220
221static void
222_play_scene(void *data,
223 Evas *e EINA_UNUSED,
224 Evas_Object *eo EINA_UNUSED,
225 void *event_info EINA_UNUSED)
226{
227 Scene_Data *d = (Scene_Data *)data;
228
229 d_angle = 0.5;
230
231 evas_canvas3d_node_scale_set(d->mesh_node, 1.0, 1.0, 1.0);
232}
233
234EAPI_MAIN int
235elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
236{
237 Scene_Data data;
238
239 elm_config_accel_preference_set("3d");
240 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
241
242 win = elm_win_util_standard_add("evas3d-scene-button", "3d object on the button");
243 if (!win) return 0;
244 elm_win_autodel_set(win, EINA_TRUE);
245
246 evas = evas_object_evas_get(win);
247 if (!evas) return 0;
248
249 _scene_setup(&data);
250
251 image = efl_add(EFL_CANVAS_SCENE3D_CLASS, evas);
252 efl_gfx_entity_visible_set(image, EINA_TRUE);
253
254 /* Set the image object as render target for 3D scene. */
255 efl_canvas_scene3d_set(image, data.scene);
256
257 /* Setup scene to the widget button. */
258 btn = elm_button_add(win);
259 elm_object_content_set(btn, image);
260 evas_object_resize(btn, (WIDTH - d_w), (HEIGHT - d_h));
261 evas_object_move(btn, (d_w / 2), (d_h / 2));
262 evas_object_show(btn);
263
264 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN, _stop_scene,
265 &data);
266 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _play_scene,
267 &data);
268
269 /* Add animation timer callback. */
270 ecore_timer_add(0.016, _animate_scene, &data);
271
272 evas_object_resize(win, WIDTH, HEIGHT);
273 evas_object_show(win);
274
275 /* Enter main loop. */
276 elm_run();
277
278 return 0;
279}
280ELM_MAIN()
diff --git a/src/examples/elementary/meson.build b/src/examples/elementary/meson.build
index cdb08d4b35..14a743c9c5 100644
--- a/src/examples/elementary/meson.build
+++ b/src/examples/elementary/meson.build
@@ -100,9 +100,6 @@ examples = [
100 'web_example_02', 100 'web_example_02',
101 'win_example', 101 'win_example',
102 'track_example_01', 102 'track_example_01',
103 'evas3d_object_on_button_example',
104 'evas3d_scene_on_button_example',
105 'evas3d_map_example',
106 'efl_thread_1', 103 'efl_thread_1',
107 'efl_thread_2', 104 'efl_thread_2',
108 'efl_thread_3', 105 'efl_thread_3',
@@ -194,6 +191,3 @@ executable('codegen_example',
194 dependencies: [elementary], 191 dependencies: [elementary],
195 include_directories : include_directories('..') 192 include_directories : include_directories('..')
196) 193)
197
198subdir('sphere_hunter')
199subdir('performance')
diff --git a/src/examples/elementary/performance/HowTo b/src/examples/elementary/performance/HowTo
deleted file mode 100644
index 8417fa0f34..0000000000
--- a/src/examples/elementary/performance/HowTo
+++ /dev/null
@@ -1,13 +0,0 @@
1It is application for quick checking changes in Evas 3D.
2
3Dependences (tested on):
4 efl >= 1.13.0 elementary >= 1.13.0
5 xserver-xorg-video-nouveau driver
6 OpenGL rendering acceleration for elemenatry
7Main features:
8 effects shadow, fog, colorpick
9 fps (Be careful, don't use changing speed animation and stop animation during measuring).
10 load 3D models
11 navigation panel (by right click)
12
13Warnings: Until 3D destructor work properly, you can have lags after set a lot of 3D models or spheres with precision >=50
diff --git a/src/examples/elementary/performance/Tools.h b/src/examples/elementary/performance/Tools.h
deleted file mode 100644
index c3cf8ca3a7..0000000000
--- a/src/examples/elementary/performance/Tools.h
+++ /dev/null
@@ -1,19 +0,0 @@
1
2/*initialization navigation panel*/
3Evas_Object *
4init_panel_camera_light(Evas_Object *win, Eo* camera_node, Eo* light_node, double posX, double posY);
5/*free resources*/
6void
7panel_camera_light_fini(Evas_Object *navigation);
8/*initialization graphical objects*/
9Evas_Object *
10init_graphical_window(Evas_Object *image);
11/*Set step of range*/
12Eina_Bool
13panel_camera_coord_step_set(Evas_Object *navigation, int step);
14Eina_Bool
15panel_camera_angle_step_set(Evas_Object *navigation, int step);
16Eina_Bool
17panel_light_coord_step_set(Evas_Object *navigation, int step);
18Eina_Bool
19panel_light_angle_step_set(Evas_Object *navigation, int step);
diff --git a/src/examples/elementary/performance/background.png b/src/examples/elementary/performance/background.png
deleted file mode 100644
index 190a74f631..0000000000
--- a/src/examples/elementary/performance/background.png
+++ /dev/null
Binary files differ
diff --git a/src/examples/elementary/performance/camera_light.c b/src/examples/elementary/performance/camera_light.c
deleted file mode 100644
index 98be8c24ef..0000000000
--- a/src/examples/elementary/performance/camera_light.c
+++ /dev/null
@@ -1,354 +0,0 @@
1#include "tools_private.h"
2
3Eina_Bool _alloc_memory(Axis_Key **ckey, Panel_Struct **pobj, Axis_Key **lkey)
4{
5 *ckey = calloc(1, sizeof(Axis_Key));
6 *pobj = calloc(1, sizeof(Panel_Struct));
7 *lkey = calloc(1, sizeof(Axis_Key));
8
9 if (!(*ckey) || !(*pobj) || !(*lkey))
10 {
11 printf("Not enough memory - at %s line %d\n", __FILE__, __LINE__);
12 free(*ckey);
13 free(*pobj);
14 free(*lkey);
15 return EINA_FALSE;
16 }
17
18 return EINA_TRUE;
19}
20
21Evas_Object *
22init_panel_camera_light(Evas_Object *win, Eo *camera_node, Eo *light_node, double posX, double posY)
23{
24 Evas_Object *nnavig = NULL, *bx_navigall = NULL;
25 Evas_Object *bx_navigcamup = NULL, *bx_navigcamlow = NULL, *bx_navigligthup = NULL, *bx_navigligthlow = NULL;
26 Evas_Object *spX = NULL, *spY = NULL, *spZ = NULL;
27 Evas_Object *spangle = NULL, *spaX = NULL, *spaY = NULL, *spaZ = NULL;
28 Evas_Object *splX = NULL, *splY = NULL, *splZ = NULL;
29 Evas_Object *splangle = NULL, *splaX = NULL, *splaY = NULL, *splaZ = NULL;
30 Evas_Object *separator = NULL;
31 Axis_Key *camera_xyz = NULL, *light_xyz = NULL;
32 Panel_Struct *pobject = NULL;
33 Evas_Real px = 0, py = 0, pz = 0;
34
35 if (ELM_WIN_UNKNOWN == elm_win_type_get(win))
36 {
37 printf("Not appropriate parent object - at %s line %d\n", __FILE__, __LINE__);
38 return NULL;
39 }
40
41 if (!_alloc_memory(&camera_xyz, &pobject, &light_xyz)) return NULL;
42
43 /*Navigation panel layout*/
44 bx_navigall = elm_box_add(win);
45 elm_box_homogeneous_set(bx_navigall, EINA_TRUE);
46 evas_object_show(bx_navigall);
47
48 bx_navigcamup = elm_box_add(win);
49 elm_box_horizontal_set(bx_navigcamup, EINA_TRUE);
50 elm_box_homogeneous_set(bx_navigcamup, EINA_TRUE);
51 elm_box_pack_end(bx_navigall, bx_navigcamup);
52 evas_object_show(bx_navigcamup);
53 bx_navigcamlow = elm_box_add(win);
54 elm_box_horizontal_set(bx_navigcamlow, EINA_TRUE);
55 elm_box_homogeneous_set(bx_navigcamlow, EINA_TRUE);
56 elm_box_pack_end(bx_navigall, bx_navigcamlow);
57 evas_object_show(bx_navigcamlow);
58
59 separator = elm_separator_add(win);
60 elm_separator_horizontal_set(separator, EINA_TRUE);
61 elm_box_pack_end(bx_navigall, separator);
62 evas_object_show(separator);
63
64 bx_navigligthup = elm_box_add(win);
65 elm_box_horizontal_set(bx_navigligthup, EINA_TRUE);
66 elm_box_homogeneous_set(bx_navigligthup, EINA_TRUE);
67 elm_box_pack_end(bx_navigall, bx_navigligthup);
68 evas_object_show(bx_navigligthup);
69 bx_navigligthlow = elm_box_add(win);
70 elm_box_horizontal_set(bx_navigligthlow, EINA_TRUE);
71 elm_box_homogeneous_set(bx_navigligthlow, EINA_TRUE);
72 elm_box_pack_end(bx_navigall, bx_navigligthlow);
73 evas_object_show(bx_navigligthlow);
74
75 /*Set UI panel for changing camera and light*/
76 /*Init sp camera by default*/
77 spX = elm_spinner_add(win);
78 elm_spinner_editable_set(spX, EINA_TRUE);
79 elm_spinner_min_max_set(spX, -COORDRANGE, COORDRANGE);
80 elm_spinner_label_format_set(spX, "camera X: %1.0f");
81 elm_spinner_step_set(spX, 1.0);
82 pobject->cspX = spX;
83 elm_box_pack_end(bx_navigcamup, spX);
84 evas_object_show(spX);
85 evas_object_smart_callback_add(spX, "changed", _camera_light_changeX_cb, camera_node);
86
87 spY = elm_spinner_add(win);
88 elm_spinner_editable_set(spY, EINA_TRUE);
89 elm_spinner_min_max_set(spY, -COORDRANGE, COORDRANGE);
90 elm_spinner_label_format_set(spY, "camera Y: %1.0f");
91 elm_spinner_step_set(spY, 1.0);
92 pobject->cspY = spY;
93 elm_box_pack_end(bx_navigcamup, spY);
94 evas_object_show(spY);
95 evas_object_smart_callback_add(spY, "changed", _camera_light_changeY_cb, camera_node);
96
97 spZ = elm_spinner_add(win);
98 elm_spinner_editable_set(spZ, EINA_TRUE);
99 elm_spinner_min_max_set(spZ, -COORDRANGE, COORDRANGE);
100 elm_spinner_label_format_set(spZ, "camera Z: %1.0f");
101 elm_spinner_step_set(spY, 1.0);
102 pobject->cspZ = spZ;
103 elm_box_pack_end(bx_navigcamup, spZ);
104 evas_object_show(spZ);
105 evas_object_smart_callback_add(spZ, "changed", _camera_light_changeZ_cb, camera_node);
106
107 evas_canvas3d_node_position_get(camera_node, EVAS_CANVAS3D_SPACE_PARENT, &px, &py, &pz);
108 elm_spinner_value_set(spX, px);
109 elm_spinner_value_set(spY, py);
110 elm_spinner_value_set(spZ, pz);
111
112 spangle = elm_spinner_add(win);
113 elm_spinner_editable_set(spangle, EINA_TRUE);
114 elm_spinner_min_max_set(spangle, 0.0, ANGLERANGE);
115 elm_spinner_label_format_set(spangle, "angle: %1.0f");
116 elm_spinner_step_set(spangle, 1.0);
117 pobject->cspangle = spangle;
118 evas_object_data_set(spangle, axiskeys, camera_xyz);
119 elm_box_pack_end(bx_navigcamlow, spangle);
120 elm_spinner_value_set(spangle, 0.0);
121 evas_object_show(spangle);
122 evas_object_smart_callback_add(spangle, "changed", _camera_light_angle_change_cb, camera_node);
123
124 spaX = elm_spinner_add(win);
125 elm_spinner_min_max_set(spaX, 0.0, 1.0);
126 elm_spinner_label_format_set(spaX, "axisX: %1.0f");
127 elm_spinner_step_set(spaX, 1.0);
128 elm_box_pack_end(bx_navigcamlow, spaX);
129 evas_object_show(spaX);
130 evas_object_smart_callback_add(spaX, "changed", _camera_light_axisX_change_cb, spangle);
131
132 spaY = elm_spinner_add(win);
133 elm_spinner_min_max_set(spaY, 0.0, 1.0);
134 elm_spinner_label_format_set(spaY, "axisY: %1.0f");
135 elm_spinner_step_set(spaY, 1.0);
136 elm_box_pack_end(bx_navigcamlow, spaY);
137 evas_object_show(spaY);
138 evas_object_smart_callback_add(spaY, "changed", _camera_light_axisY_change_cb, spangle);
139
140 spaZ = elm_spinner_add(win);
141 elm_spinner_min_max_set(spaZ, 0.0, 1.0);
142 elm_spinner_label_format_set(spaZ, "axisZ: %1.0f");
143 elm_spinner_step_set(spaZ, 1.0);
144 elm_box_pack_end(bx_navigcamlow, spaZ);
145 evas_object_show(spaZ);
146 evas_object_smart_callback_add(spaZ, "changed", _camera_light_axisZ_change_cb, spangle);
147
148 /*Init spl light by default*/
149 splX = elm_spinner_add(win);
150 elm_spinner_editable_set(splX, EINA_TRUE);
151 elm_spinner_min_max_set(splX, -COORDRANGE, COORDRANGE);
152 elm_spinner_label_format_set(splX, "light X: %1.0f");
153 elm_spinner_step_set(splX, 1.0);
154 pobject->lspX = splX;
155 elm_box_pack_end(bx_navigligthup, splX);
156 evas_object_show(splX);
157 evas_object_smart_callback_add(splX, "changed", _camera_light_changeX_cb, light_node);
158
159 splY = elm_spinner_add(win);
160 elm_spinner_editable_set(splY, EINA_TRUE);
161 elm_spinner_min_max_set(splY, -COORDRANGE, COORDRANGE);
162 elm_spinner_label_format_set(splY, "light Y: %1.0f");
163 elm_spinner_step_set(splY, 1.0);
164 pobject->lspY = splY;
165 elm_box_pack_end(bx_navigligthup, splY);
166 evas_object_show(splY);
167 evas_object_smart_callback_add(splY, "changed", _camera_light_changeY_cb, light_node);
168
169 splZ = elm_spinner_add(win);
170 elm_spinner_editable_set(splZ, EINA_TRUE);
171 elm_spinner_min_max_set(splZ, -COORDRANGE, COORDRANGE);
172 elm_spinner_label_format_set(splZ, "light Z: %1.0f");
173 elm_spinner_step_set(splY, 1.0);
174 pobject->lspZ = splZ;
175 elm_box_pack_end(bx_navigligthup, splZ);
176 evas_object_show(splZ);
177 evas_object_smart_callback_add(splZ, "changed", _camera_light_changeZ_cb, light_node);
178
179 evas_canvas3d_node_position_get(light_node, EVAS_CANVAS3D_SPACE_PARENT, &px, &py, &pz);
180 elm_spinner_value_set(splX, px);
181 elm_spinner_value_set(splY, py);
182 elm_spinner_value_set(splZ, pz);
183
184 splangle = elm_spinner_add(win);
185 elm_spinner_editable_set(splangle, EINA_TRUE);
186 elm_spinner_min_max_set(splangle, 0.0, ANGLERANGE);
187 elm_spinner_label_format_set(splangle, "angle: %1.0f");
188 elm_spinner_step_set(splangle, 1.0);
189 pobject->lspangle = splangle;
190 evas_object_data_set(splangle, axiskeys, light_xyz);
191 elm_box_pack_end(bx_navigligthlow, splangle);
192 elm_spinner_value_set(splangle, 0.0);
193 evas_object_show(splangle);
194 evas_object_smart_callback_add(splangle, "changed", _camera_light_angle_change_cb, light_node);
195
196 splaX = elm_spinner_add(win);
197 elm_spinner_min_max_set(splaX, 0.0, 1.0);
198 elm_spinner_label_format_set(splaX, "axisX: %1.0f");
199 elm_spinner_step_set(splaX, 1.0);
200 elm_box_pack_end(bx_navigligthlow, splaX);
201 evas_object_show(splaX);
202 evas_object_smart_callback_add(splaX, "changed", _camera_light_axisX_change_cb, splangle);
203
204 splaY = elm_spinner_add(win);
205 elm_spinner_min_max_set(splaY, 0.0, 1.0);
206 elm_spinner_label_format_set(splaY, "axisY: %1.0f");
207 elm_spinner_step_set(splaY, 1.0);
208 elm_box_pack_end(bx_navigligthlow, splaY);
209 evas_object_show(splaY);
210 evas_object_smart_callback_add(splaY, "changed", _camera_light_axisY_change_cb, splangle);
211
212 splaZ = elm_spinner_add(win);
213 elm_spinner_min_max_set(splaZ, 0.0, 1.0);
214 elm_spinner_label_format_set(splaZ, "axisZ: %1.0f");
215 elm_spinner_step_set(splaZ, 1.0);
216 elm_box_pack_end(bx_navigligthlow, splaZ);
217 evas_object_show(splaZ);
218 evas_object_smart_callback_add(spaZ, "changed", _camera_light_axisZ_change_cb, splangle);
219
220 nnavig = elm_notify_add(win);
221 elm_object_content_set(nnavig, bx_navigall);
222 elm_notify_align_set(nnavig, posX, posY);
223 evas_object_data_set(nnavig, pb, pobject);
224
225 return nnavig;
226}
227
228static void
229_camera_light_changeX_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
230{
231 Evas_Real x, y, z;
232
233 if ((Eo*)data)
234 {
235 evas_canvas3d_node_position_get((Eo*)data, EVAS_CANVAS3D_SPACE_PARENT, NULL, &y, &z);
236 x = elm_spinner_value_get(obj);
237 evas_canvas3d_node_position_set((Eo*)data, x, y, z);
238 }
239}
240static void
241_camera_light_changeY_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
242{
243 Evas_Real x, y, z;
244
245 if ((Eo*)data)
246 {
247 evas_canvas3d_node_position_get((Eo*)data, EVAS_CANVAS3D_SPACE_PARENT, &x, NULL, &z);
248 y = elm_spinner_value_get(obj);
249 evas_canvas3d_node_position_set((Eo*)data, x, y, z);
250 }
251}
252static void
253_camera_light_changeZ_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
254{
255 Evas_Real x, y, z;
256
257 if ((Eo*)data)
258 {
259 evas_canvas3d_node_position_get((Eo*)data, EVAS_CANVAS3D_SPACE_PARENT, &x, &y, NULL);
260 z = elm_spinner_value_get(obj);
261 evas_canvas3d_node_position_set((Eo*)data, x, y, z);
262 }
263}
264static void
265_camera_light_angle_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
266{
267 Axis_Key *key = evas_object_data_get(obj, axiskeys);
268 Evas_Real aw = 0;
269 if ((Eo*)data)
270 {
271 aw = elm_spinner_value_get(obj);
272 aw = cos(aw * M_PI / 360.0);
273 evas_canvas3d_node_orientation_set(((Eo*)data), key->x, key->y, key->z, aw);
274 }
275}
276static void
277_camera_light_axisX_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
278{
279 Evas_Object *fsa = (Evas_Object*)data;
280 Axis_Key *key = evas_object_data_get(fsa, axiskeys);
281 if (key)
282 key->x = elm_spinner_value_get(obj);
283}
284static void
285_camera_light_axisY_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
286{
287 Evas_Object *fsa = (Evas_Object*)data;
288 Axis_Key *key = evas_object_data_get(fsa, axiskeys);
289 if (key)
290 key->y = elm_spinner_value_get(obj);
291}
292static void
293_camera_light_axisZ_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
294{
295 Evas_Object *fsa = (Evas_Object*)data;
296 Axis_Key *key = evas_object_data_get(fsa, axiskeys);
297 if (key)
298 key->z = elm_spinner_value_get(obj);
299}
300
301Eina_Bool
302panel_camera_coord_step_set(Evas_Object *navigation, int step)
303{
304 Panel_Struct *pobject = NULL;
305
306 pobject = evas_object_data_get(navigation, pb);
307 elm_spinner_step_set(pobject->cspX, step);
308 elm_spinner_step_set(pobject->cspY, step);
309 elm_spinner_step_set(pobject->cspZ, step);
310 return EINA_TRUE;
311}
312
313Eina_Bool
314panel_camera_angle_step_set(Evas_Object *navigation, int step)
315{
316 Panel_Struct *pobject = NULL;
317
318 pobject = evas_object_data_get(navigation, pb);
319 elm_spinner_step_set(pobject->cspangle, step);
320 return EINA_TRUE;
321}
322
323Eina_Bool
324panel_light_coord_step_set(Evas_Object *navigation, int step)
325{
326 Panel_Struct *pobject = NULL;
327
328 pobject = evas_object_data_get(navigation, pb);
329 elm_spinner_step_set(pobject->lspX, step);
330 elm_spinner_step_set(pobject->lspY, step);
331 elm_spinner_step_set(pobject->lspZ, step);
332 return EINA_TRUE;
333}
334
335Eina_Bool