Mercurial > hg > Game > Cerium
diff Renderer/Engine/SceneGraph.cc @ 1336:3f95f61faef6 draft
collada file might be readable.
author | e095732 <e095732@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 21 Dec 2011 17:43:20 +0900 |
parents | ab9b7d21b32b |
children | e51127dbd63c |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc Wed Dec 21 13:47:40 2011 +0900 +++ b/Renderer/Engine/SceneGraph.cc Wed Dec 21 17:43:20 2011 +0900 @@ -622,8 +622,165 @@ } +void Polygon::pickup_coordinate(char *cont) +{ + + // size は頂点の数, count は面の数 + char *tmp_cont = cont; + int count = size / 3; + + for (int i = 0; i < pp_num; i++) { + + TrianglePackPtr tri = pp[i].tri; + // TrianglePack の size のチェック + + int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; + + //それを構造体に登録 + pp[i].info.size = tri_size; + + + for (int j = 0; j < tri_size; j++) { + + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.y)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.z)); + + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.y)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.z)); + + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.y)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.z)); + + if (tmp_cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + + count -= 1; + + } + + } + + if (count != 0) { + printf("miss pickup_coordinate size. diff size = %d\n", count); + } + +} + +void Polygon::pickup_normal(char *cont) +{ + + + // size は頂点の数, count は面の数 + char *tmp_cont = cont; + int count = size / 3; + + for (int i = 0; i < pp_num; i++) { + + TrianglePackPtr tri = pp[i].tri; + // TrianglePack の size のチェック + int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; + pp[i].info.size = tri_size; + + for (int j = 0; j < tri_size; j++) { + + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.y)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal1.z)); + + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.y)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal2.z)); + + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.y)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].normal3.z)); + + + if (tmp_cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + + count -= 1; + + } + + + } + + if (count != 0) { + printf("miss pickup_normal size. diff size = %d\n", count); + } + +} + +void Polygon::pickup_model(char *cont) +{ + cont = pickup_float(cont,c_xyz); + cont = pickup_float(cont,c_xyz+1); + cont = pickup_float(cont,c_xyz+2); + + if (cont == NULL) + { + cout << "Analyzing obj data failed model\n"; + } +} + +void Polygon::pickup_texture(char *cont) +{ + + char *tmp_cont = cont; + int count = size / 3; + + for (int i = 0; i < pp_num; i++) { + + TrianglePackPtr tri = pp[i].tri; + // TrianglePack の size のチェック + int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; + pp[i].info.size = tri_size; + + for (int j = 0; j < tri_size; j++) { + + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.tex_x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver1.tex_y)); + + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.tex_x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver2.tex_y)); + + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_x)); + tmp_cont = pickup_float(tmp_cont, &(tri[j].ver3.tex_y)); + + + if (tmp_cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + + count -= 1; + + } + + + } + + if (count != 0) { + printf("miss pickup_texture size. diff size = %d\n", count); + } + + + +} + + /* * surface nodeからポリゴンの情報を読み出す 再帰しない + * + * get_data,get_image,makeTapestorys このファイルの外に追い出すのがよい */ void SceneGraph::get_data(TaskManager *manager, xmlNodePtr cur)