Hi Koduri,

You are not assigning texture coordinates to your Quad, so I guess this
texture coordinates are by default. Apply your own texture coordinates, I
did something like this, but this was local to my application:

osg::ref_ptr<osg::Geometry> quad = osg::createTexturedQuadGeometry(
        osg::Vec3(0.0f, 0.0f, 0.0f), osg::Vec3(0.5f, 0.0f, 0.0f),
osg::Vec3(0.0f, 0.0f, 0.5f),0,1,1,0 );


The full code, take what you want:

    osg::ref_ptr<osg::Image> image = osgDB::readImageFile(
"/sdcard/videodemo256256.avi.ffmpeg" );
    osg::ImageStream* imageStream = dynamic_cast<osg::ImageStream*>(
image.get() );
    if ( imageStream )
    {
     imageStream->play();
    }
    osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
    texture->setImage( image.get() );

    osg::ref_ptr<osg::Geometry> quad = osg::createTexturedQuadGeometry(
        osg::Vec3(0.0f, 0.0f, 0.0f), osg::Vec3(0.5f, 0.0f, 0.0f),
osg::Vec3(0.0f, 0.0f, 0.5f),0,1,1,0 );
    quad->getOrCreateStateSet()->setTextureAttributeAndModes( 0,
texture.get() );
    quad->getOrCreateStateSet()->setMode(GL_LIGHTING,
osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;
    geode->addDrawable( quad.get() );
    osg::Matrix M = osg::Matrix::rotate(osg::inDegrees(-90.0f),
osg::X_AXIS)* osg::Matrix::translate(-0.25f, -0.25f, 0);

// Use matrix M with, for example, an osg::MatrixTransform to transform its
child nodes
    osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform(M);
    mt->addChild(geode);




2013/7/25 Koduri Lakshmi <[email protected]>

> Hi,
>
> I am trying to play the video on android device.  I did the coding as
> follows.
>
> in ".H" file.
>
>
> Code:
> osg::ref_ptr<osg::Geode> geode;
> osg::ref_ptr<osg::Texture2D> mVideoTexture;
> osg::Image* img;
> osg::ref_ptr<osg::ImageStream> videoStream[2];
> osg::ref_ptr<osg::MatrixTransform> mtForMarker[2];
>     osg::ref_ptr<osg::Switch> modelSwitch;
>
>
>
>
> In ".CPP" file
>
>
> Code:
> int idx=0;
> img = osgDB::readImageFile("1.mp4.mpeg");
> videoStream[idx] = dynamic_cast<osg::ImageStream*>(img);
> if (videoStream[idx].valid())
>         {
>                 LOG( "Got movie");
>                 videoStream[idx]->setLoopingMode(
> osg::ImageStream::NO_LOOPING);
>                 videoStream[idx]->seek(0);
>                 videoStream[idx]->play();
>         }
>         else
>            {
>                   LOG( "No movie!");
>            }
> aspectRatio = (float)img->t() / (float)img->s();
>          videoWidth = img->s();
>          videoHeight =videoWidth * aspectRatio;
>
>          mVideoTexture = new osg::Texture2D;
>          geode = new osg::Geode;
>          mVideoTexture->setImage( videoStream[idx].get() );
>
>          geode->addDrawable(osg::createTexturedQuadGeometry(
>                          osg::Vec3(0.0f, 0.0f, 0.0f),
>                          osg::Vec3(videoWidth, 0.0f, 0.0f),
>                          osg::Vec3(0.0f, 0.0f, videoHeight)
>
>                          ));
> geode->getOrCreateStateSet()->setTextureAttributeAndModes(0,
> mVideoTexture, osg::StateAttribute::ON );
>
>                 mtForMarker[idx] = new osg::MatrixTransform();
>                 mtForMarker[idx]->addChild(geode.get());
>
>
>                  modelSwitch->addChild(mtForMarker[idx]);
>
>
>
>
> With this code the video displayed in  a small size (like 50X50) around
> the centre of the device (Not exactly at the centre of the device). The
> original video size is 640X480. Video is also displaying in upside down.
>
> I am sung ffmpeg plug in for android.
>
> Can you please suggest me what could be the mistake.
> ...
>
> Thank you!
>
> Cheers,
> Koduri
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=55425#55425
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Jordi Torres
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to