Mercurial > hg > Members > kono > Cerium
changeset 123:f515436feb71
delete scene_graph->child (instead use "children")
author | gongo@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 25 Nov 2008 10:32:23 +0900 |
parents | e92959ebceff |
children | 85f40aab232f |
files | TaskManager/Test/test_render/Makefile.def TaskManager/Test/test_render/polygon.cpp TaskManager/Test/test_render/polygon.h TaskManager/Test/test_render/scene_graph_pack.h TaskManager/Test/test_render/spe/DrawSpan.cpp TaskManager/Test/test_render/task/create_sgp.cpp TaskManager/Test/test_render/task/update_sgp.cpp TaskManager/Test/test_render/viewer.cpp |
diffstat | 8 files changed, 66 insertions(+), 245 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Makefile.def Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/Makefile.def Tue Nov 25 10:32:23 2008 +0900 @@ -3,10 +3,10 @@ # include/library path # ex: macosx #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium -CERIUM = /Users/gongo/Source/hg/Cerium +#CERIUM = /Users/gongo/Source/hg/Cerium # ex: linux/ps3 -#CERIUM = /home/gongo/Cerium +CERIUM = /home/gongo/Cerium #CERIUM = ../../..
--- a/TaskManager/Test/test_render/polygon.cpp Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/polygon.cpp Tue Nov 25 10:32:23 2008 +0900 @@ -37,7 +37,6 @@ angle[2] = 0; angle[3] = 1; next = NULL; - child = NULL; parent = NULL; brother = NULL; children = NULL; @@ -54,10 +53,10 @@ while(t) { cout << "my_name : " << t->name << endl; - if(t->child != NULL) + if(t->children != NULL) { - cout << "--move child : " << t->child->name << endl; - t = t->child; + cout << "--move children : " << t->children->name << endl; + t = t->children; } else if(t->brother != NULL) { @@ -126,9 +125,9 @@ { cout << "parent->name = " << parent->name << endl; } - if(child != NULL) + if(children != NULL) { - cout << "child->name = " << child->name << endl; + cout << "children->name = " << children->name << endl; } } @@ -208,8 +207,8 @@ for (int n = 0; n < sp->info.size; n++) { span = &sp->span[n]; - int x = span->x; - int y = span->y; + //int x = span->x; + //int y = span->y; float z = span->start_z; int end = span->length_x; float zpos = span->end_z; @@ -245,97 +244,6 @@ } } - -/* -void Polygon::create_scene_graph_pack() -{ - //SceneGraphPack *sgp = new SceneGraphPack; - sgp = new SceneGraphPack; - int i = 0; - int nnpn = -1; - - Polygon *t; - t = this; - - while(t) - { - //SceneGraphNode node; - sgp->node[i].size = t->size; - int d,tex; - for(d=0,tex=0; d<t->size*3; d+=3,tex+=2) - { - sgp->node[i].vertex[d] = t->data[d]; - sgp->node[i].vertex[d+1] = t->data[d+1]; - sgp->node[i].vertex[d+2] = t->data[d+2]; - sgp->node[i].texture[tex] = t->data[d+t->size*6]; - sgp->node[i].texture[tex+1] = t->data[d+t->size*6+1]; - } - - sgp->node[i].obj_pos[0] = 0; - sgp->node[i].obj_pos[1] = 0; - sgp->node[i].obj_pos[2] = 0; - sgp->node[i].obj_pos[3] = 1; - sgp->node[i].angle[0] = 0; - sgp->node[i].angle[1] = 0; - sgp->node[i].angle[2] = 0; - sgp->node[i].angle[3] = 1; - - for(int tm=0; tm<16; tm++) - { - sgp->node[i].translation[tm] = 0; - } - sgp->node[i].id = 0; - sgp->node[i].move = 0; - sgp->node[i].interaction = 0; - sgp->node[i].pn = nnpn; - - if(t->child != NULL) - { - nnpn = i; - t = t->child; - } - else if(t->brother != NULL) - { - nnpn = sgp->node[i].pn; - t = t->brother; - } - else - { - while(t) - { - if(t->brother != NULL) - { - t = t->brother; - break; - } - else - { - if(t->parent == NULL) - { - t = NULL; - break; - } - nnpn = sgp->node[nnpn].pn; - t = t->parent; - } - } - } - //printf("sgp->node[%d].pn = %d\n", i, sgp->node[i].pn); - i++; - } - sgp->info.size = i; - - - //for(int s=0; s<i; s++) - //{ - //printf("sgp.node[%d].pn = %d\n",s,sgp.node[s].pn); - //} - - //delete sgp; -} -*/ - - void Polygon::add_next() { Polygon *p; @@ -354,126 +262,34 @@ check_list = this; - for(list=this; list; list=list->next) - { - if(xmlStrcmp((xmlChar *)list->parent_name, (xmlChar *)"NULL")) - { + for (list=this; list; list=list->next) { + if (xmlStrcmp((xmlChar *)list->parent_name, (xmlChar *)"NULL")) { p = this; - while(p) - { - if(!xmlStrcmp((xmlChar *)p->name,(xmlChar *)list->parent_name)) - { - list->parent = p; - if(p->child == NULL) - { - p->child = list; - } - else - { - bros = p->child; - while(bros->brother != NULL) - { - bros = bros->brother; - } - bros->brother = list; - } - break; - } - p = p->next; - } - } - } -} - -/* -void Polygon::create_scene_graph_pack() -{ - SceneGraphPack sgp; - int i = 0; - int nnpn = -1; - Polygon *t; - t = this; - while(t) - { - //t->draw(); - SceneGraphNode node; - node.obj_pos[0] = 0; - node.obj_pos[1] = 0; - node.obj_pos[2] = 0; - node.obj_pos[3] = 1; - for(int tm=0; tm<16; tm++) - { - node.translation[tm] = 0; - } - node.id = 0; - node.move = 0; - node.interaction = 0; - for(int a=0; a<10; a++) - { - node.op[a] = -1; - } - node.pn = nnpn; - int p = 0; - - if(t->child != NULL) - { - //glPushMatrix(); - //node.op[p] = PUSH; - //nnpn = i; - t = t->child; - } - else if(t->brother != NULL) - { - //glPopMatrix(); - //glPushMatrix(); - //node.op[p] = SHIFT; - //nnpn = node.pn; - t = t->brother; - } - else - { - while(t) - { - if(t->brother != NULL) - { - //glPopMatrix(); - //glPushMatrix(); - //node.op[p] = SHIFT; - t = t->brother; - break; - } - else - { - t = t->parent; - if(t) - { - //glPopMatrix(); - //node.op[p] = POP; - //nnpn = sgp.node[nnpn].pn; - p++; - } - } - } - } - sgp.node[i] = node; - i++; - } - - sgp.info.size = i; - - for(int s=0; s<4; s++) - { - for(int a=0; sgp.node[s].op[a]!=-1; a++) - { - printf("sgp.node[%d].op[%d] = %d\n",s, a, sgp.node[s].op[a]); - } - //printf("sgp.node[%d].pn = %d\n",s,sgp.node[s].pn); - } + while (p) { + if (!xmlStrcmp((xmlChar *)p->name,(xmlChar *)list->parent_name)) + { + list->parent = p; + if(p->children == NULL) + { + p->children = list; + } + else + { + bros = p->children; + while(bros->brother != NULL) + { + bros = bros->brother; + } + bros->brother = list; + } + break; + } + p = p->next; + } + } + } } -*/ - - void Polygon::pickup_coordinate(char *cont) { @@ -653,6 +469,10 @@ texture_image = IMG_Load(image_name); + + /** + * image を 32bit(RGBA) に変換する + */ SDL_Surface *tmpImage = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w, texture_image->h, 32, @@ -823,7 +643,6 @@ angle[2] = 0; angle[3] = 1; next = NULL; - child = NULL; parent = NULL; brother = NULL; children = NULL; @@ -865,20 +684,21 @@ /* ポリゴン生成 */ tmp = new Polygon(cur); - if( tmp->parent_name==NULL || 0==strcmp(tmp->parent_name, "NULL")) + if ( tmp->parent_name==NULL || 0==strcmp(tmp->parent_name, "NULL")) { /* このsurfaceがroot */ root = tmp; - else - { + } else { /* 親はこのsurfaceより前に定義されているものとする (していい?) */ // ここで parent_name を用いるのは間違っていて、 // *cur->properties->children から探すべきらしい kono parent = root->searchPolygon(tmp->parent_name); if (parent==NULL) { - fprintf(stderr,"No such parent %s\n",tmp->parent_name); - root->addChild( tmp ); - } else - parent->addChild( tmp ); + fprintf(stderr, "[%s] No such parent %s\n", + tmp->name, tmp->parent_name); + root->addChild(tmp); + } else { + parent->addChild(tmp); + } } } @@ -894,16 +714,14 @@ /* childrenのリストの最後に加える */ if (this->lastChild != NULL) { tmp = this->lastChild; - tmp->next = child; + tmp->children = child; } this->lastChild = child; -#if 1 if (this->children == NULL) { this->children = child; } -#endif return child; }
--- a/TaskManager/Test/test_render/polygon.h Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/polygon.h Tue Nov 25 10:32:23 2008 +0900 @@ -40,7 +40,6 @@ //SDL_Surface *screen; //char image_name[20]; // texture image name Polygon *next; - Polygon *child; Polygon *parent; Polygon *brother; Viewer *viewer;
--- a/TaskManager/Test/test_render/scene_graph_pack.h Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/scene_graph_pack.h Tue Nov 25 10:32:23 2008 +0900 @@ -14,8 +14,6 @@ long *tex_addr, tex_width, tex_height; int id; int move, interaction; - //void (*move)(); - //int op[32]; // push pop shift => enum int pn; // parent number? SceneGraphNode *next; int pad[3];
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Nov 25 10:32:23 2008 +0900 @@ -196,6 +196,7 @@ free(free_sp); free(linebuf); free(zRow); + free(tex); return 0; }
--- a/TaskManager/Test/test_render/task/create_sgp.cpp Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/task/create_sgp.cpp Tue Nov 25 10:32:23 2008 +0900 @@ -99,25 +99,19 @@ p = p->next; } while (p); - if (t->child != NULL) { - nnpn = curNumber; - t = t->child; - } else if (t->children != NULL) { + if (t->children != NULL) { nnpn = curNumber; t = t->children; + printf("children\n"); } else if (t->brother != NULL) { nnpn = node->pn; t = t->brother; - } else if (t->next != NULL) { - nnpn = node->pn; - t = t->next; + printf("brother\n"); } else { while (t) { if (t->brother != NULL) { t = t->brother; - break; - } else if (t->next != NULL) { - t = t->next; + printf("brother2\n"); break; } else { if (t->parent == NULL) { @@ -133,5 +127,7 @@ } sgp->info.size = curNumber; + + return 0; }
--- a/TaskManager/Test/test_render/task/update_sgp.cpp Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/task/update_sgp.cpp Tue Nov 25 10:32:23 2008 +0900 @@ -37,6 +37,15 @@ } static void +move3(SceneGraphNodePtr node, int w, int h) +{ + node->angle[1] += 1.0f; + if (node->angle[1] > 360.0f) { + node->angle[1] = 0.0f; + } +} + +static void move1(SceneGraphNodePtr node, int w, int h) { node->angle[1] += 1.0f; @@ -90,7 +99,7 @@ init(void) { moveList[0] = move0; - moveList[1] = move1; + moveList[1] = move3; moveList[2] = move2; collList[0] = coll;
--- a/TaskManager/Test/test_render/viewer.cpp Tue Nov 25 09:52:27 2008 +0900 +++ b/TaskManager/Test/test_render/viewer.cpp Tue Nov 25 10:32:23 2008 +0900 @@ -281,8 +281,8 @@ // Draw Background (現在は塗りつぶし) //break; task_draw = manager->create_task(TASK_DRAW_BACK); - //task_draw->add_param(0x00ffcc55); - task_draw->add_param(0); + task_draw->add_param(0x00ffcc55); + //task_draw->add_param(0); //task_draw->add_param(st_rgb); }