# HG changeset patch # User Yutaka_Kinjyo # Date 1297617868 -32400 # Node ID 293b368027141da401c7ff86b73b5ad2bd900ea2 # Parent c4287bf771a06e6d1cf745c2758c695f722f9794 code cleanup diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/RenderingTasks.h --- a/Renderer/Engine/RenderingTasks.h Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/RenderingTasks.h Mon Feb 14 02:24:28 2011 +0900 @@ -6,15 +6,11 @@ DataUpdate, DataFree, - Create_SGP, Update_SGP, CreatePolygon, CreatePolygonFromSceneGraph, - CreatePolygonFromSceneGraph2, CreateSpan, - TEST, - DrawSpan, DrawBack, diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/SceneGraph.cc --- a/Renderer/Engine/SceneGraph.cc Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/SceneGraph.cc Mon Feb 14 02:24:28 2011 +0900 @@ -163,19 +163,12 @@ size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size")); name = (char *)xmlGetProp(surface,(xmlChar *)"name"); parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); - //texture_info = (texture_list_ptr)manager->allocate(sizeof(texture_list)); - //data = new float[size*3*3]; for (int i = 0; i < 16; i++) { matrix[i] = 0; real_matrix[i] = 0; } - - coord_xyz = (float*)manager->allocate(sizeof(float)*size*3); - coord_tex = (float*)manager->allocate(sizeof(float)*size*3); - normal = (float*)manager->allocate(sizeof(float)*size*3); - if (size % 3 != 0) { printf("vertex size is error. size %% 3 = %lld\n", size % 3); } @@ -185,10 +178,6 @@ get_data(manager, surface->children); - printf("coord_xyz[0] %f, pp[0]->tri.ver1.x %f \n", coord_xyz[0] , pp[pp_num-1].tri[0].ver1.x ); - printf("coord_xyz[0] %f, pp[0]->tri.ver1.x %f \n", coord_xyz[1] , pp[pp_num-1].tri[0].ver1.y ); - printf("coord_xyz[0] %f, pp[0]->tri.ver1.x %f \n", coord_xyz[2] , pp[pp_num-1].tri[0].ver1.z ); - finalize = &SceneGraph::finalize_original; } @@ -214,11 +203,7 @@ size = 0; //data = NULL; - - coord_xyz = NULL; - normal = NULL; - coord_tex = NULL; - + texture_info.texture_id = -1; move = no_move; collision = no_collision; @@ -245,10 +230,6 @@ { //delete [] data; - - free(coord_xyz); - free(coord_tex); - free(normal); free(pp); } diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/polygon.cc --- a/Renderer/Engine/polygon.cc Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/polygon.cc Mon Feb 14 02:24:28 2011 +0900 @@ -50,22 +50,8 @@ void Polygon::pickup_coordinate(char *cont) { + // size は頂点の数, count は面の数 char *tmp_cont = cont; - - for(int n=0; nver1.x %f\n", *(coord_xyz+ i*MAX_SIZE_TRIANGLE*9 + j*9), tri[j].ver1.x); - } - - if ( *(coord_xyz + i*MAX_SIZE_TRIANGLE*9 + j*9+1) != tri[j].ver1.y) { - printf("miss match pickup_coordinate vertex. coord %f, tri->ver1.y %f\n", *(coord_xyz+ i*MAX_SIZE_TRIANGLE*9 + j*9+1), tri[j].ver1.y); - } - if (tmp_cont == NULL) { cout << "Analyzing obj data failed coordinate\n"; @@ -105,8 +83,7 @@ count -= 1; } - - + } if (count != 0) { @@ -118,22 +95,9 @@ void Polygon::pickup_normal(char *cont) { - char *tmp_cont = cont; - - for (int n = 0; nver1.x %f\n", *(normal + i*MAX_SIZE_TRIANGLE*9 + j*9), tri[j].normal1.x); - } if (tmp_cont == NULL) { @@ -195,20 +156,6 @@ { char *tmp_cont = cont; - - for (int n = 0; n < size*3; n += 3) - { - tmp_cont = pickup_float(tmp_cont, coord_tex+n); - tmp_cont = pickup_float(tmp_cont, coord_tex+n+1); - coord_tex[n+2] = 1.0; - - if (tmp_cont == NULL) - { - cout << "Analyzing obj data failed texture\n"; - } - } - - tmp_cont = cont; int count = size / 3; for (int i = 0; i < pp_num; i++) { @@ -229,9 +176,6 @@ tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_x)); tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_y)); - if ( *(coord_tex + i*MAX_SIZE_TRIANGLE*9 + j*9) != tri[j].ver1.tex_x) { - printf("miss pickup_texture vertex. texture %f, tri->ver1.tex_x %f\n", *(coord_tex + i*MAX_SIZE_TRIANGLE*9 + j*9), tri[j].ver1.tex_x); - } if (tmp_cont == NULL) { diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/polygon.h --- a/Renderer/Engine/polygon.h Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/polygon.h Mon Feb 14 02:24:28 2011 +0900 @@ -15,9 +15,6 @@ //float *data; //"vertex" and "normal" and "texture" - float *coord_xyz; // vertex coordinate array - float *coord_tex; // texture coordinate array - float *normal; // normal vector array float matrix[16] __attribute__((aligned(16)));; float real_matrix[16] __attribute__((aligned(16)));; texture_list texture_info __attribute__((aligned(16)));; diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/spe/spe-main.cc --- a/Renderer/Engine/spe/spe-main.cc Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/spe/spe-main.cc Mon Feb 14 02:24:28 2011 +0900 @@ -16,7 +16,7 @@ SchedExternTask(CreateSpan); SchedExternTask(CreatePolygon); -//SchedExternTask(CreatePolygonFromSceneGraph); +SchedExternTask(CreatePolygonFromSceneGraph); SchedExternTask(ShowTime); @@ -44,7 +44,7 @@ SchedRegister( CreateSpan); SchedRegister( CreatePolygon); - //SchedRegister( CreatePolygonFromSceneGraph); + SchedRegister( CreatePolygonFromSceneGraph); SchedRegister( ShowTime); diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/task/CreatePolygonFromSceneGraph.cc --- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Mon Feb 14 02:24:28 2011 +0900 @@ -6,15 +6,10 @@ #include "CreatePolygonFromSceneGraph.h" #include "polygon_pack.h" -#include "scene_graph_pack.h" +#include "texture.h" SchedDefineTask(CreatePolygonFromSceneGraph); -#define SG_PACK_LOAD 10 -#define SG_NODE_LOAD 11 -#define PP_LOAD 12 -#define PP_STORE 13 - /** * ベクトルに行列を乗算する * @param[out] v vector (float[4]) @@ -35,187 +30,129 @@ } } + static int run(SchedTask *smanager, void *rbuf, void *wbuf) { - - float xyz1[4], xyz2[4], xyz3[4]; float normal1[4],normal2[4],normal3[4]; - SceneGraphPtr sg_top = (SceneGraphPtr)smanager->get_param(0); - SceneGraphPtr sg = sg_top; - - PolygonPackPtr pp - = (PolygonPackPtr)smanager->allocate(sizeof(PolygonPack)); - PolygonPackPtr send_pp - = (PolygonPackPtr)smanager->allocate(sizeof(PolygonPack)); - PolygonPackPtr pp_addr = (PolygonPackPtr)smanager->get_param(1); - PolygonPackPtr tmp_pp; - - pp->init(); - send_pp->init(); - - while (sg) { - if (sg->flag_drawable) { // sg->isDrawable() とかの方がよくね? - for (int i = 0; i < sg->size; i += 3) { - if (pp->info.size >= MAX_SIZE_TRIANGLE) { - PolygonPackPtr next; - - smanager->mainMem_alloc(0, sizeof(PolygonPack)); - smanager->mainMem_wait(); - next = (PolygonPackPtr)smanager->mainMem_get(0); - - pp->next = next; - - tmp_pp = pp; - pp = send_pp; - send_pp = tmp_pp; - - smanager->dma_wait(PP_STORE); - smanager->dma_store(send_pp, (memaddr)pp_addr, - sizeof(PolygonPack), PP_STORE); - - pp_addr = next; - - smanager->dma_wait(PP_LOAD); - smanager->dma_load(pp, (memaddr)pp_addr, - sizeof(PolygonPack), PP_LOAD); - smanager->dma_wait(PP_LOAD); - pp->init(); - } + //pp, matrix, real_matrix を受け取る + PolygonPackPtr in_pp = (PolygonPackPtr)smanager->get_input(rbuf, 0); + float *matrix = (float*)smanager->get_input(rbuf, 1); + float *real_matrix = (float*)smanager->get_input(rbuf, 2); + texture_list *tritexinfo = (texture_list*)smanager->get_input(rbuf, 3); + + PolygonPackPtr next = (PolygonPackPtr)smanager->get_param(0); - xyz1[0] = sg->coord_xyz[(i+0)*3]; - xyz1[1] = sg->coord_xyz[(i+0)*3+1]; - xyz1[2] = sg->coord_xyz[(i+0)*3+2]*-1.0f; - xyz1[3] = 1.0f; - - xyz2[0] = sg->coord_xyz[(i+1)*3]; - xyz2[1] = sg->coord_xyz[(i+1)*3+1]; - xyz2[2] = sg->coord_xyz[(i+1)*3+2]*-1.0f; - xyz2[3] = 1.0f; + PolygonPackPtr out_pp = (PolygonPackPtr)smanager->get_output(wbuf, 0); + out_pp->info.size = in_pp->info.size; + out_pp->next = next; - xyz3[0] = sg->coord_xyz[(i+2)*3]; - xyz3[1] = sg->coord_xyz[(i+2)*3+1]; - xyz3[2] = sg->coord_xyz[(i+2)*3+2]*-1.0f; - xyz3[3] = 1.0f; + if (in_pp->info.size == 0) { + printf("in_pp->info.size = 0\n"); + } - // sg->matrix = 回転行列*透視変換行列 - ApplyMatrix(xyz1, sg->matrix); - ApplyMatrix(xyz2, sg->matrix); - ApplyMatrix(xyz3, sg->matrix); - - xyz1[0] /= xyz1[2]; - xyz1[1] /= xyz1[2]; - xyz2[0] /= xyz2[2]; - xyz2[1] /= xyz2[2]; - xyz3[0] /= xyz3[2]; - xyz3[1] /= xyz3[2]; - - TrianglePack *triangle = &pp->tri[pp->info.size++]; + for (int i = 0; i < in_pp->info.size; i++) { - triangle->ver1.x = xyz1[0]; - triangle->ver1.y = xyz1[1]; - triangle->ver1.z = xyz1[2]; - triangle->ver1.tex_x = sg->coord_tex[(i+0)*3]; - triangle->ver1.tex_y = sg->coord_tex[(i+0)*3+1]; - - triangle->ver2.x = xyz2[0]; - triangle->ver2.y = xyz2[1]; - triangle->ver2.z = xyz2[2]; - triangle->ver2.tex_x = sg->coord_tex[(i+1)*3]; - triangle->ver2.tex_y = sg->coord_tex[(i+1)*3+1]; - - triangle->ver3.x = xyz3[0]; - triangle->ver3.y = xyz3[1]; - triangle->ver3.z = xyz3[2]; - triangle->ver3.tex_x = sg->coord_tex[(i+2)*3]; - triangle->ver3.tex_y = sg->coord_tex[(i+2)*3+1]; - - normal1[0] = sg->normal[(i+0)*3]; - normal1[1] = sg->normal[(i+0)*3+1]; - normal1[2] = sg->normal[(i+0)*3+2]*-1.0f; - //normal1[3] = 1.0f; - normal1[3] = 0.0f; - - normal2[0] = sg->normal[(i+1)*3]; - normal2[1] = sg->normal[(i+1)*3+1]; - normal2[2] = sg->normal[(i+1)*3+2]*-1.0f; - //normal2[3] = 1.0f; - normal2[3] = 0.0f; - - normal3[0] = sg->normal[(i+2)*3]; - normal3[1] = sg->normal[(i+2)*3+1]; - normal3[2] = sg->normal[(i+2)*3+2]*-1.0f; - //normal3[3] = 1.0f; - normal3[3] = 0.0f; + TrianglePack tri = in_pp->tri[i]; + + xyz1[0] = tri.ver1.x; + xyz1[1] = tri.ver1.y; + xyz1[2] = tri.ver1.z * -1.0f; + xyz1[3] = 1.0f; + + xyz2[0] = tri.ver2.x; + xyz2[1] = tri.ver2.y; + xyz2[2] = tri.ver2.z * -1.0f; + xyz2[3] = 1.0f; + + xyz3[0] = tri.ver3.x; + xyz3[1] = tri.ver3.y; + xyz3[2] = tri.ver3.z * -1.0f; + xyz3[3] = 1.0f; + + // matrix = 回転行列*透視変換行列 + ApplyMatrix(xyz1, matrix); + ApplyMatrix(xyz2, matrix); + ApplyMatrix(xyz3, matrix); + + xyz1[0] /= xyz1[2]; + xyz1[1] /= xyz1[2]; + xyz2[0] /= xyz2[2]; + xyz2[1] /= xyz2[2]; + xyz3[0] /= xyz3[2]; + xyz3[1] /= xyz3[2]; + + TrianglePackPtr triangle = &out_pp->tri[i]; - //ApplyNormalMatrix(normal1,sg->real_matrix); - //ApplyNormalMatrix(normal2,sg->real_matrix); - //ApplyNormalMatrix(normal3,sg->real_matrix); - - ApplyMatrix(normal1,sg->real_matrix); - ApplyMatrix(normal2,sg->real_matrix); - ApplyMatrix(normal3,sg->real_matrix); - - normal1[0] /= normal1[2]; - normal1[1] /= normal1[2]; - - normal2[0] /= normal2[2]; - normal2[1] /= normal2[2]; - - normal3[0] /= normal3[2]; - normal3[1] /= normal3[2]; - - triangle->normal1.x = normal1[0]; - triangle->normal1.y = normal1[1]; - triangle->normal1.z = normal1[2]; - - triangle->normal2.x = normal2[0]; - triangle->normal2.y = normal2[1]; - triangle->normal2.z = normal2[2]; - - triangle->normal3.x = normal3[0]; - triangle->normal3.y = normal3[1]; - triangle->normal3.z = normal3[2]; - - triangle->tex_info.addr = sg->texture_info.pixels; - triangle->tex_info.width = sg->texture_info.t_w; - triangle->tex_info.height = sg->texture_info.t_h; - triangle->tex_info.scale_max = sg->texture_info.scale_max; - } - } - - if (sg->children != NULL) { - sg = sg->children; - } else if (sg->brother != NULL) { - sg = sg->brother; - } else { - while (sg) { - if (sg->brother != NULL) { - sg = sg->brother; - break; - } else { - if (sg->parent == NULL) { - sg = NULL; - break; - } else { - sg = sg->parent; - } - } - } - } + triangle->ver1.x = xyz1[0]; + triangle->ver1.y = xyz1[1]; + triangle->ver1.z = xyz1[2]; + triangle->ver1.tex_x = tri.ver1.tex_x; + triangle->ver1.tex_y = tri.ver1.tex_y; + + triangle->ver2.x = xyz2[0]; + triangle->ver2.y = xyz2[1]; + triangle->ver2.z = xyz2[2]; + triangle->ver2.tex_x = tri.ver2.tex_x; + triangle->ver2.tex_y = tri.ver2.tex_y; + + triangle->ver3.x = xyz3[0]; + triangle->ver3.y = xyz3[1]; + triangle->ver3.z = xyz3[2]; + triangle->ver3.tex_x = tri.ver3.tex_x; + triangle->ver3.tex_y = tri.ver3.tex_y; + + normal1[0] = tri.normal1.x; + normal1[1] = tri.normal1.y; + normal1[2] = tri.normal1.z * -1.0f; + //normal1[3] = 1.0f; + normal1[3] = 0.0f; + + normal2[0] = tri.normal2.x; + normal2[1] = tri.normal2.y; + normal2[2] = tri.normal2.z * -1.0f; + //normal2[3] = 1.0f; + normal2[3] = 0.0f; + + normal3[0] = tri.normal3.x; + normal3[1] = tri.normal3.y; + normal3[2] = tri.normal3.z * -1.0f; + //normal3[3] = 1.0f; + normal3[3] = 0.0f; + + ApplyMatrix(normal1,real_matrix); + ApplyMatrix(normal2,real_matrix); + ApplyMatrix(normal3,real_matrix); + + normal1[0] /= normal1[2]; + normal1[1] /= normal1[2]; + + normal2[0] /= normal2[2]; + normal2[1] /= normal2[2]; + + normal3[0] /= normal3[2]; + normal3[1] /= normal3[2]; + + triangle->normal1.x = normal1[0]; + triangle->normal1.y = normal1[1]; + triangle->normal1.z = normal1[2]; + + triangle->normal2.x = normal2[0]; + triangle->normal2.y = normal2[1]; + triangle->normal2.z = normal2[2]; + + triangle->normal3.x = normal3[0]; + triangle->normal3.y = normal3[1]; + triangle->normal3.z = normal3[2]; + + triangle->tex_info.addr = tritexinfo->pixels; + triangle->tex_info.width = tritexinfo->t_w; + triangle->tex_info.height = tritexinfo->t_h; + triangle->tex_info.scale_max = tritexinfo->scale_max; } - - smanager->dma_wait(PP_STORE); - smanager->dma_store(pp, (memaddr)pp_addr, - sizeof(PolygonPack), PP_STORE); - smanager->dma_wait(PP_STORE); - - free(pp); - free(send_pp); return 0; - } diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/task/create_sgp.cc --- a/Renderer/Engine/task/create_sgp.cc Sun Feb 13 23:27:22 2011 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -#include "scene_graph_pack.h" -#include "SceneGraph.h" -#include "create_sgp.h" -#include "TaskManager.h" -using namespace std; - -SchedDefineTask(Create_SGP); - -/** - * TODO - * 入りきらない分は SceneGraphPack を next で繋げてるので - * node->pn をつかって sgp->node[node->pn] とかやって - * 親?の要素を探す事は出来ないかもしれません。 - * next を辿って node->pn == とかやるのは確実だけどさ。。。 - */ -static int -//create_sgp(Polygon *sg, SceneGraphPack *sgp) -run(SchedTask *smanager, void *rbuf, void *wbuf) -{ - -#if !SPE_CREATE_POLYGON - - //SceneGraph *sg = (SceneGraph*)smanager->get_input(rbuf, 0); - SceneGraph *sg = (SceneGraph*)smanager->get_param(0); - SceneGraphPack *sgp = (SceneGraphPack*)smanager->get_param(0); - sgp->init(); - - int curNumber = 0; - int nnpn = -1; - SceneGraphNodePtr node; - - SceneGraph *t = sg; - - while(t) { - // blocking はこれでいいのかな? - if (curNumber >= MAX_NODE ){ - SceneGraphPack *sgp_new = - //(SceneGraphPack*)manager->malloc(sizeof(SceneGraphPack)); - (SceneGraphPack*)smanager->allocate(sizeof(SceneGraphPack)); - sgp_new->init(); - sgp->info.size = curNumber-1; - curNumber = 0; - sgp->next = sgp_new; - sgp = sgp_new; - } - - node = &sgp->node[curNumber]; - node->init(); - - for (int i = 0,d = 0,tex = 0; i < t->size; i++, d += 3, tex += 2) { - if (node->size >= MAX_POLYGON) { - SceneGraphNodePtr node_new = (SceneGraphNodePtr)smanager->allocate(sizeof(SceneGraphNode)); - node_new->init(); - node->next = node_new; - node = node_new; - d = 0; - tex = 0; - } - - /** - * struct texture { - * int texture_id; - * float vertex[3]; - * float texture[2]; - * } - */ - - node->vertex[d] = t->coord_xyz[i*3]; - node->vertex[d+1] = t->coord_xyz[i*3+1]; - node->vertex[d+2] = t->coord_xyz[i*3+2]; - node->texture[tex] = t->coord_tex[i*3]; - node->texture[tex+1] = t->coord_tex[i*3+1]; - node->size++; - } - - node = &sgp->node[curNumber]; - - SceneGraphNode *p = node; - do { - p->obj_pos[0] = 0; - p->obj_pos[1] = 0; - p->obj_pos[2] = 0; - p->obj_pos[3] = 1; - p->angle[0] = 0; - p->angle[1] = 0; - p->angle[2] = 0; - p->angle[3] = 1; - - for (int tm = 0; tm < 16; tm++) { - p->translation[tm] = 0; - } - - p->id = 0; - p->move = 0; - p->interaction = 0; - p->self = t; - p->tree = scene_graph; - - p->pn = nnpn; - //node->tex_addr = t->texture_image->pixels; - p->tex_width = t->texture_info.texture_image->w; - p->tex_height = t->texture_info.texture_image->h; - p = p->next; - } while (p); - - if (t->children != NULL) { - nnpn = curNumber; - t = t->children; - } else if (t->brother != NULL) { - nnpn = node->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; - } - } - } - curNumber++; - } - sgp->info.size = curNumber; - -#endif - - return 0; -} diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/task/task_init.cc --- a/Renderer/Engine/task/task_init.cc Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/task/task_init.cc Mon Feb 14 02:24:28 2011 +0900 @@ -5,15 +5,11 @@ SchedExternTask(DataUpdate); SchedExternTask(DataFree); -SchedExternTask(Create_SGP); SchedExternTask(Update_SGP); SchedExternTask(CreatePolygon); SchedExternTask(CreatePolygonFromSceneGraph); -SchedExternTask(CreatePolygonFromSceneGraph2); SchedExternTask(CreateSpan); -SchedExternTask(TEST); - SchedExternTask(DrawSpan); SchedExternTask(DrawSpanRenew); SchedExternTask(DrawBack); @@ -54,15 +50,11 @@ SchedRegister( DataUpdate); SchedRegister( DataFree); - SchedRegister( Create_SGP); SchedRegister( Update_SGP); SchedRegister(CreatePolygonFromSceneGraph); - SchedRegister(CreatePolygonFromSceneGraph2); SchedRegister(CreatePolygon); SchedRegister( CreateSpan); - SchedRegister(TEST); - SchedRegister( DrawSpan); SchedRegister( DrawBack); diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/viewer.cc Mon Feb 14 02:24:28 2011 +0900 @@ -440,67 +440,21 @@ { HTaskPtr game_task_array = 0; - HTaskPtr task_test = manager->create_task(TEST); - - // SceneGraph(木構造) -> PolygonPack - HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); - task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph()); - task_create_pp->set_param(1,(memaddr)r[ppi].ppack); /* GameTask の処理の終了を待ってからポリゴンを作る */ if (sgroot->gtask_array != NULL) { game_task_array = sgroot->gtask_array->get_task_array(); - task_create_pp->wait_for(game_task_array); } - task_next->wait_for(task_create_pp); - task_test->wait_for(task_create_pp); - - //PolygonPackPtr out_pp = r[ppi].ppack; - PolygonPackPtr top_out_pp = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack)); - PolygonPackPtr out_pp = top_out_pp; - HTaskPtr wait = manager->create_task(Dummy); - wait->set_cpu(CPU_PPE); - - SceneGraphPtr sg = sgroot->getDrawSceneGraph(); - SceneGraphPtr t = sgroot->sg_remove_list; - - while(sg) { - - if (sg != t) { - printf("miss match sg %x t %x\n",sg,t); - } - - t = t->next; - - if (sg->children != NULL) { - sg = sg->children; - } else if (sg->brother != NULL) { - sg = sg->brother; - } else { - while (sg) { - if (sg->brother != NULL) { - sg = sg->brother; - break; - } else { - if (sg->parent == NULL) { - sg = NULL; - break; - } else { - sg = sg->parent; - } - } - } - } - } - - - + PolygonPackPtr out_pp = r[ppi].ppack; + HTaskPtr task_create_pp = manager->create_task(Dummy); + task_create_pp->set_cpu(CPU_PPE); + //多分このsg_remove_listであってる?。チェック対象かも for (SceneGraphPtr t = sgroot->sg_remove_list; t != NULL; t = t->next) { for (int i = 0; i < t->pp_num; i++) { - HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph2); + HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph); create_pp->add_inData(&t->pp[i], sizeof(PolygonPack)); create_pp->add_inData(t->matrix, sizeof(float)*16); create_pp->add_inData(t->real_matrix, sizeof(float)*16); @@ -512,25 +466,21 @@ create_pp->wait_for(game_task_array); } - wait->wait_for(create_pp); - task_test->wait_for(create_pp); + task_create_pp->wait_for(create_pp); PolygonPackPtr tmp_pp = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack)); tmp_pp->init(); create_pp->set_param(0, (memaddr)tmp_pp); out_pp = tmp_pp; - create_pp->set_cpu(CPU_PPE); + create_pp->set_cpu(SPE_ANY); create_pp->spawn(); } } - task_test->add_inData(r[ppi].ppack, sizeof(PolygonPack)); - task_test->add_inData(top_out_pp, sizeof(PolygonPack)); - task_next->wait_for(wait); - task_next->wait_for(task_test); + task_next->wait_for(task_create_pp); int range_base = spe_num; @@ -563,17 +513,12 @@ task_create_sp->set_param(1,starty); task_create_sp->set_param(2,endy); - //task_create_sp->add_inData(r[ppi].ppack, sizeof(PolygonPack)); - task_create_sp->add_inData(top_out_pp, sizeof(PolygonPack)); + task_create_sp->add_inData(r[ppi].ppack, sizeof(PolygonPack)); task_create_sp->add_inData(r[spi].spackList_ptr, sizeof(SpanPack*)*r[spi].spackList_length_align); task_create_sp->add_inData(&r[spi].spackList[index_start], sizeof(SpanPack)); task_create_sp->wait_for(task_create_pp); - //test用 - task_create_sp->wait_for(wait); - task_create_sp->wait_for(task_test); - task_next->wait_for(task_create_sp); task_create_sp->set_cpu(SPE_ANY); @@ -581,9 +526,7 @@ } task_create_pp->spawn(); - //test用 - wait->spawn(); - task_test->spawn(); + } diff -r c4287bf771a0 -r 293b36802714 Renderer/Engine/viewerGL.cc --- a/Renderer/Engine/viewerGL.cc Sun Feb 13 23:27:22 2011 +0900 +++ b/Renderer/Engine/viewerGL.cc Mon Feb 14 02:24:28 2011 +0900 @@ -1,4 +1,5 @@ #include "viewerGL.h" +#include "polygon_pack.h" static void @@ -208,23 +209,24 @@ glEnable(GL_TEXTURE_2D); glBegin( GL_TRIANGLES); - for (int i = 0; i < sg->size; i += 3) { - xyz1[0] = sg->coord_xyz[(i+0)*3]; - xyz1[1] = sg->coord_xyz[(i+0)*3+1]; - xyz1[2] = sg->coord_xyz[(i+0)*3+2]*-1.0f; - //xyz1[2] = sg->coord_xyz[(i+0)*3+2]; + + for (int i = 0; i < sg->pp_num; i++) { + for (int j = 0; j < sg->pp[i].info.size; j++) { + TrianglePack tri = sg->pp[i].tri[j]; + + xyz1[0] = tri.ver1.x; + xyz1[1] = tri.ver1.y; + xyz1[2] = tri.ver1.z * -1.0f; xyz1[3] = 1.0f; - xyz2[0] = sg->coord_xyz[(i+1)*3]; - xyz2[1] = sg->coord_xyz[(i+1)*3+1]; - xyz2[2] = sg->coord_xyz[(i+1)*3+2]*-1.0f; - //xyz2[2] = sg->coord_xyz[(i+1)*3+2]; + xyz2[0] = tri.ver2.x; + xyz2[1] = tri.ver2.y; + xyz2[2] = tri.ver2.z * -1.0f; xyz2[3] = 1.0f; - xyz3[0] = sg->coord_xyz[(i+2)*3]; - xyz3[1] = sg->coord_xyz[(i+2)*3+1]; - xyz3[2] = sg->coord_xyz[(i+2)*3+2]*-1.0f; - //xyz3[2] = sg->coord_xyz[(i+2)*3+2]; + xyz3[0] = tri.ver3.x; + xyz3[1] = tri.ver3.y; + xyz3[2] = tri.ver3.z * -1.0f; xyz3[3] = 1.0f; // sg->matrix = 回転行列*透視変換行列 @@ -240,29 +242,29 @@ xyz3[0] /= xyz3[2]; xyz3[1] /= xyz3[2]; - tex_xy1[0] = sg->coord_tex[(i+0)*3]; - tex_xy1[1] = sg->coord_tex[(i+0)*3+1]; - tex_xy2[0] = sg->coord_tex[(i+1)*3]; - tex_xy2[1] = sg->coord_tex[(i+1)*3+1]; - tex_xy3[0] = sg->coord_tex[(i+2)*3]; - tex_xy3[1] = sg->coord_tex[(i+2)*3+1]; + tex_xy1[0] = tri.ver1.tex_x; + tex_xy1[1] = tri.ver1.tex_y; + tex_xy2[0] = tri.ver2.tex_x; + tex_xy2[1] = tri.ver2.tex_y; + tex_xy3[0] = tri.ver3.tex_x; + tex_xy3[1] = tri.ver3.tex_y; - normal1[0] = sg->normal[(i+0)*3]; - normal1[1] = sg->normal[(i+0)*3+1]; - normal1[2] = sg->normal[(i+0)*3+2]*-1.0f; - //normal1[2] = sg->normal[(i+0)*3+2]; + normal1[0] = tri.normal1.x; + normal1[1] = tri.normal1.y; + normal1[2] = tri.normal1.z * -1.0f; + normal1[3] = 0.0f; - normal2[0] = sg->normal[(i+1)*3]; - normal2[1] = sg->normal[(i+1)*3+1]; - normal2[2] = sg->normal[(i+1)*3+2]*-1.0f; - //normal2[2] = sg->normal[(i+1)*3+2]; + normal2[0] = tri.normal2.x; + normal2[1] = tri.normal2.y; + normal2[2] = tri.normal2.z * -1.0f; + normal2[3] = 0.0f; - normal3[0] = sg->normal[(i+2)*3]; - normal3[1] = sg->normal[(i+2)*3+1]; - normal3[2] = sg->normal[(i+2)*3+2]*-1.0f; - //normal3[2] = sg->normal[(i+2)*3+2]; + normal3[0] = tri.normal3.x; + normal3[1] = tri.normal3.y; + normal3[2] = tri.normal3.z * -1.0f; + normal3[3] = 0.0f; ApplyMatrix(normal1,sg->real_matrix); @@ -272,6 +274,7 @@ obj_draw(xyz1, tex_xy1, normal1); obj_draw(xyz2, tex_xy2, normal2); obj_draw(xyz3, tex_xy3, normal3); + } } glEnd( ); glDisable(GL_TEXTURE_2D);