changeset 1292:90efd2aac2cb draft

add matrix test and debug light vector
author Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Fri, 02 Dec 2011 12:27:51 +0900
parents fe598e9b7f0e
children 82dc8a041cfe
files Renderer/Engine/Camera.cc Renderer/Engine/SceneGraph.cc Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/SceneGraphRoot.h Renderer/Engine/matrix_calc.cc Renderer/Engine/matrix_calc.h Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/DrawSpan.cc Renderer/Engine/viewer.cc Renderer/Engine/viewer.h Renderer/Test/Makefile.macosx Renderer/Test/ball_bound.cc Renderer/Test/universe.cc Renderer/Test/viewer_2.cc Renderer/Test/xml_file/universe.xml
diffstat 15 files changed, 274 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Camera.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/Camera.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -119,9 +119,8 @@
     sgroot = sgroot_;
 
     fov  = 60.0f;
-    near = 0.0f;
-    far  = 10.0f;
-
+    near = 100.0f;
+    far  = 1000.0f;
 
     zd[0] =  0.0f;
     zd[1] =  0.0f;
@@ -313,12 +312,81 @@
     updateView();
     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/SceneGraph.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -135,6 +135,7 @@
       matrix[i]      = 0;
       real_matrix[i] = 0;
     }
+
     for (int i = 0; i < 4; i++) {
       matrix[i*4+i]      = 1;
       real_matrix[i*4+i] = 1;
--- a/Renderer/Engine/SceneGraphRoot.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -41,19 +41,9 @@
 
     screen_w = (int)w;
     screen_h = (int)h;
-    int light_num = 4;
-    light_sysswitch = 0;
 
-    for (int i = 0; i < light_num; i++) {
-        light[i] = new SceneGraph(sgroot->tmanager);
-	light[i]->xyz[0] = 0;
-	light[i]->xyz[1] = 0;
-	light[i]->xyz[2] = 0;
-
-	light_switch[i] = 0;
-
-    }
-
+    light_init();
+ 
     move_finish_flag = 0;
 
     gtask_array = NULL;
@@ -64,6 +54,7 @@
     //sg_exec_tree = camera;
 }
 
+
 SceneGraphRoot::~SceneGraphRoot()
 {
     SceneGraphPtr p = sg_available_list;
@@ -98,6 +89,35 @@
     }
 }
 
+void
+SceneGraphRoot::light_init()
+{
+
+   int light_num = 4;
+    light_sysswitch = 0;
+
+    for (int i = 0; i < light_num; i++) {
+
+        light[i] = new SceneGraph(sgroot->tmanager);
+	light[i]->xyz[0] = 0;
+	light[i]->xyz[1] = 0;
+	light[i]->xyz[2] = 0;
+	light[i]->xyz[3] = 1.0f;
+
+	light_switch[i] = 0;
+
+    }
+
+    for (int i = 0; i < 4; i++) {
+        light_vector[i*4]   = 0.0f;
+        light_vector[i*4+1] = 0.0f;
+        light_vector[i*4+2] = 0.0f;
+        light_vector[i*4+3] = 1.0f;
+    }
+
+}
+
+
 /**
  * xml ファイルから生成された SceneGraph を sg_src に登録する。
  *
@@ -437,23 +457,46 @@
 SceneGraphRoot::lightCalc()
 {
     int light_num = 4;
+    float light_vector_tmp[16];
+    
+    for (int i = 0; i < 4; i++) {
+        light_vector_tmp[i*4]   = 0.0f;
+        light_vector_tmp[i*4+1] = 0.0f;
+        light_vector_tmp[i*4+2] = 0.0f;
+        light_vector_tmp[i*4+3] = 1.0f;
+    }
+
+
     for (int i = 0; i < light_num; i++) {
 
-        get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->real_matrix);
-      
-	light_vector[i*4] = 0.0f;
-	light_vector[i*4+1] = 0.0f;
-	light_vector[i*4+2] = 0.0f;
-	light_vector[i*4+3] = 1.0f;
+        //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);
 
-	ApplyMatrix(&light_vector[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[i*4] /= light_vector[i*4+2];
-	light_vector[i*4+1] /= light_vector[i*4+2];
+        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];
 
 	/*SIMD演算のため*/
-	light_vector[i*4+2] *= -1;
-	light_vector[i*4+3] *= -1;
+	light_vector_tmp[i*4+2] *= -1;
+	light_vector_tmp[i*4+3] *= -1;
+
+    for (int i = 0; i < 4; i++) {
+        light_vector[i*4] = light_vector_tmp[i*4];
+        light_vector[i*4+1] = light_vector_tmp[i*4+1];
+        light_vector[i*4+2] = light_vector_tmp[i*4+2];
+        light_vector[i*4+3] = light_vector_tmp[i*4+3];
+    }
+
+
+
 
     }
 }
