summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <chuneon.park@samsung.com>2020-03-25 19:14:02 +0900
committerHermet Park <chuneon.park@samsung.com>2020-03-25 19:14:02 +0900
commit476e2b0521df500776ef0e88f3f28bb5f6b26e78 (patch)
tree8b455b1e731c16efca7f4a4352e7b369e3cc1349
parentd4e6303d9e14c38f2d901b571261f27fe544b1de (diff)
canvas 3d: remove all canvas3d features across efl.
Reviewers: jsuya, kimcinoo, bu5hm4n, raster Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11552
-rw-r--r--src/bin/edje/edje_cc_handlers.c65
-rw-r--r--src/bin/edje/edje_cc_out.c7
-rw-r--r--src/lib/edje/edje_data.c2
-rw-r--r--src/lib/edje/edje_private.h11
-rw-r--r--src/lib/evas/Evas_Eo.h212
-rw-r--r--src/lib/evas/canvas/efl_canvas_scene3d.c310
-rw-r--r--src/lib/evas/canvas/efl_canvas_scene3d.eo20
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_camera.c203
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_camera.eo89
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_eet.c211
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_light.c309
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_light.eo249
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_material.c206
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_material.eo116
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_mesh.c1172
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_mesh.eo421
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_node.c1695
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_node.eo368
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_node_callback.h36
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_object.c101
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_object.eo77
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_primitive.c152
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_primitive.eo130
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_scene.c839
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_scene.eo168
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_texture.c606
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_texture.eo159
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_types.eot293
-rw-r--r--src/lib/evas/canvas/evas_image_legacy.c2
-rw-r--r--src/lib/evas/canvas/evas_image_private.h6
-rw-r--r--src/lib/evas/canvas/evas_main.c5
-rw-r--r--src/lib/evas/canvas/evas_object_image.c43
-rw-r--r--src/lib/evas/canvas/evas_object_main.c32
-rw-r--r--src/lib/evas/canvas/evas_render.c14
-rw-r--r--src/lib/evas/canvas/meson.build23
-rw-r--r--src/lib/evas/common3d/meson.build2
-rw-r--r--src/lib/evas/common3d/primitives/meson.build5
-rw-r--r--src/lib/evas/common3d/primitives/primitive_common.c203
-rw-r--r--src/lib/evas/common3d/primitives/primitive_common.h62
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/cone.c140
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/cylinder.c136
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/meson.build6
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/sphere.c189
-rw-r--r--src/lib/evas/common3d/primitives/solids_of_revolution/torus.c67
-rw-r--r--src/lib/evas/common3d/primitives/surfaces/meson.build4
-rw-r--r--src/lib/evas/common3d/primitives/surfaces/surface.c91
-rw-r--r--src/lib/evas/common3d/primitives/surfaces/terrain.c86
-rw-r--r--src/lib/evas/common3d/primitives/tabulated_primitives/cube.c57
-rw-r--r--src/lib/evas/common3d/primitives/tabulated_primitives/meson.build4
-rw-r--r--src/lib/evas/common3d/primitives/tabulated_primitives/square.c18
-rw-r--r--src/lib/evas/common3d/save_load/evas_model_load.c82
-rw-r--r--src/lib/evas/common3d/save_load/evas_model_load_save_common.c230
-rw-r--r--src/lib/evas/common3d/save_load/evas_model_load_save_common.h62
-rw-r--r--src/lib/evas/common3d/save_load/evas_model_save.c34
-rw-r--r--src/lib/evas/common3d/save_load/meson.build6
-rw-r--r--src/lib/evas/include/evas_3d_utils.h1698
-rw-r--r--src/lib/evas/include/evas_common_private.h3
-rw-r--r--src/lib/evas/include/evas_inline.x2
-rw-r--r--src/lib/evas/include/evas_private.h509
-rw-r--r--src/lib/evas/meson.build23
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d.c1494
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d_common.h40
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d_private.h183
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d_renderer.c428
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d_shader.c751
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_define.h1
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/color_pick_frag.shd15
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/color_pick_vert.shd11
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/diffuse_frag.shd16
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/diffuse_vert.shd13
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x2198
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/flat_frag.shd64
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/flat_vert.shd92
-rwxr-xr-xsrc/modules/evas/engines/gl_common/shader_3d/gen_shaders_3d.sh68
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/include.shd254
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/normal_map_frag.shd147
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/normal_map_vert.shd128
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/parallax_occlusion_frag.shd240
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/parallax_occlusion_vert.shd88
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/phong_frag.shd103
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/phong_vert.shd51
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/post_processing_fxaa_frag.shd63
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/post_processing_fxaa_vert.shd12
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/shadow_map_frag.shd60
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/shadow_map_vert.shd21
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/vertex_color_frag.shd17
-rw-r--r--src/modules/evas/engines/gl_common/shader_3d/vertex_color_vert.shd24
-rw-r--r--src/modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h2
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c204
-rw-r--r--src/modules/evas/engines/gl_generic/meson.build5
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c19
-rw-r--r--src/modules/evas/meson.build2
-rw-r--r--src/modules/evas/model_loaders/eet/evas_model_load_eet.c111
-rw-r--r--src/modules/evas/model_loaders/md2/evas_model_load_md2.c423
-rw-r--r--src/modules/evas/model_loaders/meson.build1
-rw-r--r--src/modules/evas/model_loaders/obj/evas_model_load_obj.c461
-rw-r--r--src/modules/evas/model_loaders/ply/evas_model_load_ply.c252
-rw-r--r--src/modules/evas/model_savers/eet/evas_model_save_eet.c205
-rw-r--r--src/modules/evas/model_savers/meson.build1
-rw-r--r--src/modules/evas/model_savers/obj/evas_model_save_obj.c241
-rw-r--r--src/modules/evas/model_savers/ply/evas_model_save_ply.c91
-rw-r--r--src/tests/evas/evas_suite.c5
-rw-r--r--src/tests/evas/evas_suite.h5
-rw-r--r--src/tests/evas/evas_test_matrix.c42
-rw-r--r--src/tests/evas/evas_test_mesh.c202
-rw-r--r--src/tests/evas/meshes/md2/sonic.md2bin660576 -> 0 bytes
-rw-r--r--src/tests/evas/meshes/obj/man_mesh.obj2493
-rw-r--r--src/tests/evas/meshes/obj/sweet_home.obj107
-rw-r--r--src/tests/evas/meshes/ply/NoNormal_NoUVs_Colors.ply1679
-rw-r--r--src/tests/evas/meshes/ply/NoNormal_NoUVs_NoColors.ply1676
-rw-r--r--src/tests/evas/meshes/ply/NoNormal_UVs_Colors.ply1681
-rw-r--r--src/tests/evas/meshes/ply/NoNormal_UVs_NoColors.ply1678
-rw-r--r--src/tests/evas/meshes/ply/Normal_NoUVs_Colors.ply1682
-rw-r--r--src/tests/evas/meshes/ply/Normal_NoUVs_NoColors.ply1679
-rw-r--r--src/tests/evas/meshes/ply/Normal_UVs_Colors.ply1684
-rw-r--r--src/tests/evas/meshes/ply/Normal_UVs_NoColors.ply1681
-rw-r--r--src/tests/evas/meson.build2
118 files changed, 9 insertions, 36960 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 8a1f36b47c..3c9d997930 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -270,7 +270,6 @@ static void st_collections_group_script_recursion(void);
270static void st_collections_group_alias(void); 270static void st_collections_group_alias(void);
271static void st_collections_group_min(void); 271static void st_collections_group_min(void);
272static void st_collections_group_max(void); 272static void st_collections_group_max(void);
273static void st_collections_group_scene_size(void);
274static void st_collections_group_broadcast_signal(void); 273static void st_collections_group_broadcast_signal(void);
275static void st_collections_group_data_item(void); 274static void st_collections_group_data_item(void);
276static void st_collections_group_orientation(void); 275static void st_collections_group_orientation(void);
@@ -680,7 +679,6 @@ New_Statement_Handler statement_handlers[] =
680 {"collections.group.alias", st_collections_group_alias}, 679 {"collections.group.alias", st_collections_group_alias},
681 {"collections.group.min", st_collections_group_min}, 680 {"collections.group.min", st_collections_group_min},
682 {"collections.group.max", st_collections_group_max}, 681 {"collections.group.max", st_collections_group_max},
683 {"collections.group.scene_size", st_collections_group_scene_size},
684 {"collections.group.broadcast_signal", st_collections_group_broadcast_signal}, 682 {"collections.group.broadcast_signal", st_collections_group_broadcast_signal},
685 {"collections.group.orientation", st_collections_group_orientation}, 683 {"collections.group.orientation", st_collections_group_orientation},
686 {"collections.group.mouse_events", st_collections_group_mouse_events}, 684 {"collections.group.mouse_events", st_collections_group_mouse_events},
@@ -4126,9 +4124,6 @@ ob_collections_group(void)
4126 pcp->default_mouse_events = 1; 4124 pcp->default_mouse_events = 1;
4127 pcp->inherit_script = EINA_FALSE; 4125 pcp->inherit_script = EINA_FALSE;
4128 4126
4129 pc->scene_size.width = 0;
4130 pc->scene_size.height = 0;
4131
4132#ifdef HAVE_EPHYSICS 4127#ifdef HAVE_EPHYSICS
4133 pc->physics.world.gravity.x = 0; 4128 pc->physics.world.gravity.x = 0;
4134 pc->physics.world.gravity.y = 294; 4129 pc->physics.world.gravity.y = 294;
@@ -4317,18 +4312,6 @@ _parts_count_update(unsigned int type, int inc)
4317 current_de->count.PROXY += inc; 4312 current_de->count.PROXY += inc;
4318 break; 4313 break;
4319 4314
4320 case EDJE_PART_TYPE_MESH_NODE:
4321 current_de->count.MESH_NODE += inc;
4322 break;
4323
4324 case EDJE_PART_TYPE_LIGHT:
4325 current_de->count.LIGHT += inc;
4326 break;
4327
4328 case EDJE_PART_TYPE_CAMERA:
4329 current_de->count.CAMERA += inc;
4330 break;
4331
4332 case EDJE_PART_TYPE_SPACER: 4315 case EDJE_PART_TYPE_SPACER:
4333 current_de->count.SPACER += inc; 4316 current_de->count.SPACER += inc;
4334 break; 4317 break;
@@ -5183,30 +5166,6 @@ st_collections_group_max(void)
5183} 5166}
5184 5167
5185/** 5168/**
5186 @page edcref
5187 @property
5188 scene_size
5189 @parameters
5190 [width] [height]
5191 @effect
5192 Size of scene.
5193
5194 Defaults: 0.0 0.0
5195 @endproperty
5196 */
5197static void
5198st_collections_group_scene_size(void)
5199{
5200 Edje_Part_Collection *pc;
5201
5202 check_arg_count(2);
5203
5204 pc = eina_list_data_get(eina_list_last(edje_collections));
5205 pc->scene_size.width = parse_float(0);
5206 pc->scene_size.height = parse_float(1);
5207}
5208
5209/**
5210 @page edcref 5169 @page edcref
5211 @property 5170 @property
5212 broadcast_signal 5171 broadcast_signal
@@ -6524,9 +6483,6 @@ st_collections_group_parts_part_name(void)
6524 @li BOX 6483 @li BOX
6525 @li TABLE 6484 @li TABLE
6526 @li EXTERNAL 6485 @li EXTERNAL
6527 @li MESH_NODE
6528 @li CAMERA
6529 @li LIGHT
6530 @li PROXY 6486 @li PROXY
6531 @li SPACER 6487 @li SPACER
6532 @li SNAPSHOT 6488 @li SNAPSHOT
@@ -6538,9 +6494,6 @@ static void
6538st_collections_group_parts_part_type(void) 6494st_collections_group_parts_part_type(void)
6539{ 6495{
6540 unsigned int type; 6496 unsigned int type;
6541 unsigned int i = 0;
6542
6543 Edje_Part_Collection *pc;
6544 6497
6545 check_arg_count(1); 6498 check_arg_count(1);
6546 6499
@@ -6556,29 +6509,11 @@ st_collections_group_parts_part_type(void)
6556 "TABLE", EDJE_PART_TYPE_TABLE, 6509 "TABLE", EDJE_PART_TYPE_TABLE,
6557 "EXTERNAL", EDJE_PART_TYPE_EXTERNAL, 6510 "EXTERNAL", EDJE_PART_TYPE_EXTERNAL,
6558 "PROXY", EDJE_PART_TYPE_PROXY, 6511 "PROXY", EDJE_PART_TYPE_PROXY,
6559 "MESH_NODE", EDJE_PART_TYPE_MESH_NODE,
6560 "LIGHT", EDJE_PART_TYPE_LIGHT,
6561 "CAMERA", EDJE_PART_TYPE_CAMERA,
6562 "SPACER", EDJE_PART_TYPE_SPACER, 6512 "SPACER", EDJE_PART_TYPE_SPACER,
6563 "SNAPSHOT", EDJE_PART_TYPE_SNAPSHOT, 6513 "SNAPSHOT", EDJE_PART_TYPE_SNAPSHOT,
6564 "VECTOR", EDJE_PART_TYPE_VECTOR, 6514 "VECTOR", EDJE_PART_TYPE_VECTOR,
6565 NULL); 6515 NULL);
6566 6516
6567 pc = eina_list_data_get(eina_list_last(edje_collections));
6568
6569 if (type == EDJE_PART_TYPE_CAMERA)
6570 {
6571 for (i = 0; i < (pc->parts_count - 1); i++)
6572 {
6573 if (pc->parts[i]->type == EDJE_PART_TYPE_CAMERA)
6574 {
6575 WRN("parse error %s:%i. more then one part of type CAMERA in scene.",
6576 file_in, line - 1);
6577 exit(-1);
6578 }
6579 }
6580 }
6581
6582 _part_type_set(type); 6517 _part_type_set(type);
6583} 6518}
6584 6519
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 0dcde387e9..64f6cec29d 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -715,13 +715,6 @@ check_program(Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef)
715 Edje_Program_Target *et; 715 Edje_Program_Target *et;
716 Eina_List *l; 716 Eina_List *l;
717 unsigned int i = 0; 717 unsigned int i = 0;
718 int camera_id = -1;
719
720 for (i = 0; (i < pc->parts_count) && (camera_id < 0); i++)
721 {
722 if (pc->parts[i]->type == EDJE_PART_TYPE_CAMERA)
723 camera_id = i;
724 }
725 718
726 if ((!ep->targets) && (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT)) 719 if ((!ep->targets) && (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT))
727 { 720 {
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 8b07c9dc13..a4b3f90a94 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -1297,8 +1297,6 @@ _edje_edd_init(void)
1297 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT); 1297 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT);
1298 EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "alias", alias); 1298 EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "alias", alias);
1299 EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "aliased", aliased); 1299 EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "aliased", aliased);
1300 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.width", scene_size.width, EDJE_T_FLOAT);
1301 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.height", scene_size.height, EDJE_T_FLOAT);
1302 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT); 1300 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT);
1303 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT); 1301 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT);
1304 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT); 1302 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT);
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index fa2d921212..03e288c567 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -897,9 +897,6 @@ struct _Edje_Limit
897 TYPE TABLE; \ 897 TYPE TABLE; \
898 TYPE SPACER; \ 898 TYPE SPACER; \
899 TYPE EXTERNAL; \ 899 TYPE EXTERNAL; \
900 TYPE MESH_NODE; \
901 TYPE LIGHT; \
902 TYPE CAMERA; \
903 TYPE SNAPSHOT; \ 900 TYPE SNAPSHOT; \
904 TYPE VECTOR; 901 TYPE VECTOR;
905 902
@@ -1149,11 +1146,6 @@ struct _Edje_Part_Collection
1149 } patterns; 1146 } patterns;
1150 /* *** *** */ 1147 /* *** *** */
1151 1148
1152 struct {
1153 Evas_Real height;
1154 Evas_Real width;
1155 } scene_size;
1156
1157 unsigned char lua_script_only; 1149 unsigned char lua_script_only;
1158 unsigned char broadcast_signal; 1150 unsigned char broadcast_signal;
1159 unsigned char physics_enabled; /* will be 1 if a body is declared */ 1151 unsigned char physics_enabled; /* will be 1 if a body is declared */
@@ -2368,9 +2360,6 @@ EAPI extern Eina_Mempool *_emp_BOX;
2368EAPI extern Eina_Mempool *_emp_TABLE; 2360EAPI extern Eina_Mempool *_emp_TABLE;
2369EAPI extern Eina_Mempool *_emp_EXTERNAL; 2361EAPI extern Eina_Mempool *_emp_EXTERNAL;
2370EAPI extern Eina_Mempool *_emp_SPACER; 2362EAPI extern Eina_Mempool *_emp_SPACER;
2371EAPI extern Eina_Mempool *_emp_MESH_NODE;
2372EAPI extern Eina_Mempool *_emp_LIGHT;
2373EAPI extern Eina_Mempool *_emp_CAMERA;
2374EAPI extern Eina_Mempool *_emp_SNAPSHOT; 2363EAPI extern Eina_Mempool *_emp_SNAPSHOT;
2375EAPI extern Eina_Mempool *_emp_part; 2364EAPI extern Eina_Mempool *_emp_part;
2376EAPI extern Eina_Mempool *_emp_VECTOR; 2365EAPI extern Eina_Mempool *_emp_VECTOR;
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 046f2c55d6..aefbe144f7 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -119,218 +119,6 @@ struct _Efl_Canvas_Object_Animation_Event
119#include "canvas/efl_canvas_object_animation.eo.h" 119#include "canvas/efl_canvas_object_animation.eo.h"
120#include "canvas/efl_canvas_event_grabber.eo.h" 120#include "canvas/efl_canvas_event_grabber.eo.h"
121 121
122 /**
123 * @defgroup Evas_3D Evas 3D Extensions
124 *
125 * Evas extension to support 3D rendering.
126 *
127 * @ingroup Evas
128 */
129
130#include "canvas/evas_canvas3d_types.eot.h"
131
132/**
133 * @page evas_canvas3d_main Evas 3D
134 *
135 * @since 1.10
136 *
137 * @section evas_canvas3d_toc Table of Contents
138 *
139 * @li @ref evas_canvas3d_intro
140 * @li @ref evas_canvas3d_example
141 *
142 * @section evas_canvas3d_intro Introduction
143 *
144 * Evas 3D is an extension to support 3D scene graph rendering into 2D Evas
145 * canvases, with tree-based scene graph manipulation and other typical 3D
146 * rendering techniques.
147 *
148 * 3D objects are used to describe three dimensional scenes and to provide
149 * interfaces to connect the scene to an Evas image object for rendering.
150 *
151 * Scenes are constructed by locating cameras and lights and selecting desired
152 * meshes, and organizing Node objects into hierarchical n-ary tree data structures.
153 * The scene is stacked on the canvas with existing Evas objects, which permits
154 * intermingling 3D rendered content in existing 2D application layouts.
155 *
156 * Rendering techniques supported by Evas 3D include flat and phong
157 * shading, normal and texture mapping, and triangle meshes. Existing
158 * Evas objects may also be used as textures inside the 3D scene,
159 * including EFL widgets and even application windows. This latter
160 * capability makes it possible to create a 3D version of an arbitrary
161 * EFL application with minimal code changes.
162 *
163 * @section evas_canvas3d_example Introductory Example
164 *
165 * @include evas-3d-cube.c
166 */
167
168/**
169 * @defgroup Evas_Canvas3D_Types Types & Enums
170 * @ingroup Evas_3D
171 *
172 * Primitive type definitions and enumerations.
173 */
174
175/**
176 * @defgroup Evas_Canvas3D_Object Generic 3D Object Descriptions
177 * @ingroup Evas_3D
178 *
179 * The Evas_Canvas3D_Object structure is an abstract base for other Evas
180 * 3D objects (scenes, nodes, lights, meshes, textures, and materials)
181 * with reference counting and propagation of modifications via
182 * reference tracking. This permits, for example, when a scene object
183 * is modified (marked dirty), a number of image objects rendering that
184 * object to be notified to update themselves, without needing to call
185 * update functions manually.
186 */
187
188/**
189 * @defgroup Evas_Canvas3D_Scene Scene Object
190 * @ingroup Evas_3D
191 *
192 * The Evas_Canvas3D_Scene structure represents a captured image of a
193 * scene graph through its viewing camera. A scene can be associated
194 * with an image object for canvas display via the
195 * evas_object_image_scene_set() function.
196 */
197
198/**
199 * @defgroup Evas_Canvas3D_Node Node Object
200 * @ingroup Evas_3D
201 *
202 * The Evas_Canvas3D_Node structure defines the position, orientation,
203 * and scale of canvas objects (cameras, lights, meshes, etc.) in a 3D
204 * space. These nodes can be organized into a hierarchical n-ary tree
205 * structure to construct a scene graph.
206 */
207
208/**
209 * @defgroup Evas_Canvas3D_Camera Camera Object
210 * @ingroup Evas_3D
211 *
212 * The Evas_Canvas3D_Camera structure defines properties used to
213 * generate 2D pictures of a given scene graph, similar in concept to
214 * focus length and film size for a real world camera.
215 *
216 * A given camera definition can be used to take multiple pictures of
217 * the scene by establishing multiple nodes for the
218 * Evas_Canvas3D_Camera, each of which are located at different
219 * positions and with different orientations. Convenience routines
220 * evas_canvas3d_node_position_set() and
221 * evas_canvas3d_node_look_at_set() are provided to adjust the position
222 * and viewing direction for these nodes.
223 */
224
225/**
226 * @defgroup Evas_Canvas3D_Light Light Object
227 * @ingroup Evas_3D
228 *
229 * The Evas_Canvas3D_Light structure defines various light source
230 * properties. Reflection models include: Ambient, diffuse, and
231 * specular. Light models include directional, point, and spot. The
232 * position and direction for the light is tracked by the node that
233 * contains the light.
234 */
235
236/**
237 * @defgroup Evas_Canvas3D_Mesh Mesh Object
238 * @ingroup Evas_3D
239 *
240 * The Evas_Canvas3D_Mesh structure manages key-frame based mesh
241 * animations for geometrical objects like character models, terrain,
242 * buildings, and other such visible objects. Each mesh frame can have
243 * its own material and geometric data. Blending functions, fog
244 * effects, level of detail boundaries, and shadow properties are also
245 * supported.
246 *
247 * Like other data objects, a mesh definition is located and oriented in
248 * the canvas with one or more nodes, with the mesh transformed from its
249 * modeling coordinate space to the node's coordinate space. The frame
250 * number is also tracked by the node, permitting creation of multiple
251 * nodes in the canvas each set to a different animation frame, for
252 * example.
253 *
254 * Unlike camera and light objects, multiple meshes can be contained in
255 * a single node.
256 */
257
258/**
259 * @defgroup Evas_Canvas3D_Primitive Primitive Object
260 * @ingroup Evas_3D
261 *
262 * The Evas_Canvas3D_Primitive structure defines the data for
263 * generating meshes for various types of primitive shapes such as
264 * cubes, cylinders, spheres, surfaces, terrain, etc. Use the
265 * evas_canvas3d_mesh_from_primitive_set() function to generate a
266 * mesh's frame of this primitive.
267 */
268
269/**
270 * @defgroup Evas_Canvas3D_Texture Texture Object
271 * @ingroup Evas_3D
272 *
273 * The Evas_Canvas3D_Texture structure associates a 2D bitmap image to a
274 * material for a surface. Image data for the texture can be loaded
275 * from memory, a file, or an Evas_Object. Use the
276 * evas_canvas3d_material_texture_set() function to add the texture to
277 * an Evas_Canvas3DMaterial's slot.
278 */
279
280/**
281 * @defgroup Evas_Canvas3D_Material Material Object
282 * @ingroup Evas_3D
283 *
284 * The Evas_Canvas3D_Material structure defines a set of material
285 * attributes used for determining the color of mesh surfaces. Each
286 * attribute is defined by a color value and texture map. The five
287 * attributes are: ambient, diffuse, specular, emission, and normal.
288 */
289
290/**
291 * @typedef Evas_Canvas3D_Surface_Func
292 *
293 * The Evas_Canvas3D_Surface_Func type of functions are used to
294 * create parametric surfaces as primitives. These compute the
295 * vertex x,y,z values for given v,u values.
296 *
297 * @param out_x The x component of the calculated value.
298 * @param out_y The y component of the calculated value.
299 * @param out_z The z component of the calculated value.
300 * @param a is the v value.
301 * @param b is the u value.
302
303 * @see Evas_Canvas3D_Primitive
304 *
305 * @since 1.15
306 * @ingroup Evas_Canvas3D_Primitive
307 */
308typedef void (Evas_Canvas3D_Surface_Func)(Evas_Real *out_x,
309 Evas_Real *out_y,
310 Evas_Real *out_z,
311 Evas_Real a,
312 Evas_Real b);
313
314#include "canvas/evas_canvas3d_object.eo.h"
315
316#include "canvas/evas_canvas3d_texture.eo.h"
317
318#include "canvas/evas_canvas3d_material.eo.h"
319
320#include "canvas/evas_canvas3d_light.eo.h"
321
322#include "canvas/evas_canvas3d_primitive.eo.h"
323
324#include "canvas/evas_canvas3d_mesh.eo.h"
325
326#include "canvas/evas_canvas3d_node.eo.h"
327
328#include "canvas/evas_canvas3d_camera.eo.h"
329
330#include "canvas/evas_canvas3d_scene.eo.h"
331
332#include "canvas/efl_canvas_scene3d.eo.h"
333
334#include "canvas/efl_canvas_image_internal.eo.h" 122#include "canvas/efl_canvas_image_internal.eo.h"
335#include "canvas/efl_canvas_image.eo.h" 123#include "canvas/efl_canvas_image.eo.h"
336#include "canvas/efl_canvas_snapshot.eo.h" 124#include "canvas/efl_canvas_snapshot.eo.h"
diff --git a/src/lib/evas/canvas/efl_canvas_scene3d.c b/src/lib/evas/canvas/efl_canvas_scene3d.c
deleted file mode 100644
index 513a68ba94..0000000000
--- a/src/lib/evas/canvas/efl_canvas_scene3d.c
+++ /dev/null
@@ -1,310 +0,0 @@
1#include "evas_image_private.h"
2#include "efl_canvas_scene3d.eo.h"
3
4#define MY_CLASS EFL_CANVAS_SCENE3D_CLASS
5
6EOLIAN static void
7_efl_canvas_scene3d_scene3d_set(Eo *eo_obj, void *pd EINA_UNUSED, Evas_Canvas3D_Scene *scene)
8{
9 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
10 Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
11 Evas_Image_Load_Opts lo;
12 int load_error;
13
14 if (o->cur->scene == scene) return;
15
16 evas_object_async_block(obj);
17 _evas_image_init_set(NULL, NULL, eo_obj, obj, o, &lo);
18 o->engine_data = ENFN->image_mmap(ENC, o->cur->f, o->cur->key, &load_error, &lo);
19 o->load_error = _evas_load_error_to_efl_gfx_image_load_error(load_error);
20 _evas_image_done_set(eo_obj, obj, o);
21
22 if (scene) _evas_image_3d_set(eo_obj, scene);
23 else _evas_image_3d_unset(eo_obj, obj, o);
24}
25
26EOLIAN static Evas_Canvas3D_Scene *
27_efl_canvas_scene3d_scene3d_get(const Eo *eo_obj, void *pd EINA_UNUSED)
28{
29 Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
30 return o->cur->scene;
31}
32
33void
34_evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj,
35 Evas_Object_Protected_Data *obj, Evas_Image_Data *o EINA_UNUSED,
36 Evas_Canvas3D_Scene *scene, void *engine, void *output)
37{
38 Evas_Public_Data *e;
39 Eina_Bool need_native_set = EINA_FALSE;
40 Evas_Canvas3D_Scene_Public_Data scene_data;
41 Evas_Canvas3D_Scene_Data *pd_scene = NULL;
42
43 pd_scene = efl_data_scope_get(scene, EVAS_CANVAS3D_SCENE_CLASS);
44
45 if ((pd_scene->w == 0) || (pd_scene->h == 0)) return;
46 if (!pd_scene->camera_node)
47 {
48 WRN("Camera has not been set to scene(%p)", scene);
49 return;
50 }
51
52 e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
53
54 if (pd_scene->surface)
55 {
56 int w = 0;
57 int h = 0;
58
59 if (e->engine.func->drawable_size_get)
60 {
61 e->engine.func->drawable_size_get(engine,
62 pd_scene->surface, &w, &h);
63 }
64 if ((w != pd_scene->w) || (h != pd_scene->h))
65 {
66 if (e->engine.func->drawable_free)
67 {
68 e->engine.func->drawable_free(engine,
69 pd_scene->surface);
70 }
71 pd_scene->surface = NULL;
72 need_native_set = EINA_TRUE;
73 }
74 }
75 else
76 {
77 /* TODO: Hard-coded alpha on. */
78 if (e->engine.func->drawable_new)
79 {
80 pd_scene->surface =
81 e->engine.func->drawable_new(engine,
82 pd_scene->w, pd_scene->h, 1);
83 }
84 need_native_set = EINA_TRUE;
85 }
86
87 EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data,
88 data)
89 {
90 if (need_native_set)
91 {
92 if (e->engine.func->image_drawable_set)
93 {
94 data->surface =
95 e->engine.func->image_drawable_set(engine,
96 data->surface,
97 pd_scene->surface);
98 }
99 }
100 data->w = pd_scene->w;
101 data->h = pd_scene->h;
102 }
103 EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
104
105 evas_canvas3d_scene_data_init(&scene_data);
106
107 scene_data.bg_color = pd_scene->bg_color;
108 scene_data.shadows_enabled = pd_scene->shadows_enabled;
109 scene_data.camera_node = pd_scene->camera_node;
110 scene_data.depth_offset = pd_scene->depth_offset;
111 scene_data.depth_constant = pd_scene->depth_constant;
112 if (evas_object_anti_alias_get(eo_obj))
113 {
114 /*Use post processing render*/
115 scene_data.post_processing = EINA_TRUE;
116 scene_data.color_pick_enabled = EINA_FALSE;
117 scene_data.render_to_texture = EINA_TRUE;
118 scene_data.post_processing_type = EVAS_CANVAS3D_SHADER_MODE_POST_PROCESSING_FXAA;
119 }
120 /* Phase 1 - Update scene graph tree. */
121 evas_canvas3d_object_update(scene);
122
123 /* Phase 2 - Do frustum culling and get visible model nodes. */
124 evas_canvas3d_node_tree_traverse(pd_scene->root_node,
125 EVAS_CANVAS3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE,
126 evas_canvas3d_node_mesh_collect, &scene_data);
127
128 /* Phase 3 - Collect active light nodes in the scene graph tree. */
129 evas_canvas3d_node_tree_traverse(pd_scene->root_node,
130 EVAS_CANVAS3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE,
131 evas_canvas3d_node_light_collect, &scene_data);
132
133 /* Phase 5 - Draw the scene. */
134 if (e->engine.func->drawable_scene_render)
135 {
136 e->engine.func->drawable_scene_render(engine, output,
137 pd_scene->surface, &scene_data);
138 }
139 /* Clean up temporary resources. */
140 evas_canvas3d_scene_data_fini(&scene_data);
141}
142
143void
144_evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene)
145{
146 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
147 Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
148 Evas_Canvas3D_Scene_Data *pd_scene = efl_data_scope_get(scene,
149 EVAS_CANVAS3D_SCENE_CLASS);
150 EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data,
151 data)
152 {
153 data->surface = NULL;
154 data->w = 0;
155 data->h = 0;
156 efl_ref(scene);
157 }
158 EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
159
160 EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
161 {
162 state_write->scene = scene;
163 }
164 EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
165
166 pd_scene->images = eina_list_append(pd_scene->images, eo_obj);
167}
168
169void
170_evas_image_3d_unset(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj,
171 Evas_Image_Data *o)
172{
173 Evas_Public_Data *e;
174
175 if (!o->cur->scene) return;
176
177 Evas_Canvas3D_Scene_Data *pd_scene =
178 efl_data_scope_get(o->cur->scene, EVAS_CANVAS3D_SCENE_CLASS);
179
180 EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
181 {
182 pd_scene->images = eina_list_remove(pd_scene->images, eo_obj);
183 efl_unref(state_write->scene);
184 state_write->scene = NULL;
185 }
186 EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
187
188 if (o->cur->defmap)
189 {
190 EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
191 {
192 evas_map_free(state_write->defmap);
193 state_write->defmap = NULL;
194 }
195 EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
196 }
197
198 EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data,
199 data)
200 {
201 e = obj->layer->evas;
202
203 if (data->surface)
204 e->engine.func->image_free(_evas_engine_context(e), data->surface);
205
206 data->surface = NULL;
207 data->w = 0;
208 data->h = 0;
209 }
210 EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data);
211}
212
213EOLIAN static Eina_Rw_Slice
214_efl_canvas_scene3d_efl_gfx_buffer_buffer_map(Eo *eo_obj, void *_pd EINA_UNUSED,
215 Efl_Gfx_Buffer_Access_Mode mode,
216 const Eina_Rect *region,
217 Efl_Gfx_Colorspace cspace, int plane,
218 int *stride)
219{
220 Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
221 Evas_Public_Data *e;
222 Evas_Canvas3D_Object_Data *pd_parent;
223 Evas_Canvas3D_Scene_Data *pd_scene;
224 int width = -1, height = -1, ntex = -1;
225 unsigned char *pixels = NULL;
226 Eina_Rw_Slice slice = {};
227 int x, y, w, h;
228 size_t len = 0;
229
230 if (!o->cur->scene)
231 {
232 ERR("invalid scene data");
233 return slice;
234 }
235 if (mode & EFL_GFX_BUFFER_ACCESS_MODE_WRITE)
236 {
237 ERR("invalid map access mode");
238 return slice;
239 }
240 if (cspace != EFL_GFX_COLORSPACE_ARGB8888)
241 {
242 ERR("invalid map colorspace. Only ARGB is supported");
243 return slice;
244 }
245
246 pd_parent = efl_data_scope_get(o->cur->scene, EVAS_CANVAS3D_OBJECT_CLASS);
247 e = efl_data_scope_get(pd_parent->evas, EVAS_CANVAS_CLASS);
248 pd_scene = efl_data_scope_get(o->cur->scene, EVAS_CANVAS3D_SCENE_CLASS);
249
250 if (e->engine.func->drawable_size_get)
251 {
252 e->engine.func->drawable_size_get(_evas_engine_context(e),
253 pd_scene->surface, &width, &height);
254 }
255
256 if (region)
257 {
258 x = region->x;
259 y = region->y;
260 w = region->w;
261 h = region->h;
262 }
263 else
264 {
265 x = y = 0;
266 w = width;
267 h = height;
268 }
269
270 if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || ((x + w) > width) || ((y + h) > height))
271 {
272 ERR("Invalid map dimensions : %dx%d +%d,%d. Image is %dx%d.",
273 w, h, x, y, width, height);
274 return slice;
275 }
276
277 if (e->engine.func->drawable_texture_target_id_get)
278 {
279 ntex = e->engine.func->drawable_texture_target_id_get(pd_scene->surface);
280
281 if (e->engine.func->drawable_texture_rendered_pixels_get)
282 {
283 len = w * h * sizeof(DATA32); //four component texture
284 pixels = malloc(len + sizeof(slice) + 8);
285 e->engine.func->drawable_texture_rendered_pixels_get(ntex, x, y, w, h,
286 pd_scene->surface, pixels);
287 }
288 else
289 return slice;
290 }
291 else
292 return slice;
293
294 if (stride) *stride = w * sizeof(DATA32);
295 slice.mem = pixels;
296 slice.len = len;
297 DBG("map(%p, %d,%d %dx%d plane:%d) -> " EINA_SLICE_FMT,
298 eo_obj, x, y, w, h, plane, EINA_SLICE_PRINT(slice));
299
300 return slice;
301}
302EOLIAN static Eina_Bool
303_efl_canvas_scene3d_efl_gfx_buffer_buffer_unmap(Eo *eo_obj EINA_UNUSED, void *_pd EINA_UNUSED,
304 const Eina_Rw_Slice slice)
305{
306 free(slice.mem);
307 return EINA_TRUE;
308}
309
310#include "efl_canvas_scene3d.eo.c"
diff --git a/src/lib/evas/canvas/efl_canvas_scene3d.eo b/src/lib/evas/canvas/efl_canvas_scene3d.eo
deleted file mode 100644
index 8d506be64c..0000000000
--- a/src/lib/evas/canvas/efl_canvas_scene3d.eo
+++ /dev/null
@@ -1,20 +0,0 @@
1class @beta Efl.Canvas.Scene3d extends Efl.Canvas.Image_Internal
2{
3 [[A UI view for EFL Canvas 3D.]]
4 data: null;
5 methods {
6 @property scene3d {
7 [[The 3d scene to display in this view.
8 ]]
9 set {}
10 get {}
11 values {
12 scene: Evas.Canvas3D.Scene; [[3D scene.]]
13 }
14 }
15 }
16 implements {
17 Efl.Gfx.Buffer.buffer_map;
18 Efl.Gfx.Buffer.buffer_unmap;
19 }
20}
diff --git a/src/lib/evas/canvas/evas_canvas3d_camera.c b/src/lib/evas/canvas/evas_canvas3d_camera.c
deleted file mode 100644
index 97f0576431..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_camera.c
+++ /dev/null
@@ -1,203 +0,0 @@
1#include "evas_common_private.h"
2#include "evas_private.h"
3
4#define MY_CLASS EVAS_CANVAS3D_CAMERA_CLASS
5
6static Eina_Bool
7_camera_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
8 void *data EINA_UNUSED, void *fdata)
9{
10 Evas_Canvas3D_Node *n = *(Evas_Canvas3D_Node **)key;
11 evas_canvas3d_object_change(n, EVAS_CANVAS3D_STATE_NODE_CAMERA, (Evas_Canvas3D_Object *)fdata);
12 return EINA_TRUE;
13}
14
15EOLIAN static void
16_evas_canvas3d_camera_evas_canvas3d_object_change_notify(Eo *obj,Evas_Canvas3D_Camera_Data *pd, Evas_Canvas3D_State state EINA_UNUSED, Evas_Canvas3D_Object *ref EINA_UNUSED)
17{
18 if (pd->nodes) eina_hash_foreach(pd->nodes, _camera_node_change_notify, obj);
19}
20
21EOLIAN static void
22_evas_canvas3d_camera_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED,
23 Evas_Canvas3D_Camera_Data *pd EINA_UNUSED)
24{
25
26}
27
28void
29evas_canvas3d_camera_node_add(Evas_Canvas3D_Camera *camera, Evas_Canvas3D_Node *node)
30{
31 Evas_Canvas3D_Camera_Data *pd = efl_data_scope_get(camera, MY_CLASS);
32 int count = 0;
33
34 if (!pd->nodes)
35 {
36 pd->nodes = eina_hash_pointer_new(NULL);
37
38 if (!pd->nodes)
39 {
40 ERR("Failed to create hash table. camera(%p)", camera);
41 return;
42 }
43 }
44 else count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
45 eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count + 1));
46}
47
48void
49evas_canvas3d_camera_node_del(Evas_Canvas3D_Camera *camera, Evas_Canvas3D_Node *node)
50{
51 Evas_Canvas3D_Camera_Data *pd = efl_data_scope_get(camera, MY_CLASS);
52 int count = 0;
53
54 if (!pd->nodes)
55 {
56 ERR("No node to delete.");
57 return;
58 }
59
60 count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
61 if (count == 1) eina_hash_del(pd->nodes, &node, NULL);
62 else eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count - 1));
63}
64
65EOLIAN static Eo *
66_evas_canvas3d_camera_efl_object_constructor(Eo *obj,
67 Evas_Canvas3D_Camera_Data *pd EINA_UNUSED)
68{
69 obj = efl_constructor(efl_super(obj, MY_CLASS));
70 evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_CAMERA);
71
72 return obj;
73}
74
75EOLIAN static void
76_evas_canvas3d_camera_efl_object_destructor(Eo *obj,
77 Evas_Canvas3D_Camera_Data *pd)
78{
79 Eina_Iterator *it = NULL;
80 void *data = NULL;
81 Evas_Canvas3D_Node_Data *node = NULL;
82
83 if (pd->nodes)
84 {
85 it = eina_hash_iterator_key_new(pd->nodes);
86 while (eina_iterator_next(it, &data))
87 {
88 node = efl_data_scope_get(data, EVAS_CANVAS3D_NODE_CLASS);
89 node->data.camera.camera = NULL;
90 }
91
92 eina_hash_free(pd->nodes);
93 }
94
95 efl_destructor(efl_super(obj, MY_CLASS));
96}
97
98EAPI Evas_Canvas3D_Camera *
99evas_canvas3d_camera_add(Evas *e)
100{
101 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
102 return NULL;
103 MAGIC_CHECK_END();
104 return efl_add(MY_CLASS, e);
105}
106
107EOLIAN static void
108_evas_canvas3d_camera_projection_matrix_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
109 const Evas_Real *matrix)
110{
111 eina_matrix4_array_set(&pd->projection, matrix);
112 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
113}
114
115EOLIAN static void
116_evas_canvas3d_camera_projection_matrix_get(const Eo *obj EINA_UNUSED,
117 Evas_Canvas3D_Camera_Data *pd,
118 Evas_Real *matrix)
119{
120 memcpy(matrix, &pd->projection.xx, sizeof(Evas_Real) * 16);
121}
122
123EOLIAN static void
124_evas_canvas3d_camera_projection_perspective_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
125 Evas_Real fovy, Evas_Real aspect,
126 Evas_Real dnear, Evas_Real dfar)
127{
128 Evas_Real xmax;
129 Evas_Real ymax;
130
131 ymax = dnear * (Evas_Real)tan((double)fovy * M_PI / 360.0);
132 xmax = ymax * aspect;
133
134 evas_mat4_frustum_set(&pd->projection, -xmax, xmax, -ymax, ymax, dnear, dfar);
135 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
136}
137
138EOLIAN static void
139_evas_canvas3d_camera_projection_frustum_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
140 Evas_Real left, Evas_Real right,
141 Evas_Real bottom, Evas_Real top,
142 Evas_Real dnear, Evas_Real dfar)
143{
144 evas_mat4_frustum_set(&pd->projection, left, right, bottom, top, dnear, dfar);
145 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
146}
147
148EOLIAN static void
149_evas_canvas3d_camera_projection_ortho_set(Eo *obj, Evas_Canvas3D_Camera_Data *pd,
150 Evas_Real left, Evas_Real right,
151 Evas_Real bottom, Evas_Real top,
152 Evas_Real dnear, Evas_Real dfar)
153{
154 eina_matrix4_ortho_set(&pd->projection, left, right, bottom, top, dnear, dfar);
155 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_CAMERA_PROJECTION, NULL);
156}
157
158EOLIAN static Eina_Bool
159_evas_canvas3d_camera_node_visible_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Camera_Data *pd, Evas_Canvas3D_Node *camera_node, Evas_Canvas3D_Node *node, Evas_Canvas3D_Frustum_Mode key)
160{
161 Eina_Matrix4 matrix_vp;
162 Eina_Quaternion planes[6];
163 Evas_Canvas3D_Node_Data *pd_node = efl_data_scope_get(node, EVAS_CANVAS3D_NODE_CLASS);
164 Evas_Canvas3D_Node_Data *pd_camera = efl_data_scope_get(camera_node, EVAS_CANVAS3D_NODE_CLASS);
165 Eina_Vector3 central_point;
166
167 if (!node || pd_node->type != EVAS_CANVAS3D_NODE_TYPE_MESH)
168 {
169 ERR("Mesh node %p type mismatch.", node);
170 return EINA_FALSE;
171 }
172
173 if (!camera_node || pd_camera->type != EVAS_CANVAS3D_NODE_TYPE_CAMERA)
174 {
175 ERR("Camera node %p type mismatch.", camera_node);
176 return EINA_FALSE;
177 }
178
179 /*get need matrix like multiply projection matrix with view matrix*/
180 eina_matrix4_multiply(&matrix_vp, &pd->projection, &pd_camera->data.camera.matrix_world_to_eye);
181
182 evas_frustum_calculate(planes, &matrix_vp);
183
184 if (key == EVAS_CANVAS3D_FRUSTUM_MODE_BSPHERE)
185 return evas_is_sphere_in_frustum(&pd_node->bsphere, planes);
186 else if (key == EVAS_CANVAS3D_FRUSTUM_MODE_AABB)
187 return evas_is_box_in_frustum(&pd_node->aabb, planes);
188 else if (key == EVAS_CANVAS3D_FRUSTUM_MODE_CENTRAL_POINT)
189 {
190 central_point.x = (pd_node->aabb.p0.x + pd_node->aabb.p1.x) / 2;
191 central_point.y = (pd_node->aabb.p0.y + pd_node->aabb.p1.y) / 2;
192 central_point.z = (pd_node->aabb.p0.z + pd_node->aabb.p1.z) / 2;
193 return evas_is_point_in_frustum(&central_point, planes);
194 }
195 else
196 {
197 ERR("Unknown frustun mode.");
198 return EINA_TRUE;
199 }
200}
201
202#include "canvas/evas_canvas3d_camera.eo.c"
203
diff --git a/src/lib/evas/canvas/evas_canvas3d_camera.eo b/src/lib/evas/canvas/evas_canvas3d_camera.eo
deleted file mode 100644
index 9cd98007f2..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_camera.eo
+++ /dev/null
@@ -1,89 +0,0 @@
1import evas_canvas3d_types;
2
3class @beta Evas.Canvas3D.Camera extends Evas.Canvas3D.Object
4{
5 [[Evas 3D canvas camera class]]
6 data: Evas_Canvas3D_Camera_Data;
7 methods {
8 projection_matrix_set {
9 [[Set the projection matrix of the given camera.
10
11 Default projection matrix is identity matrix.
12
13 See also @.projection_perspective_set, @.projection_ortho_set and @.projection_frustum_set.]]
14 params {
15 @in matrix: ptr(const(Evas.Real)); [[Projection Matrix]]
16 }
17 }
18
19 projection_matrix_get @const {
20 [[Get the projection matrix of the given camera.
21
22 See also @.projection_matrix_set.]]
23 params {
24 @out matrix: Evas.Real; [[Projection Matrix]]
25 }
26 }
27
28 projection_perspective_set {
29 [[Set the projection matrix of the given camera with perspective projection.
30
31 See also @.projection_matrix_set.]]
32
33 params {
34 fovy: Evas.Real; [[Field of view angle in Y direction.]]
35 aspect: Evas.Real; [[Aspect ratio.]]
36 dnear: Evas.Real; [[Distance to near clipping plane.]]
37 dfar: Evas.Real; [[Distance to far clipping plane.]]
38 }
39 }
40
41 projection_frustum_set {
42 [[Set the projection matrix of the given camera with frustum projection.
43
44 See also @.projection_matrix_set.]]
45 params {
46 left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
47 right: Evas.Real; [[Right X coordinate of the near clipping plane..]]
48 bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
49 top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
50 dnear: Evas.Real; [[Distance to near clipping plane.]]
51 dfar: Evas.Real; [[Distance to far clipping plane.]]
52 }
53 }
54 projection_ortho_set {
55 [[Set the projection matrix of the given camera with orthogonal projection.
56
57 See also @.projection_matrix_set.]]
58 params {
59 left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
60 right: Evas.Real; [[Right X coordinate of the near clipping plane..]]
61 bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
62 top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
63 dnear: Evas.Real; [[Distance to near clipping plane.]]
64 dfar: Evas.Real; [[Distance to far clipping plane.]]
65 }
66 }
67 node_visible_get {
68 [[Check is bounding sphere of given node inside frustum of camera node.
69
70 If the nodes are $null or nodes type mismatch error wrong type of nodes will be generated and returned $false.]]
71 return: bool; [[$true in frustum, $false otherwise]]
72 params {
73 @in camera_node: Evas.Canvas3D.Node; [[The given camera node.]]
74 @in node: Evas.Canvas3D.Node; [[The given node.]]
75 @in key: Evas.Canvas3D.Frustum_Mode; [[The given key]]
76 }
77 }
78 }
79
80 implements {
81 Efl.Object.constructor;
82 Efl.Object.destructor;
83 Evas.Canvas3D.Object.update_notify;
84 Evas.Canvas3D.Object.change_notify;
85 @empty Evas.Canvas3D.Object.callback_register;
86 @empty Evas.Canvas3D.Object.callback_unregister;
87 }
88
89}
diff --git a/src/lib/evas/canvas/evas_canvas3d_eet.c b/src/lib/evas/canvas/evas_canvas3d_eet.c
deleted file mode 100644
index ca24450626..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_eet.c
+++ /dev/null
@@ -1,211 +0,0 @@
1#include "evas_common_private.h"
2#include "evas_private.h"
3
4static Eet_Data_Descriptor *_vec2_descriptor = NULL;
5static Eet_Data_Descriptor *_vec3_descriptor = NULL;
6static Eet_Data_Descriptor *_vertex_descriptor = NULL;
7static Eet_Data_Descriptor *_geometry_descriptor = NULL;
8static Eet_Data_Descriptor *_color_descriptor = NULL;
9static Eet_Data_Descriptor *_material_descriptor = NULL;
10static Eet_Data_Descriptor *_frame_descriptor = NULL;
11static Eet_Data_Descriptor *_mesh_descriptor = NULL;
12static Eet_Data_Descriptor *_header_descriptor = NULL;
13static Eet_Data_Descriptor *_file_descriptor = NULL;
14
15Evas_Canvas3D_File_Eet *
16_evas_canvas3d_eet_file_new(void)
17{
18 Evas_Canvas3D_File_Eet *creating_file = calloc(1, sizeof(Evas_Canvas3D_File_Eet));
19
20 if (!creating_file)
21 {
22 ERR("Could not calloc Evas_Canvas3D_File_Eet");
23 return NULL;
24 }
25
26 return creating_file;
27}
28
29Eet_Data_Descriptor*
30_evas_canvas3d_eet_file_get(void)
31{
32 if(_file_descriptor == NULL)
33 _evas_canvas3d_eet_file_init();
34
35 return _file_descriptor;
36}
37void
38_evas_canvas3d_eet_file_init(void)
39{
40/* initialization of bonding between structure units in eet file */
41 Eet_Data_Descriptor_Class eddc;
42 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Vec2_Eet);
43 _vec2_descriptor = eet_data_descriptor_file_new(&eddc);
44 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Vec3_Eet);
45 _vec3_descriptor = eet_data_descriptor_file_new(&eddc);
46 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Vertex_Eet);
47 _vertex_descriptor = eet_data_descriptor_file_new(&eddc);
48 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Geometry_Eet);
49 _geometry_descriptor = eet_data_descriptor_file_new(&eddc);
50 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Color_Eet);
51 _color_descriptor = eet_data_descriptor_file_new(&eddc);
52 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Frame_Eet);
53 _frame_descriptor = eet_data_descriptor_file_new(&eddc);
54 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Material_Eet);
55 _material_descriptor = eet_data_descriptor_file_new(&eddc);
56 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Mesh_Eet);
57 _mesh_descriptor = eet_data_descriptor_file_new(&eddc);
58 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_Header_Eet);
59 _header_descriptor = eet_data_descriptor_file_new(&eddc);
60 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_Canvas3D_File_Eet);
61 _file_descriptor = eet_data_descriptor_file_new(&eddc);
62
63/* Vec_2 */
64#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
65 (_vec2_descriptor, Evas_Canvas3D_Vec3_Eet, # member, member, eet_type);
66 ADD_BASIC(x, EET_T_FLOAT);
67 ADD_BASIC(y, EET_T_FLOAT);
68#undef ADD_BASIC
69
70/* Vec_3 */
71#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
72 (_vec3_descriptor, Evas_Canvas3D_Vec3_Eet, # member, member, eet_type);
73 ADD_BASIC(x, EET_T_FLOAT);
74 ADD_BASIC(y, EET_T_FLOAT);
75 ADD_BASIC(z, EET_T_FLOAT);
76#undef ADD_BASIC
77
78/* Vertex */
79 EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_Canvas3D_Vertex_Eet,
80 "position", position, _vec3_descriptor);
81 EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_Canvas3D_Vertex_Eet,
82 "normal", normal, _vec3_descriptor);
83 EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_Canvas3D_Vertex_Eet,
84 "texcoord", texcoord, _vec2_descriptor);
85
86/* Geometry */
87 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_geometry_descriptor, Evas_Canvas3D_Geometry_Eet,
88 "vertices", vertices, _vertex_descriptor);
89#define ADD_BASIC(member, eet_type) \
90 EET_DATA_DESCRIPTOR_ADD_BASIC \
91 (_geometry_descriptor, Evas_Canvas3D_Geometry_Eet, # member, member, eet_type);
92 ADD_BASIC(vertices_count, EET_T_UINT);
93 ADD_BASIC(id, EET_T_UINT);
94#undef ADD_BASIC
95
96/* Color */
97#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
98 (_color_descriptor, Evas_Canvas3D_Color_Eet, # member, member, eet_type);
99 ADD_BASIC(r, EET_T_FLOAT);
100 ADD_BASIC(g, EET_T_FLOAT);
101 ADD_BASIC(b, EET_T_FLOAT);
102 ADD_BASIC(a, EET_T_FLOAT);
103#undef ADD_BASIC
104
105/* Material */
106 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_material_descriptor, Evas_Canvas3D_Material_Eet,
107 "colors", colors, _color_descriptor);
108#define ADD_BASIC(member, eet_type) \
109 EET_DATA_DESCRIPTOR_ADD_BASIC \
110 (_material_descriptor, Evas_Canvas3D_Material_Eet, # member, member, eet_type);
111 ADD_BASIC(id, EET_T_UINT);
112 ADD_BASIC(colors_count, EET_T_UINT);
113 ADD_BASIC(shininess, EET_T_FLOAT);
114#undef ADD_BASIC
115
116/* Frame */
117#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
118 (_frame_descriptor, Evas_Canvas3D_Frame_Eet, # member, member, eet_type);
119 ADD_BASIC(id, EET_T_UINT);
120 ADD_BASIC(geometry_id, EET_T_UINT);
121 ADD_BASIC(material_id, EET_T_UINT);
122#undef ADD_BASIC
123
124/* Mesh */
125 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_Canvas3D_Mesh_Eet,
126 "frames", frames, _frame_descriptor);
127 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_Canvas3D_Mesh_Eet,
128 "geometries", geometries, _geometry_descriptor);
129 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_Canvas3D_Mesh_Eet,
130 "materials", materials, _material_descriptor);
131#define ADD_BASIC(member, eet_type) \
132 EET_DATA_DESCRIPTOR_ADD_BASIC \
133 (_mesh_descriptor, Evas_Canvas3D_Mesh_Eet, # member, member, eet_type);
134 ADD_BASIC(materials_count, EET_T_UINT);
135 ADD_BASIC(frames_count, EET_T_UINT);
136 ADD_BASIC(geometries_count, EET_T_UINT);
137#undef ADD_BASIC
138
139/* Header */
140 EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(_header_descriptor, Evas_Canvas3D_Header_Eet,
141 "materials", materials, EET_T_UINT);
142 EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(_header_descriptor, Evas_Canvas3D_Header_Eet,
143 "geometries", geometries, EET_T_UINT);
144#define ADD_BASIC(member, eet_type) \
145 EET_DATA_DESCRIPTOR_ADD_BASIC \
146 (_header_descriptor, Evas_Canvas3D_Header_Eet, # member, member, eet_type);
147 ADD_BASIC(version, EET_T_UINT);
148 ADD_BASIC(materials_count, EET_T_UINT);
149 ADD_BASIC(frames, EET_T_UINT);
150 ADD_BASIC(geometries_count, EET_T_UINT);
151#undef ADD_BASIC
152
153/* File */
154 EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_Canvas3D_File_Eet,
155 "mesh", mesh, _mesh_descriptor);
156 EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_Canvas3D_File_Eet,
157 "header", header, _header_descriptor);
158}
159
160void
161_evas_canvas3d_eet_descriptor_shutdown(void)
162{
163 eet_data_descriptor_free(_geometry_descriptor);
164 _geometry_descriptor = NULL;
165 eet_data_descriptor_free(_vertex_descriptor);
166 _vertex_descriptor = NULL;
167 eet_data_descriptor_free(_vec2_descriptor);
168 _vec2_descriptor = NULL;
169 eet_data_descriptor_free(_vec3_descriptor);
170 _vec3_descriptor = NULL;
171 eet_data_descriptor_free(_color_descriptor);
172 _color_descriptor = NULL;
173 eet_data_descriptor_free(_material_descriptor);
174 _material_descriptor = NULL;
175 eet_data_descriptor_free(_frame_descriptor);
176 _frame_descriptor = NULL;
177 eet_data_descriptor_free(_mesh_descriptor);
178 _mesh_descriptor = NULL;
179 eet_data_descriptor_free(_header_descriptor);
180 _header_descriptor = NULL;
181 eet_data_descriptor_free(_file_descriptor);
182 _file_descriptor = NULL;
183}
184
185void
186_evas_canvas3d_eet_file_free(Evas_Canvas3D_File_Eet* eet_file)
187{
188 if (eet_file)
189 {
190 if (eet_file->mesh)
191 {
192 free(eet_file->mesh->geometries[0].vertices);
193 free(eet_file->mesh->geometries);
194 free(eet_file->mesh->frames);
195 free(eet_file->mesh->materials[0].colors);
196 free(eet_file->mesh->materials);
197 free(eet_file->mesh);
198 }
199
200 if (eet_file->header)
201 {
202 free(eet_file->header->materials);
203 free(eet_file->header->geometries);
204 free(eet_file->header);
205 }
206
207 free(eet_file);
208 }
209
210 _evas_canvas3d_eet_descriptor_shutdown();
211}
diff --git a/src/lib/evas/canvas/evas_canvas3d_light.c b/src/lib/evas/canvas/evas_canvas3d_light.c
deleted file mode 100644
index 887f3abb6c..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_light.c
+++ /dev/null
@@ -1,309 +0,0 @@
1#include "evas_common_private.h"
2#include "evas_private.h"
3
4#define MY_CLASS EVAS_CANVAS3D_LIGHT_CLASS
5
6static Eina_Bool
7_light_node_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
8 void *data EINA_UNUSED, void *fdata)
9{
10 Evas_Canvas3D_Node *n = *(Evas_Canvas3D_Node **)key;
11 evas_canvas3d_object_change(n, EVAS_CANVAS3D_STATE_NODE_LIGHT, (Evas_Canvas3D_Object *)fdata);
12 return EINA_TRUE;
13}
14
15EOLIAN static void
16_evas_canvas3d_light_evas_canvas3d_object_change_notify(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Canvas3D_State state EINA_UNUSED, Evas_Canvas3D_Object *ref EINA_UNUSED)
17{
18 if (pd->nodes)
19 eina_hash_foreach(pd->nodes, _light_node_change_notify, obj);
20}
21
22EOLIAN static void
23_evas_canvas3d_light_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd EINA_UNUSED)
24{
25
26}
27
28void
29evas_canvas3d_light_node_add(Evas_Canvas3D_Light *light, Evas_Canvas3D_Node *node)
30{
31 int count = 0;
32 Evas_Canvas3D_Light_Data *pd = efl_data_scope_get(light, MY_CLASS);
33 if (pd->nodes == NULL)
34 {
35 pd->nodes = eina_hash_pointer_new(NULL);
36
37 if (pd->nodes == NULL)
38 {
39 ERR("Failed to create hash table.");
40 return;
41 }
42 }
43 else
44 count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
45
46 eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count + 1));
47}
48
49void
50evas_canvas3d_light_node_del(Evas_Canvas3D_Light *light, Evas_Canvas3D_Node *node)
51{
52 int count = 0;
53 Evas_Canvas3D_Light_Data *pd = efl_data_scope_get(light, MY_CLASS);
54 if (pd->nodes == NULL)
55 {
56 ERR("No node to delete.");
57 return;
58 }
59
60 count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
61
62 if (count == 1)
63 eina_hash_del(pd->nodes, &node, NULL);
64 else
65 eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count - 1));
66}
67
68
69EAPI Evas_Canvas3D_Light *
70evas_canvas3d_light_add(Evas *e)
71{
72 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
73 return NULL;
74 MAGIC_CHECK_END();
75 return efl_add(MY_CLASS, e);
76}
77
78EOLIAN static Eo *
79_evas_canvas3d_light_efl_object_constructor(Eo *obj, Evas_Canvas3D_Light_Data *pd)
80{
81 obj = efl_constructor(efl_super(obj, MY_CLASS));
82 evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_LIGHT);
83 evas_color_set(&pd->ambient, 0.0, 0.0, 0.0, 1.0);
84 evas_color_set(&pd->diffuse, 1.0, 1.0, 1.0, 1.0);
85 evas_color_set(&pd->specular, 1.0, 1.0, 1.0, 1.0);
86
87 pd->spot_exp = 0.0;
88 pd->spot_cutoff = 180.0;
89 pd->spot_cutoff_cos = -1.0;
90
91 pd->atten_const = 1.0;
92 pd->atten_linear = 0.0;
93 pd->atten_quad = 0.0;
94
95 return obj;
96}
97
98EOLIAN static void
99_evas_canvas3d_light_efl_object_destructor(Eo *obj, Evas_Canvas3D_Light_Data *pd)
100{
101 Eina_Iterator *it = NULL;
102 void *data = NULL;
103 Evas_Canvas3D_Node_Data *node = NULL;
104
105 if (pd->nodes)
106 {
107 it = eina_hash_iterator_key_new(pd->nodes);
108 while (eina_iterator_next(it, &data))
109 {
110 node = efl_data_scope_get(data, EVAS_CANVAS3D_NODE_CLASS);
111 node->data.light.light = NULL;
112 }
113
114 eina_hash_free(pd->nodes);
115 }
116
117 efl_destructor(efl_super(obj, MY_CLASS));
118}
119
120
121EOLIAN static void
122_evas_canvas3d_light_directional_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Eina_Bool directional)
123{
124 if (pd->directional != directional)
125 {
126 pd->directional = directional;
127 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_ANY, NULL);
128 }
129}
130
131EOLIAN static Eina_Bool
132_evas_canvas3d_light_directional_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
133{
134 return pd->directional;
135}
136
137EOLIAN static void
138_evas_canvas3d_light_ambient_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
139{
140 pd->ambient.r = r;
141 pd->ambient.g = g;
142 pd->ambient.b = b;
143 pd->ambient.a = a;
144
145 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_AMBIENT, NULL);
146}
147
148EOLIAN static void
149_evas_canvas3d_light_ambient_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
150{
151 if (r) *r = pd->ambient.r;
152 if (g) *g = pd->ambient.g;
153 if (b) *b = pd->ambient.b;
154 if (a) *a = pd->ambient.a;
155}
156
157EOLIAN static void
158_evas_canvas3d_light_diffuse_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
159{
160 pd->diffuse.r = r;
161 pd->diffuse.g = g;
162 pd->diffuse.b = b;
163 pd->diffuse.a = a;
164
165 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_DIFFUSE, NULL);
166}
167
168EOLIAN static void
169_evas_canvas3d_light_diffuse_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
170{
171 if (r) *r = pd->diffuse.r;
172 if (g) *g = pd->diffuse.g;
173 if (b) *b = pd->diffuse.b;
174 if (a) *a = pd->diffuse.a;
175}
176
177EOLIAN static void
178_evas_canvas3d_light_specular_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
179{
180 pd->specular.r = r;
181 pd->specular.g = g;
182 pd->specular.b = b;
183 pd->specular.a = a;
184
185 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_SPECULAR, NULL);
186}
187
188EOLIAN static void
189_evas_canvas3d_light_specular_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
190{
191 if (r) *r = pd->specular.r;
192 if (g) *g = pd->specular.g;
193 if (b) *b = pd->specular.b;
194 if (a) *a = pd->specular.a;
195}
196
197EOLIAN static void
198_evas_canvas3d_light_spot_exponent_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real exponent)
199{
200 pd->spot_exp = exponent;
201 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_SPOT_EXP, NULL);
202}
203
204EOLIAN static Evas_Real
205_evas_canvas3d_light_spot_exponent_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
206{
207 return pd->spot_exp;
208}
209
210EOLIAN static void
211_evas_canvas3d_light_spot_cutoff_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real cutoff)
212{
213 pd->spot_cutoff = cutoff;
214 pd->spot_cutoff_cos = cos(cutoff * M_PI / 180.0);
215 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_SPOT_CUTOFF, NULL);
216}
217
218EOLIAN static Evas_Real
219_evas_canvas3d_light_spot_cutoff_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
220{
221 return pd->spot_cutoff;
222}
223
224EOLIAN static void
225_evas_canvas3d_light_attenuation_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Evas_Real constant, Evas_Real linear, Evas_Real quadratic)
226{
227 pd->atten_const = constant;
228 pd->atten_linear = linear;
229 pd->atten_quad = quadratic;
230 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_ATTENUATION, NULL);
231}
232
233EOLIAN static void
234_evas_canvas3d_light_attenuation_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd, Evas_Real *constant, Evas_Real *linear, Evas_Real *quadratic)
235{
236 if (constant) *constant = pd->atten_const;
237 if (linear) *linear = pd->atten_linear;
238 if (quadratic) *quadratic = pd->atten_quad;
239}
240
241EOLIAN static void
242_evas_canvas3d_light_attenuation_enable_set(Eo *obj, Evas_Canvas3D_Light_Data *pd, Eina_Bool enable)
243{
244 if (pd->enable_attenuation != enable)
245 {
246 pd->enable_attenuation = enable;
247 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_ATTENUATION, NULL);
248 }
249}
250
251EOLIAN static Eina_Bool
252_evas_canvas3d_light_attenuation_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Light_Data *pd)
253{
254 return pd->enable_attenuation;
255}
256
257EOLIAN static void
258_evas_canvas3d_light_projection_matrix_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
259 const Evas_Real *matrix)
260{
261 eina_matrix4_array_set(&pd->projection, matrix);
262 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
263}
264
265EOLIAN static void
266_evas_canvas3d_light_projection_matrix_get(const Eo *obj EINA_UNUSED,
267 Evas_Canvas3D_Light_Data *pd,
268 Evas_Real *matrix)
269{
270 memcpy(matrix, &pd->projection.xx, sizeof(Evas_Real) * 16);
271}
272
273EOLIAN static void
274_evas_canvas3d_light_projection_perspective_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
275 Evas_Real fovy, Evas_Real aspect,
276 Evas_Real dnear, Evas_Real dfar)
277{
278 Evas_Real xmax;
279 Evas_Real ymax;
280
281 ymax = dnear * (Evas_Real)tan((double)fovy * M_PI / 360.0);
282 xmax = ymax * aspect;
283
284 evas_mat4_frustum_set(&pd->projection, -xmax, xmax, -ymax, ymax, dnear, dfar);
285 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
286}
287
288EOLIAN static void
289_evas_canvas3d_light_projection_frustum_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
290 Evas_Real left, Evas_Real right,
291 Evas_Real bottom, Evas_Real top,
292 Evas_Real dnear, Evas_Real dfar)
293{
294 evas_mat4_frustum_set(&pd->projection, left, right, bottom, top, dnear, dfar);
295 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
296}
297
298EOLIAN static void
299_evas_canvas3d_light_projection_ortho_set(Eo *obj, Evas_Canvas3D_Light_Data *pd,
300 Evas_Real left, Evas_Real right,
301 Evas_Real bottom, Evas_Real top,
302 Evas_Real dnear, Evas_Real dfar)
303{
304 eina_matrix4_ortho_set(&pd->projection, left, right, bottom, top, dnear, dfar);
305 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_LIGHT_PROJECTION, NULL);
306}
307
308
309#include "canvas/evas_canvas3d_light.eo.c"
diff --git a/src/lib/evas/canvas/evas_canvas3d_light.eo b/src/lib/evas/canvas/evas_canvas3d_light.eo
deleted file mode 100644
index f15a088f17..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_light.eo
+++ /dev/null
@@ -1,249 +0,0 @@
1import evas_canvas3d_types;
2
3class @beta Evas.Canvas3D.Light extends Evas.Canvas3D.Object
4{
5 [[Evas 3D canvas light class]]
6
7 data: Evas_Canvas3D_Light_Data;
8
9 methods {
10 @property directional {
11 [[The directional flag of the given light.
12
13 Directional light is a type of light which is infinitely far away with no
14 attenuation. The light direction is determined by the containing node's
15 forward vector (negative Z-axis).
16
17 By default, directional is not enabled.
18
19 \@ref evas_canvas3d_node_look_at_set]]
20 set {
21 }
22 get {
23 }
24 values {
25 directional: bool; [[Whether the light is directional ($true), or not ($false).]]
26 }
27 }
28
29 @property spot_exponent {
30 [[The spot exponent of the given light.
31
32 Higher spot exponent means intensity at the center of the cone is relatively
33 stronger. Zero exponent means the light intensity is evenly distributed. The
34 spot exponent has no effect when the light is not spot light (spot cutoff
35 angle is less than 180 degree).
36
37 Default spot exponent is 0.
38
39 See also @.spot_cutoff.set]]
40 set {
41 }
42 get {
43 }
44 values {
45 exponent: Evas.Real; [[Spot exponent value.]]
46 }
47 }
48
49 @property spot_cutoff {
50 [[The spot cutoff angle of the given light.
51
52 Only angle less than 180 degree will make it spot light, so that other spot
53 light attribute will take effect.
54
55 Default spot cutoff angle is 180.]]
56 set {
57 }
58 get {
59 }
60 values {
61 cutoff: Evas.Real; [[Cutoff angle in degree..]]
62 }
63 }
64
65 @property attenuation_enable {
66 [[The attenuation enable flag of the given light.
67
68 By default, light attenuation is not enabled.
69
70 See also @.attenuation_set]]
71 set {
72 }
73 get {
74 }
75 values {
76 enable: bool; [[Whether to enable attenuation ($true), or not ($false)..]]
77 }
78 }
79
80 ambient_set {
81 [[Set the ambient color of the given light.
82
83 Default ambient color is (0.0, 0.0, 0.0, 1.0).]]
84 params {
85 @in r: Evas.Real; [[Red component of the ambient color between [0.0, 1.0].]]
86 @in g: Evas.Real; [[Green component of the ambient color between [0.0, 1.0].]]
87 @in b: Evas.Real; [[Blue component of the ambient color between [0.0, 1.0].]]
88 @in a: Evas.Real; [[Alpha component of the ambient color between [0.0, 1.0].]]
89 }
90 }
91 ambient_get @const {
92 [[Get the ambient color of the given light.
93
94 See also @.ambient_set]]
95 params {
96 @out r: Evas.Real; [[Red component of the ambient color between [0.0, 1.0].]]
97 @out g: Evas.Real; [[Green component of the ambient color between [0.0, 1.0].]]
98 @out b: Evas.Real; [[Blue component of the ambient color between [0.0, 1.0].]]
99 @out a: Evas.Real; [[Alpha component of the ambient color between [0.0, 1.0].]]
100 }
101 }
102
103 diffuse_set {
104 [[Set the diffuse color of the given light.
105
106 Default diffuse color is (1.0, 1.0, 1.0, 1.0).]]
107 params {
108 @in r: Evas.Real; [[Red component of the diffuse color between [0.0, 1.0].]]
109 @in g: Evas.Real; [[Green component of the diffuse color between [0.0, 1.0].]]
110 @in b: Evas.Real; [[Blue component of the diffuse color between [0.0, 1.0].]]
111 @in a: Evas.Real; [[Alpha component of the diffuse color between [0.0, 1.0].]]
112 }
113 }
114 diffuse_get @const {
115 [[Get the diffuse color of the given light.
116
117 See also @.diffuse_set]]
118 params {
119 @out r: Evas.Real; [[Red component of the diffuse color between [0.0, 1.0].]]
120 @out g: Evas.Real; [[Green component of the diffuse color between [0.0, 1.0].]]
121 @out b: Evas.Real; [[Blue component of the diffuse color between [0.0, 1.0].]]
122 @out a: Evas.Real; [[Alpha component of the diffuse color between [0.0, 1.0].]]
123 }
124 }
125
126 specular_set {
127 [[Set the specular color of the given light.
128
129 Default specular color is (1.0, 1.0, 1.0, 1.0).]]
130 params {
131 @in r: Evas.Real; [[Red component of the specular color between [0.0, 1.0].]]
132 @in g: Evas.Real; [[Green component of the specular color between [0.0, 1.0].]]
133 @in b: Evas.Real; [[Blue component of the specular color between [0.0, 1.0].]]
134 @in a: Evas.Real; [[Alpha component of the specular color between [0.0, 1.0].]]
135 }
136 }
137 specular_get @const {
138 [[Get the specular color of the given light.
139
140 See also @.specular_set]]
141 params {
142 @out r: Evas.Real; [[Red component of the specular color between [0.0, 1.0].]]
143 @out g: Evas.Real; [[Green component of the specular color between [0.0, 1.0].]]
144 @out b: Evas.Real; [[Blue component of the specular color between [0.0, 1.0].]]
145 @out a: Evas.Real; [[Alpha component of the specular color between [0.0, 1.0].]]
146 }
147 }
148
149 attenuation_set {
150 [[Set the attenuation of the given light.
151
152 Light attenuation has no effect with directional light. And the attenuation
153 should be enabled first to take effect. The attenuation factor is calculated
154 as follows.
155
156 atten = 1.0 / constant + linear * distance + quadratic * distance * distance
157
158 Default attenuation is constant = 1.0, linear = 0.0, quadratic = 0.0.
159
160 See also @.attenuation_enable.set]]
161 params {
162 @in constant: Evas.Real; [[Constant attenuation term..]]
163 @in linear: Evas.Real; [[Linear attenuation term..]]
164 @in quadratic: Evas.Real; [[Quadratic attenuation term..]]
165 }
166 }
167
168 attenuation_get @const {
169 [[Get the attenuation of the given light.
170
171 See also @.attenuation_set]]
172 params {
173 @out constant: Evas.Real; [[Constant attenuation term..]]
174 @out linear: Evas.Real; [[Linear attenuation term..]]
175 @out quadratic: Evas.Real; [[Quadratic attenuation term..]]
176 }
177 }
178
179 projection_matrix_set {
180 [[Set the projection matrix of the given light source.
181
182 Default projection matrix is identity matrix.
183
184 See also @.projection_perspective_set, @.projection_ortho_set and @.projection_frustum_set]]
185 params {
186 @in matrix: ptr(const(Evas.Real)); [[Projection Matrix. Pointer to the array of 16 Evas.Real values in column major order.]]
187 }
188 }
189
190 projection_matrix_get @const {
191 [[Get the projection matrix of the given light source.
192
193 See also @.projection_matrix_set]]
194 params {
195 @out matrix: Evas.Real; [[Projection Matrix]]
196 }
197 }
198
199 projection_perspective_set {
200 [[Set the projection matrix of the given light source with perspective projection.
201
202 See also @.projection_matrix_set]]
203
204 params {
205 fovy: Evas.Real; [[Field of view angle in Y direction.]]
206 aspect: Evas.Real; [[Aspect ratio.]]
207 dnear: Evas.Real; [[Distance to near clipping plane.]]
208 dfar: Evas.Real; [[Distance to far clipping plane.]]
209 }
210 }
211
212 projection_frustum_set {
213 [[Set the projection matrix of the given light source with frustum projection.
214
215 @Evas.Canvas3D.Light.projection_matrix_set]]
216 params {
217 left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
218 right: Evas.Real; [[Right X coordinate of the near clipping plane.]]
219 bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
220 top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
221 dnear: Evas.Real; [[Distance to near clipping plane.]]
222 dfar: Evas.Real; [[Distance to far clipping plane.]]
223 }
224 }
225 projection_ortho_set {
226 [[Set the projection matrix of the given light source with orthogonal projection.
227
228 See also @.projection_matrix_set]]
229 params {
230 left: Evas.Real; [[Left X coordinate of the near clipping plane.]]
231 right: Evas.Real; [[Right X coordinate of the near clipping plane.]]
232 bottom: Evas.Real; [[Bottom Y coordinate of the near clipping plane.]]
233 top: Evas.Real; [[Top Y coordinate of the near clipping plane]]
234 dnear: Evas.Real; [[Distance to near clipping plane.]]
235 dfar: Evas.Real; [[Distance to far clipping plane.]]
236 }
237 }
238 }
239
240 implements {
241 Efl.Object.constructor;
242 Efl.Object.destructor;
243 Evas.Canvas3D.Object.update_notify;
244 Evas.Canvas3D.Object.change_notify;
245 @empty Evas.Canvas3D.Object.callback_register;
246 @empty Evas.Canvas3D.Object.callback_unregister;
247 }
248
249}
diff --git a/src/lib/evas/canvas/evas_canvas3d_material.c b/src/lib/evas/canvas/evas_canvas3d_material.c
deleted file mode 100644
index 48f6ce1e5a..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_material.c
+++ /dev/null
@@ -1,206 +0,0 @@
1#include "evas_common_private.h"
2#include "evas_private.h"
3
4#define MY_CLASS EVAS_CANVAS3D_MATERIAL_CLASS
5
6static Eina_Bool
7_material_mesh_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
8 void *data EINA_UNUSED, void *fdata)
9{
10 Evas_Canvas3D_Mesh *m = *(Evas_Canvas3D_Mesh **)key;
11 evas_canvas3d_object_change(m, EVAS_CANVAS3D_STATE_MESH_MATERIAL, (Evas_Canvas3D_Object *)fdata);
12 return EINA_TRUE;
13}
14
15EOLIAN static void
16_evas_canvas3d_material_evas_canvas3d_object_change_notify(Eo *obj, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_State state EINA_UNUSED, Evas_Canvas3D_Object *ref EINA_UNUSED)
17{
18 if (pd->meshes)
19 eina_hash_foreach(pd->meshes, _material_mesh_change_notify, obj);
20}
21
22EOLIAN static void
23_evas_canvas3d_material_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd)
24{
25 int i;
26 for (i = 0; i < EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT; i++)
27 {
28 if (pd->attribs[i].enable)
29 {
30 if (pd->attribs[i].texture)
31 {
32 evas_canvas3d_object_update(pd->attribs[i].texture);
33 }
34 }
35 }
36}
37
38void
39evas_canvas3d_material_mesh_add(Evas_Canvas3D_Material *material, Evas_Canvas3D_Mesh *mesh)
40{
41 int count = 0;
42 Evas_Canvas3D_Material_Data *pd = efl_data_scope_get(material, MY_CLASS);
43
44 if (pd->meshes == NULL)
45 {
46 pd->meshes = eina_hash_pointer_new(NULL);
47
48 if (pd->meshes == NULL)
49 {
50 ERR("Failed to create hash table.");
51 return;
52 }
53 }
54 else
55 count = (int)(uintptr_t)eina_hash_find(pd->meshes, &mesh);
56
57 eina_hash_set(pd->meshes, &mesh, (const void *)(uintptr_t)(count + 1));
58}
59
60void
61evas_canvas3d_material_mesh_del(Evas_Canvas3D_Material *material, Evas_Canvas3D_Mesh *mesh)
62{
63 int count = 0;
64 Evas_Canvas3D_Material_Data *pd = efl_data_scope_get(material, MY_CLASS);
65
66 if (pd->meshes == NULL)
67 {
68 ERR("No mesh to delete.");
69 return;
70 }
71
72 count = (int)(uintptr_t)eina_hash_find(pd->meshes, &mesh);
73
74 if (count == 1)
75 eina_hash_del(pd->meshes, &mesh, NULL);
76 else
77 eina_hash_set(pd->meshes, &mesh, (const void *)(uintptr_t)(count - 1));
78}
79
80
81EAPI Evas_Canvas3D_Material *
82evas_canvas3d_material_add(Evas *e)
83{
84 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
85 return NULL;
86 MAGIC_CHECK_END();
87 return efl_add(MY_CLASS, e);
88}
89
90EOLIAN static Eo *
91_evas_canvas3d_material_efl_object_constructor(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd)
92{
93 obj = efl_constructor(efl_super(obj, MY_CLASS));
94 evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_MATERIAL);
95
96 evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT].color, 0.2, 0.2, 0.2, 1.0);
97 evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE].color, 0.8, 0.8, 0.8, 1.0);
98 evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR].color, 1.0, 1.0, 1.0, 1.0);
99 evas_color_set(&pd->attribs[EVAS_CANVAS3D_MATERIAL_ATTRIB_EMISSION].color, 0.0, 0.0, 0.0, 1.0);
100 pd->shininess = 150.0;
101
102 return obj;
103}
104
105EOLIAN static void
106_evas_canvas3d_material_efl_object_destructor(Eo *obj, Evas_Canvas3D_Material_Data *pd)
107{
108 int i = 0;
109 Eina_Iterator *it = NULL;
110 void *data = NULL;
111 Evas_Canvas3D_Mesh_Data *mesh = NULL;
112 Eina_List *l = NULL;
113 Evas_Canvas3D_Mesh_Frame *f = NULL;
114
115 if (pd->meshes)
116 {
117 it = eina_hash_iterator_key_new(pd->meshes);
118 while (eina_iterator_next(it, &data))
119 {
120 mesh = efl_data_scope_get(data, EVAS_CANVAS3D_MESH_CLASS);
121 if (mesh->frames)
122 {
123 EINA_LIST_FOREACH(mesh->frames, l, f)
124 f->material = NULL;
125 }
126 }
127 eina_iterator_free(it);
128 eina_hash_free(pd->meshes);
129 }
130
131 for (i = 0; i < EVAS_CANVAS3D_MATERIAL_ATTRIB_COUNT; i++)
132 {
133 if (pd->attribs[i].texture)
134 {
135 evas_canvas3d_texture_material_del(pd->attribs[i].texture, obj);
136 }
137 }
138 efl_destructor(efl_super(obj, MY_CLASS));
139}
140
141EOLIAN static void
142_evas_canvas3d_material_enable_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Eina_Bool enable)
143{
144 pd->attribs[attrib].enable = enable;
145}
146
147EOLIAN static Eina_Bool
148_evas_canvas3d_material_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib)
149{
150 return pd->attribs[attrib].enable;
151}
152
153EOLIAN static void
154_evas_canvas3d_material_color_set(Eo *obj, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
155{
156 evas_color_set(&pd->attribs[attrib].color, r, g, b, a);
157 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MATERIAL_COLOR, NULL);
158}
159
160EOLIAN static void
161_evas_canvas3d_material_color_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
162{
163 if (r) *r = pd->attribs[attrib].color.r;
164 if (g) *g = pd->attribs[attrib].color.g;
165 if (b) *b = pd->attribs[attrib].color.b;
166 if (a) *a = pd->attribs[attrib].color.a;
167}
168
169EOLIAN static void
170_evas_canvas3d_material_shininess_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Real shininess)
171{
172 pd->shininess = shininess;
173}
174
175EOLIAN static Evas_Real
176_evas_canvas3d_material_shininess_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd)
177{
178 return pd->shininess;
179}
180
181EOLIAN static void
182_evas_canvas3d_material_texture_set(Eo *obj, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib, Evas_Canvas3D_Texture *texture)
183{
184 if (pd->attribs[attrib].texture != texture)
185 {
186 if (pd->attribs[attrib].texture)
187 {
188 evas_canvas3d_texture_material_del(pd->attribs[attrib].texture, obj);
189 efl_unref(pd->attribs[attrib].texture);
190 }
191
192 pd->attribs[attrib].texture = texture;
193 evas_canvas3d_texture_material_add(texture, obj);
194 efl_ref(texture);
195 }
196
197 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MATERIAL_TEXTURE, NULL);
198}
199
200EOLIAN static Evas_Canvas3D_Texture *
201_evas_canvas3d_material_texture_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Material_Data *pd, Evas_Canvas3D_Material_Attrib attrib)
202{
203 return pd->attribs[attrib].texture;
204}
205
206#include "canvas/evas_canvas3d_material.eo.c"
diff --git a/src/lib/evas/canvas/evas_canvas3d_material.eo b/src/lib/evas/canvas/evas_canvas3d_material.eo
deleted file mode 100644
index 3576de1dcc..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_material.eo
+++ /dev/null
@@ -1,116 +0,0 @@
1class @beta Evas.Canvas3D.Material extends Evas.Canvas3D.Object
2{
3 [[Evas 3D canvas material class]]
4 data: Evas_Canvas3D_Material_Data;
5 methods {
6 color_set {
7 [[Set the material attribute color of the given material.
8
9 Material color is used also when texture map is enabled. The colors
10 will be modulated (multiplied). To control the color contribution
11 of a material attribute, use gray color. Setting color value for
12 normal attribute has no effect.
13
14 Default color is as follows.
15
16 Ambient : (0.2, 0.2, 0.2, 1.0)
17 Diffuse : (0.8, 0.8, 0.8, 1.0)
18 Specular : (1.0, 1.0, 1.0, 1.0)
19 Emission : (0.0, 0.0, 0.0, 1.0)
20 Normal : Not used
21 ]]
22
23 params {
24 @in attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
25 @in r: Evas.Real; [[Red component of the color.]]
26 @in g: Evas.Real; [[Green component of the color.]]
27 @in b: Evas.Real; [[Blue component of the color.]]
28 @in a: Evas.Real; [[Alpha component of the color.]]
29 }
30 }
31
32 color_get @const {
33 [[Get the material attribute color of the given material.
34
35 See also @.color_set.
36 ]]
37 params {
38 @in attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
39 @out r: Evas.Real; [[Pointer to receive red component of the color.]]
40 @out g: Evas.Real; [[Pointer to receive green component of the color.]]
41 @out b: Evas.Real; [[Pointer to receive blue component of the color.]]
42 @out a: Evas.Real; [[Pointer to receive alpha component of the color.]]
43 }
44 }
45
46 @property enable {
47 [[The material attribute enable flag of the given material.
48
49 You might want to disable some material reflection contribution.
50 For example, Emission attribute is rarely used. Disabling unused
51 attributes might help the shading less complex so that can get
52 speed up.
53
54 By default, diffuse and specular is enabled.
55 ]]
56 set {
57 }
58 get {
59 }
60 keys {
61 attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
62 }
63 values {
64 enable: bool; [[Whether to enable the attribute or not.]]
65 }
66 }
67
68 @property shininess {
69 [[The shininess of the given material.
70
71 Shininess is only used when specular attribute is enabled. Higher shininess
72 value will make the object more shiny.
73
74 Default shininess value is 150.0.
75
76 See also @.enable.set.
77 ]]
78 set {
79 }
80 get {
81 }
82 values {
83 shininess: Evas.Real; [[Shininess value.]]
84 }
85 }
86
87 @property texture {
88 [[The texture of the given material.
89
90 You have to enable the desired attribute first.
91
92 See also @.enable.set.
93 ]]
94 set {
95 }
96 get {
97 }
98
99 keys {
100 attrib: Evas.Canvas3D.Material_Attrib; [[Material attribute ID.]]
101 }
102 values {
103 texture: Evas.Canvas3D.Texture; [[The texture set to the attribute.]]
104 }
105 }
106 }
107 implements {
108 Efl.Object.constructor;
109 Efl.Object.destructor;
110 Evas.Canvas3D.Object.update_notify;
111 Evas.Canvas3D.Object.change_notify;
112 @empty Evas.Canvas3D.Object.callback_register;
113 @empty Evas.Canvas3D.Object.callback_unregister;
114 }
115
116}
diff --git a/src/lib/evas/canvas/evas_canvas3d_mesh.c b/src/lib/evas/canvas/evas_canvas3d_mesh.c
deleted file mode 100644
index 0bea10eb21..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_mesh.c
+++ /dev/null
@@ -1,1172 +0,0 @@
1#include "evas_common_private.h"
2#include "evas_private.h"
3
4#define MY_CLASS EVAS_CANVAS3D_MESH_CLASS
5
6static Evas_Canvas3D_Mesh_Frame *
7evas_canvas3d_mesh_frame_new(Evas_Canvas3D_Mesh *mesh)
8{
9 Evas_Canvas3D_Mesh_Frame *frame = NULL;
10 frame = (Evas_Canvas3D_Mesh_Frame *)calloc(1, sizeof(Evas_Canvas3D_Mesh_Frame));
11
12 if (frame == NULL)
13 {
14 ERR("Failed to allocate memory.");
15 return NULL;
16 }
17
18 frame->mesh = mesh;
19 evas_box3_empty_set(&frame->aabb);
20
21 return frame;
22}
23
24static void
25evas_canvas3d_mesh_frame_free(Evas_Canvas3D_Mesh_Frame *frame)
26{
27 int i;
28
29 if (frame->material)
30 evas_canvas3d_material_mesh_del(frame->material, frame->mesh);
31
32 for (i = 0; i < EVAS_CANVAS3D_VERTEX_ATTRIB_COUNT; i++)
33 {
34 if (frame->vertices[i].owns_data)
35 free(frame->vertices[i].data);
36 }
37
38 free(frame);
39}
40
41Evas_Canvas3D_Mesh_Frame *
42evas_canvas3d_mesh_frame_find(Evas_Canvas3D_Mesh_Data *pd, int frame)
43{
44 Eina_List *l;
45 Evas_Canvas3D_Mesh_Frame *f;
46
47 EINA_LIST_FOREACH(pd->frames, l, f)
48 {
49 if (f->frame == frame)
50 return f;
51 }
52
53 return NULL;
54}
55
56Eina_Bool
57evas_canvas3d_mesh_aabb_add_to_frame(Evas_Canvas3D_Mesh_Data *pd, int frame, int stride)
58{
59 Evas_Canvas3D_Mesh_Frame *curframe = evas_canvas3d_mesh_frame_find(pd, frame);
60 int i = 0, j = 0, step = 0, size = 0, max;
61 float vxmin, vymin, vzmin, vxmax, vymax, vzmax;
62 float *minmaxdata = NULL;
63 Evas_Box3 box3;
64
65 if (stride <= 0) return EINA_FALSE;
66
67 if (!curframe)
68 {
69 ERR("Invalid frame %i.", frame);
70 return EINA_FALSE;
71 }
72
73 step = curframe->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].element_count;
74 size = curframe->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].size;
75 minmaxdata = (float *)curframe->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].data;
76
77 if (!minmaxdata)
78 {
79 ERR("Invalid vertex data.");
80 return EINA_FALSE;
81 }
82
83 vxmax = vxmin = minmaxdata[0];
84 vymax = vymin = minmaxdata[1];
85 vzmax = vzmin = minmaxdata[2];
86 j += step;
87
88 max = size / stride;
89 for (i = 1; i < max; ++i)
90 {
91 vxmin > minmaxdata[j] ? vxmin = minmaxdata[j] : 0;
92 vxmax < minmaxdata[j] ? vxmax = minmaxdata[j] : 0;
93 vymin > minmaxdata[j + 1] ? vymin = minmaxdata[j + 1] : 0;
94 vymax < minmaxdata[j + 1] ? vymax = minmaxdata[j + 1] : 0;
95 vzmin > minmaxdata[j + 2] ? vzmin = minmaxdata[j + 2] : 0;
96 vzmax < minmaxdata[j + 2] ? vzmax = minmaxdata[j + 2] : 0;
97 j += step;
98 }
99
100 evas_box3_empty_set(&box3);
101 evas_box3_set(&box3, vxmin, vymin, vzmin, vxmax, vymax, vzmax);
102 curframe->aabb = box3;
103 return EINA_TRUE;
104}
105
106static inline void
107_mesh_init(Evas_Canvas3D_Mesh_Data *pd)
108{
109 pd->vertex_count = 0;
110 pd->frame_count = 0;
111 pd->frames = NULL;
112
113 pd->index_format = EVAS_CANVAS3D_INDEX_FORMAT_NONE;
114 pd->index_count = 0;
115 pd->indices = NULL;
116 pd->owns_indices = EINA_FALSE;
117 pd->assembly = EVAS_CANVAS3D_VERTEX_ASSEMBLY_TRIANGLES;
118
119 pd->nodes = NULL;
120 pd->blend_sfactor = EVAS_CANVAS3D_BLEND_FUNC_ONE;
121 pd->blend_dfactor = EVAS_CANVAS3D_BLEND_FUNC_ZERO;
122 pd->blending = EINA_FALSE;
123
124 pd->alpha_comparison = EVAS_CANVAS3D_COMPARISON_ALWAYS;
125 pd->alpha_ref_value = 0.0f;
126 pd->alpha_test_enabled = EINA_FALSE;
127
128 pd->color_pick_key.r = 0.0;
129 pd->color_pick_key.g = 0.0;
130 pd->color_pick_key.b = 0.0;
131 pd->color_pick_enabled = EINA_FALSE;
132
133 pd->shadows_edges_filtering_level = 4;
134 pd->shadows_edges_size = 300.0;
135 pd->shadows_constant_bias = 0.00015;
136 pd->near_lod_boundary = 0.0;
137 pd->far_lod_boundary = 0.0;
138}
139
140static inline void
141_mesh_fini(Evas_Canvas3D_Mesh_Data *pd)
142{
143 Eina_List *l;
144 Evas_Canvas3D_Mesh_Frame *f;
145
146 if (pd->frames)
147 {
148 EINA_LIST_FOREACH(pd->frames, l, f)
149 {
150 evas_canvas3d_mesh_frame_free(f);
151 }
152
153 eina_list_free(pd->frames);
154 }
155
156 if (pd->indices && pd->owns_indices)
157 {
158 free(pd->indices);
159 pd->indices = NULL;
160 }
161
162 if (pd->nodes)
163 eina_hash_free(pd->nodes);
164}
165
166static Eina_Bool
167_mesh_node_geometry_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
168 void *data EINA_UNUSED, void *fdata)
169{
170 Evas_Canvas3D_Node *n = *(Evas_Canvas3D_Node **)key;
171 evas_canvas3d_object_change(n, EVAS_CANVAS3D_STATE_NODE_MESH_GEOMETRY, (Evas_Canvas3D_Object *)fdata);
172 return EINA_TRUE;
173}
174
175static Eina_Bool
176_mesh_node_material_change_notify(const Eina_Hash *hash EINA_UNUSED, const void *key,
177 void *data EINA_UNUSED, void *fdata)
178{
179 Evas_Canvas3D_Node *n = *(Evas_Canvas3D_Node **)key;
180 evas_canvas3d_object_change(n, EVAS_CANVAS3D_STATE_NODE_MESH_MATERIAL, (Evas_Canvas3D_Object *)fdata);
181 return EINA_TRUE;
182}
183
184static void
185_evas_canvas3d_mesh_evas_canvas3d_object_change_notify(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_State state, Evas_Canvas3D_Object *ref EINA_UNUSED)
186{
187 if (state == EVAS_CANVAS3D_STATE_MESH_MATERIAL)
188 {
189 if (pd->nodes)
190 eina_hash_foreach(pd->nodes, _mesh_node_material_change_notify, obj);
191 }
192 else
193 {
194 if (pd->nodes)
195 eina_hash_foreach(pd->nodes, _mesh_node_geometry_change_notify, obj);
196 }
197}
198
199EOLIAN static void
200_evas_canvas3d_mesh_evas_canvas3d_object_update_notify(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
201{
202 Eina_List *l;
203 Evas_Canvas3D_Mesh_Frame *f;
204
205 EINA_LIST_FOREACH(pd->frames, l, f)
206 {
207 if (f->material)
208 {
209 evas_canvas3d_object_update(f->material);
210 }
211 }
212}
213
214
215void
216evas_canvas3d_mesh_node_add(Evas_Canvas3D_Mesh *mesh, Evas_Canvas3D_Node *node)
217{
218 int count = 0;
219 Evas_Canvas3D_Mesh_Data *pd = efl_data_scope_get(mesh, MY_CLASS);
220 if (pd->nodes == NULL)
221 {
222 pd->nodes = eina_hash_pointer_new(NULL);
223
224 if (pd->nodes == NULL)
225 {
226 ERR("Failed to create hash table.");
227 return;
228 }
229 }
230 else
231 count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
232
233 eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count + 1));
234}
235
236void
237evas_canvas3d_mesh_node_del(Evas_Canvas3D_Mesh *mesh, Evas_Canvas3D_Node *node)
238{
239 int count = 0;
240 Evas_Canvas3D_Mesh_Data *pd = efl_data_scope_get(mesh, MY_CLASS);
241 if (pd->nodes == NULL)
242 {
243 ERR("No node to delete.");
244 return;
245 }
246
247 count = (int)(uintptr_t)eina_hash_find(pd->nodes, &node);
248
249 if (count == 1)
250 eina_hash_del(pd->nodes, &node, NULL);
251 else
252 eina_hash_set(pd->nodes, &node, (const void *)(uintptr_t)(count - 1));
253}
254
255
256EAPI Evas_Canvas3D_Mesh *
257evas_canvas3d_mesh_add(Evas *e)
258{
259 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
260 return NULL;
261 MAGIC_CHECK_END();
262 return efl_add(MY_CLASS, e);
263}
264
265EOLIAN static Eo *
266_evas_canvas3d_mesh_efl_object_constructor(Eo *obj, Evas_Canvas3D_Mesh_Data *pd)
267{
268 obj = efl_constructor(efl_super(obj, MY_CLASS));
269 evas_canvas3d_object_type_set(obj, EVAS_CANVAS3D_OBJECT_TYPE_MESH);
270 _mesh_init(pd);
271
272 return obj;
273}
274
275EOLIAN static void
276_evas_canvas3d_mesh_efl_object_destructor(Eo *obj, Evas_Canvas3D_Mesh_Data *pd)
277{
278 _mesh_fini(pd);
279 efl_destructor(efl_super(obj, MY_CLASS));
280}
281
282EOLIAN static void
283_evas_canvas3d_mesh_shader_mode_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Shader_Mode mode)
284{
285 if (pd->shader_mode != mode)
286 {
287 pd->shader_mode = mode;
288 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_SHADER_MODE, NULL);
289 }
290}
291
292EOLIAN static Evas_Canvas3D_Shader_Mode
293_evas_canvas3d_mesh_shader_mode_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
294{
295 return pd->shader_mode;
296}
297
298EOLIAN static void
299_evas_canvas3d_mesh_vertex_count_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, unsigned int count)
300{
301 pd->vertex_count = count;
302 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_VERTEX_COUNT, NULL);
303}
304
305EOLIAN static unsigned int
306_evas_canvas3d_mesh_vertex_count_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
307{
308 return pd->vertex_count;
309}
310
311EOLIAN static Eina_Bool
312_evas_canvas3d_mesh_frame_exist(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, int frame)
313{
314 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
315
316 if (f)
317 return EINA_TRUE;
318
319 return EINA_FALSE;
320}
321
322EOLIAN static void
323_evas_canvas3d_mesh_frame_add(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, int frame)
324{
325 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
326
327 if (f != NULL)
328 {
329 ERR("Already existing frame.");
330 return;
331 }
332
333 f = evas_canvas3d_mesh_frame_new(obj);
334
335 if (f == NULL)
336 return;
337
338 f->frame = frame;
339 pd->frames = eina_list_append(pd->frames, f);
340 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_FRAME, NULL);
341}
342
343EOLIAN static void
344_evas_canvas3d_mesh_frame_del(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, int frame)
345{
346 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
347
348 if (f == NULL)
349 {
350 ERR("Not existing mesh frame.");
351 return;
352 }
353
354 pd->frames = eina_list_remove(pd->frames, f);
355 evas_canvas3d_mesh_frame_free(f);
356 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_FRAME, NULL);
357}
358
359EOLIAN static void
360_evas_canvas3d_mesh_frame_material_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, int frame, Evas_Canvas3D_Material *material)
361{
362 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
363
364 if (f == NULL)
365 {
366 ERR("Not existing mesh frame.");
367 return;
368 }
369
370 if (f->material == material)
371 return;
372
373 if (f->material)
374 {
375 evas_canvas3d_material_mesh_del(f->material, obj);
376 efl_unref(f->material);
377 }
378
379 f->material = material;
380 efl_ref(material);
381 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_MATERIAL, NULL);
382 evas_canvas3d_material_mesh_add(material, obj);
383}
384
385EOLIAN static Evas_Canvas3D_Material *
386_evas_canvas3d_mesh_frame_material_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, int frame)
387{
388 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
389
390 if (f == NULL)
391 {
392 ERR("Not existing mesh frame.");
393 return NULL;
394 }
395
396 return f->material;
397}
398
399EOLIAN static void
400_evas_canvas3d_mesh_frame_vertex_data_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, int frame, Evas_Canvas3D_Vertex_Attrib attrib, int stride, const void *data)
401{
402 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
403 int element_count;
404
405 if (f == NULL)
406 {
407 ERR("Not existing mesh frame.");
408 return;
409 }
410
411 if (stride < (int)sizeof(float))
412 {
413 ERR("Stride too small");
414 return;
415 }
416
417 if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION)
418 {
419 int i = 0, j = 0, size = stride/sizeof(float);
420 float vxmin, vymin, vzmin, vxmax, vymax, vzmax;
421 float *minmaxdata = (float *)data;
422 Evas_Box3 box3;
423
424 element_count = 3;
425
426 if (minmaxdata)
427 {
428 vxmax = vxmin = minmaxdata[0];
429 vymax = vymin = minmaxdata[1];
430 vzmax = vzmin = minmaxdata[2];
431 j += size;
432
433 for (i = 1; i < size; ++i)
434 {
435 vxmin > minmaxdata[j] ? vxmin = minmaxdata[j] : 0;
436 vxmax < minmaxdata[j] ? vxmax = minmaxdata[j] : 0;
437 vymin > minmaxdata[j + 1] ? vymin = minmaxdata[j + 1] : 0;
438 vymax < minmaxdata[j + 1] ? vymax = minmaxdata[j + 1] : 0;
439 vzmin > minmaxdata[j + 2] ? vzmin = minmaxdata[j + 2] : 0;
440 vzmax < minmaxdata[j + 2] ? vzmax = minmaxdata[j + 2] : 0;
441 j += size;
442 }
443
444 evas_box3_empty_set(&box3);
445 evas_box3_set(&box3, vxmin, vymin, vzmin, vxmax, vymax, vzmax);
446 f->aabb = box3;
447 }
448 else
449 {
450 ERR("Axis-Aligned Bounding Box wasn't added in frame %d ", frame);
451 }
452 }
453 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL)
454 {
455 element_count = 3;
456 }
457 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT)
458 {
459 element_count = 3;
460 }
461 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR)
462 {
463 element_count = 4;
464 }
465 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD)
466 {
467 element_count = 2;
468 }
469 else
470 {
471 ERR("Invalid vertex attrib.");
472 return;
473 }
474
475 if (f->vertices[attrib].owns_data && f->vertices[attrib].data)
476 free(f->vertices[attrib].data);
477
478 f->vertices[attrib].size = 0;
479 f->vertices[attrib].stride = stride;
480 f->vertices[attrib].data = (void *)data;
481 f->vertices[attrib].owns_data = EINA_FALSE;
482 f->vertices[attrib].element_count = element_count;
483
484 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_VERTEX_DATA, NULL);
485}
486
487EOLIAN static void
488_evas_canvas3d_mesh_frame_vertex_data_copy_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, int frame, Evas_Canvas3D_Vertex_Attrib attrib, int stride, const void *data)
489{
490 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
491 Evas_Canvas3D_Vertex_Buffer *vb;
492 int size, element_count;
493
494 if (f == NULL)
495 {
496 ERR("Not existing mesh frame.");
497 return;
498 }
499
500 if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION)
501 {
502 element_count = 3;
503 }
504 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_NORMAL)
505 {
506 element_count = 3;
507 }
508 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_TANGENT)
509 {
510 element_count = 3;
511 }
512 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_COLOR)
513 {
514 element_count = 4;
515 }
516 else if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_TEXCOORD)
517 {
518 element_count = 2;
519 }
520 else
521 {
522 ERR("Invalid vertex attrib.");
523 return;
524 }
525
526 vb = &f->vertices[attrib];
527 size = element_count * sizeof(float) * pd->vertex_count;
528
529 if (!vb->owns_data || vb->size < size)
530 {
531 if (vb->owns_data && vb->data)
532 free(vb->data);
533
534 vb->data = malloc(size);
535
536 if (vb->data == NULL)
537 {
538 vb->element_count = 0;
539 vb->size = 0;
540 vb->stride = 0;
541 vb->owns_data = EINA_FALSE;
542
543 ERR("Failed to allocate memory.");
544 return;
545 }
546
547 vb->size = size;
548 vb->owns_data = EINA_TRUE;
549 }
550
551 vb->element_count = element_count;
552 vb->stride = 0;
553
554 if (data == NULL)
555 return;
556
557 if (stride == 0 || stride == (int)(element_count * sizeof(float)))
558 {
559 memcpy(vb->data, data, size);
560 }
561 else
562 {
563 int i;
564 float *dst = (float *)vb->data;
565 float *src = (float *)data;
566
567 if (element_count == 2)
568 {
569 for (i = 0; i <pd->vertex_count; i++)
570 {
571 *dst++ = src[0];
572 *dst++ = src[1];
573
574 src = (float *)((char *)src + stride);
575 }
576 }
577 else if (element_count == 3)
578 {
579 for (i = 0; i <pd->vertex_count; i++)
580 {
581 *dst++ = src[0];
582 *dst++ = src[1];
583 *dst++ = src[2];
584
585 src = (float *)((char *)src + stride);
586 }
587 }
588 else if (element_count == 4)
589 {
590 for (i = 0; i <pd->vertex_count; i++)
591 {
592 *dst++ = src[0];
593 *dst++ = src[1];
594 *dst++ = src[2];
595 *dst++ = src[3];
596
597 src = (float *)((char *)src + stride);
598 }
599 }
600 }
601
602 if (attrib == EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION &&
603 !evas_canvas3d_mesh_aabb_add_to_frame(pd, frame, stride))
604 {
605 ERR("Axis-Aligned Bounding Box wasn't added in frame %d ", frame);
606 }
607
608 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_VERTEX_DATA, NULL);
609}
610
611EOLIAN static void *
612_evas_canvas3d_mesh_frame_vertex_data_map(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, int frame, Evas_Canvas3D_Vertex_Attrib attrib)
613{
614 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
615
616 if (f == NULL)
617 {
618 ERR("Not existing mesh frame.");
619 return NULL;
620 }
621
622 if (f->vertices[attrib].mapped)
623 {
624 ERR("Try to map already mapped data.");
625 return NULL;
626 }
627
628 f->vertices[attrib].mapped = EINA_TRUE;
629 return f->vertices[attrib].data;
630}
631
632EOLIAN static void
633_evas_canvas3d_mesh_frame_vertex_data_unmap(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, int frame, Evas_Canvas3D_Vertex_Attrib attrib)
634{
635 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
636
637 if (f == NULL)
638 {
639 ERR("Not existing mesh frame.");
640 return;
641 }
642
643 if (!f->vertices[attrib].mapped)
644 {
645 ERR("Try to unmap data which is not mapped yet.");
646 return;
647 }
648
649 f->vertices[attrib].mapped = EINA_FALSE;
650}
651
652EOLIAN static int
653_evas_canvas3d_mesh_frame_vertex_stride_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, int frame, Evas_Canvas3D_Vertex_Attrib attrib)
654{
655 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
656
657 if (f == NULL)
658 {
659 ERR("Not existing mesh frame.");
660 return 0;
661 }
662
663 return f->vertices[attrib].stride;
664}
665
666EOLIAN static void
667_evas_canvas3d_mesh_index_data_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Index_Format format, int count, const void *indices)
668{
669 if (pd->owns_indices && pd->indices)
670 free(pd->indices);
671
672 pd->index_format = format;
673 pd->index_count = count;
674 pd->index_size = 0;
675 pd->indices = (void *)indices;
676 pd->owns_indices = EINA_FALSE;
677
678 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_INDEX_DATA, NULL);
679}
680
681EOLIAN static void
682_evas_canvas3d_mesh_index_data_copy_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Index_Format format, int count, const void *indices)
683{
684 int size;
685
686 if (format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_BYTE)
687 {
688 size = count * sizeof(unsigned char);
689 }
690 else if (format == EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT)
691 {
692 size = count * sizeof(unsigned short);
693 }
694 else
695 {
696 ERR("Invalid index format.");
697 return;
698 }
699
700 if (!pd->owns_indices || pd->index_size < size)
701 {
702 if (pd->owns_indices && pd->indices)
703 free(pd->indices);
704
705 pd->indices = malloc(size);
706
707 if (pd->indices == NULL)
708 {
709 ERR("Failed to allocate memory.");
710 return;
711 }
712
713 pd->index_size = size;
714 pd->owns_indices = EINA_TRUE;
715 }
716
717 pd->index_format = format;
718 pd->index_count = count;
719
720 if (indices)
721 memcpy(pd->indices, indices, size);
722}
723
724EOLIAN static Evas_Canvas3D_Index_Format
725_evas_canvas3d_mesh_index_format_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
726{
727 return pd->index_format;
728}
729
730EOLIAN static int
731_evas_canvas3d_mesh_index_count_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
732{
733 return pd->index_count;
734}
735
736EOLIAN static void *
737_evas_canvas3d_mesh_index_data_map(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
738{
739 if (pd->index_mapped)
740 {
741 ERR("Try to map already mapped data.");
742 return NULL;
743 }
744
745 pd->index_mapped = EINA_TRUE;
746 return pd->indices;
747}
748
749EOLIAN static void
750_evas_canvas3d_mesh_index_data_unmap(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
751{
752 if (!pd->index_mapped)
753 {
754 ERR("Try to unmap data which is not mapped yet.");
755 return;
756 }
757
758 pd->index_mapped = EINA_FALSE;
759}
760
761EOLIAN static void
762_evas_canvas3d_mesh_vertex_assembly_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Vertex_Assembly assembly)
763{
764 pd->assembly = assembly;
765 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_VERTEX_ASSEMBLY, NULL);
766}
767
768EOLIAN static Evas_Canvas3D_Vertex_Assembly
769_evas_canvas3d_mesh_vertex_assembly_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
770{
771 return pd->assembly;
772}
773
774EOLIAN static void
775_evas_canvas3d_mesh_fog_color_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Evas_Real r, Evas_Real g, Evas_Real b, Evas_Real a)
776{
777 evas_color_set(&pd->fog_color, r, g, b, a);
778 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_FOG, NULL);
779}
780
781EOLIAN static void
782_evas_canvas3d_mesh_fog_color_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
783 Evas_Real *r, Evas_Real *g, Evas_Real *b, Evas_Real *a)
784{
785 if (r) *r = pd->fog_color.r;
786 if (g) *g = pd->fog_color.g;
787 if (b) *b = pd->fog_color.b;
788 if (a) *a = pd->fog_color.a;
789}
790
791EOLIAN static void
792_evas_canvas3d_mesh_fog_enable_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Eina_Bool enabled)
793{
794 pd->fog_enabled = enabled;
795 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_FOG, NULL);
796}
797
798EOLIAN static Eina_Bool
799_evas_canvas3d_mesh_fog_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
800{
801 return pd->fog_enabled;
802}
803
804EOLIAN static void
805_evas_canvas3d_mesh_blending_enable_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Eina_Bool blending)
806{
807 pd->blending = blending;
808 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_BLENDING, NULL);
809}
810
811EOLIAN static Eina_Bool
812_evas_canvas3d_mesh_blending_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
813{
814 return pd->blending;
815}
816
817EOLIAN static void
818_evas_canvas3d_mesh_blending_func_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Blend_Func sfactor, Evas_Canvas3D_Blend_Func dfactor)
819{
820 pd->blend_sfactor = sfactor;
821 pd->blend_dfactor = dfactor;
822 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_BLENDING, NULL);
823}
824
825EOLIAN static void
826_evas_canvas3d_mesh_blending_func_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
827 Evas_Canvas3D_Blend_Func *sfactor, Evas_Canvas3D_Blend_Func *dfactor)
828{
829 if (sfactor) *sfactor = pd->blend_sfactor;
830 if (dfactor) *dfactor = pd->blend_dfactor;
831}
832
833EOLIAN static void
834_evas_canvas3d_mesh_alpha_func_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Evas_Canvas3D_Comparison comparison,
835 Evas_Real ref_value)
836{
837 if (pd->alpha_comparison == comparison &&
838 (EINA_DBL_EQ(pd->alpha_ref_value, ref_value)))
839 return;
840 pd->alpha_comparison = comparison;
841 pd->alpha_ref_value = ref_value;
842 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_ALPHA_TEST, NULL);
843}
844
845EOLIAN static void
846_evas_canvas3d_mesh_alpha_func_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
847 Evas_Canvas3D_Comparison *comparison,
848 Evas_Real *ref_value)
849{
850 if (comparison) *comparison = pd->alpha_comparison;
851 if (ref_value) *ref_value = pd->alpha_ref_value;
852}
853
854EOLIAN static void
855_evas_canvas3d_mesh_alpha_test_enable_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Eina_Bool enabled)
856{
857 pd->alpha_test_enabled = enabled;
858 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_ALPHA_TEST, NULL);
859}
860
861EOLIAN static Eina_Bool
862_evas_canvas3d_mesh_alpha_test_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
863{
864 return pd->alpha_test_enabled;
865}
866
867EOLIAN static void
868_evas_canvas3d_mesh_efl_file_unload(Eo *obj, Evas_Canvas3D_Mesh_Data *pd)
869{
870 efl_file_unload(efl_super(obj, MY_CLASS));
871 _mesh_fini(pd);
872}
873
874EOLIAN static Eina_Error
875_evas_canvas3d_mesh_efl_file_load(Eo *obj, Evas_Canvas3D_Mesh_Data *pd)
876{
877 const Eina_File *f;
878 Eina_Error err;
879
880 if (efl_file_loaded_get(obj)) return 0;
881
882 err = efl_file_load(efl_super(obj, MY_CLASS));
883 if (err) return err;
884
885 _mesh_fini(pd);
886 _mesh_init(pd);
887
888 f = efl_file_mmap_get(obj);
889 if (f == NULL) return EFL_GFX_IMAGE_LOAD_ERROR_DOES_NOT_EXIST;
890
891 evas_common_load_model_from_eina_file(obj, f);
892
893 return 0;
894}
895
896EOLIAN static Eina_Bool
897_evas_canvas3d_mesh_efl_file_save_save(const Eo *obj, Evas_Canvas3D_Mesh_Data *pd,
898 const char *file,
899 const char *key EINA_UNUSED,
900 const Efl_File_Save_Info *info EINA_UNUSED)
901{
902 if ((file == NULL) || (obj == NULL) || (pd == NULL)) return EINA_FALSE;
903
904 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, 0);
905
906 if (f == NULL)
907 {
908 ERR("Not existing mesh frame.");
909 return EINA_FALSE;
910 }
911
912 evas_common_save_model_to_file(obj, file, f);
913 return EINA_TRUE;
914}
915
916EOLIAN static void
917_evas_canvas3d_mesh_from_primitive_set(Eo *obj,
918 Evas_Canvas3D_Mesh_Data *pd EINA_UNUSED,
919 int frame,
920 Eo *primitive)
921{
922 if ((primitive == NULL) || (obj == NULL)) return;
923
924 Evas_Canvas3D_Primitive_Data *ppd = efl_data_scope_get(primitive, EVAS_CANVAS3D_PRIMITIVE_CLASS);
925
926 evas_common_set_model_from_primitive(obj, frame, ppd);
927}
928
929void
930evas_canvas3d_mesh_interpolate_position_get(Eina_Vector3 *out, const Evas_Canvas3D_Vertex_Buffer *pos0, const Evas_Canvas3D_Vertex_Buffer *pos1,
931 Evas_Real weight, int index)
932{
933 if (pos1->data == NULL)
934 {
935 float *ptr;
936
937 if (pos0->stride != 0)
938 ptr = (float *)((char *)pos0->data + pos0->stride * index);
939 else
940 ptr = (float *)pos0->data + 3 * index;
941
942 out->x = ptr[0];
943 out->y = ptr[1];
944 out->z = ptr[2];
945 }
946 else
947 {
948 float *ptr0, *ptr1;
949
950 if (pos0->stride != 0)
951 ptr0 = (float *)((char *)pos0->data + pos0->stride * index);
952 else
953 ptr0 = (float *)pos0->data + 3 * index;
954
955 if (pos1->stride != 0)
956 ptr1 = (float *)((char *)pos1->data + pos1->stride * index);
957 else
958 ptr1 = (float *)pos1->data + 3 * index;
959
960 out->x = ptr0[0] * weight + ptr1[0] * (1.0 - weight);
961 out->y = ptr0[1] * weight + ptr1[1] * (1.0 - weight);
962 out->z = ptr0[2] * weight + ptr1[2] * (1.0 - weight);
963 }
964}
965
966static inline void
967_mesh_frame_find(Evas_Canvas3D_Mesh *mesh, int frame,
968 Eina_List **l, Eina_List **r)
969{
970 Eina_List *left, *right;
971 Evas_Canvas3D_Mesh_Frame *f0 = NULL, *f1;
972 Evas_Canvas3D_Mesh_Data *pdmesh = efl_data_scope_get(mesh, EVAS_CANVAS3D_MESH_CLASS);
973
974 left = pdmesh->frames;
975 right = eina_list_next(left);
976
977 while (right)
978 {
979 f0 = (Evas_Canvas3D_Mesh_Frame *)eina_list_data_get(left);
980 f1 = (Evas_Canvas3D_Mesh_Frame *)eina_list_data_get(right);
981
982 if (frame >= f0->frame && frame <= f1->frame)
983 break;
984
985 left = right;
986 right = eina_list_next(left);
987 }
988
989 if (right == NULL)
990 {
991 if (f0 && frame <= f0->frame)
992 {
993 *l = NULL;
994 *r = left;
995 }
996 else
997 {
998 *l = left;
999 *r = NULL;
1000 }
1001 return;
1002 }
1003
1004 *l = left;
1005 *r = right;
1006}
1007
1008void
1009evas_canvas3d_mesh_interpolate_vertex_buffer_get(Evas_Canvas3D_Mesh *mesh, int frame,
1010 Evas_Canvas3D_Vertex_Attrib attrib,
1011 Evas_Canvas3D_Vertex_Buffer *buf0,
1012 Evas_Canvas3D_Vertex_Buffer *buf1,
1013 Evas_Real *weight)
1014{
1015 Eina_List *l, *r;
1016 const Evas_Canvas3D_Mesh_Frame *f0 = NULL, *f1 = NULL;
1017 _mesh_frame_find(mesh, frame, &l, &r);
1018
1019 while (l)
1020 {
1021 f0 = (const Evas_Canvas3D_Mesh_Frame *)eina_list_data_get(l);
1022
1023 if (f0->vertices[attrib].data != NULL)
1024 break;
1025
1026 l = eina_list_prev(l);
1027 f0 = NULL;
1028 }
1029
1030 while (r)
1031 {
1032 f1 = (const Evas_Canvas3D_Mesh_Frame *)eina_list_data_get(r);
1033
1034 if (f1->vertices[attrib].data != NULL)
1035 break;
1036
1037 r = eina_list_next(r);
1038 f1 = NULL;
1039 }
1040
1041 if (f0 == NULL && f1 == NULL)
1042 return;
1043
1044 if (f0 == NULL)
1045 {
1046 f0 = f1;
1047 }
1048 else if (f1 != NULL)
1049 {
1050 if (frame == f0->frame)
1051 {
1052 f1 = NULL;
1053 }
1054 else if (frame == f1->frame)
1055 {
1056 f0 = f1;
1057 f1 = NULL;
1058 }
1059 }
1060
1061 buf0->data = f0->vertices[attrib].data;
1062 buf0->stride = f0->vertices[attrib].stride;
1063 buf0->size = f0->vertices[attrib].size;
1064
1065 if (f1)
1066 {
1067 buf1->data = f1->vertices[attrib].data;
1068 buf1->stride = f1->vertices[attrib].stride;
1069 buf1->size = f1->vertices[attrib].size;
1070
1071 *weight = (f1->frame - frame) / (Evas_Real)(f1->frame - f0->frame);
1072 }
1073 else
1074 {
1075 buf1->data = NULL;
1076 buf1->stride = 0;
1077 buf1->size = 0;
1078
1079 *weight = 1.0;
1080 }
1081}
1082
1083EOLIAN static Eina_Bool
1084_evas_canvas3d_mesh_color_pick_enable_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
1085{
1086 return pd->color_pick_enabled;
1087}
1088EOLIAN static void
1089_evas_canvas3d_mesh_color_pick_enable_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, Eina_Bool enabled)
1090{
1091 if (pd->color_pick_enabled != enabled)
1092 pd->color_pick_enabled = enabled;
1093 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_COLOR_PICK, NULL);
1094}
1095
1096EOLIAN static void
1097_evas_canvas3d_mesh_shadows_edges_filtering_set(Eo *obj, Evas_Canvas3D_Mesh_Data *pd,
1098 int blur_level, Evas_Real edges_size)
1099{
1100 if (blur_level > 0)
1101 pd->shadows_edges_filtering_level = blur_level;
1102 if (edges_size >= 0)
1103 pd->shadows_edges_size = edges_size;
1104 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_SHADOWS_EDGES_FILTERING, NULL);
1105}
1106
1107EOLIAN static void
1108_evas_canvas3d_mesh_shadows_edges_filtering_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
1109 int *blur_level, Evas_Real *edges_size)
1110{
1111 if (blur_level) *blur_level = pd->shadows_edges_filtering_level;
1112 if (edges_size) *edges_size = pd->shadows_edges_size;
1113}
1114
1115EOLIAN static void
1116_evas_canvas3d_mesh_shadows_constant_bias_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
1117 Evas_Real bias)
1118{
1119 if (!EINA_DBL_EQ(pd->shadows_constant_bias, bias))
1120 {
1121 pd->shadows_constant_bias = bias;
1122 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_MESH_SHADOWS_CONSTANT_BIAS, NULL);
1123 }
1124}
1125
1126EOLIAN static Evas_Real
1127_evas_canvas3d_mesh_shadows_constant_bias_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd)
1128{
1129 return pd->shadows_constant_bias;
1130}
1131EOLIAN static void
1132_evas_canvas3d_mesh_convex_hull_data_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
1133 int frame, Eina_Inarray *vertex, Eina_Inarray *index)
1134{
1135 int stride;
1136
1137 Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
1138
1139 if (!f)
1140 {
1141 ERR("Not existing mesh frame %d %s", __LINE__, __FILE__);
1142 return;
1143 }
1144
1145 if (f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].stride != 0)
1146 stride = f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].stride / sizeof(float);
1147 else
1148 stride = 3;
1149
1150 float *data = (float *)f->vertices[EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION].data;
1151
1152 evas_convex_hull_get(data, pd->vertex_count, stride, vertex, index);
1153
1154 return;
1155}
1156
1157EOLIAN static void
1158_evas_canvas3d_mesh_lod_boundary_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
1159 Evas_Real near_lod, Evas_Real far_lod)
1160{
1161 pd->near_lod_boundary = near_lod;
1162 pd->far_lod_boundary = far_lod;
1163}
1164
1165EOLIAN static void
1166_evas_canvas3d_mesh_lod_boundary_get(const Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
1167 Evas_Real *near_lod, Evas_Real *far_lod)
1168{
1169 *near_lod = pd->near_lod_boundary;
1170 *far_lod = pd->far_lod_boundary;
1171}
1172#include "canvas/evas_canvas3d_mesh.eo.c"
diff --git a/src/lib/evas/canvas/evas_canvas3d_mesh.eo b/src/lib/evas/canvas/evas_canvas3d_mesh.eo
deleted file mode 100644
index 364390d18f..0000000000
--- a/src/lib/evas/canvas/evas_canvas3d_mesh.eo
+++ /dev/null
@@ -1,421 +0,0 @@
1import evas_canvas3d_types;
2
3struct @beta @extern Eina.Inarray; [[Eina inarray data structure]]
4
5class @beta Evas.Canvas3D.Mesh extends Evas.Canvas3D.Object implements Efl.File, Efl.File_Save
6{
7 [[Evas 3D canvas mesh class]]
8 data: Evas_Canvas3D_Mesh_Data;
9
10 methods {
11 frame_vertex_data_set {
12 [[Set the vertex data of the key frame of the given mesh.
13
14 This function make evas read from the given buffer whenever it
15 requires. If you want to release the buffer after calling this
16 function, use @.frame_vertex_data_copy_set instead.
17
18 After setting the vertex data, further modifications should be
19 protected by map/unmap pair.
20
21 See also @.frame_vertex_data_map, @.frame_vertex_data_unmap.
22 ]]
23 params {
24 @in frame: int; [[The number of the key frame.]]
25 @in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
26 @in stride: int; [[Stride to go to the next vertex (in bytes).]]
27 @in data: const(void_ptr); [[Pointer to the vertex data buffer.]]
28 }
29 }
30
31 frame_vertex_data_copy_set {
32 [[Set the vertex data of the key frame of the given mesh by copying
33 from a buffer. This function allocates internal vertex buffer and
34 copy from the given buffer. So you can release the buffer. If you
35 want to modify the vertex data use @.frame_vertex_data_map. After
36 finishing the modifications, you should call @.frame_vertex_data_unmap.
37
38 See also @.frame_vertex_data_set.
39 ]]
40 params {
41 @in frame: int; [[The number of the key frame.]]
42 @in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
43 @in stride: int; [[Stride to go to the next vertex (in bytes).]]
44 @in data: const(void_ptr); [[Pointer to the vertex data buffer.]]
45 }
46 }
47
48 frame_vertex_data_map {
49 [[Map the vertex buffer of the key frame of the given mesh.
50
51 After manipulating the mapped buffer, @.frame_vertex_data_unmap
52 should be called to properly download the data to the engine. If
53 the data was set using @.frame_vertex_data_set, pointer to the
54 original buffer will be returned. Otherwise, the returned pointer
55 can differ every time calling this function.
56 ]]
57 return: void_ptr; [[Starting address of the mapped vertex buffer.]]
58 params {
59 @in frame: int; [[The number of the key frame.]]
60 @in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
61 }
62 }
63
64 frame_vertex_data_unmap {
65 [[Unmap the vertex buffer of the key frame of the given mesh.
66
67 See also @.frame_vertex_data_map.
68 ]]
69 params {
70 @in frame: int; [[The number of the key frame.]]
71 @in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
72 }
73 }
74
75 frame_vertex_stride_get @const {
76 [[Get the vertex buffer stride of the key frame of the given mesh.
77
78 This function returns valid stride only when the vertex buffer
79 is mapped. If the data was set with @.frame_vertex_data_set, the
80 original stride will be returned unchanged.
81 ]]
82 return: int; [[Stride to go to the next vertex (in bytes).]]
83 params {
84 @in frame: int; [[The number of the key frame.]]
85 @in attrib: Evas.Canvas3D.Vertex_Attrib; [[Vertex attribute ID.]]
86 }
87 }
88
89 index_data_set {
90 [[Set the vertex index data of the given mesh.
91
92 When the index data is set, Evas 3D assembles vertices using the
93 index data. If you want to free the data buffer, use
94 @.index_data_copy_set. Further modifications should be made
95 within map/unmap pair.
96 ]]
97 params {
98 @in format: Evas.Canvas3D.Index_Format; [[Vertex index data format.]]
99 @in count: int; [[Vertex index count.]]
100 @in indices: const(void_ptr); [[Pointer to the index data.]]
101 }
102 }
103
104 convex_hull_data_get {
105 [[Get the vertex and index data of convex hull around the given mesh.
106 ]]
107 params {
108 @in frame: int; [[ The number of the key frame.]]
109 @in vertex: ptr(Eina.Inarray); [[Vertex data pointer]]
110 @in index: ptr(Eina.Inarray); [[Index data pointer]]
111 }
112 }
113
114 index_data_copy_set {
115 [[Set the vertex index data of the given mesh by copying from a
116 buffer.
117
118 This function allocates internal index buffer any copy data from
119 the given buffer. Further modifications can be made within
120 map/unmap pair.
121
122 See also @.index_data_set.