comparison 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
comparison
equal deleted inserted replaced
199:eb20274baa7c 200:10ad99550ee8
32 { 32 {
33 xyz[i] = abc[0]*matrix[i] + abc[1]*matrix[i+4] + abc[2]*matrix[i+8] + abc[3]*matrix[i+12]; 33 xyz[i] = abc[0]*matrix[i] + abc[1]*matrix[i+4] + abc[2]*matrix[i+8] + abc[3]*matrix[i+12];
34 } 34 }
35 } 35 }
36 36
37 static void
38 apply_matrix(float *xyz, float *mat)
39 {
40 float tmp[4];
41
42 tmp[0] = xyz[0];
43 tmp[1] = xyz[1];
44 tmp[2] = xyz[2];
45 tmp[3] = xyz[3];
46
47 for (int i = 0; i < 4; i++) {
48 xyz[i] = tmp[0]*mat[i*4+0] + tmp[1]*mat[i*4+1]
49 + tmp[2]*mat[i*4+2] + tmp[3]*mat[i*4+3];
50 }
51 }
52
53 float fx = 1.0f;
54 float fy = 1.0f;
55 float fz = 0.9f;
56 float fd = 0.05f;
57
37 int 58 int
38 CreatePolygonFromSceneGraph::run(void *rbuf, void *wbuf) 59 CreatePolygonFromSceneGraph::run(void *rbuf, void *wbuf)
39 { 60 {
40 float xyz1[4], xyz2[4], xyz3[4]; 61 float xyz1[4], xyz2[4], xyz3[4];
62 float mat[16] = {fx, 0, 0, 0, 0, fy, 0, 0, 0, 0, 1.0f, 1.0f, 20.0f, 30.0f, 0, 0};
63
64 //fx -= fd;
65 //fy -= fd;
66
67 if (fx < 0.0f) {
68 fx = 0.0f;
69 fy = 0.0f;
70 fd = -fd;
71 } else if (fx > 1.0f) {
72 fx = 1.0f;
73 fy = 1.0f;
74 fd = -fd;
75 }
76
41 77
42 SceneGraphPtr sg_top = (SceneGraphPtr)smanager->get_param(0); 78 SceneGraphPtr sg_top = (SceneGraphPtr)smanager->get_param(0);
43 SceneGraphPtr sg = sg_top; 79 SceneGraphPtr sg = sg_top;
44 80
45 PolygonPackPtr pp 81 PolygonPackPtr pp
96 xyz3[3] = 1; 132 xyz3[3] = 1;
97 133
98 rotate(xyz1, sg->matrix); 134 rotate(xyz1, sg->matrix);
99 rotate(xyz2, sg->matrix); 135 rotate(xyz2, sg->matrix);
100 rotate(xyz3, sg->matrix); 136 rotate(xyz3, sg->matrix);
137
138 apply_matrix(xyz1, mat);
139 apply_matrix(xyz2, mat);
140 apply_matrix(xyz3, mat);
101 141
102 triangle->ver1.x = xyz1[0]; 142 triangle->ver1.x = xyz1[0];
103 triangle->ver1.y = xyz1[1]; 143 triangle->ver1.y = xyz1[1];
104 triangle->ver1.z = xyz1[2]; 144 triangle->ver1.z = xyz1[2];
105 triangle->ver1.tex_x = sg->data[(i+0)*3 + sg->size*6]; 145 triangle->ver1.tex_x = sg->data[(i+0)*3 + sg->size*6];