# HG changeset patch # User e065725@yutaka.st.ie.u-ryukyu.ac.jp # Date 1246102226 -32400 # Node ID 2964ed8fd3213ca98bf8946e896485c5c9e4d546 # Parent 553dfcdd8db522ffc38d563cf83b0f5e549fd43b add normal vector rotate diff -r 553dfcdd8db5 -r 2964ed8fd321 TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp --- a/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Tue Jun 23 20:53:31 2009 +0900 +++ b/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Sat Jun 27 20:30:26 2009 +0900 @@ -35,6 +35,21 @@ } } +static void +ApplyNormalMatrix(float *v, float *m) +{ + float t[4]; + + t[0] = v[0]; + t[1] = v[1]; + t[2] = v[2]; + + for (int i = 0; i < 3; i++) { + v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8]; + } +} + + /** * 行列の積 * @@ -160,19 +175,21 @@ normal1[0] = sg->normal[(i+0)*3]; normal1[1] = sg->normal[(i+0)*3+1]; - normal1[2] = sg->normal[(i+0)*3+2]; + normal1[2] = sg->normal[(i+0)*3+2]*-1.0f; normal1[3] = 1.0f; normal2[0] = sg->normal[(i+1)*3]; normal2[1] = sg->normal[(i+1)*3+1]; - normal2[2] = sg->normal[(i+1)*3+2]; + normal2[2] = sg->normal[(i+1)*3+2]*-1.0f; normal2[3] = 1.0f; normal3[0] = sg->normal[(i+2)*3]; normal3[1] = sg->normal[(i+2)*3+1]; - normal3[2] = sg->normal[(i+2)*3+2]; + normal3[2] = sg->normal[(i+2)*3+2]*-1.0f; normal3[3] = 1.0f; + ApplyNormalMatrix(normal1,sg->matrix); + //ここでpolygonに法線ベクトルの情報がわたったby yutaka triangle->normal1.x = normal1[0]; diff -r 553dfcdd8db5 -r 2964ed8fd321 TaskManager/Test/test_render/task/DrawSpan.cpp --- a/TaskManager/Test/test_render/task/DrawSpan.cpp Tue Jun 23 20:53:31 2009 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.cpp Sat Jun 27 20:30:26 2009 +0900 @@ -553,7 +553,7 @@ int flag; float normal_vector[4] = {normal_x,normal_y,normal_z,0}; // 光のベクトル,きめうちしちゃった。どうにかする - float light_vector[4] = {0,0,1,0}; + float light_vector[4] = {0,0,-1,0}; float inner_product; // 引数で受け取った color の rgb 情報の抜き出し