Mercurial > hg > Game > Cerium
changeset 1293:82dc8a041cfe draft
refactoring matrix_test.cc
author | Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 02 Dec 2011 15:03:54 +0900 |
parents | 90efd2aac2cb |
children | 3fa46ff7824e |
files | Renderer/Engine/Camera.cc Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/DrawSpan.cc |
diffstat | 4 files changed, 4 insertions(+), 111 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Camera.cc Fri Dec 02 12:27:51 2011 +0900 +++ b/Renderer/Engine/Camera.cc Fri Dec 02 15:03:54 2011 +0900 @@ -313,80 +313,12 @@ updatePerspective(w, h); updateScreen(w, h); -/* - float det = determinant(this->m_screen); - printf ("m_screen det %f\n",det); - - float inv_m[16]; - float re_m[16]; - inverseMatrix(inv_m, this->m_screen); - matrix4x4(re_m, this->m_screen, inv_m); - for (int i = 0; i < 16; i++) printf("%f ",re_m[i]); - printf("\n"); -*/ matrix4x4(tmp, this->m_pers, this->m_screen); matrix4x4(this->matrix, this->m_view, tmp); - //matrix4x4(this->real_matrix, this->real_matrix, this->m_view); - -/* - //float normal_temp[4] = { 0.0490661252103785, 0.00483240745105885, -0.998783842077487, 0}; - float normal_temp[4] = { 0.0, -0.0, 1.0, 0.0}; - float result_v[4]; - applyMatrix(result_v, normal_temp, matrix); - printf("nomral_v \n"); - for (int i = 0; i < 4; i++) printf(" %f ", result_v[i]); - printf("\n"); - normalize(result_v, result_v); - printf("nomralize \n"); - for (int i = 0; i < 4; i++) printf(" %f ", result_v[i]); - printf("\n"); - - float object_temp[4] = { 20, 20, 20, 1}; - float light_temp[4] = { 30, 10, 40, 1 }; - float re_object[4]; - float re_light[4]; - float world_light_vec[4]; - - for (int i = 0; i < 4; i++) world_light_vec[i] = light_temp[i] - object_temp[i]; - - printf("light nomralize 1\n"); - normalize(world_light_vec, world_light_vec); - for (int i = 0; i < 4; i++) printf(" %f ", world_light_vec[i]); - printf("\n"); - - float p = innerProduct(world_light_vec, normal_temp); - printf("no mul matrix p %f\n",p); - - applyMatrix(re_object, object_temp, matrix); - applyMatrix(re_light, light_temp, matrix); - - re_object[0] /= re_object[3]; - re_object[1] /= re_object[3]; - re_object[2] /= re_object[3]; - - re_light[0] /= re_light[3]; - re_light[1] /= re_light[3]; - re_light[2] /= re_light[3]; - - for (int i = 0; i < 4; i++) world_light_vec[i] = re_light[i] - re_object[i]; - printf("light nomralize 2\n"); - for (int i = 0; i < 4; i++) printf(" %f ", world_light_vec[i]); - printf("\n"); - printf("light nomralize 3\n"); - normalize(world_light_vec, world_light_vec); - for (int i = 0; i < 4; i++) printf(" %f ", world_light_vec[i]); - printf("\n"); - - p = innerProduct(world_light_vec, result_v); - printf("mul matrix p %f\n",p); -*/ /* 法線ベクトル、光源ベクトル に使うビュー座標変換までの行列 */ for (int i = 0; i < 16; i++) this->real_matrix[i] = this->m_view[i]; - //matrix4x4(real_matrix, m_view, m_pers); - - #else get_matrix(matrix, angle, xyz, NULL); #endif
--- a/Renderer/Engine/SceneGraphRoot.cc Fri Dec 02 12:27:51 2011 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Fri Dec 02 15:03:54 2011 +0900 @@ -469,17 +469,9 @@ for (int i = 0; i < light_num; i++) { - //printf("light_xyz 1\n"); - //for (int j = 0; j < 4; j++) printf(" %f",light_vector[i*4+j]); - //printf("\n"); - get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix); ApplyMatrix(&light_vector_tmp[i*4], light[i]->matrix); - //printf("light_xyz 2\n"); - //for (int j = 0; j < 4; j++) printf(" %f",light_vector[i*4+j]); - //printf("\n"); - light_vector_tmp[i*4] /= light_vector_tmp[i*4+3]; light_vector_tmp[i*4+1] /= light_vector_tmp[i*4+3]; light_vector_tmp[i*4+2] /= light_vector_tmp[i*4+3];
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Fri Dec 02 12:27:51 2011 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Fri Dec 02 15:03:54 2011 +0900 @@ -73,10 +73,10 @@ float *matrix = (float*)smanager->get_input(rbuf, 1); //float real_matrix[16]; // = (float*)smanager->get_input(rbuf, 2); - float *real_matrix = (float*)smanager->get_input(rbuf, 2); + //float *real_matrix = (float*)smanager->get_input(rbuf, 2); //for (int i = 0; i<16; i++) real_matrix[i]=matrix[i]; - //real_matrix[4*0+3]=real_matrix[4*1+3]=real_matrix[4*2+3]=0; + real_matrix[4*0+3]=real_matrix[4*1+3]=real_matrix[4*2+3]=0; texture_list *tritexinfo = (texture_list*)smanager->get_input(rbuf, 3); @@ -115,6 +115,7 @@ ApplyMatrix(xyz2, matrix); ApplyMatrix(xyz3, matrix); + // このif文は、視錐台カリングに変えられる. 違うやり方があるはず if (xyz1[2] > 100 && xyz2[2] > 100 && xyz3[2] > 100) { /* @@ -193,22 +194,6 @@ ApplyMatrix(normal2,real_matrix); ApplyMatrix(normal3,real_matrix); - -/* - normal1[0] /= normal1[3]; - normal1[1] /= normal1[3]; - normal1[2] /= normal1[3]; - - normal2[0] /= normal1[3]; - normal2[1] /= normal1[3]; - normal2[2] /= normal1[3]; - - normal3[0] /= normal1[3]; - normal3[1] /= normal1[3]; - normal3[2] /= normal1[3]; -*/ - - triangle->normal1.x = normal1[0]; triangle->normal1.y = normal1[1]; triangle->normal1.z = normal1[2];
--- a/Renderer/Engine/task/DrawSpan.cc Fri Dec 02 12:27:51 2011 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Fri Dec 02 15:03:54 2011 +0900 @@ -567,33 +567,18 @@ int tmp_rgb[3] = {0,0,0}; int light_num = 4; - //float inner_product = 0.2; // 0.2 は環境光ってことにしてみた。 - float inner_product = 0; // 0.2 は環境光ってことにしてみた。 + float inner_product = 0; int *light_switch = (int*)smanager->global_get(LightSwitch); - //printf("light_switch\n"); - //for (int i = 0; i < 4; i++) printf(" %d",light_switch[i]); - //printf("\n"); - for (int i = 0; i < light_num; i++) { // 光源のスイッチが入ってたら if (light_switch[i] == 1) { - //printf("light_xyz\n"); - //for (int j = 0; j < 4; j++) printf(" %f",light_xyz[i*4+j]); - //printf("\n"); - light_vector[0] = world_x - light_xyz[i*4]; light_vector[1] = world_y - light_xyz[i*4+1]; light_vector[2] = light_xyz[i*4+2] - world_z; - //light_vector[2] = world_z - light_xyz[i*4+2]; - //light_vector[3] = 0; - -// light_vector[0] = 0; -// light_vector[1] = 0; -// light_vector[2] = -1; normalize(light_vector, light_vector); @@ -614,7 +599,6 @@ tmp_rgb[2] = (unsigned char)(rgb[2]*inner_product); } - } int rgb_flag[3];