383 final float tcW = tc.right() - tc.left();
385 colorTexBBox[0] = box.getMinX() / tcW;
386 colorTexBBox[2] = box.getMaxX() / tcW;
387 if( tex.getMustFlipVertically() ) {
388 tcH = tc.bottom() - tc.top();
389 colorTexBBox[1] = box.getMaxY() / tcH;
390 colorTexBBox[3] = box.getMinY() / tcH;
392 tcH = tc.top() - tc.bottom();
393 colorTexBBox[1] = box.getMinY() / tcH;
394 colorTexBBox[3] = box.getMaxY() / tcH;
396 colorTexBBox[4] = tcW;
397 colorTexBBox[5] = tcH;
399 final float colorTexBBoxW = colorTexBBox[2] - colorTexBBox[0];
400 final float colorTexBBoxH = colorTexBBox[3] - colorTexBBox[1];
401 System.err.println(
"XXX setTexCoordBBoxSimple:");
402 System.err.println(
"XXX ColorTex "+tex);
403 System.err.println(
"XXX ColorTexBBox min "+colorTexBBox[0]+
"/"+colorTexBBox[1]+
", max "+colorTexBBox[2]+
"/"+colorTexBBox[3]+
404 ", dim "+colorTexBBoxW+
" x "+colorTexBBoxH+
405 ", tc-dim "+tcW+
" x "+tcH+
", tc "+tc);
421 final float boxRatio = box.getWidth() / box.getHeight();
422 final float imgRatio = tex.getAspectRatio();
423 final float box2ImgRatio = boxRatio / imgRatio;
424 final float tcW = tc.right() - tc.left();
426 float boxWidthCut=0, boxHeightCut=0, boxWidthExt=0, boxHeightExt=0;
428 if( box2ImgRatio >= 1.0f ) {
430 boxWidthCut = box.getWidth() * ( 1
f - 1
f / box2ImgRatio );
431 final float tcWH = tcW * 0.5f;
432 final float boxWidthCutL = boxWidthCut * tcWH;
433 final float boxWidthCutR = boxWidthCut * ( 1
f - tcWH );
434 colorTexBBox[0] = ( box.getMinX() + boxWidthCutL ) / tcW;
435 colorTexBBox[2] = ( box.getMaxX() - boxWidthCutR ) / tcW;
436 if( tex.getMustFlipVertically() ) {
437 tcH = tc.bottom() - tc.top();
438 colorTexBBox[1] = box.getMaxY() / tcH;
439 colorTexBBox[3] = box.getMinY() / tcH;
441 tcH = tc.top() - tc.bottom();
442 colorTexBBox[1] = box.getMinY() / tcH;
443 colorTexBBox[3] = box.getMaxY() / tcH;
446 colorTexBBox[0] = box.getMinX() / tcW;
447 colorTexBBox[2] = box.getMaxX() / tcW;
448 boxHeightExt = box.getHeight() * ( box2ImgRatio - 1
f );
449 if( tex.getMustFlipVertically() ) {
450 tcH = tc.bottom() - tc.top();
451 final float tcHH = tcH * 0.5f;
452 final float boxHeightExtB = boxHeightExt * tcHH;
453 final float boxHeightExtT = boxHeightExt * ( 1
f - tcHH );
454 colorTexBBox[1] = ( box.getMaxY() + boxHeightExtT ) / tcH;
455 colorTexBBox[3] = ( box.getMinY() - boxHeightExtB ) / tcH;
457 tcH = tc.top() - tc.bottom();
458 final float tcHH = tcH * 0.5f;
459 final float boxHeightExtB = boxHeightExt * tcHH;
460 final float boxHeightExtT = boxHeightExt * ( 1
f - tcHH );
461 colorTexBBox[1] = ( box.getMinY() - boxHeightExtB ) / tcH;
462 colorTexBBox[3] = ( box.getMaxY() + boxHeightExtT ) / tcH;
467 colorTexBBox[0] = box.getMinX() / tcW;
468 colorTexBBox[2] = box.getMaxX() / tcW;
469 boxHeightCut = box.getHeight() * ( 1
f - box2ImgRatio );
470 if( tex.getMustFlipVertically() ) {
471 tcH = tc.bottom() - tc.top();
472 final float tcHH = tcH * 0.5f;
473 final float boxHeightCutB = boxHeightCut * tcHH;
474 final float boxHeightCutT = boxHeightCut * ( 1
f - tcHH );
475 colorTexBBox[1] = ( box.getMaxY() - boxHeightCutT ) / tcH;
476 colorTexBBox[3] = ( box.getMinY() + boxHeightCutB ) / tcH;
478 tcH = tc.top() - tc.bottom();
479 final float tcHH = tcH * 0.5f;
480 final float boxHeightCutB = boxHeightCut * tcHH;
481 final float boxHeightCutT = boxHeightCut * ( 1
f - tcHH );
482 colorTexBBox[1] = ( box.getMinY() + boxHeightCutB ) / tcH;
483 colorTexBBox[3] = ( box.getMaxY() - boxHeightCutT ) / tcH;
486 boxWidthExt = box.getWidth() * ( 1
f / box2ImgRatio - 1
f );
487 final float tcWH = tcW * 0.5f;
488 final float boxWidthExtL = boxWidthExt * tcWH;
489 final float boxWidthExtR = boxWidthExt * ( 1
f - tcWH );
490 colorTexBBox[0] = ( box.getMinX() - boxWidthExtL ) / tcW;
491 colorTexBBox[2] = ( box.getMaxX() + boxWidthExtR ) / tcW;
492 if( tex.getMustFlipVertically() ) {
493 tcH = tc.bottom() - tc.top();
494 colorTexBBox[1] = box.getMaxY() / tcH;
495 colorTexBBox[3] = box.getMinY() / tcH;
497 tcH = tc.top() - tc.bottom();
498 colorTexBBox[1] = box.getMinY() / tcH;
499 colorTexBBox[3] = box.getMaxY() / tcH;
503 colorTexBBox[4] = tcW;
504 colorTexBBox[5] = tcH;
506 final float texWidthRatio = (float)tex.getImageWidth() / (float)tex.getWidth();
507 final float texHeightRatio = (float)tex.getImageHeight() / (float)tex.getHeight();
508 final float texRatio = ( tc.right() - tc.left() ) / ( tc.bottom() - tc.top() );
509 final float box2TexRatio = boxRatio / texRatio;
510 final float colorTexBBoxW = colorTexBBox[2] - colorTexBBox[0];
511 final float colorTexBBoxH = colorTexBBox[3] - colorTexBBox[1];
512 System.err.println(
"XXX setTexCoordBBox:");
513 System.err.println(
"XXX ColorTex imgRatio "+imgRatio+
", texRatio "+texRatio+
", texPixelRatio[w "+texWidthRatio+
", h "+texHeightRatio+
"], "+tex);
514 System.err.println(
"XXX ColorTexBBox lbox "+letterBox+
", cut "+boxWidthCut+
"/"+boxHeightCut+
", ext "+boxWidthExt+
"/"+boxHeightExt);
515 System.err.println(
"XXX ColorTexBBox min "+colorTexBBox[0]+
"/"+colorTexBBox[1]+
", max "+colorTexBBox[2]+
"/"+colorTexBBox[3]+
516 ", dim "+colorTexBBoxW+
" x "+colorTexBBoxH+
517 ", tc-dim "+tcW+
" x "+tcH+
", tc "+tc+
", box2ImgRatio "+box2ImgRatio+
", box2TexRatio "+box2TexRatio);
518 System.err.println(
"XXX Box ratio "+boxRatio+
", "+box);