On 9/4/06, Robert Osfield <[EMAIL PROTECTED]> wrote:
On reflection I think one workable solution would be to have the osg::TexMat class be able to have a special TextureRectangle section that allows you to tell it to watch a special osg::TextureRectangle, and  to apply a texture matrix that it approrpriate for its current size.   This route would require you to set the scene graph with this extra TexMat in the StateSet alongside the TextureRectangle, so scene graph set up would be a little more complicated, but at least it shoudl behave consistently, and will only require modifications to osg::TexMat and nothing else in the OSG.

I will go ahead with this implementation and see how things turn out.

I have now implemented the above approach and works fine so far, at least for the modified osgtexturerectangle example.  The texture setup code now looks like:

    // load image
    osg::Image* img = osgDB::readImageFile(filename);

    // setup texture
    osg::TextureRectangle* texture = new osg::TextureRectangle(img);

    osg::TexMat* texmat = new osg::TexMat;
    texmat->setScaleByTextureRectangleSize(true);

    // setup state
    osg::StateSet* state = geom->getOrCreateStateSet();
    state->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
    state->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON);

The key addition being the osg::TexMat code.  Its worth noting that the matrix in TexMat is still works, the only change is that its post multiplied by the size of the texture rectangle on a per frame basis.

I have also updated the .osg and .ive plugins for this change.  The only core part of the OSG touched in osg::TexMat, there are no other changes required beyond this.

Let me know how you get on.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to