Hi Jeremy,

Thanks for reply. My target with creating HUD display is playing osgMovie
imagestreamed texture in it. If I can achive this operation by osgWidget I
glad to use this API. And if it is possible, which osgWidget sample should I
glimps? Because I have never tried osgWidget before except looking built-in
samples in osg.

Best Regards.

2008/11/3 Jeremy Moles <[EMAIL PROTECTED]>

> On Mon, 2008-11-03 at 18:56 +0200, Ümit Uzun wrote:
> > Hi Folks,
> >
> > I have tried to create HUD for textured quad. I have read all about
> > archive and looked to osgHUD sample but it isn't working for textured
> > quad. And same time given code works for text. I can create HUD text
> > on the screen but can not create textured quad on the screen. I know
> > giving lots of code isn't good for you but I will paste all of them if
> > anyone want to look for find out the problem.
>
> I really think you should try using osgWidget; even in it's very young
> stage of development, it can handle easy stuff like this without a
> hitch. And, of course, I'm very responsive to questions about it so
> you're bound to get the help you need (except on the weekends, which I
> waste playing video games).
>
> If I have my way, all e-mails about creating custom "HUDs" will be
> gone. :)
>
> > If created texture quad add as a child to the root node, it works
> > without giving any problem. But if add as a child to the osg::Camera
> > node it get visible and is seen nothing. I think so, the problem is in
> > osg::Camera node which was initilazed by;
> >
> >
> /----------------------------------Camera-------------------------------------/
> >   // create a camera to set up the projection and model view matrices,
> > and the subgraph to drawn in the HUD
> >    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
> >
> >    // set the projection matrix
> >    camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
> >
> >    // set the view matrix
> >    camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
> >    camera->setViewMatrix(osg::Matrix::identity());
> >
> >    // only clear the depth buffer
> >    camera->setClearMask(GL_DEPTH_BUFFER_BIT);
> >
> >    // draw subgraph after main camera view.
> >    camera->setRenderOrder(osg::Camera::POST_RENDER);
> >
> >    // add geode to the camera node as a child
> >    camera->addChild( geode );
> >
> /----------------------------------Camera-------------------------------------/
> >
> > Best Regards.
> > --
> > Ümit Uzun,
> > Environmental Tectonics Corporation Turkey
> > ODTU Teknokent
> > Gumus Bloklar A Blok
> > Zemin Kat Bati Cephe Suit 1
> > 06531 ODTU
> > Ankara, Turkey
> > Tel: 90 (312) 210 17 80
> > Fax: 90 (312) 210 17 84
> > E-Mail: umituzun84<at>gmail<dot>com
> > Website: http://www.etc-turkey.com
> >
> >
> /---------------------------------------HUD---------------------------------------/
> > int main()
> > {
> >    osg::Vec3 coords[] =
> >    {
> >       osg::Vec3(-1, 0.f ,-1), //LL
> >       osg::Vec3( 1, 0.f, -1), //LR
> >       osg::Vec3( 1, 0.f, 1), //UR
> >       osg::Vec3( -1, 0.f, 1) //UL
> >    };
> >
> >    osg::Vec2 tCoords[] =
> >    {
> >       osg::Vec2(0,0),
> >       osg::Vec2(1,0),
> >       osg::Vec2(1,1),
> >       osg::Vec2(0,1)
> >    };
> >
> >    int numCoords = sizeof(coords) / sizeof(osg::Vec3);
> >    int numTexCoords = sizeof(tCoords) / sizeof(osg::Vec2);
> >
> >   osg::ref_ptr<osg::Group> root = new osg::Group();
> >   osgViewer::Viewer viewer;
> >   osg::Geode *geode = new osg::Geode();
> >   osg::Geometry *quad = new osg::Geometry();
> >
> >   quad->setVertexArray(new osg::Vec3Array(numCoords, coords));
> >   quad->setTexCoordArray(0, new osg::Vec2Array(numTexCoords,
> > tCoords));
> >   quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,
> > 0, numCoords));
> >
> >   geode->addDrawable(quad);
> >
> >   osg::Image* image = osgDB::readImageFile( "RWR_256_256.bmp" );
> >   if (image == NULL)
> >   {
> >       osg::notify(osg::WARN) << "Can't find texture file:" <<
> > std::endl;
> >   }
> >
> >   osg::Texture2D* texture = new osg::Texture2D();
> >   texture->setImage(image);
> >   texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
> >   texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);
> >
> >   osg::StateSet *stateSet = quad->getOrCreateStateSet();
> >   stateSet->setTextureAttributeAndModes(0, texture,
> > osg::StateAttribute::ON);
> >   stateSet->setMode(GL_BLEND,osg::StateAttribute::ON);
> >   stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
> >   stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> >
> >    // create a camera to set up the projection and model view
> > matrices, and the subgraph to drawn in the HUD
> >    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
> >
> >    // set the projection matrix
> >    camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
> >
> >    // set the view matrix
> >    camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
> >    camera->setViewMatrix(osg::Matrix::identity());
> >
> >    // only clear the depth buffer
> >    camera->setClearMask(GL_DEPTH_BUFFER_BIT);
> >
> >    // draw subgraph after main camera view.
> >    camera->setRenderOrder(osg::Camera::POST_RENDER);
> >
> >    // add geode to the camera node as a child
> >    camera->addChild(geode);
> >
> >    // add  camera to the root node as a child
> >    root->addChild(camera.get());
> >
> >    viewer.setSceneData(root.get());
> >    viewer.setCameraManipulator(new osgGA::TrackballManipulator());
> >
> >    viewer.run();
> >
> >    return 0;
> > }
> >
> /---------------------------------------HUD---------------------------------------/
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Ümit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to