1 |
#include "Paper.hxx" |
hwo todd#include "Paper.hxx" |
2 |
|
|
3 |
#include <sstream> |
#include <sstream> |
4 |
|
|
9 |
|
|
10 |
namespace Paper { |
namespace Paper { |
11 |
|
|
|
bool useVertexProgram = true; |
|
|
|
|
12 |
TexGen::TexGen(const float *tex_mat) { |
TexGen::TexGen(const float *tex_mat) { |
13 |
this->tex_mat[0] = tex_mat[0]; |
this->tex_mat[0] = tex_mat[0]; |
14 |
this->tex_mat[1] = tex_mat[1]; |
this->tex_mat[1] = tex_mat[1]; |
187 |
} |
} |
188 |
|
|
189 |
void TexGenEmboss::setUp_explicit(LightParam * param) { |
void TexGenEmboss::setUp_explicit(LightParam * param) { |
190 |
std::cerr << "Warning: setUp_explicit for TexGenEmboss not implemented yet"; |
/** Does some as TexGenEmboss::setUp_VP, but without |
191 |
|
* using vertex programs. In other words, calculates |
192 |
|
* translation matrix for translating paper position |
193 |
|
* into embossed texture coordinates. |
194 |
|
* |
195 |
|
* Proper translation matrix is T A^-1 E^-1 A (see |
196 |
|
* TexGenEmboss::setUp_VP for details) and it's stored |
197 |
|
* into float TexGenEmboss::explicit_tmp_mat[16]. |
198 |
|
*/ |
199 |
|
|
200 |
|
/** Implementing under progress O:-) |
201 |
|
|
202 |
|
// Matrix E |
203 |
|
float eps = this->eps * param->e2.dot(param->e2) |
204 |
|
/ (param->Light - param->Light_w * param->orig).dot(param->e2); |
205 |
|
|
206 |
|
float transl_mat[16] = { 1, 0, 0, eps * param->Light.x, |
207 |
|
0, 1, 0, eps * param->Light.y, |
208 |
|
0, 0, 1, eps * param->Light.z, |
209 |
|
0, 0, 0, 1}; |
210 |
|
|
211 |
|
float s = 1 - param->Light_w * eps; |
212 |
|
|
213 |
|
float scale_mat[16] = { s, 0, 0, 0, |
214 |
|
0, s, 0, 0, |
215 |
|
0, 0, s, 0, |
216 |
|
0, 0, 0, 1}; |
217 |
|
|
218 |
|
// Matrix A |
219 |
|
float p2v_mat[16] = { param->e0.x, param->e0.y, param->e0.z, 0, |
220 |
|
param->e1.x, param->e1.y, param->e1.z, 0, |
221 |
|
param->e2.x, param->e2.y, param->e2.z, 0, |
222 |
|
param->orig.x, param->orig.y, param->orig.z, 1 }; |
223 |
|
|
224 |
|
*/ |
225 |
|
|
226 |
|
/** We don't have Matrix invertion or multiplications routines yet... |
227 |
|
|
228 |
|
// Matrix E |
229 |
|
float emb_map_mat[16] = matrix_multiplication(transl_mat, scale_mat); |
230 |
|
// Matrix E^-1 |
231 |
|
invert_translation_matrix(emb_map_mat); |
232 |
|
|
233 |
|
// Matrix E^-1 A |
234 |
|
float tmp_mat[16] = matrix_multiplication(emb_map_mat, p2v_mat); |
235 |
|
// Matrix A^-1 |
236 |
|
invert_translation_matrix(p2v_mat); |
237 |
|
// Matrix T A^-1 |
238 |
|
float tmp_mat2[16] = matrix_multiplication(tex_mat, p2v_mat); |
239 |
|
// Matrix T A^-1 E^-1 A |
240 |
|
explicit_tmp_map = matrix_multiplication(tmp_mat2, tmp_mat); |
241 |
|
// explicit_mat shoulde be made to point explicit_tmp_map |
242 |
|
*/ |
243 |
|
|
244 |
|
std::cerr << "Warning: TexGenEmboss::setUp_explicit() not yet implemented!\n"; |
245 |
explicit_mat = tex_mat; |
explicit_mat = tex_mat; |
246 |
} |
} |
247 |
|
|
389 |
} |
} |
390 |
} |
} |
391 |
|
|
392 |
void PaperPass::vertex_explicit(float *ppos) { |
void PaperPass::texcoords_explicit(float *ppos) { |
393 |
const float *mat; |
const float *mat; |
394 |
float texCoords[4]; |
float texCoords[4]; |
395 |
|
|