Mercurial > hg > Members > kono > Cerium
changeset 845:1e3b67117ad9
light bug fix.
author | Yutaka_Kinjyo |
---|---|
date | Thu, 03 Jun 2010 02:55:29 +0900 |
parents | 61bfd8e246fc |
children | dbcfa04ee4db |
files | Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/DrawSpan.cc Renderer/Test/Makefile.macosx |
diffstat | 4 files changed, 34 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc Wed Jun 02 17:04:26 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Thu Jun 03 02:55:29 2010 +0900 @@ -408,6 +408,8 @@ get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix); + //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix); + } if (t->children != NULL && c != NULL) {
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Wed Jun 02 17:04:26 2010 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Thu Jun 03 02:55:29 2010 +0900 @@ -196,8 +196,6 @@ normal3[0] /= normal3[2]; normal3[1] /= normal3[2]; - //ここでpolygonに法線ベクトルの情報がわたった - triangle->normal1.x = normal1[0]; triangle->normal1.y = normal1[1]; triangle->normal1.z = normal1[2];
--- a/Renderer/Engine/task/DrawSpan.cc Wed Jun 02 17:04:26 2010 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Thu Jun 03 02:55:29 2010 +0900 @@ -57,7 +57,13 @@ static float innerProduct1(float *v0, float *v1) { - return (v0[0]*v1[0] + v0[1]*v1[1] + v0[2]*v1[2]); + + if (v0[2] > 0) { + return 0; + } else { + return (v0[0]*v1[0] + v0[1]*v1[1] + v0[2]*v1[2]); + } + } @@ -194,12 +200,19 @@ #else int alpha = color & 0xff000000; #endif + + int *light_sysswitch = (int*)smanager->global_get(LightSysSwitch); + /*完全に透けているか判断*/ int flag = (alpha != 0); - color = infinity_light_calc(color,normal_x,normal_y,normal_z, - smanager,localx,localy,zpos, - world_x,world_y,world_z); + //printf("light_sysswitch %d\n",light_sysswitch); + + //if ( *light_sysswitch == 1) { + color = infinity_light_calc(color,normal_x,normal_y,normal_z, + smanager,localx,localy,zpos, + world_x,world_y,world_z); + //} g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag); int *point = &g->linebuf[localy][localx] ; @@ -415,6 +428,7 @@ int light_num = 4; for (int i = 0; i < light_num; i++) { + 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; @@ -428,9 +442,10 @@ //printf("inner_product %f\n",inner_product); // 内積がマイナスの場合は色がない。 - flag = (inner_product > 0); + flag = (inner_product > 0); // 内積を rgb にかけていく + tmp_rgb[0] += (unsigned char)(rgb[0]*inner_product*flag); tmp_rgb[1] += (unsigned char)(rgb[1]*inner_product*flag); tmp_rgb[2] += (unsigned char)(rgb[2]*inner_product*flag); @@ -463,7 +478,7 @@ run(SchedTask *smanager, void *rbuf, void *wbuf) { - + //get_param(5) is spack->info.size if ((int)smanager->get_param(5) == 0) { int rangex_start = (long)smanager->get_param(2); @@ -530,13 +545,13 @@ span = &spack->span[t]; if (span->length_x != 1) { - drawLine1( - smanager, g, - span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); + drawLine1( + smanager, g, + span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); } else { - drawDot1( - smanager, g, - span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); + drawDot1( + smanager, g, + span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); } next_span = span;
--- a/Renderer/Test/Makefile.macosx Wed Jun 02 17:04:26 2010 +0900 +++ b/Renderer/Test/Makefile.macosx Thu Jun 03 02:55:29 2010 +0900 @@ -10,7 +10,7 @@ .cc.o: $(CC) $(CFLAGS) -c $< -o $@ -ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange +ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer oFLAGS=-g -O2 CFLAGt=-g -O2 @@ -80,6 +80,10 @@ SgRootChange : $(SGCHANGE_OBJ) $(CC) -o $@ $? $(LIBS) +VIEWER_OBJ = viewer.o +viewer : $(VIEWER_OBJ) + $(CC) -o $@ $? $(LIBS) + run: $(TARGET) sudo ./$(TARGET) -width 576 -height 384 -bpp 32