diff Renderer/Engine/task/DrawSpan.cc @ 845:1e3b67117ad9

light bug fix.
author Yutaka_Kinjyo
date Thu, 03 Jun 2010 02:55:29 +0900
parents 41302b72c895
children dbcfa04ee4db
line wrap: on
line diff
--- 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;