Mercurial > hg > Game > Cerium
changeset 328:5467c2bedc3a draft
merge
author | aaa |
---|---|
date | Fri, 12 Jun 2009 02:15:06 +0900 |
parents | fbd7337bf220 (current diff) c8edba9cabb7 (diff) |
children | d3ea1d049230 |
files | TaskManager/Test/test_render/Camera.cpp TaskManager/Test/test_render/Func.h TaskManager/Test/test_render/show_time.cpp TaskManager/Test/test_render/task/ShowTime.cpp TaskManager/Test/test_render/task/task_init.cpp |
diffstat | 3 files changed, 23 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Func.h Thu Jun 11 22:47:00 2009 +0900 +++ b/TaskManager/Test/test_render/Func.h Fri Jun 12 02:15:06 2009 +0900 @@ -20,6 +20,6 @@ TASK_DRAW_BACK, TASK_SET_TEXTURE, TASK_DUMMY, - + SHOW_TIME, };
--- a/TaskManager/Test/test_render/show_time.cpp Thu Jun 11 22:47:00 2009 +0900 +++ b/TaskManager/Test/test_render/show_time.cpp Fri Jun 12 02:15:06 2009 +0900 @@ -11,4 +11,5 @@ show->set_cpu(SPE_ANY); show->spawn(); printf("testですよ\n"); + }
--- a/TaskManager/Test/test_render/task/DrawSpan.cpp Thu Jun 11 22:47:00 2009 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.cpp Fri Jun 12 02:15:06 2009 +0900 @@ -544,45 +544,41 @@ } } + int DrawSpan::infinity_light_calc(int color,float normal_x, float normal_y, float normal_z) { unsigned char rgb[4]; - float normal_vector[3] = {normal_x,normal_y,normal_z}; - //光のベクトル,きめうちしちゃった。どうにかする - float light_vector[3] = {0,1,0}; - float inner_product; + int light_rgb; int flag; - //内積の下限 - int min_inner_product = 0.5; - int mask = 0xff000000; + float normal_vector[4] = {normal_x,normal_y,normal_z,0}; + // 光のベクトル,きめうちしちゃった。どうにかする + float light_vector[4] = {0,0,1,0}; + float inner_product; - //rgb情報の抜き出し - for (int i = 0; i < 4; i++) { - rgb[i] = (color & mask) >> (3 - i) * 8; - mask >>= 8; - } + // 引数で受け取った color の rgb 情報の抜き出し + rgb[0] = (color & 0xff000000) >> 24; + rgb[1] = (color & 0x00ff0000) >> 16; + rgb[2] = (color & 0x0000ff00) >> 8; + rgb[3] = (color & 0x000000ff); - //内積の計算 + // 法線ベクトルと光源ベクトルとの内積をとる inner_product = innerProduct(normal_vector,light_vector); - //min_inner_productが下限。環境光ってやつ? - flag = (inner_product <= min_inner_product); + // 内積がマイナスの場合は色がない。 + flag = (inner_product > 0); - //内積をrgbにかけていく - for (int i = 0; i < 3; i++) { - rgb[i] = rgb[i]*inner_product + min_inner_product*rgb[i] * flag; - } + // 内積を rgb にかけていく + rgb[0] = rgb[0]*inner_product*flag; + rgb[1] = rgb[1]*inner_product*flag; + rgb[2] = rgb[2]*inner_product*flag; + + //計算した rgb を light_rgb にまとめる。 + light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]); - int light_rgb = rgb[0]; - for (int i = 1; i < 4; i++) { - light_rgb <<= 8; - light_rgb |= rgb[i]; - } return light_rgb; } - int DrawSpan::run(void *rbuf, void *wbuf) {