@@ -532,7 +575,7 @@
 	    /*親の回転、座標から、子の回転、座標を算出*/
 	    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, cur_parent->real_matrix);
 	    //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix);
 
 	}
@@ -628,16 +671,12 @@
     for (int i = 0; i < light_num; i++) {
 
 	get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix);
-
-	light_vector[i*4] = 0.0f;
-	light_vector[i*4+1] = 0.0f;
-	light_vector[i*4+2] = 0.0f;
-	light_vector[i*4+3] = 1.0f;
-
 	ApplyMatrix(&light_vector[i*4], light[i]->matrix);
 
-	light_vector[i*4] /= light_vector[i*4+2];
-	light_vector[i*4+1] /= light_vector[i*4+2];
+	light_vector[i*4] /= light_vector[i*4+3];
+	light_vector[i*4+1] /= light_vector[i*4+3];
+	light_vector[i*4+2] /= light_vector[i*4+3];
+
 
 	light_vector[i*4+2] *= -1;
 	light_vector[i*4+3] *= -1;
--- a/Renderer/Engine/SceneGraphRoot.h	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Fri Dec 02 12:27:51 2011 +0900
@@ -144,6 +144,9 @@
     // void speExecute(int screen_w, int screen_h);
     // void speExecute(int screen_w, int screen_h, Application *app);
 
+    // initialize API
+    void light_init();
+
     /* System API */
     void registSceneGraph(SceneGraphPtr sg);
     void registSceneGraphList(SceneGraphPtr sg);
--- a/Renderer/Engine/matrix_calc.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/matrix_calc.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -27,6 +27,37 @@
     m[15] = 1.0f;
 }
 
+float
+determinant(float *m) {
+
+    float det = 1.0f;
+    float buf;
+    int n = 4; // 4次                                                                  
+
+    float det_m[16];
+    for (int i = 0; i < 16; i++) det_m[i] = m[i];
+
+    // 三角行列を作成                                                                   
+    for (int i = 0; i < n; i++) {
+        for (int j = 0; j < n; j++) {
+            if ( i < j ) {
+                buf = det_m[j*n+i] / det_m[i*n+i];
+                for (int k = 0; k < n; k++) {
+                    det_m[j*n+k] -= det_m[i*n+k] * buf;
+                }
+            }
+        }
+    }
+
+    // 対角部分の積                                                                     
+    for (int i = 0; i < n; i++) {
+        det *= det_m[i*n+i];
+    }
+
+    return det;
+}
+
+
 void
 inverseMatrix(float *m0, float *m1)
 {
@@ -144,6 +175,25 @@
     }
 }
 
+/**
+ *     xyz = xyz * xyz1
+ */
+void mulMatrix4x4(float *xyz, float *xyz1) //xyz[16]
+{
+
+    float tmp[16];
+    for(int i = 0; i<16; i++) {
+        tmp[i] = xyz[i];
+    }
+
+  for(int t=0; t<16; t+=4) {
+      for(int i=0; i<4; i++) {
+      	  xyz[t+i] = tmp[t]*xyz1[i] + tmp[t+1]*xyz1[4+i] + tmp[t+2]*xyz1[8+i] + tmp[t+3]*xyz1[12+i];
+      }
+  }
+}
+
+
 void matrix4x4R(float xyz[16], float xyz1[16], float xyz2[16]) 
 {
   for(int t=0; t<16; t+=4)
--- a/Renderer/Engine/matrix_calc.h	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/matrix_calc.h	Fri Dec 02 12:27:51 2011 +0900
@@ -12,6 +12,7 @@
 void translate(float *xyz, float x, float y, float z);
 void scale_matrix(float *xyz, float *scale, float *c_xyz);
 void matrix4x4(float *, float *, float *);
+void mulMatrix4x4(float *xyz, float *xyz1);
 
 void normalize(float *v0, float *v1);
 void subVector(float *v0, float *v1, float *v2);
@@ -21,6 +22,7 @@
 void inverseMatrix(float *m0, float *m1);
 void transposeMatrix(float *m0, float *m1);
 void unitMatrix(float *m);
+float determinant(float *m);
 void transMatrix(float *m0, float *m1, float *v);
 void ApplyMatrix(float *v1, float *v2);
 void ScaleMatrix(float *m, float v);
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -10,6 +10,7 @@
 #include "CreatePolygonFromSceneGraph.h"
 #include "polygon_pack.h"
 #include "texture.h"
+#include "matrix_calc.h"
 
 #define  STATUS_NUM 3
 
@@ -20,6 +21,7 @@
  * @param[out] v vector (float[4])
  * @param[in] m matrix (float[16])
  */
+/*
 static void
 ApplyMatrix(float *v, float *m)
 {
@@ -34,6 +36,7 @@
 	v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12];
     }
 }
+*/
 
 
 static int
@@ -57,17 +60,10 @@
 
 }
 
