Mercurial > hg > Game > Cerium
comparison Renderer/Engine/SceneGraphRoot.cc @ 1298:bb8b7f179f31 draft
improve collada file.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 02 Dec 2011 18:57:10 +0900 |
parents | f20e6e6500db |
children | f0e805c09ed6 |
comparison
equal
deleted
inserted
replaced
1297:f20e6e6500db | 1298:bb8b7f179f31 |
---|---|
274 return v; | 274 return v; |
275 } | 275 } |
276 } | 276 } |
277 return ""; | 277 return ""; |
278 }*/ | 278 }*/ |
279 typedef struct source { | |
280 char *id; | |
281 int count; | |
282 float *array; | |
283 struct source *next; | |
284 } SOURCE; | |
285 typedef SOURCE *SOURCE_P; | |
286 | |
287 typedef struct list { | |
288 SOURCE_P first; | |
289 SOURCE_P end; | |
290 } LIST; | |
291 typedef LIST *LIST_P; | |
292 | |
293 static void | |
294 addSource(LIST_P list, SOURCE_P src) { | |
295 if (list->first == NULL && list->end == NULL) { | |
296 list->first = list->end = src; | |
297 return; | |
298 } | |
299 list->end->next = src; | |
300 list->end = src; | |
301 } | |
279 | 302 |
280 static void | 303 static void |
281 xml_walk( SceneGraphRoot* self, xmlNodePtr cur) | 304 xml_walk( SceneGraphRoot* self, xmlNodePtr cur, LIST_P list) |
282 { | 305 { |
283 | 306 |
284 /*get float array.*/ | 307 /*get float array.*/ |
285 printf("name = %s, child:%s\n", cur->name, cur->children); | 308 printf("name = %s, child:%s\n", cur->name, cur->children); |
286 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { | 309 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { |
287 | 310 |
311 SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE)); | |
312 | |
313 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id"); | |
314 src->id = (char*)xmlGetProp(cur, (xmlChar*)"id"); | |
315 | |
316 int count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); | |
317 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); | |
318 src->array = (float*)malloc(sizeof(float) * src->count); | |
319 | |
288 char *cont =(char*)xmlNodeGetContent(cur); | 320 char *cont =(char*)xmlNodeGetContent(cur); |
289 //const char *id = get_property("id", cur); | 321 //const char *id = get_property("id", cur); |
290 | |
291 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id"); | |
292 //int count = atoi(get_property("count", cur)); | 322 //int count = atoi(get_property("count", cur)); |
293 | 323 for (int i = 0; cont != NULL; i++) { |
294 int count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); | 324 cont = pickup_float(cont, src->array+1); |
295 | 325 } |
326 | |
327 src->next = NULL; | |
328 addSource(list, src); | |
296 printf("id:%s count:%d cont:%s\n", id, count, cont); | 329 printf("id:%s count:%d cont:%s\n", id, count, cont); |
297 | 330 |
298 if (cur->children == "(null)") { | 331 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { |
299 return; | 332 char *p = (char*)xmlNodeGetContent(cur); |
333 printf("p:%s", p); | |
300 } | 334 } |
301 | 335 |
302 } | 336 } |
303 for (cur=cur->children; cur; cur=cur->next){ | 337 for (cur=cur->children; cur; cur=cur->next){ |
304 xml_walk(self, cur); | 338 xml_walk(self, cur, list); |
305 } | 339 } |
306 | 340 |
307 } | 341 } |
342 | |
343 void | |
344 init_list(LIST_P list) { | |
345 list->first = NULL; | |
346 list->end = NULL; | |
347 } | |
308 | 348 |
309 void | 349 void |
310 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) | 350 SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile) |
311 { | 351 { |
312 /*make parse dom*/ | 352 /*make parse dom*/ |
324 }; | 364 }; |
325 | 365 |
326 /* node analyze */ | 366 /* node analyze */ |
327 for(cur=cur->children; cur; cur=cur->next){ | 367 for(cur=cur->children; cur; cur=cur->next){ |
328 | 368 |
329 | 369 LIST list; |
330 xml_walk(this, cur); | 370 init_list(&list); |
371 | |
372 xml_walk(this, cur, &list); | |
331 /* if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){ | 373 /* if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){ |
332 cur_images = cur; | 374 cur_images = cur; |
333 continue; | 375 continue; |
334 } | 376 } |
335 if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){ | 377 if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){ |