summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-01-28 19:08:11 +0200
committerBogdan Devichev <b.devichev@samsung.com>2015-01-28 19:08:11 +0200
commit5bcc44953bca32958c7515b05cbd46d288fbf1f3 (patch)
tree8784a3381bcdb590d5eaa08a09d5075831325652
parent6053e67310fdcc8bd067ca1729b6c6cda3ea3bb7 (diff)
Obj_io. Step 3. Refactoring of reading of faces. Prepearing for stabilization of obj.
-rw-r--r--src/modules/evas/model_loaders/obj/evas_model_load_obj.c74
1 files changed, 43 insertions, 31 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 062d179ff6..953789e998 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
@@ -19,6 +19,14 @@
19 &ARRAY_2D(_##array_name##_obj, counts.current_##name##_counter, 2, 3)); \ 19 &ARRAY_2D(_##array_name##_obj, counts.current_##name##_counter, 2, 3)); \
20 counts.current_##name##_counter++; 20 counts.current_##name##_counter++;
21 21
22#define AFTER_NEXT_SPACE(pointer)\
23 do\
24 {\
25 pointer++;\
26 i++;\
27 }\
28 while (*pointer != ' ');
29
22/* Structures for reading data from file. */ 30/* Structures for reading data from file. */
23typedef struct _OBJ_Counts OBJ_Counts; 31typedef struct _OBJ_Counts OBJ_Counts;
24 32
@@ -178,6 +186,19 @@ _count_elements(char *map)//count elements of mesh in .obj
178} 186}
179 187
180void 188void
189_read_point(int *triangles,
190 int num,
191 OBJ_Counts counts EINA_UNUSED,
192 int num_cur,
193 char *pointer)
194{
195 sscanf(pointer, "%i/%i/%i",
196 &ARRAY_2D(triangles, num_cur, (num - 1) * 3, 9),
197 &ARRAY_2D(triangles, num_cur, (num - 1) * 3 + 1, 9),
198 &ARRAY_2D(triangles, num_cur, (num - 1) * 3 + 2, 9));
199}
200
201void
181evas_model_load_file_obj(Evas_3D_Mesh *mesh, Eina_File *file) 202evas_model_load_file_obj(Evas_3D_Mesh *mesh, Eina_File *file)
182{ 203{
183 long i; 204 long i;
@@ -249,50 +270,42 @@ evas_model_load_file_obj(Evas_3D_Mesh *mesh, Eina_File *file)
249 } 270 }
250 else if (first_char_is_f) 271 else if (first_char_is_f)
251 { 272 {
252 char * auxiliary_pointer = current; 273 char *auxiliary_pointer = current;
253 int count_of_triangles_in_line; 274 int count_of_triangles_in_line;
275 int the_first_point = counts.current_triangles_counter;
254 276
255 _analyze_face_line(auxiliary_pointer, 277 _analyze_face_line(auxiliary_pointer,
256 &count_of_triangles_in_line); 278 &count_of_triangles_in_line);
257 current++; 279 current++;
258 i++; 280 i++;
259 int first_pos, first_tex, first_norm; 281 _read_point(_triangles, 1, counts,
260 sscanf (current,"%i/%i/%i", 282 the_first_point,
261 &first_pos, 283 current);
262 &first_tex,
263 &first_norm);
264 284
265 do 285 AFTER_NEXT_SPACE(current)
266 {
267 current++;
268 i++;
269 }
270 while (*current != ' ');
271
272 current++;
273 i++;
274 286
275 for (j = 0; j < count_of_triangles_in_line; j++) 287 for (j = 0; j < count_of_triangles_in_line; j++)
276 { 288 {
277 auxiliary_pointer = current; 289 auxiliary_pointer = current;
278 ARRAY_2D(_triangles, counts.current_triangles_counter, 0, 9) = first_pos; 290 if (counts.current_triangles_counter != the_first_point)
279 ARRAY_2D(_triangles, counts.current_triangles_counter, 1, 9) = first_tex;
280 ARRAY_2D(_triangles, counts.current_triangles_counter, 2, 9) = first_norm;
281 sscanf (auxiliary_pointer,"%i/%i/%i %i/%i/%i",
282 &ARRAY_2D(_triangles, counts.current_triangles_counter, 3, 9),
283 &ARRAY_2D(_triangles, counts.current_triangles_counter, 4, 9),
284 &ARRAY_2D(_triangles, counts.current_triangles_counter, 5, 9),
285 &ARRAY_2D(_triangles, counts.current_triangles_counter, 6, 9),
286 &ARRAY_2D(_triangles, counts.current_triangles_counter, 7, 9),
287 &ARRAY_2D(_triangles, counts.current_triangles_counter, 8, 9));
288
289 current++;
290 while (*current != ' ')
291 { 291 {
292 current++; 292 ARRAY_2D(_triangles, counts.current_triangles_counter, 0, 9) = \
293 i++; 293 ARRAY_2D(_triangles, the_first_point, 0, 9);
294 ARRAY_2D(_triangles, counts.current_triangles_counter, 1, 9) = \
295 ARRAY_2D(_triangles, the_first_point, 1, 9);
296 ARRAY_2D(_triangles, counts.current_triangles_counter, 2, 9) = \
297 ARRAY_2D(_triangles, the_first_point, 2, 9);
294 } 298 }
295 299
300 _read_point(_triangles, 2, counts,
301 counts.current_triangles_counter,
302 auxiliary_pointer);
303 AFTER_NEXT_SPACE(auxiliary_pointer);
304 _read_point(_triangles, 3, counts,
305 counts.current_triangles_counter,
306 auxiliary_pointer);
307 AFTER_NEXT_SPACE(current);
308
296 counts.current_triangles_counter++; 309 counts.current_triangles_counter++;
297 } 310 }
298 first_char_is_f = EINA_FALSE; 311 first_char_is_f = EINA_FALSE;
@@ -389,4 +402,3 @@ evas_model_load_file_obj(Evas_3D_Mesh *mesh, Eina_File *file)
389 map = NULL; 402 map = NULL;
390 } 403 }
391} 404}
392