Mercurial > hg > Members > kono > Cerium
changeset 202:3f4c6a75d7e0
fix SceneGraphIterator::hasNext(), next()
add variable SceneGraph::sgid, flag_drawbale
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 26 Jan 2009 16:58:35 +0900 |
parents | b257e27d995c |
children | 5c6c9667ac61 |
files | TaskManager/Test/test_render/ChangeLog TaskManager/Test/test_render/SceneGraph.cpp TaskManager/Test/test_render/SceneGraph.h TaskManager/Test/test_render/SceneGraphIterator.cpp TaskManager/Test/test_render/SceneGraphIterator.h TaskManager/Test/test_render/SceneGraphRoot.cpp TaskManager/Test/test_render/ieshoot.cpp TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp |
diffstat | 8 files changed, 91 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/ChangeLog Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/ChangeLog Mon Jan 26 16:58:35 2009 +0900 @@ -1,5 +1,13 @@ 2009-01-26 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + * SceneGraphIterator.cpp (SceneGraphIterator::hasNext) + (SceneGraphIterator::next): fix + 検索する引数を int id に変更。 + + * SceneGraph.h (class SceneGraph): add variable + int flag_drawbale : この SceneGraph は描画する物かどうか + int sgid : SceneGraph の ID 。ID は SGList.h にあるものを使う + * SceneGraphIterator.cpp : add file SceneGraph を走査する用。 基本、Java の Iterator を参考にしてます。
--- a/TaskManager/Test/test_render/SceneGraph.cpp Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraph.cpp Mon Jan 26 16:58:35 2009 +0900 @@ -126,6 +126,9 @@ collision = no_collision; flag_remove = 0; + flag_drawable = 1; + sgid = -1; + frame = 0; }
--- a/TaskManager/Test/test_render/SceneGraph.h Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraph.h Mon Jan 26 16:58:35 2009 +0900 @@ -41,6 +41,12 @@ // Tree から削除されていたら 1 をセット。default = 0 int flag_remove; + // SceneGraph ID (SGList.h) + int sgid; + + // この SceneGraph は描画するものかどうか (0:しない 1:する + int flag_drawable; + // 関数ポインタ move_func move; collision_func collision;
--- a/TaskManager/Test/test_render/SceneGraphIterator.cpp Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraphIterator.cpp Mon Jan 26 16:58:35 2009 +0900 @@ -21,17 +21,17 @@ /** * 指定した名前をもつ SceneGraph が以降存在するか * - * @param name 検索したい SceneGraph の名前 + * @param id 検索したい SceneGraph の ID * @retval 1 next がある * @retval 0 next がない */ int -SceneGraphIterator::hasNext(const char *name) +SceneGraphIterator::hasNext(int id) { SceneGraphPtr p; for (p = cur->next; p; p = p->next) { - if (strcmp(p->name, name) == 0) { + if (p->sgid == id) { return 1; } } @@ -49,16 +49,18 @@ } /** - * iterator を指定した名前を持つ SceneGraph まで進める + * iterator を指定した ID を持つ SceneGraph まで進める * SceneGraph が無い場合、NULL にする + * + * @param id 検索したい SceneGraph の ID */ void -SceneGraphIterator::next(const char *name) +SceneGraphIterator::next(int id) { SceneGraphPtr p; for (p = cur->next; p; p = p->next) { - if (strcmp(p->name, name) == 0) { + if (p->sgid == id) { break; } }
--- a/TaskManager/Test/test_render/SceneGraphIterator.h Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraphIterator.h Mon Jan 26 16:58:35 2009 +0900 @@ -15,9 +15,9 @@ void set(SceneGraphPtr list); int hasNext(void); - int hasNext(const char *name); + int hasNext(int id); void next(void); - void next(const char *name); + void next(int id); void remove(void); SceneGraphPtr get(void); };
--- a/TaskManager/Test/test_render/SceneGraphRoot.cpp Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraphRoot.cpp Mon Jan 26 16:58:35 2009 +0900 @@ -116,6 +116,8 @@ /* ユーザーにはオリジナルの clone を返す */ p = src->clone(); + p->sgid = id; + p->flag_drawable = 1; addNext(p);
--- a/TaskManager/Test/test_render/ieshoot.cpp Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/ieshoot.cpp Mon Jan 26 16:58:35 2009 +0900 @@ -30,8 +30,8 @@ SceneGraphIteratorPtr it = sgroot->getIterator(tree); static int damage = 0; - for (; it->hasNext("IETAMA");) { - it->next("IETAMA"); + for (; it->hasNext(IETAMA);) { + it->next(IETAMA); SceneGraphPtr tama = it->get(); if (node->xyz[0] - boss_radius_x < tama->xyz[0] + tama_radius
--- a/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Mon Jan 26 16:46:59 2009 +0900 +++ b/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Mon Jan 26 16:58:35 2009 +0900 @@ -89,81 +89,82 @@ send_pp->init(); while (sg) { - for (int i = 0; i < sg->size; i += 3) { - if (pp->info.size >= MAX_SIZE_TRIANGLE) { - PolygonPackPtr next; + 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); + smanager->mainMem_alloc(0, sizeof(PolygonPack)); + smanager->mainMem_wait(); + next = (PolygonPackPtr)smanager->mainMem_get(0); - pp->next = next; + pp->next = next; - tmp_pp = pp; - pp = send_pp; - send_pp = tmp_pp; + tmp_pp = pp; + pp = send_pp; + send_pp = tmp_pp; - smanager->dma_wait(PP_STORE); - smanager->dma_store(send_pp, (uint32)pp_addr, - sizeof(PolygonPack), PP_STORE); + smanager->dma_wait(PP_STORE); + smanager->dma_store(send_pp, (uint32)pp_addr, + sizeof(PolygonPack), PP_STORE); - pp_addr = next; + pp_addr = next; - smanager->dma_wait(PP_LOAD); - smanager->dma_load(pp, (uint32)pp_addr, - sizeof(PolygonPack), PP_LOAD); - smanager->dma_wait(PP_LOAD); - pp->init(); - } + smanager->dma_wait(PP_LOAD); + smanager->dma_load(pp, (uint32)pp_addr, + sizeof(PolygonPack), PP_LOAD); + smanager->dma_wait(PP_LOAD); + pp->init(); + } - TrianglePack *triangle = &pp->tri[pp->info.size++]; + TrianglePack *triangle = &pp->tri[pp->info.size++]; - xyz1[0] = sg->data[(i+0)*3]; - xyz1[1] = sg->data[(i+0)*3+1]; - xyz1[2] = sg->data[(i+0)*3+2]*-1; - xyz1[3] = 1; - xyz2[0] = sg->data[(i+1)*3]; - xyz2[1] = sg->data[(i+1)*3+1]; - xyz2[2] = sg->data[(i+1)*3+2]*-1; - xyz2[3] = 1; - xyz3[0] = sg->data[(i+2)*3]; - xyz3[1] = sg->data[(i+2)*3+1]; - xyz3[2] = sg->data[(i+2)*3+2]*-1; - xyz3[3] = 1; + xyz1[0] = sg->data[(i+0)*3]; + xyz1[1] = sg->data[(i+0)*3+1]; + xyz1[2] = sg->data[(i+0)*3+2]*-1; + xyz1[3] = 1; + xyz2[0] = sg->data[(i+1)*3]; + xyz2[1] = sg->data[(i+1)*3+1]; + xyz2[2] = sg->data[(i+1)*3+2]*-1; + xyz2[3] = 1; + xyz3[0] = sg->data[(i+2)*3]; + xyz3[1] = sg->data[(i+2)*3+1]; + xyz3[2] = sg->data[(i+2)*3+2]*-1; + xyz3[3] = 1; - rotate(xyz1, sg->matrix); - rotate(xyz2, sg->matrix); - rotate(xyz3, sg->matrix); + rotate(xyz1, sg->matrix); + rotate(xyz2, sg->matrix); + rotate(xyz3, sg->matrix); - apply_matrix(xyz1, mat); - apply_matrix(xyz2, mat); - apply_matrix(xyz3, mat); + apply_matrix(xyz1, mat); + apply_matrix(xyz2, mat); + apply_matrix(xyz3, mat); - triangle->ver1.x = xyz1[0]; - triangle->ver1.y = xyz1[1]; - triangle->ver1.z = xyz1[2]; - triangle->ver1.tex_x = sg->data[(i+0)*3 + sg->size*6]; - triangle->ver1.tex_y = sg->data[(i+0)*3 + sg->size*6+1]; + triangle->ver1.x = xyz1[0]; + triangle->ver1.y = xyz1[1]; + triangle->ver1.z = xyz1[2]; + triangle->ver1.tex_x = sg->data[(i+0)*3 + sg->size*6]; + triangle->ver1.tex_y = sg->data[(i+0)*3 + sg->size*6+1]; - triangle->ver2.x = xyz2[0]; - triangle->ver2.y = xyz2[1]; - triangle->ver2.z = xyz2[2]; - triangle->ver2.tex_x = sg->data[(i+1)*3 + sg->size*6]; - triangle->ver2.tex_y = sg->data[(i+1)*3 + sg->size*6+1]; + triangle->ver2.x = xyz2[0]; + triangle->ver2.y = xyz2[1]; + triangle->ver2.z = xyz2[2]; + triangle->ver2.tex_x = sg->data[(i+1)*3 + sg->size*6]; + triangle->ver2.tex_y = sg->data[(i+1)*3 + sg->size*6+1]; - triangle->ver3.x = xyz3[0]; - triangle->ver3.y = xyz3[1]; - triangle->ver3.z = xyz3[2]; - triangle->ver3.tex_x = sg->data[(i+2)*3 + sg->size*6]; - triangle->ver3.tex_y = sg->data[(i+2)*3 + sg->size*6+1]; + triangle->ver3.x = xyz3[0]; + triangle->ver3.y = xyz3[1]; + triangle->ver3.z = xyz3[2]; + triangle->ver3.tex_x = sg->data[(i+2)*3 + sg->size*6]; + triangle->ver3.tex_y = sg->data[(i+2)*3 + sg->size*6+1]; - 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; + 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) {