Mercurial > hg > Members > kono > Cerium
changeset 338:2964ed8fd321
add normal vector rotate
author | e065725@yutaka.st.ie.u-ryukyu.ac.jp |
---|---|
date | Sat, 27 Jun 2009 20:30:26 +0900 |
parents | 553dfcdd8db5 |
children | be8f785a82e9 |
files | TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp TaskManager/Test/test_render/task/DrawSpan.cpp |
diffstat | 2 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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];
--- 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 情報の抜き出し