comparison Renderer/Engine/SceneGraphRoot.cc @ 1299:f0e805c09ed6 draft

minor fix xml_walk and pickup_float, not work yet.
author Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Sun, 04 Dec 2011 18:50:53 +0900
parents bb8b7f179f31
children ab9b7d21b32b
comparison
equal deleted inserted replaced
1298:bb8b7f179f31 1299:f0e805c09ed6
274 return v; 274 return v;
275 } 275 }
276 } 276 }
277 return ""; 277 return "";
278 }*/ 278 }*/
279
279 typedef struct source { 280 typedef struct source {
280 char *id; 281 char *id;
281 int count; 282 int count;
282 float *array; 283 float *array;
283 struct source *next; 284 struct source *next;
302 303
303 static void 304 static void
304 xml_walk( SceneGraphRoot* self, xmlNodePtr cur, LIST_P list) 305 xml_walk( SceneGraphRoot* self, xmlNodePtr cur, LIST_P list)
305 { 306 {
306 307
307 /*get float array.*/ 308 /*get float array.*/
308 printf("name = %s, child:%s\n", cur->name, cur->children); 309 printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children);
309 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { 310 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
310 311
311 SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE)); 312 SOURCE_P src = (SOURCE_P)malloc(sizeof(SOURCE));
312 313
313 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id"); 314 char *id = (char*)xmlGetProp(cur, (xmlChar*)"id");
314 src->id = (char*)xmlGetProp(cur, (xmlChar*)"id"); 315 src->id = (char*)xmlGetProp(cur, (xmlChar*)"id");
315 316
316 int count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); 317 int count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count"));
317 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count")); 318 src->count = atoi((char*)xmlGetProp(cur, (xmlChar*)"count"));
318 src->array = (float*)malloc(sizeof(float) * src->count); 319 src->array = (float*)malloc(sizeof(float) * src->count);
319 320
320 char *cont =(char*)xmlNodeGetContent(cur); 321 char *cont =(char*)xmlNodeGetContent(cur);
321 //const char *id = get_property("id", cur); 322 //const char *id = get_property("id", cur);
322 //int count = atoi(get_property("count", cur)); 323 //int count = atoi(get_property("count", cur));
324
323 for (int i = 0; cont != NULL; i++) { 325 for (int i = 0; cont != NULL; i++) {
324 cont = pickup_float(cont, src->array+1); 326
327 //cont = pickup_float(cont, src->array+1);
328 // ここ+1じゃなくて、+iじゃない?
329 cont = pickup_float(cont, src->array+i);
325 } 330 }
331
326 332
327 src->next = NULL; 333 src->next = NULL;
328 addSource(list, src); 334 addSource(list, src);
329 printf("id:%s count:%d cont:%s\n", id, count, cont); 335 printf("id:%s count:%d cont:%s\n", id, count, cont);
330 336
331 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) { 337 if (!xmlStrcmp(cur->name, (xmlChar*)"float_array")) {
332 char *p = (char*)xmlNodeGetContent(cur); 338 char *p = (char*)xmlNodeGetContent(cur);
333 printf("p:%s", p); 339 printf("p:%s", p);
334 } 340 }
335 341
336 } 342 }
337 for (cur=cur->children; cur; cur=cur->next){ 343
338 xml_walk(self, cur, list); 344 for (cur=cur->children; cur; cur=cur->next){
339 } 345 xml_walk(self, cur, list);
340 346 }
341 } 347 }
342 348
343 void 349 void
344 init_list(LIST_P list) { 350 init_list(LIST_P list) {
345 list->first = NULL; 351 list->first = NULL;