Mercurial > hg > Game > Cerium
changeset 1392:555d2a31cf0c draft
collada moved
author | e095732 <e095732@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 30 Jan 2012 16:12:20 +0900 |
parents | 1ea6e4eb2b0a |
children | e838c90ba498 |
files | Renderer/Engine/Collada.cc Renderer/Test/ball_bound.cc Renderer/Test/collada.cc |
diffstat | 3 files changed, 142 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Collada.cc Fri Jan 27 18:23:56 2012 +0900 +++ b/Renderer/Engine/Collada.cc Mon Jan 30 16:12:20 2012 +0900 @@ -296,7 +296,7 @@ * s->vcsum と s->vertex_float->countの値が違うので大きい方をとりあえず使っておく */ - /* p separate vertex position and nomal position. */ + /* if (s->texcoord_offset == 2){ for (int i=0,j=0; i < s->limit; i+=3,j++) { normal_table[j] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; @@ -312,46 +312,145 @@ normal_table[j+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3+2]; } } + */ + /* p separate vertex position and nomal position. */ /* make triangle */ - int k=0,l=0,size=0; - for (int i=0;i<s->vmember;i++) { - if (s->vcount[i] == 4) { - vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; - vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; - vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; - vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+0]; - vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+1]; - vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+2]; - vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+0]; - vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1]; - vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2]; + int k=0,size=0; + if (s->texcoord_offset == 2){ + for (int i=0;i<s->vmember;i++) { + if (s->vcount[i] == 4) { + vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; + vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; + vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; + vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+3]*3]; + vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1]; + vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2]; + vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; + vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; + vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; + vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; + vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; + vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; + vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+9]*3]; + vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+9]*3+1]; + vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+9]*3+2]; + vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i]*3]; + vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; + vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; + + normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; + normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; + normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+4]*3]; + normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+4]*3+1]; + normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+4]*3+2]; + normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[i+10]*3]; + normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[i+10]*3]; + normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[i+10]*3]; + normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + k+=18; + size +=2; + } else if (s->vcount[i]==3) { + vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; + vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; + vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; + vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+3]*3]; + vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1]; + vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2]; + vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; + vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; + vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; + + normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; + normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; + normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+4]*3]; + normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+4]*3+1]; + normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+4]*3+2]; + normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; - vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i]*3]; - vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; - vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; - vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+0]; - vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+1]; - vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+3]*3+2]; - vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+0]; - vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1]; - vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2]; - k+=18; - l+=4; - size +=2; - } else if (s->vcount[i]==3) { - vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; - vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; - vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; - vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+0]; - vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+1]; - vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+1]*3+2]; - vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+0]; - vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1]; - vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2]; - k+=9; - size++; - } + k+=9; + size++; + } + } + }else{ + for (int i=0;i<s->vmember;i++) { + if (s->vcount[i] == 4) { + vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; + vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; + vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; + vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+2]*3]; + vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1]; + vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2]; + vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+4]*3]; + vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1]; + vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2]; + vertex_table[k+9] = s->vertex_float->u.array[(int)s->pcount[i+4]*3]; + vertex_table[k+10] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1]; + vertex_table[k+11] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2]; + vertex_table[k+12] = s->vertex_float->u.array[(int)s->pcount[i+6]*3]; + vertex_table[k+13] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+1]; + vertex_table[k+14] = s->vertex_float->u.array[(int)s->pcount[i+6]*3+2]; + vertex_table[k+15] = s->vertex_float->u.array[(int)s->pcount[i]*3]; + vertex_table[k+16] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; + vertex_table[k+17] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; + + normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; + normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; + normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+3]*3]; + normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+3]*3+1]; + normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+3]*3+2]; + normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+9] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+10] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+11] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+12] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+13] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+14] = s->normal_float->u.array[(int)s->pcount[i+7]*3]; + normal_table[k+15] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+16] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+17] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + + k+=18; + size +=2; + } else if (s->vcount[i]==3) { + vertex_table[k] = s->vertex_float->u.array[(int)s->pcount[i]*3]; + vertex_table[k+1] = s->vertex_float->u.array[(int)s->pcount[i]*3+1]; + vertex_table[k+2] = s->vertex_float->u.array[(int)s->pcount[i]*3+2]; + vertex_table[k+3] = s->vertex_float->u.array[(int)s->pcount[i+2]*3]; + vertex_table[k+4] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+1]; + vertex_table[k+5] = s->vertex_float->u.array[(int)s->pcount[i+2]*3+2]; + vertex_table[k+6] = s->vertex_float->u.array[(int)s->pcount[i+4]*3]; + vertex_table[k+7] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+1]; + vertex_table[k+8] = s->vertex_float->u.array[(int)s->pcount[i+4]*3+2]; + + normal_table[k] = s->normal_float->u.array[(int)s->pcount[i+1]*3]; + normal_table[k+1] = s->normal_float->u.array[(int)s->pcount[i+1]*3+1]; + normal_table[k+2] = s->normal_float->u.array[(int)s->pcount[i+1]*3*2]; + normal_table[k+3] = s->normal_float->u.array[(int)s->pcount[i+3]*3]; + normal_table[k+4] = s->normal_float->u.array[(int)s->pcount[i+3]*3+1]; + normal_table[k+5] = s->normal_float->u.array[(int)s->pcount[i+3]*3+2]; + normal_table[k+6] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+7] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + normal_table[k+8] = s->normal_float->u.array[(int)s->pcount[i+5]*3]; + k+=9; + size++; + } + } } /**
--- a/Renderer/Test/ball_bound.cc Fri Jan 27 18:23:56 2012 +0900 +++ b/Renderer/Test/ball_bound.cc Mon Jan 30 16:12:20 2012 +0900 @@ -115,7 +115,8 @@ // random な値が欲しいなら、man random に方法が書いてあります。 srandom(100); - sgroot->createFromXMLfile("xml_file/Ball.xml"); + // sgroot->createFromXMLfile("xml_file/Ball.xml"); + sgroot->createFromXMLfile("/Users/YuSUGIMOTO/Desktop/sample.xml"); sgroot->OnLightSysSwitch(); @@ -125,7 +126,7 @@ light->xyz[1] = screen_h / 2; light->xyz[2] = -100; - ball = sgroot->createSceneGraph("Ball"); + ball = sgroot->createSceneGraph("Cube"); ball->set_move_collision(ball_move, ball_collision); h0 = screen_h/2;
--- a/Renderer/Test/collada.cc Fri Jan 27 18:23:56 2012 +0900 +++ b/Renderer/Test/collada.cc Mon Jan 30 16:12:20 2012 +0900 @@ -106,8 +106,8 @@ } } -static const char *collada_file="collada_file/ball.dae"; -static const char *name="Ball"; +static const char *collada_file="collada_file/sample.dae";//"collada_file/ball.dae"; +static const char *name="Cube"; MainLoopPtr ball_bound::init(Viewer *sgroot, int screen_w, int screen_h)