summaryrefslogtreecommitdiff
path: root/src/modules/evas/model_loaders/obj
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2014-12-10 18:31:20 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-12-23 21:20:20 +0100
commit61aab62be0e17fd58405debbc0f6befae66e64c8 (patch)
tree04b0b3ed39562f702fc0686a3e9d044ab5977579 /src/modules/evas/model_loaders/obj
parent17baa3fa6f87227fdba4caaea5e5c2a39257f5bb (diff)
evas: entry points to modules is Eina_File. Model_Common_Loader is deleted.
Diffstat (limited to 'src/modules/evas/model_loaders/obj')
-rw-r--r--src/modules/evas/model_loaders/obj/evas_model_load_obj.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/modules/evas/model_loaders/obj/evas_model_load_obj.c b/src/modules/evas/model_loaders/obj/evas_model_load_obj.c
index 7c6869e..64c4eb9 100644
--- a/src/modules/evas/model_loaders/obj/evas_model_load_obj.c
+++ b/src/modules/evas/model_loaders/obj/evas_model_load_obj.c
@@ -83,11 +83,11 @@ _analyze_face_line(char * face_analyzer,
83} 83}
84 84
85static inline OBJ_Counts 85static inline OBJ_Counts
86_count_elements(Model_Common_Loader *loader)//count elements of mesh in .obj 86_count_elements(char *map)//count elements of mesh in .obj
87{ 87{
88 OBJ_Counts counts = _new_count_elements(); 88 OBJ_Counts counts = _new_count_elements();
89 89
90 char * current = loader->map; 90 char *current = map;
91 int polygon_checker = -2;//polygons with n vertices can be represented as n-2 triangles 91 int polygon_checker = -2;//polygons with n vertices can be represented as n-2 triangles
92 Eina_Bool will_check_next_char = EINA_FALSE; 92 Eina_Bool will_check_next_char = EINA_FALSE;
93 Eina_Bool first_char_is_v = EINA_FALSE; 93 Eina_Bool first_char_is_v = EINA_FALSE;
@@ -178,7 +178,7 @@ _count_elements(Model_Common_Loader *loader)//count elements of mesh in .obj
178} 178}
179 179
180void 180void
181evas_model_load_file_obj(Evas_3D_Mesh *mesh, Model_Common_Loader *loader) 181evas_model_load_file_obj(Evas_3D_Mesh *mesh, Eina_File *file)
182{ 182{
183 long i; 183 long i;
184 OBJ_Counts counts;//count elements of mesh in .obj 184 OBJ_Counts counts;//count elements of mesh in .obj
@@ -188,9 +188,17 @@ evas_model_load_file_obj(Evas_3D_Mesh *mesh, Model_Common_Loader *loader)
188 float *pos, *nor, *tex; 188 float *pos, *nor, *tex;
189 int stride_pos, stride_nor, stride_tex; 189 int stride_pos, stride_nor, stride_tex;
190 int j, k; 190 int j, k;
191 char * current; 191 char *current, *map;
192 192
193 counts = _count_elements(loader); 193 map = eina_file_map_all(file, EINA_FILE_SEQUENTIAL);
194
195 if (map == NULL)
196 {
197 ERR("Failed to create map from file %s\n", eina_file_filename_get(file));
198 return;
199 }
200
201 counts = _count_elements(map);
194 202
195 float *_vertices_obj = malloc(counts._vertex_counter * 3 * sizeof(float)); 203 float *_vertices_obj = malloc(counts._vertex_counter * 3 * sizeof(float));
196 float *_normales_obj = malloc(counts._normal_counter * 3 * sizeof(float)); 204 float *_normales_obj = malloc(counts._normal_counter * 3 * sizeof(float));
@@ -198,7 +206,7 @@ evas_model_load_file_obj(Evas_3D_Mesh *mesh, Model_Common_Loader *loader)
198 /* triangle has 3 points, every point has 3(vertix, texture and normal) coord */ 206 /* triangle has 3 points, every point has 3(vertix, texture and normal) coord */
199 int *_triangles = malloc(counts._triangles_counter * 9 * sizeof(int)); 207 int *_triangles = malloc(counts._triangles_counter * 9 * sizeof(int));
200 208
201 if ((loader->map == NULL) || (_vertices_obj == NULL) || 209 if ((map == NULL) || (_vertices_obj == NULL) ||
202 (_normales_obj == NULL) || (_tex_coords_obj == NULL) || (_triangles == NULL)) 210 (_normales_obj == NULL) || (_tex_coords_obj == NULL) || (_triangles == NULL))
203 { 211 {
204 ERR("Allocate memory is failed."); 212 ERR("Allocate memory is failed.");
@@ -209,7 +217,7 @@ evas_model_load_file_obj(Evas_3D_Mesh *mesh, Model_Common_Loader *loader)
209 return; 217 return;
210 } 218 }
211 219
212 current = loader->map; 220 current = map;
213 i = 0; 221 i = 0;
214 222
215 /* put data to arrays */ 223 /* put data to arrays */
@@ -373,5 +381,11 @@ evas_model_load_file_obj(Evas_3D_Mesh *mesh, Model_Common_Loader *loader)
373 { 381 {
374 ERR("Axis-Aligned Bounding Box wan't added in frame %d ", 0); 382 ERR("Axis-Aligned Bounding Box wan't added in frame %d ", 0);
375 } 383 }
384
385 if (map)
386 {
387 eina_file_map_free(file, map);
388 map = NULL;
389 }
376} 390}
377 391