Mercurial > hg > Game > Cerium
changeset 1370:6af1f474db3e draft
merge
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 20 Jan 2012 17:36:47 +0900 |
parents | 186b0681bc87 (current diff) 6e388be03bb1 (diff) |
children | 66ae94572433 |
files | |
diffstat | 5 files changed, 116 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc Fri Jan 20 17:23:10 2012 +0900 +++ b/Renderer/Engine/SceneGraph.cc Fri Jan 20 17:36:47 2012 +0900 @@ -1273,11 +1273,23 @@ get_matrix(matrix, angle, t, m); } + +// 今の SceneGraph の構造だと、親のスケーリングが子に繁栄される。 void -SceneGraph::scaleIt(float *scale) +SceneGraph::scaleIt(float sx, float sy, float sz) { - for(int i=0;i<4;i++) { - for(int j=0;i<3;j++) { + + float scale[3] = {sx, sy, sz}; + + /* + * | sx*r sx*r sx*r 0 | + * | sy*r sy*r sy*r 0 | + * | sz*r sz*r sz*r 0 | + * | t t t 1 | + */ + + for(int i=0;i<3;i++) { + for(int j=0;j<3;j++) { matrix[i*4+j] = matrix[i*4+j]*scale[i]; } }
--- a/Renderer/Engine/SceneGraph.h Fri Jan 20 17:23:10 2012 +0900 +++ b/Renderer/Engine/SceneGraph.h Fri Jan 20 17:36:47 2012 +0900 @@ -118,7 +118,7 @@ void translateX(float x); void translateY(float y); void translateZ(float z); - void scaleIt(float *scale); + void scaleIt(float sx, float sy, float sz); void angleIt(float xangle, float yangle, float zangle);
--- a/Renderer/Engine/SceneGraphRoot.cc Fri Jan 20 17:23:10 2012 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Fri Jan 20 17:36:47 2012 +0900 @@ -366,9 +366,11 @@ polylist_count = 0; vcsum = 0; + limit = 0; vmember = 0; + images_flag=0; } int polylist; int library_images; @@ -398,10 +400,15 @@ char *name; char *tex_picname; + + int images_flag; + int vcsum; int limit; int vmember; -}; +}; + + static texture_list list[TABLE_SIZE]; @@ -486,7 +493,7 @@ } SceneGraph* -decode_points(collada_state *s, TaskManager *manager){ +decode_points(collada_state *s, TaskManager *manager, SceneGraphPtr sg){ int *vertexp; vertexp = new int[s->vcsum]; for (int i=0;i<s->vcsum;i++){ @@ -551,16 +558,19 @@ */ int count = s->vcsum / 3; //polygonの作成 - SceneGraphPtr sg = new SceneGraph(manager); sg->pp_num = (count + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE; sg->pp = new PolygonPack[sg->pp_num]; for (int i = 0;i < sg->pp_num; i++ ){ - PolygonPackPtr pp = sg->pp; + PolygonPackPtr pp = sg->pp; TrianglePackPtr tri = pp[i].tri; // TrianglePack の size のチェック int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ; pp[i].info.size = tri_size; + /* default texture peste */ + if (s->images_flag==0) { + get_texpic("collada_file/default.jpg", sg, (xmlNodePtr)NULL, manager); + } int k = 0; int m = 0; int n = 0; @@ -603,9 +613,8 @@ } sg->c_xyz[0] = sg->c_xyz[1] = sg->c_xyz[2] = 0; - int tex_id = 0; - sgid_hash.sg_hash_regist(s->name, tex_id); - //get_texpic(s->tex_picname, sg, cur , manager); + //int tex_id = 0; + //sgid_hash.sg_hash_regist(s->name, tex_id); delete []vertexp; delete []vertex_table; @@ -618,7 +627,7 @@ } static void -xml_walk(xmlNodePtr cur, struct collada_state *s, LIST_P list,SceneGraphRoot *root) +xml_walk(xmlNodePtr cur, struct collada_state *s, LIST_P list,SceneGraphPtr sg, SceneGraphRoot *root) { int in_polylist=0; printf("name = %s, child:%s\n", (char *)cur->name, (char *)cur->children); @@ -633,8 +642,10 @@ s->library_images=1;// library_images is wrote at texture image name. only use one image file } else if (s->library_images && !xmlStrcmp(cur->name, (xmlChar*)"init_from")) { s->tex_picname = (char*)xmlGetProp(cur, (xmlChar*)"init_from"); + get_texpic(s->tex_picname, sg, cur , root->tmanager); printf("------------------%s",s->tex_picname); s->library_images=0; + s->images_flag=1; } else if (!s->polylist && !xmlStrcmp(cur->name, (xmlChar*)"input")) { char *semantic = (char*)xmlGetProp(cur, (xmlChar*)"semantic"); if (!xmlStrcmp((xmlChar*)semantic, (xmlChar*)"POSITION")) { @@ -671,7 +682,7 @@ s->name = (char*)xmlGetProp(cur, (xmlChar*)"id"); } for (cur=cur->children; cur; cur=cur->next){ - xml_walk(cur,s,list,root); + xml_walk(cur,s,list,sg,root); } } @@ -699,12 +710,13 @@ /* node analyze */ struct collada_state s; + SceneGraphPtr sg = new SceneGraph(manager); for (cur=cur->children; cur; cur=cur->next){ LIST list; init_list(&list); - xml_walk(cur,&s,&list,this); + xml_walk(cur,&s,&list,sg,this); } - registSceneGraph(decode_points(&s,manager)); + registSceneGraph(decode_points(&s,manager,sg)); xmlFreeDoc(doc); }
--- a/Renderer/Engine/base64_de.cc Fri Jan 20 17:23:10 2012 +0900 +++ b/Renderer/Engine/base64_de.cc Fri Jan 20 17:36:47 2012 +0900 @@ -10,6 +10,7 @@ int nlen; }; +const char* szB64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; unsigned char CtoNum(int c) { @@ -89,3 +90,78 @@ return 0; } + +/*const char *encode(const char *infile, int outfile) +{ + int i,j,outfile_; + char *outputString; + + if (outfile==-1) + outfile_ = strlen(infile); + else + outfile_ = outfile; + + outputString = new char[(int)((double)(outfile_)*1.5)+10]; + for(i = 0,j = 0; i < (outfile_ - (outfile_ % 3)); i+=3) + { + outputString[j] = szB64[(infile[i] & 0xfc) >> 2]; + outputString[j+1] = szB64[((infile[i] &0x03) << 4)|((infile[i+1] & 0xf0) >> 4)]; + outputString[j+2] = szB64[((infile[i+1] & 0x0f) <<2 )|((infile[i+2] & 0xc0) >> 6)]; + outputString[j+3] = szB64[(infile[i+2] & 0x3f)]; + j += 4; + } + i = outfile_-(outfile_ % 3); + switch(outfile_ % 3) + { + case 2: + { + outputString[j] = szB64[(infile[i] & 0xfc) >> 2]; + outputString[j+1] = szB64[((infile[i] &0x03) << 4)|((infile[i+1] & 0xf0) >> 4)]; + outputString[j+2] = szB64[((infile[i+1] & 0x0f) <<2 )]; + outputString[j+3] = szB64[64]; // Pad + outputString[j+4] = '\0'; + } + break; + case 1: + { + outputString[j] = szB64[(infile[i] & 0xfc) >> 2]; + outputString[j+1] = szB64[((infile[i] &0x03) << 4)]; + outputString[j+2] = szB64[64]; // Pad + outputString[j+3] = szB64[64]; // Pad + outputString[j+4] = '\0'; + } + break; + } + outputString[j+4] = '\0'; + return outputString; + +}*/ +void encode(istream& istr, ostream& ostr) +{ + int iRet=76; + int i; + char c[3]; + + i = 0; + while(!istr.eof()) + { + c[0] = c[1] = c[2] = '\0'; + istr.read(c,3); + + ostr << szB64[(c[0] & 0xfc) >> 2]; + i++; if(i >= iRet && iRet != -1){ ostr << endl; i = 0; } + ostr << szB64[((c[0] &0x03) << 4) | ((c[1] & 0xf0) >> 4)]; + i++; if(i >= iRet && iRet != -1){ ostr << endl; i = 0; } + if(istr.gcount() == 1) + ostr << szB64[64]; + else + ostr << szB64[((c[1] & 0x0f) <<2 ) | ((c[2] & 0xc0) >> 6)]; + i++; if(i >= iRet && iRet != -1){ ostr << endl; i = 0; } + if(istr.gcount() == 3) + ostr << szB64[(c[2] & 0x3f)]; + else + ostr << szB64[64]; + i++; if(i >= iRet && iRet != -1){ ostr << endl; i = 0; } + } + ostr.flush(); +}
--- a/Renderer/Test/universe.cc Fri Jan 20 17:23:10 2012 +0900 +++ b/Renderer/Test/universe.cc Fri Jan 20 17:36:47 2012 +0900 @@ -71,6 +71,7 @@ earth->translateX(screen_w / 2); //earth->xyz[1] = screen_h / 2; earth->translateY(screen_h / 2); + earth->scaleIt(3,1,3); earth->stack_xyz[0] = 3.0f; earth->stack_xyz[1] = 3.0f;