summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2014-11-28 18:48:35 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-12-23 21:16:19 +0100
commit4acbae69472662feef7a88aedd19ce6ad4d0ebe1 (patch)
treea57f418e68ac4f66bdf1c19f2c980e1014362ca8 /src/modules
parentaaddf1a963c7e3b8aef18c4f366c8e9f8bf43e66 (diff)
evas: test cases are changed according to changes of API in step 4. Specific logic in obj_saver is removed for standardization of API.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/model_savers/obj/evas_model_save_obj.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/modules/evas/model_savers/obj/evas_model_save_obj.c b/src/modules/evas/model_savers/obj/evas_model_save_obj.c
index 35773e304f..1cc7e8a744 100644
--- a/src/modules/evas/model_savers/obj/evas_model_save_obj.c
+++ b/src/modules/evas/model_savers/obj/evas_model_save_obj.c
@@ -9,17 +9,11 @@
9#include "evas_private.h" 9#include "evas_private.h"
10 10
11#define OPEN_FILE(extension)\ 11#define OPEN_FILE(extension)\
12 int length=strlen(file);\
13 char * extension = "."#extension;\
14 char * _##extension##_file_name = (char *)malloc(length+4);\
15 strcpy(_##extension##_file_name,file);\
16 strcpy(_##extension##_file_name+length,extension);\
17 FILE * _##extension##_file = fopen(_##extension##_file_name, "w+");\ 12 FILE * _##extension##_file = fopen(_##extension##_file_name, "w+");\
18 free(_##extension##_file_name);
19 13
20#define SAVE_GEOMETRICS(a, format)\ 14#define SAVE_GEOMETRICS(a, format)\
21 vb = &f->vertices[a];\ 15 vb = &f->vertices[a];\
22 fprintf(_obj_file, "o %s\n",file);\ 16 fprintf(_obj_file, "o %s\n",_obj_file_name);\
23 if (vb->data == NULL)\ 17 if (vb->data == NULL)\
24 {\ 18 {\
25 ERR("Reading of geometrics is failed.");\ 19 ERR("Reading of geometrics is failed.");\
@@ -34,7 +28,7 @@
34 } 28 }
35 29
36static void 30static void
37_save_mesh(Evas_3D_Mesh_Data *pd, const char *file, Evas_3D_Mesh_Frame *f) 31_save_mesh(Evas_3D_Mesh_Data *pd, const char *_obj_file_name, Evas_3D_Mesh_Frame *f)
38{ 32{
39 Evas_3D_Vertex_Buffer *vb; 33 Evas_3D_Vertex_Buffer *vb;
40 time_t current_time; 34 time_t current_time;
@@ -45,7 +39,7 @@ _save_mesh(Evas_3D_Mesh_Data *pd, const char *file, Evas_3D_Mesh_Frame *f)
45 OPEN_FILE(obj) 39 OPEN_FILE(obj)
46 if (!_obj_file) 40 if (!_obj_file)
47 { 41 {
48 ERR("File open '%s' for save failed", file); 42 ERR("File open '%s' for save failed", _obj_file_name);
49 return; 43 return;
50 } 44 }
51 fprintf(_obj_file, "# Evas_3D saver OBJ v0.03 \n");//_obj_file created in macro 45 fprintf(_obj_file, "# Evas_3D saver OBJ v0.03 \n");//_obj_file created in macro
@@ -69,7 +63,7 @@ _save_mesh(Evas_3D_Mesh_Data *pd, const char *file, Evas_3D_Mesh_Frame *f)
69 } 63 }
70 64
71 fprintf(_obj_file,"# Current time is %s \n", c_time_string); 65 fprintf(_obj_file,"# Current time is %s \n", c_time_string);
72 fprintf(_obj_file,"mtllib %s.mtl \n\n", file); 66 fprintf(_obj_file,"mtllib %s.mtl \n\n", _obj_file_name);
73 67
74 /* Adding geometrics to file. */ 68 /* Adding geometrics to file. */
75 if (f == NULL) 69 if (f == NULL)
@@ -95,14 +89,14 @@ _save_mesh(Evas_3D_Mesh_Data *pd, const char *file, Evas_3D_Mesh_Frame *f)
95} 89}
96 90
97static void 91static void
98_save_material(Evas_3D_Mesh_Data *pd EINA_UNUSED, const char *file, Evas_3D_Mesh_Frame *f) 92_save_material(Evas_3D_Mesh_Data *pd EINA_UNUSED, const char *_mtl_file_name, Evas_3D_Mesh_Frame *f)
99{ 93{
100 Evas_3D_Material_Data *mat = eo_data_scope_get(f->material, EVAS_3D_MATERIAL_CLASS); 94 Evas_3D_Material_Data *mat = eo_data_scope_get(f->material, EVAS_3D_MATERIAL_CLASS);
101 95
102 OPEN_FILE(mtl) 96 OPEN_FILE(mtl)
103 if (!_mtl_file) 97 if (!_mtl_file)
104 { 98 {
105 ERR("File open '%s' for save failed", file); 99 ERR("File open '%s' for save failed", _mtl_file_name);
106 return; 100 return;
107 } 101 }
108 fprintf(_mtl_file, "# Evas_3D saver OBJ v0.03 \n");//_mtl_file created in macro 102 fprintf(_mtl_file, "# Evas_3D saver OBJ v0.03 \n");//_mtl_file created in macro
@@ -129,9 +123,24 @@ _save_material(Evas_3D_Mesh_Data *pd EINA_UNUSED, const char *file, Evas_3D_Mesh
129} 123}
130 124
131void 125void
132evas_model_save_file_obj(Evas_3D_Mesh *mesh, const char *file, Evas_3D_Mesh_Frame *f) 126evas_model_save_file_obj(Evas_3D_Mesh *mesh, const char *_obj_file_name, Evas_3D_Mesh_Frame *f)
133{ 127{
128 int len;
129 char *without_extention, *_mtl_extension, *_mtl_file_name;
130
131 len = strlen(_obj_file_name);
132 without_extention = (char*)malloc((len - 4) * sizeof(char));
133 _mtl_extension = ".mtl";
134 _mtl_file_name = (char *)malloc(len * sizeof(char));
135
136 memcpy(without_extention, _obj_file_name, len-4);
137 strcpy(_mtl_file_name, without_extention);
138 strcpy(_mtl_file_name + len - 4, _mtl_extension);
139
134 Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, EVAS_3D_MESH_CLASS); 140 Evas_3D_Mesh_Data *pd = eo_data_scope_get(mesh, EVAS_3D_MESH_CLASS);
135 _save_mesh(pd, file, f); 141 _save_mesh(pd, _obj_file_name, f);
136 _save_material(pd, file, f); 142 _save_material(pd, _mtl_file_name, f);
143
144 free(without_extention);
145 free(_mtl_file_name);
137} 146}