Mercurial > hg > Members > kono > Cerium
diff Renderer/Engine/task/DrawSpan.cc @ 748:b7376415fa5f
TaskManager changeset 683, Renderer changeset 746
author | hiroki |
---|---|
date | Mon, 25 Jan 2010 18:01:19 +0900 |
parents | 60aa3f241b10 |
children | 984e6aa17174 |
line wrap: on
line diff
--- a/Renderer/Engine/task/DrawSpan.cc Sun Dec 06 10:23:19 2009 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Mon Jan 25 18:01:19 2010 +0900 @@ -39,9 +39,10 @@ // static TilePtr isAvailableTile(memaddr addr); static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top); static int getTexBlock(int tx, int ty, int twidth); -static void updateBuffer(Gptr g, float zpos, int rangex, int x, int y, - int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z, TilePtr tile); +static void updateBuffer(Gptr g, float zpos, int rangex, int loaclx, int localy, + int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z, + TilePtr tile, int world_x, int world_y, float world_z,SchedTask *smanager); // static void reboot(SpanPackPtr spack, int cur_span_x); @@ -49,7 +50,10 @@ //static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); static int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); // static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); -static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z); + +static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z, + SchedTask *smanager,int x, int y, float z, int world_x, int world_y, float world_z); + static float innerProduct1(float *v0, float *v1) @@ -179,8 +183,9 @@ * @param tex_addr テクスチャのアドレス(MainMemory) */ static void -updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y, - float normal_x, float normal_y, float normal_z, TilePtr tile) +updateBuffer(Gptr g, float zpos, int rangex, int localx, int localy, int tex_x, int tex_y, + float normal_x, float normal_y, float normal_z, TilePtr tile, + int world_x, int world_y, float world_z, SchedTask *smanager) { int color = get_rgb(tex_x, tex_y, tile); @@ -193,12 +198,16 @@ /*完全に透けているか判断*/ int flag = (alpha != 0); - color = infinity_light_calc(color,normal_x,normal_y,normal_z); + color = infinity_light_calc(color,normal_x,normal_y,normal_z, + smanager,localx,localy,zpos, + world_x,world_y,world_z); - g->zRow[x + (rangex*y)] = zpos*flag + g->zRow[x + (rangex*y)]*(1-flag); - int *point = &g->linebuf[y][x] ; + g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag); + int *point = &g->linebuf[localy][localx] ; *point = color*flag + *point *(1-flag); + + } /** @@ -258,7 +267,8 @@ updateBuffer(g, zpos, rangex, localx, localy, tex_localx, tex_localy, - normal_x,normal_y,normal_z,tile); + normal_x,normal_y,normal_z,tile, + span->x, span->y, zpos, smanager); } return -1; @@ -319,6 +329,10 @@ float zpos1 = span->start_z; float zpos2 = span->end_z; + //spanを右から左に見ていくうちに、zが下がるのか、上がっていくのか。 + float z_inclination = (zpos1 - zpos2) / x_len; + float world_z = zpos2; + // Tile 内での座標 int localx, localy = getLocalY(span->y-1); @@ -328,6 +342,8 @@ for (int j = je; j >= js; j--) { float tex_x, tex_y, tex_z; + world_z += z_inclination; + localx = getLocalX(x-1+j); tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1); @@ -357,7 +373,8 @@ updateBuffer(g, tex_z, rangex, localx, localy, tex_localx, tex_localy, - normal_x, normal_y, normal_z, tile); + normal_x, normal_y, normal_z, tile, + span->x+j, span->y, world_z, smanager); } } @@ -365,7 +382,10 @@ } static int -infinity_light_calc(int color,float normal_x, float normal_y, float normal_z) +infinity_light_calc(int color,float normal_x, float normal_y, + float normal_z, SchedTask *smanager, int x, int y, float z, + int world_x, int world_y, float world_z) + { unsigned char rgb[4]; int light_rgb; @@ -423,8 +443,8 @@ Span nop_span; nop_span.length_x = 1; - // uint32 display = smanager->get_param(0); - // int screen_width = smanager->get_param(1); + // uint32 display = (long)smanager->get_param(0); + // int screen_width = (long)smanager->get_param(1); int rangex_start = (long)smanager->get_param(2); int rangex_end = (long)smanager->get_param(3); @@ -456,11 +476,9 @@ } SpanPtr resume_span = &nop_span; - int resume_span_x = 0; for (int t = 0; t < spack->info.size; t++) { SpanPtr next_span; - int next_span_x; span = &spack->span[t]; @@ -476,7 +494,6 @@ next_span = span; resume_span = next_span; - resume_span_x = next_span_x; tl_tag_flg1 ^= 1; tl_tag_flg2 ^= 1;