Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp @ 354:81b25e5d5379
add example/get_segment and change spe/DrawSpan.cpp
author | koba |
---|---|
date | Wed, 15 Jul 2009 17:39:51 +0900 |
parents | e1d24c951408 |
children | b89ba1d96fff |
comparison
equal
deleted
inserted
replaced
284:6ceb40aec7fb | 354:81b25e5d5379 |
---|---|
32 | 32 |
33 for (int i = 0; i < 4; i++) { | 33 for (int i = 0; i < 4; i++) { |
34 v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12]; | 34 v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12]; |
35 } | 35 } |
36 } | 36 } |
37 | |
38 static void | |
39 ApplyNormalMatrix(float *v, float *m) | |
40 { | |
41 float t[4]; | |
42 | |
43 t[0] = v[0]; | |
44 t[1] = v[1]; | |
45 t[2] = v[2]; | |
46 | |
47 for (int i = 0; i < 3; i++) { | |
48 v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8]; | |
49 } | |
50 } | |
51 | |
37 | 52 |
38 /** | 53 /** |
39 * 行列の積 | 54 * 行列の積 |
40 * | 55 * |
41 * @param[out] m0 output matrix | 56 * @param[out] m0 output matrix |
57 */ | 72 */ |
58 int | 73 int |
59 CreatePolygonFromSceneGraph::run(void *rbuf, void *wbuf) | 74 CreatePolygonFromSceneGraph::run(void *rbuf, void *wbuf) |
60 { | 75 { |
61 float xyz1[4], xyz2[4], xyz3[4]; | 76 float xyz1[4], xyz2[4], xyz3[4]; |
77 /* | |
78 *頂点毎に法線ベクトルがある | |
79 *面毎じゃない | |
80 *なにかに使うのかな?わからないから、一応とっておく。 | |
81 *by yutaka | |
82 */ | |
83 float normal1[4],normal2[4],normal3[4]; | |
62 | 84 |
63 SceneGraphPtr sg_top = (SceneGraphPtr)smanager->get_param(0); | 85 SceneGraphPtr sg_top = (SceneGraphPtr)smanager->get_param(0); |
64 SceneGraphPtr sg = sg_top; | 86 SceneGraphPtr sg = sg_top; |
65 | 87 |
66 PolygonPackPtr pp | 88 PolygonPackPtr pp |
146 triangle->ver3.x = xyz3[0]; | 168 triangle->ver3.x = xyz3[0]; |
147 triangle->ver3.y = xyz3[1]; | 169 triangle->ver3.y = xyz3[1]; |
148 triangle->ver3.z = xyz3[2]; | 170 triangle->ver3.z = xyz3[2]; |
149 triangle->ver3.tex_x = sg->coord_tex[(i+2)*3]; | 171 triangle->ver3.tex_x = sg->coord_tex[(i+2)*3]; |
150 triangle->ver3.tex_y = sg->coord_tex[(i+2)*3+1]; | 172 triangle->ver3.tex_y = sg->coord_tex[(i+2)*3+1]; |
173 | |
174 //法線もApplyMatrixとかするのかな?一応値をとっておくby yutaka | |
175 | |
176 normal1[0] = sg->normal[(i+0)*3]; | |
177 normal1[1] = sg->normal[(i+0)*3+1]; | |
178 normal1[2] = sg->normal[(i+0)*3+2]*-1.0f; | |
179 normal1[3] = 1.0f; | |
180 | |
181 normal2[0] = sg->normal[(i+1)*3]; | |
182 normal2[1] = sg->normal[(i+1)*3+1]; | |
183 normal2[2] = sg->normal[(i+1)*3+2]*-1.0f; | |
184 normal2[3] = 1.0f; | |
185 | |
186 normal3[0] = sg->normal[(i+2)*3]; | |
187 normal3[1] = sg->normal[(i+2)*3+1]; | |
188 normal3[2] = sg->normal[(i+2)*3+2]*-1.0f; | |
189 normal3[3] = 1.0f; | |
190 | |
191 ApplyNormalMatrix(normal1,sg->matrix); | |
192 | |
193 //ここでpolygonに法線ベクトルの情報がわたったby yutaka | |
194 | |
195 triangle->normal1.x = normal1[0]; | |
196 triangle->normal1.y = normal1[1]; | |
197 triangle->normal1.z = normal1[2]; | |
198 | |
199 triangle->normal2.x = normal2[0]; | |
200 triangle->normal2.y = normal2[1]; | |
201 triangle->normal2.z = normal2[2]; | |
202 | |
203 triangle->normal3.x = normal3[0]; | |
204 triangle->normal3.y = normal3[1]; | |
205 triangle->normal3.z = normal3[2]; | |
206 | |
207 | |
151 | 208 |
152 triangle->tex_info.addr = sg->texture_info.pixels; | 209 triangle->tex_info.addr = sg->texture_info.pixels; |
153 triangle->tex_info.width = sg->texture_info.t_w; | 210 triangle->tex_info.width = sg->texture_info.t_w; |
154 triangle->tex_info.height = sg->texture_info.t_h; | 211 triangle->tex_info.height = sg->texture_info.t_h; |
155 triangle->tex_info.scale_max = sg->texture_info.scale_max; | 212 triangle->tex_info.scale_max = sg->texture_info.scale_max; |