[osg-users] Adding code for movie textures

Robert Osfield robert.osfield at gmail.com
Fri Sep 19 00:54:50 PDT 2008

Hi Patrick,

Playing movies automatically isn't that what all users will want all
the time, so hard coding this in isn't appropriate.  In the past I've
always just used a custom NodeVisitor to traverse through an enable
the movies, this is pretty straight forward to write and retains
complete control to the application developer. You could place such a
visitor inside a osgDB::Registry::ReadFileCallback to apply the
visitor automatically to all loaded models.


On Fri, Sep 19, 2008 at 12:53 AM, Patrick A. Webb <webb at arsc.edu> wrote:
> I've been trying to find a way to get movie textures to play using only a
> .osg file as the input to osgviewer. From skulking around in the source code
> I figured out how "osgviewer --movie" plays movies on a polygon and took
> that idea and applied it to the texture handling source files in
> osgPlugins/osg.
> I added the following code to Texture1D.cpp, Texture2D.cpp, Texture3D.cpp
> and TextureRectangle.cpp:
> #include "osg/ImageStream"
> ....
> if (fr[0].matchWord("movie") && fr[1].isString())
> {
>        std::string filename = fr[1].getStr();
>        Image* image = fr.readImage(filename.c_str());
>        ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
>        if (imagestream) {
>                texture.setImage(imagestream);
>                imagestream->play();
>        }
> }
> ....
> So far it's worked. Is this something that's going to work out in the long
> run? Is there a better way for me to do what I've done?
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list