| 527 | | osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" image-t()="<<image->t()<<std::endl; |
| 528 | | |
| 529 | | geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip)); |
| 530 | | |
| 531 | | bottomright = pos + osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f); |
| 532 | | |
| 533 | | if (xyPlane) pos.y() += image->t()*1.05f; |
| 534 | | else pos.z() += image->t()*1.05f; |
| | 527 | osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" image-t()="<<image->t()<<" aspectRatio="<<image->getPixelAspectRatio()<<std::endl; |
| | 528 | |
| | 529 | float width = image->s(); |
| | 530 | float height = image->t() * image->getPixelAspectRatio(); |
| | 531 | |
| | 532 | osg::ref_ptr<osg::Drawable> drawable = myCreateTexturedQuadGeometry(pos, width, height,image, useTextureRectangle, xyPlane, flip); |
| | 533 | |
| | 534 | if (image->isImageTranslucent()) |
| | 535 | { |
| | 536 | osg::notify(osg::NOTICE)<<"Transparent movie, enabling blending."<<std::endl; |
| | 537 | |
| | 538 | drawable->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); |
| | 539 | drawable->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); |
| | 540 | } |
| | 541 | |
| | 542 | geode->addDrawable(drawable.get()); |
| | 543 | |
| | 544 | bottomright = pos + osg::Vec3(width,height,0.0f); |
| | 545 | |
| | 546 | if (xyPlane) pos.y() += height*1.05f; |
| | 547 | else pos.z() += height*1.05f; |
| 575 | | |
| | 588 | |
| | 589 | viewer.getCamera()->setClearColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); |
| | 590 | |
| | 591 | float screenAspectRatio = 1280.0f/1024.0f; |
| | 592 | |
| | 593 | osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); |
| | 594 | if (wsi) |
| | 595 | { |
| | 596 | unsigned int width, height; |
| | 597 | wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); |
| | 598 | |
| | 599 | screenAspectRatio = float(width) / float(height); |
| | 600 | } |
| | 601 | |
| | 602 | float modelAspectRatio = (bottomright.x()-topleft.x())/(bottomright.y()-topleft.y()); |
| | 603 | |
| | 605 | |
| | 606 | |
| | 607 | osg::Vec3 center = (bottomright + topleft)*0.5f; |
| | 608 | osg::Vec3 dx(bottomright.x()-center.x(), 0.0f, 0.0f); |
| | 609 | osg::Vec3 dy(0.0f, topleft.y()-center.y(), 0.0f); |
| | 610 | |
| | 611 | float ratio = modelAspectRatio/screenAspectRatio; |
| | 612 | |
| | 613 | if (ratio>1.0f) |
| | 614 | { |
| | 615 | // use model width as the control on model size. |
| | 616 | bottomright = center + dx - dy * ratio; |
| | 617 | topleft = center - dx + dy * ratio; |
| | 618 | } |
| | 619 | else |
| | 620 | { |
| | 621 | // use model height as the control on model size. |
| | 622 | bottomright = center + dx / ratio - dy; |
| | 623 | topleft = center - dx / ratio + dy; |
| | 624 | } |
| | 625 | |