X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fpolytest.c;h=dfca5ef2a5978aeb3e52d1e3287ccdd5bc290525;hp=8d81262196a5cea3b542f4105b7cce3388282ea9;hb=45f6f46fe758d15aafccdb69ae837fc7d84ee466;hpb=100da5f0dbf2d9edbc65d6308f9481ca2e4f55df diff --git a/src/polytest.c b/src/polytest.c index 8d81262..dfca5ef 100644 --- a/src/polytest.c +++ b/src/polytest.c @@ -102,6 +102,9 @@ static void update(void) static void draw(void) { + float vdir[3]; + float mat[16]; + update(); memset(fb_pixels, 0, fb_width * fb_height * 2); @@ -116,6 +119,14 @@ static void draw(void) g3d_rotate(cam_theta, 0, 1, 0); } + /* calc world-space view direction */ + g3d_get_matrix(G3D_MODELVIEW, mat); + /* transform (0, 0, -1) with transpose(mat3x3) */ + vdir[0] = -mat[2]; + vdir[1] = -mat[6]; + vdir[2] = -mat[10]; + + g3d_light_pos(0, -10, 10, 20); zsort_mesh(&torus); @@ -123,8 +134,8 @@ static void draw(void) g3d_mtl_diffuse(0.4, 0.7, 1.0); g3d_set_texture(tex.width, tex.height, tex.pixels); - draw_mesh(&torus); - /*draw_bsp(&torus_bsp);*/ + /*draw_mesh(&torus);*/ + draw_bsp(&torus_bsp, vdir[0], vdir[1], vdir[2]); /*draw_mesh(&cube);*/ swap_buffers(fb_pixels);