summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2014-12-22 16:16:19 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-12-23 21:20:21 +0100
commitc471665ac84b159d3cd4587380fae6ac78c33c3b (patch)
tree110c4eae1da7bd238b9f5c11bdabd13300d3caee
parentce36f8f5ad1e516d077ea935adf09c74c6ba403f (diff)
downloadefl-c471665ac84b159d3cd4587380fae6ac78c33c3b.tar.gz
evas: make Evas 3d mesh is inherited from Efl.File (functions file_set and save)
-rw-r--r--src/examples/evas/evas-3d-aabb.c4
-rw-r--r--src/examples/evas/evas-3d-eet.c9
-rw-r--r--src/examples/evas/evas-3d-frustum.c2
-rw-r--r--src/examples/evas/evas-3d-md2.c2
-rw-r--r--src/examples/evas/evas-3d-obj.c6
-rw-r--r--src/examples/evas/evas-3d-ply.c18
-rw-r--r--src/examples/evas/evas-3d-shadows.c4
-rw-r--r--src/examples/evas/shooter/evas-3d-shooter.c11
-rw-r--r--src/lib/evas/canvas/evas_3d_mesh.c23
-rw-r--r--src/lib/evas/canvas/evas_3d_mesh.eo34
-rw-r--r--src/tests/evas/evas_test_mesh.c10
11 files changed, 49 insertions, 74 deletions
diff --git a/src/examples/evas/evas-3d-aabb.c b/src/examples/evas/evas-3d-aabb.c
index 6210fa2b49..7fd8d98de3 100644
--- a/src/examples/evas/evas-3d-aabb.c
+++ b/src/examples/evas/evas-3d-aabb.c
@@ -3,7 +3,7 @@
* @see _mesh_aabb(Evas_3D_Mesh **mesh_b, const Evas_3D_Node *node);
* Rotate axises (keys 1-4) for model and bounding box view from another angle.
- * Compile with "gcc -o evas-3d-aabb evas-3d-aabb.c `pkg-config --libs --cflags evas ecore ecore-evas eo`"
+ * Compile with "gcc -o evas-3d-aabb evas-3d-aabb.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`"
*/
#define EFL_EO_API_SUPPORT
@@ -227,7 +227,7 @@ main(void)
material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(mesh,
- evas_3d_mesh_file_set("sonic.md2", NULL),
+ efl_file_set("sonic.md2", NULL),
evas_3d_mesh_frame_material_set(0, material),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
diff --git a/src/examples/evas/evas-3d-eet.c b/src/examples/evas/evas-3d-eet.c
index 96ab16bf29..b9c11e473d 100644
--- a/src/examples/evas/evas-3d-eet.c
+++ b/src/examples/evas/evas-3d-eet.c
@@ -9,7 +9,7 @@
* Show it in right side.
*
* @verbatim
-* gcc -o evas-3d-eet evas-3d-eet.c `pkg-config --libs --cflags eina evas ecore ecore-evas eo`
+* gcc -o evas-3d-eet evas-3d-eet.c `pkg-config --libs --cflags efl eina evas ecore ecore-evas eo`
* @endverbatim
*/
@@ -151,7 +151,7 @@ main(void)
material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(mesh,
- evas_3d_mesh_file_set("sonic.md2", NULL),
+ efl_file_set("sonic.md2", NULL),
evas_3d_mesh_frame_material_set(0, material),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
@@ -168,11 +168,10 @@ main(void)
0.50, 0.00, 0.50, 0.30),
evas_3d_material_shininess_set(50.0));
- eo_do(mesh,
- evas_3d_mesh_save("saved_Sonic_EET.eet", NULL));
+ eo_do(mesh, efl_file_save("saved_Sonic_EET.eet", NULL, NULL));
eo_do(mesh2,
- evas_3d_mesh_file_set("saved_Sonic_EET.eet", NULL),
+ efl_file_set("saved_Sonic_EET.eet", NULL),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
mesh_node = eo_add(EVAS_3D_NODE_CLASS, evas,
diff --git a/src/examples/evas/evas-3d-frustum.c b/src/examples/evas/evas-3d-frustum.c
index c23195773d..3443e26222 100644
--- a/src/examples/evas/evas-3d-frustum.c
+++ b/src/examples/evas/evas-3d-frustum.c
@@ -525,7 +525,7 @@ _mesh_setup_model(Scene_Data *data)
evas_3d_material_shininess_set(100.0));
eo_do(data->mesh_model,
- evas_3d_mesh_file_set("eagle.md2", NULL),
+ efl_file_set("eagle.md2", NULL),
evas_3d_mesh_frame_material_set(0, data->material_model),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_DIFFUSE));
}
diff --git a/src/examples/evas/evas-3d-md2.c b/src/examples/evas/evas-3d-md2.c
index 4b53c2e1c4..b22c76e2ca 100644
--- a/src/examples/evas/evas-3d-md2.c
+++ b/src/examples/evas/evas-3d-md2.c
@@ -120,7 +120,7 @@ main(void)
material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(mesh,
- evas_3d_mesh_file_set("sonic.md2", NULL),
+ efl_file_set("sonic.md2", NULL),
evas_3d_mesh_frame_material_set(0, material),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
diff --git a/src/examples/evas/evas-3d-obj.c b/src/examples/evas/evas-3d-obj.c
index d19a36db91..ed6778afb9 100644
--- a/src/examples/evas/evas-3d-obj.c
+++ b/src/examples/evas/evas-3d-obj.c
@@ -7,7 +7,7 @@
* and geometry to "saved_man.obj".
*
* @verbatim
-* gcc -o evas-3d-obj evas-3d-obj.c `pkg-config --libs --cflags evas ecore ecore-evas`
+* gcc -o evas-3d-obj evas-3d-obj.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`
* @endverbatim
*/
@@ -134,7 +134,7 @@ main(void)
material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(mesh,
- evas_3d_mesh_file_set("man_mesh.obj", NULL),
+ efl_file_set("man_mesh.obj", NULL),
evas_3d_mesh_frame_material_set(0, material),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
@@ -159,7 +159,7 @@ main(void)
1.0, 1.0, 1.0, 1.0),
evas_3d_material_shininess_set(50.0));
- eo_do(mesh, evas_3d_mesh_save("saved_man.obj", NULL));
+ eo_do(mesh, efl_file_save("saved_man.obj", NULL, NULL));
mesh_node = eo_add(EVAS_3D_NODE_CLASS, evas,
evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
diff --git a/src/examples/evas/evas-3d-ply.c b/src/examples/evas/evas-3d-ply.c
index 75505cd341..ed8209edd9 100644
--- a/src/examples/evas/evas-3d-ply.c
+++ b/src/examples/evas/evas-3d-ply.c
@@ -7,7 +7,7 @@
* and geometry to "saved_man_all_with_mods.ply", "saved_man_only_geometry.ply" and "saved_man_without_UVs.ply".
*
* @verbatim
-* gcc -o evas-3d-ply evas-3d-ply.c `pkg-config --libs --cflags evas ecore ecore-evas eo`
+* gcc -o evas-3d-ply evas-3d-ply.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo`
* @endverbatim
*/
@@ -189,18 +189,20 @@ main(void)
mesh[i] = eo_add(EVAS_3D_MESH_CLASS, evas);
eo_do(mesh[i],
- evas_3d_mesh_file_set(path_file[i % 8], NULL),
+ efl_file_set(path_file[i % 8], NULL),
evas_3d_mesh_frame_material_set(0, material),
evas_3d_mesh_shade_mode_set(draw_mode[(i % 16) / 8]));
snprintf(buffer, PATH_MAX, "%s/Saved_%s", folder, file_name[i % 8]);
- eo_do(mesh[i], evas_3d_mesh_save(buffer, NULL));
+ eo_do(mesh[i], efl_file_save(buffer, NULL, NULL));
if (i > 15)
- eo_do(mesh[i],
- evas_3d_mesh_file_set(path_file[i % 8], NULL),
- evas_3d_mesh_frame_material_set(0, material),
- evas_3d_mesh_shade_mode_set(draw_mode[(i % 16) / 8]));
+ {
+ eo_do(mesh[i],
+ efl_file_set(path_file[i % 8], NULL),
+ evas_3d_mesh_frame_material_set(0, material),
+ evas_3d_mesh_shade_mode_set(draw_mode[(i % 16) / 8]));
+ }
mesh_node[i] = eo_add(EVAS_3D_NODE_CLASS, evas,
evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH));
@@ -234,7 +236,7 @@ main(void)
/* Set the image object as render target for 3D scene. */
eo_do(image, evas_obj_image_scene_set(scene));
- ecore_animator_frametime_set(0.01);
+ ecore_animator_frametime_set(0.03);
for (i = 0; i < NUMBER_OF_MESHES; i++)
anim = ecore_animator_add(_animate_scene, mesh_node[i]);
diff --git a/src/examples/evas/evas-3d-shadows.c b/src/examples/evas/evas-3d-shadows.c
index 142a98eb35..840614cf0d 100644
--- a/src/examples/evas/evas-3d-shadows.c
+++ b/src/examples/evas/evas-3d-shadows.c
@@ -3,7 +3,7 @@
*
* @see evas_3d_scene_shadows_enable_set(Eina_Bool _shadows_enabled)
*
- * Compile with "gcc -o evas-3d-shadows evas-3d-shadows.c `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm"
+ * Compile with "gcc -o evas-3d-shadows evas-3d-shadows.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo` -lm"
*/
@@ -219,7 +219,7 @@ main(void)
material = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(mesh,
- evas_3d_mesh_file_set("sonic.md2", NULL),
+ efl_file_set("sonic.md2", NULL),
evas_3d_mesh_frame_material_set(0, material),
evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG));
diff --git a/src/examples/evas/shooter/evas-3d-shooter.c b/src/examples/evas/shooter/evas-3d-shooter.c
index 3fa1d2a1ad..fa5aedfa54 100644
--- a/src/examples/evas/shooter/evas-3d-shooter.c
+++ b/src/examples/evas/shooter/evas-3d-shooter.c
@@ -8,7 +8,7 @@
* The warrior isn't passable for camera, neither is wall. There is a possibility to go upstairs
* and break down.
*
-* Compile with "gcc -g evas-3d-shooter.c evas-3d-shooter-header.c -o evas-3d-shooter `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm"
+* Compile with "gcc -g evas-3d-shooter.c evas-3d-shooter-header.c -o evas-3d-shooter `pkg-config --libs --cflags efl evas ecore ecore-evas eo` -lm"
*/
#include "evas-3d-shooter-header.h"
@@ -840,8 +840,7 @@ _mesh_setup_gun_planet(Scene_Data *data)
/* Setup material and texture for eagle. */
data->mesh_eagle = eo_add(EVAS_3D_MESH_CLASS, evas);
- eo_do(data->mesh_eagle,
- evas_3d_mesh_file_set("shooter/eagle.obj", NULL));
+ eo_do(data->mesh_eagle, efl_file_set("shooter/eagle.obj", NULL));
data->material_eagle = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
@@ -1294,8 +1293,7 @@ _mesh_setup_warrior(Scene_Data *data, int index)
{
data->mesh_level[index] = eo_add(EVAS_3D_MESH_CLASS, evas);
- eo_do(data->mesh_level[index],
- evas_3d_mesh_file_set("shooter/warrior.md2", NULL));
+ eo_do(data->mesh_level[index], efl_file_set("shooter/warrior.md2", NULL));
data->material_level = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(data->mesh_level[index],
@@ -1328,8 +1326,7 @@ void
_mesh_setup_snake(Scene_Data *data)
{
data->mesh_snake = eo_add(EVAS_3D_MESH_CLASS, evas);
- eo_do(data->mesh_snake,
- evas_3d_mesh_file_set("shooter/snake.md2", NULL));
+ eo_do(data->mesh_snake, efl_file_set("shooter/snake.md2", NULL));
data->material_snake = eo_add(EVAS_3D_MATERIAL_CLASS, evas);
eo_do(data->mesh_snake,
diff --git a/src/lib/evas/canvas/evas_3d_mesh.c b/src/lib/evas/canvas/evas_3d_mesh.c
index 1868c0da6f..ddbf61916f 100644
--- a/src/lib/evas/canvas/evas_3d_mesh.c
+++ b/src/lib/evas/canvas/evas_3d_mesh.c
@@ -813,33 +813,38 @@ _evas_3d_mesh_mmap_set(Eo *obj, Evas_3D_Mesh_Data *pd,
evas_common_load_model_from_eina_file(obj, file);
}
-EOLIAN static void
-_evas_3d_mesh_file_set(Eo *obj, Evas_3D_Mesh_Data *pd,
- const char *file, const char *key EINA_UNUSED)
+EOLIAN static Eina_Bool
+_evas_3d_mesh_efl_file_file_set(Eo *obj, Evas_3D_Mesh_Data *pd,
+ const char *file,
+ const char *key EINA_UNUSED)
{
_mesh_fini(pd);
_mesh_init(pd);
- if (file == NULL) return;
+ if (file == NULL) return EINA_FALSE;
evas_common_load_model_from_file(obj, file);
+ return EINA_TRUE;
}
-EOLIAN static void
-_evas_3d_mesh_save(Eo *obj, Evas_3D_Mesh_Data *pd,
- const char *file, const char *key EINA_UNUSED)
+EOLIAN static Eina_Bool
+_evas_3d_mesh_efl_file_save(Eo *obj, Evas_3D_Mesh_Data *pd,
+ const char *file,
+ const char *key EINA_UNUSED,
+ const char *flags EINA_UNUSED)
{
- if ((file == NULL) || (obj == NULL) || (pd == NULL)) return;
+ if ((file == NULL) || (obj == NULL) || (pd == NULL)) return EINA_FALSE;
Evas_3D_Mesh_Frame *f = evas_3d_mesh_frame_find(pd, 0);
if (f == NULL)
{
ERR("Not existing mesh frame.");
- return;
+ return EINA_FALSE;
}
evas_common_save_model_to_file(obj, file, f);
+ return EINA_TRUE;
}
static inline void
diff --git a/src/lib/evas/canvas/evas_3d_mesh.eo b/src/lib/evas/canvas/evas_3d_mesh.eo
index e958ff4206..5657b32e54 100644
--- a/src/lib/evas/canvas/evas_3d_mesh.eo
+++ b/src/lib/evas/canvas/evas_3d_mesh.eo
@@ -1,4 +1,4 @@
-class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface)
+class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface, Efl.File)
{
legacy_prefix: null;
data: Evas_3D_Mesh_Data;
@@ -19,36 +19,6 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface)
}
}
- file_set {
- /**
- * Load mesh data from file.
- *
- * Loading a mesh from existing file is supported. Currently, only MD2, OBJ, PLY and EET file
- * formats are supported.
- *
- * @ingroup Evas_3D_Mesh
- */
- params {
- @in const(char)* file; /*@ Path to the mesh file. */
- @in const(char)* key; /*@ Key in the mesh file. */
- }
- }
-
- save {
- /**
- * Save mesh data to file.
- *
- * Saving a mesh to file is supported. Currently, only OBJ, PLY and EET file
- * format are supported.
- *
- * @ingroup Evas_3D_Mesh
- */
- params {
- @in const(char)* file; /*@ Path to the mesh file. */
- @in const(char)* key; /*@ Key in the mesh file. */
- }
- }
-
frame_vertex_data_set {
/*@
Set the vertex data of the key frame of the given mesh.
@@ -494,6 +464,8 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface)
Eo.Base.destructor;
Evas_3D_Object.update_notify;
Evas_3D_Object.change_notify;
+ Efl.File.file.set;
+ Efl.File.save;
}
}
diff --git a/src/tests/evas/evas_test_mesh.c b/src/tests/evas/evas_test_mesh.c
index 51f601e4b1..e510798412 100644
--- a/src/tests/evas/evas_test_mesh.c
+++ b/src/tests/evas/evas_test_mesh.c
@@ -43,13 +43,13 @@
fail_if(mesh == NULL); \
fail_if(mesh2 == NULL); \
snprintf(buffer, PATH_MAX, "%s", ext); \
- eo_do(mesh, evas_3d_mesh_file_set(file->path, NULL)); \
- eo_do(mesh, evas_3d_mesh_save(buffer, NULL)); \
- eo_do(mesh2, evas_3d_mesh_file_set(buffer, NULL)); \
+ eo_do(mesh, efl_file_set(file->path, NULL), \
+ efl_file_save(buffer, NULL, NULL)); \
+ eo_do(mesh2, efl_file_set(buffer, NULL)); \
res = _compare_meshes(mesh, mesh2); \
fail_if(res == 1); \
- eo_do(mesh, evas_3d_mesh_mmap_set(eina_file_open(file->path, 0), NULL)); \
- eo_do(mesh, evas_3d_mesh_save(buffer, NULL)); \
+ eo_do(mesh, evas_3d_mesh_mmap_set(eina_file_open(file->path, 0), NULL), \
+ efl_file_save(buffer, NULL, NULL)); \
eo_do(mesh2, evas_3d_mesh_mmap_set(eina_file_open(buffer, 0), NULL)); \
res = _compare_meshes(mesh, mesh2); \
fail_if(res == 1); \