Mercurial > hg > Members > kono > Cerium
diff TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp @ 200:10ad99550ee8
fix run_draw
author | gongo@localhost.localdomain |
---|---|
date | Mon, 26 Jan 2009 14:27:45 +0900 |
parents | 08e2bb36639b |
children | 3f4c6a75d7e0 |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Mon Jan 26 14:27:45 2009 +0900 @@ -34,10 +34,46 @@ } } +static void +apply_matrix(float *xyz, float *mat) +{ + float tmp[4]; + + tmp[0] = xyz[0]; + tmp[1] = xyz[1]; + tmp[2] = xyz[2]; + tmp[3] = xyz[3]; + + for (int i = 0; i < 4; i++) { + xyz[i] = tmp[0]*mat[i*4+0] + tmp[1]*mat[i*4+1] + + tmp[2]*mat[i*4+2] + tmp[3]*mat[i*4+3]; + } +} + +float fx = 1.0f; +float fy = 1.0f; +float fz = 0.9f; +float fd = 0.05f; + int CreatePolygonFromSceneGraph::run(void *rbuf, void *wbuf) { float xyz1[4], xyz2[4], xyz3[4]; + float mat[16] = {fx, 0, 0, 0, 0, fy, 0, 0, 0, 0, 1.0f, 1.0f, 20.0f, 30.0f, 0, 0}; + + //fx -= fd; + //fy -= fd; + + if (fx < 0.0f) { + fx = 0.0f; + fy = 0.0f; + fd = -fd; + } else if (fx > 1.0f) { + fx = 1.0f; + fy = 1.0f; + fd = -fd; + } + SceneGraphPtr sg_top = (SceneGraphPtr)smanager->get_param(0); SceneGraphPtr sg = sg_top; @@ -98,6 +134,10 @@ rotate(xyz1, sg->matrix); rotate(xyz2, sg->matrix); rotate(xyz3, sg->matrix); + + apply_matrix(xyz1, mat); + apply_matrix(xyz2, mat); + apply_matrix(xyz3, mat); triangle->ver1.x = xyz1[0]; triangle->ver1.y = xyz1[1];