-
-
 static int 
 createPolygon(SchedTask *smanager, void *rbuf, void *wbuf)
 {
 
-    /*
-
-      もっと細かなTaskに分けるぞ!
-
-     */
 
     float xyz1[4], xyz2[4], xyz3[4];
     float normal1[4],normal2[4],normal3[4];
@@ -126,28 +122,9 @@
            *
            */
 
-          xyz1[0] /= xyz1[2];
-          xyz1[1] /= xyz1[2];
-
-          xyz2[0] /= xyz2[2];
-          xyz2[1] /= xyz2[2];
-
-          xyz3[0] /= xyz3[2];
-          xyz3[1] /= xyz3[2];
-
-
-/*
-
-           * 本当はz座標で除算するんじゃなくて
-           * 同次座標でx,y,z座標を除算するんじゃないのかな
-           * これすると、光源がうまくいかず。多分z座標をどこかで使ってる
-           * 同次座標は、もとのz座標と同じだから、入れ替えてやればいいか。
-           * そしたらこの位置で、視錐台カリングとかもできるはず
-           *
-
           xyz1[0] /= xyz1[3];
           xyz1[1] /= xyz1[3];
-          xyz1[2] /= xyz2[3];
+          xyz1[2] /= xyz1[3];
 
           xyz2[0] /= xyz2[3];
           xyz2[1] /= xyz2[3];
@@ -155,8 +132,8 @@
 
           xyz3[0] /= xyz3[3];
           xyz3[1] /= xyz3[3];
-          xyz3[2] /= xyz2[3];
-*/
+          xyz3[2] /= xyz3[3];
+
 
       } else {
           
@@ -212,45 +189,26 @@
       //normal3[3] = 1.0f;
       normal3[3] = 0.0f;
 
-      /*
-       * 法線は回転、平行移動、ビュー座標変換までの段階でよい
-       * Camera が持っている matrix は 射影変換とスクリーン変換が入っている 
-       * 
-       * Matrix をバラバラに持つ必要がある 
-       * 今はreal_matrixがビュー座標変換行列までを演算した行列になっている
-       *
-       */
-
-      /*
-       * real_matrix = ビュー座標変換行列
-       * スケーリングが入ると、演算が終わった normal vector を正規化する必要がある
-       * 今は DrawSpan で normalize している
-       *
-       * normal vector の同次座標は 0 なので、real_matrix の平行移動部分を除く必要はない
-       *
-       */
-
       ApplyMatrix(normal1,real_matrix);
       ApplyMatrix(normal2,real_matrix);
       ApplyMatrix(normal3,real_matrix);
 
+
 /*
-
-     * 法線ベクトルは透視変換しなくていい
-  
       normal1[0] /= normal1[3];
       normal1[1] /= normal1[3];
       normal1[2] /= normal1[3];
-      
-      normal2[0] /= normal2[3];
-      normal2[1] /= normal2[3];
-      normal2[2] /= normal2[3];
-      
-      normal3[0] /= normal3[3];
-      normal3[1] /= normal3[3];
-      normal3[2] /= normal3[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 Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/task/DrawSpan.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -550,7 +550,7 @@
     float light_vector[4];
     float *light_xyz = (float*)smanager->global_get(Light);
 
-    //normalize(normal_vector, normal_vector);
+    normalize(normal_vector, normal_vector);
 
     // 引数で受け取った color の rgb 情報の抜き出し
 #if LITTLEENDIAN
@@ -569,31 +569,52 @@
     int light_num = 4;
     //float inner_product = 0.2; // 0.2 は環境光ってことにしてみた。
     float inner_product = 0; // 0.2 は環境光ってことにしてみた。
+
+    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++) {
 
-      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[3] = light_xyz[i*4+3];
+      // 光源のスイッチが入ってたら 
+      if (light_switch[i] == 1) {
 
-      normalize(light_vector, light_vector);
+          //printf("light_xyz\n");
+          //for (int j = 0; j < 4; j++) printf(" %f",light_xyz[i*4+j]);
+          //printf("\n");
 
-      float tmp_inner_product = 0;
+        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;
 
-      // 法線ベクトルと光源ベクトルとの内積をとる
-      tmp_inner_product = innerProduct1(normal_vector,light_vector);
+//        light_vector[0] = 0;
+//        light_vector[1] = 0;
+//        light_vector[2] = -1;
+        
+        normalize(light_vector, light_vector);
+        
+        float tmp_inner_product = 0;
+        
+        // 法線ベクトルと光源ベクトルとの内積をとる
+        tmp_inner_product = innerProduct1(normal_vector,light_vector);
+        
+        // 内積がマイナスの場合は色がない。
+        if (inner_product < tmp_inner_product) {
+            inner_product = tmp_inner_product;
+        }
+        
+        // 内積を rgb にかけていく
+        
+        tmp_rgb[0] = (unsigned char)(rgb[0]*inner_product);
+        tmp_rgb[1] = (unsigned char)(rgb[1]*inner_product);
+        tmp_rgb[2] = (unsigned char)(rgb[2]*inner_product);
 
-      // 内積がマイナスの場合は色がない。
-      if (inner_product < tmp_inner_product) {
-	inner_product = tmp_inner_product;
       }
 
-      // 内積を rgb にかけていく
-
-      tmp_rgb[0] = (unsigned char)(rgb[0]*inner_product);
-      tmp_rgb[1] = (unsigned char)(rgb[1]*inner_product);
-      tmp_rgb[2] = (unsigned char)(rgb[2]*inner_product);
-
     }
 
     int rgb_flag[3];
--- a/Renderer/Engine/viewer.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/viewer.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -298,6 +298,8 @@
     }
 
     light_xyz_stock = sgroot->getLightVector();
+
+
     light_switch_stock = sgroot->getLightSwitch();
     light_sysswitch_stock = sgroot->getLightSysSwitch();
 
--- a/Renderer/Engine/viewer.h	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Engine/viewer.h	Fri Dec 02 12:27:51 2011 +0900
@@ -184,6 +184,12 @@
       return sgroot->getLight(id);
     }
 
+    CameraPtr getCamera()
+    {
+      return sgroot->getCamera();
+    }
+
+
     void OnLightSwitch(int id)
     {
       sgroot->OnLightSwitch(id);
--- a/Renderer/Test/Makefile.macosx	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Test/Makefile.macosx	Fri Dec 02 12:27:51 2011 +0900
@@ -13,7 +13,7 @@
 %.pb.cc: $(PROTODIR)/%.proto
 	$(PROTO) $(PROTOFLAGS) $<
 
-ALL =  collada ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer viewer_2 light_test aquarium network init_aquarium test_linda
+ALL =  collada ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer viewer_2 light_test matrix_test aquarium network init_aquarium test_linda
 
 all: $(ALL)
 
@@ -98,6 +98,10 @@
 light_test : $(LIGHT_TEST_OBJ) 
 	$(CC) $(CFLAGS) -o $@ $?    $(LIBS)
 
+MATRIX_TEST_OBJ = matrix_test.o
+matrix_test : $(MATRIX_TEST_OBJ) 
+	$(CC) $(CFLAGS) -o $@ $?    $(LIBS)
+
 
 VIEWER_OBJ2 = viewer_2.o
 viewer_2 : $(VIEWER_OBJ2) 
--- a/Renderer/Test/ball_bound.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Test/ball_bound.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -117,7 +117,7 @@
 
     sgroot->createFromXMLfile("xml_file/Ball.xml");
 
-    //sgroot->OnLightSysSwitch();
+    sgroot->OnLightSysSwitch();
 
     SceneGraphPtr light = sgroot->getLight(0);
     sgroot->OnLightSwitch(0);
--- a/Renderer/Test/universe.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Test/universe.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -50,8 +50,10 @@
     sgroot->createFromXMLfile( "xml_file/cube.xml");
     sgroot->OnLightSysSwitch();
     SceneGraphPtr light = sgroot->getLight(0); 
-    sgroot->OnLightSwitch(1);
-    light->xyz[2] -= 10;
+    sgroot->OnLightSwitch(0);
+    light->xyz[0] = screen_w;
+    light->xyz[1] = screen_h;
+    light->xyz[2] = 100;
 
     // SceneGraph ID から SceneGraph を生成する
     earth = sgroot->createSceneGraph("Earth");
--- a/Renderer/Test/viewer_2.cc	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Test/viewer_2.cc	Fri Dec 02 12:27:51 2011 +0900
@@ -117,7 +117,7 @@
     sgroot->OnLightSwitch(i);
     light->xyz[0] = screen_w / 2;
     light->xyz[1] = screen_h / 2;
-    light->xyz[2] = -100;
+    light->xyz[2] = 100;
   }
 
   // 固定した値で srandom すると、毎回同じ、random() 列が生成される
--- a/Renderer/Test/xml_file/universe.xml	Fri Nov 25 18:43:21 2011 +0900
+++ b/Renderer/Test/xml_file/universe.xml	Fri Dec 02 12:27:51 2011 +0900
@@ -28871,4 +28871,4 @@
 			oFAoFAoFAoFAoFAoFAoFAoFAoFAoFAoFAoFAoFAoFAoFAoFAoP/Z
 		</image>
 	</surface>
-</OBJECT-3D>
\ No newline at end of file
+</OBJECT-3D>