Mercurial > hg > Members > kono > Cerium
diff Renderer/Engine/SceneGraph.cc @ 860:649e4cb84683
Still on the way
author | yutaka@localhost.localdomain |
---|---|
date | Fri, 18 Jun 2010 01:30:06 +0900 |
parents | 0e5dcda89c8e |
children | 000a8b63ad9a |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/SceneGraph.cc Fri Jun 18 01:30:06 2010 +0900 @@ -16,7 +16,8 @@ SceneGraphPtr scene_graph_viewer = NULL; static TextureHash texture_hash; -struct texture_list list[TABLE_SIZE]; +texture_list list[TABLE_SIZE]; + extern int decode(char *cont, FILE *outfile); @@ -138,12 +139,38 @@ 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)*TABLE_SIZE); + //data = new float[size*3*3]; - //data = new float[size*3*3]; +#if SPE_CREATE_POLYGON + + /* CreatePolygon を spe 側でやるために。 + size は頂点の数。speに渡す場合には、16の倍数にして + 16Kbyte以上の場合、16Kbyte毎に分割できるようにしなければならない。 + CreatePolygonFromSceneGraphTaskをspeで動かすために、speに渡すのは + TrianglePackでよい。 + polygon_pack 1つには triangle が 128 になってる。polygon_pack の + triangle 数に合わせる方が楽だよね。なんか変な気もするけど、polygon + クラスにもTrianglePackを持たす。SceneGraph は自分の polygon 数が入る + 分だけ、TrianglePackを持つ。CreatePolygonTask にはSceneGraph 側の + TrianglePack を input に、polygon_pack の TriganlePack を output とする + */ + + int tri_pack_size = sizeof(TrianglePack)*(size/3); + tri_pack = (TrianglePackPtr)manager->allocate(tri_pack_size); + texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); + sg_matrix = (float*)manager->allocate(sizeof(float)*32); + matrix = sg_matrix; + real_matrix = sg_matrix + 16; + +#else + 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); +#endif + get_data(manager, surface->children); finalize = &SceneGraph::finalize_original; @@ -170,10 +197,23 @@ size = 0; //data = NULL; + +#if SPE_CREATE_POLYGON + + tri_pack = NULL; + sg_matrix = NULL; + matrix = NULL; + real_matrix = NULL; + texture_info = NULL; + +#else + coord_xyz = NULL; normal = NULL; coord_tex = NULL; +#endif + texture_id = -1; move = no_move; collision = no_collision; @@ -199,9 +239,23 @@ SceneGraph::finalize_original() { //delete [] data; + +#if SPE_CREATE_POLYGON + + free(tri_pack); + free(sg_matrix); + free(matrix); + free(real_matrix); + free(texture_info); + +#else + free(coord_xyz); free(coord_tex); free(normal); + +#endif + } /** @@ -497,13 +551,29 @@ texture_id = tex_id; } - // こんなことすると list[] のいみあるのかなーと - // 微妙に思う、自分で書き換えた感想 by gongo - texture_info.t_w = list[texture_id].t_w; - texture_info.t_h = list[texture_id].t_h;; - texture_info.pixels_orig = list[texture_id].pixels_orig; - texture_info.pixels = list[texture_id].pixels; - texture_info.scale_max = list[texture_id].scale_max; + +#if SPE_CREATE_POLYGON + + + texture_info->t_w = list[texture_id].t_w; + texture_info->t_h = list[texture_id].t_h;; + texture_info->pixels_orig = list[texture_id].pixels_orig; + texture_info->pixels = list[texture_id].pixels; + texture_info->scale_max = list[texture_id].scale_max; + + +#else + + // こんなことすると list[] のいみあるのかなーと + // 微妙に思う、自分で書き換えた感想 by gongo + texture_info.t_w = list[texture_id].t_w; + texture_info.t_h = list[texture_id].t_h;; + texture_info.pixels_orig = list[texture_id].pixels_orig; + texture_info.pixels = list[texture_id].pixels; + texture_info.scale_max = list[texture_id].scale_max; + +#endif + }