Go to the documentation of this file.
4 #ifndef tools_sg_tex_quadrilateral
5 #define tools_sg_tex_quadrilateral
26 virtual void*
cast(
const std::string& a_class)
const {
27 {
if(
void* p = cmp_cast<tex_quadrilateral>(
this,a_class))
return p;}
29 return parent::cast(a_class);
37 static const desc_fields s_v(parent::node_desc_fields(),6,
169 parent::operator=(a_from);
172 if(&a_from==
this)
return *
this;
194 int ix = int(
float(_img.
width())*a_x);
195 int iy = int(
float(_img.
height())*a_y);
198 std::vector<unsigned char> pixel;
199 if((ix<0)||(iy<0)||!_img.
pixel(ix,iy,pixel)) {a_s.clear();
return false;}
202 for(
unsigned int ipix=0;ipix<pixel.size();ipix++) {
204 if(!numas<float>(
float(pixel[ipix])/255.0f,a_s)){}
213 if(
corners.size()!=4) {a_x = 0;a_y = 0;
return false;}
223 if(l_01==0.0f) {a_x = 0;a_y = 0;
return false;}
226 if(l_03==0.0f) {a_x = 0;a_y = 0;
return false;}
228 float alpha = x_axis.
dot(y_axis);
229 float alpha_sq = alpha*alpha;
230 if(alpha_sq==1.0f) {a_x = 0;a_y = 0;
return false;}
234 float px = Op.
dot(x_axis);
235 float py = Op.
dot(y_axis);
237 float lambda = (px-alpha*py)/(1.0f-alpha_sq);
238 float mu = (py-alpha*px)/(1-alpha_sq);
250 if(
corners.size()!=4) {a_x = 0;a_y = 0;
return false;}
269 if(l_01==0.0f) {a_point.
set_value(0,0,0);
return false;}
272 if(l_03==0.0f) {a_point.
set_value(0,0,0);
return false;}
274 float alpha = x_axis.
dot(y_axis);
278 float lambda = a_x*l_01;
291 float px = lambda+mu*alpha;
292 float py = lambda*alpha+mu;
294 vec3f Op = px*x_axis+py*y_axis;
331 const std::vector<vec3f>& cs =
corners.values();
333 a_front[0] = cs[0].x()-a_epsil;
334 a_front[1] = cs[0].y()-a_epsil;
335 a_front[2] = cs[0].z();
337 a_front[3] = cs[1].x()+a_epsil;
338 a_front[4] = cs[1].y()-a_epsil;
339 a_front[5] = cs[1].z();
341 a_front[6] = cs[2].x()+a_epsil;
342 a_front[7] = cs[2].y()+a_epsil;
343 a_front[8] = cs[2].z();
345 a_front[ 9] = cs[3].x()-a_epsil;
346 a_front[10] = cs[3].y()+a_epsil;
347 a_front[11] = cs[3].z();
367 const std::vector<vec3f>& cs =
corners.values();
369 a_back[0] = cs[1].x();
370 a_back[1] = cs[1].y();
371 a_back[2] = cs[1].z();
373 a_back[3] = cs[0].x();
374 a_back[4] = cs[0].y();
375 a_back[5] = cs[0].z();
377 a_back[6] = cs[3].x();
378 a_back[7] = cs[3].y();
379 a_back[8] = cs[3].z();
381 a_back[ 9] = cs[2].x();
382 a_back[10] = cs[2].y();
383 a_back[11] = cs[2].z();
404 a_tris[10] = back[7];
405 a_tris[11] = back[8];
407 a_tris[12] = back[9];
408 a_tris[13] = back[10];
409 a_tris[14] = back[11];
411 a_tris[15] = back[0];
412 a_tris[16] = back[1];
413 a_tris[17] = back[2];
#define TOOLS_NODE_NO_CAST(a__class, a__sclass, a__parent)
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
#define TOOLS_ARG_FIELD_DESC(a__field)