Re: [osg-users] Texture Problem with ATI Radeon Mobility!!!!
Hi, Nectarios Check class called GLObjectsVisitor in osg. Among other things it has options to turn on\off display lists, all you need is to traverse with it over your graph. I thought this problem was solved somewhere around 10.7 catalyst version. Cheers, Sergey. 04.03.2011, 18:24, Nectarios Pelekanos nectarios.peleka...@armes-tech.com: Hi, The problem is solved, it was what Sergev mentioned above, setting the display list off. But how can I do it globally? Now I am setting the display list off in the osg code of the model Thank you! Cheers, Nectarios -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37337#37337 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Textures Problem!!! Urgent!!
Hi, There are ready-to-use visitor in osg for this kind of thing, GLObjectsVisitor (in osgUtil namespace iirc). Cheers, Sergey. 04.03.2011, 23:02, Robert Osfield robert.osfi...@gmail.com: Hi Nectarios, On Fri, Mar 4, 2011 at 3:21 PM, Nectarios Pelekanos Does anyone know how can i set the display list false globally? There is no global settings for display lists, you just have to set each Drawable separately. It's easy to write a visitor that finds the Geodes and then sets the Drawable settings. i.e class DisableDisplayListsVisitor : public osg::NodeVisitor { public: DisableDisplayListsVisitor(): osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} void apply(osg::Geode geode) { for(unsigned int i=0; igeode.getNumDrawables(); ++i) { geode.getDrawable(i)-setUseDisplayList(false); } } }; // then to run it.. DisableDisplayListVisitor ddlv; node-accept(ddlv); You can customize this visitor to switch on VBO's etc. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Show a model in the front of the texture background of a viewer
Hi, Tang There are different way to do this, i prefer to use one camera. For background: put quad with background texture into ortho projection and identity transform with reference frame set to ABSOLUTE_RF, or draw it with shaders ignoring view and projection matrices with quad vertices coords from -1,-1 to 1,1 (like gl_Position = gl_Vertex in vs) You might need to ensure that your background draws before models to avoid trasparency related problems, this can be done with setRenderBinDetails(-1,RenderBin) on stateset of your backgound quad. So your scene structure wil be like / background projection (ortho) - background transform (with absolute_rf) - quad with background texture root \ your models Cheers, Sergey 05.03.2011, 06:15, Tang Yu tangy...@yahoo.com.cn: Hi, I want to put a IVE Model in the viewer which renders a Texture2D Image as the viewer's whole background. Now, I put the texture image into a camera and rendered as the background successfully. The code is below: Code: -(osg::Node *) create2DBGTexture { unsigned int w = 480; unsigned int h = 320; float vx = (float)w; float vy = (float)h; osg::ref_ptrosg::Geometry rectBG_geom = new osg::Geometry; osg::Vec3Array * vertices = new osg::Vec3Array; vertices-push_back(osg::Vec3(0.0, 0.0, -1.0)); vertices-push_back(osg::Vec3(0.0, vy, -1.0)); vertices-push_back(osg::Vec3(vx, vy, -1.0)); vertices-push_back(osg::Vec3(vx, 0.0, -1.0)); rectBG_geom-setVertexArray(vertices); osg::Vec2Array * texcoords = new osg::Vec2Array; texcoords-push_back(osg::Vec2(0.0, 0.0625)); texcoords-push_back(osg::Vec2(0.0, 0.9375)); texcoords-push_back(osg::Vec2(1.0, 0.9375)); texcoords-push_back(osg::Vec2(1.0, 0.0625)); rectBG_geom-setTexCoordArray(0,texcoords); osg::Vec3Array * normals = new osg::Vec3Array; normals-push_back(osg::Vec3(0.0f,0.0f,1.0f)); rectBG_geom-setNormalArray(normals); rectBG_geom-setNormalBinding(osg::Geometry::BIND_OVERALL); rectBG_geom-addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); BG_image = new osg::Image; BG_image-setImage(AVWidth, AVHeight, 1, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, pAVImage, osg::Image::NO_DELETE); BG_texture = new osg::Texture2D; BG_texture-setDataVariance(osg::Object::DYNAMIC); BG_texture-setImage(BG_image); BG_texture-setResizeNonPowerOfTwoHint(false); BG_texture-setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST); BG_texture-setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST); osg::StateSet* stateset = rectBG_geom-getOrCreateStateSet(); stateset-setTextureAttributeAndModes(0,BG_texture,osg::StateAttribute::ON); osg::Geode * BG_geode = new osg::Geode; BG_geode-addDrawable(rectBG_geom); return BG_geode; } -(int) initOsgTree { int dwError = 0; osg::setNotifyLevel(osg::DEBUG_INFO); // camera unsigned int w = 480; unsigned int h = 320; //create and attach ortho camera for hud text osg::ref_ptrosg::Camera hudCamera = new osg::Camera; hudCamera-setProjectionMatrix(osg::Matrix::ortho2D(0,w,0,h)); hudCamera-setReferenceFrame(osg::Transform::ABSOLUTE_RF); hudCamera-setViewMatrix(osg::Matrix::identity()); hudCamera-setClearMask(GL_DEPTH_BUFFER_BIT); hudCamera-setRenderOrder(osg::Camera::POST_RENDER); osg::ref_ptrosg::Group MARRoot = new osg::Group; MARRoot-getOrCreateStateSet()-setMode(GL_LIGHTING,osg::StateAttribute::OFF); hudCamera-addChild([self create2DBGTexture]); MARRoot-addChild(hudCamera.get()); // viewer MARViewer = new osgViewer::Viewer(); MARViewer-setSceneData(MARRoot.get()); MARViewer-realize(); MARViewer-frame(); return dwError; } My question is: How do i put the model in the viewer so that it can be showed in the front of the background? Use two cameras? Put the model in another camera, then add this camera as the slave camera into viewer? I ever tried it, but it did not work, maybe my code is wrong. Maybe my thought is not right. I hope you can give me a hand to help me to solve this question. I will appreciate you very much. Thank you! Cheers, Tang -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37357#37357 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Billboard with two layer
Hi, currently I create a healthbar for a minion. So I use a billboard for it. But now I have a problem: I want give the billboard a background. So I have following both gemoetries: A colored border, filled with another which is a little bit transparent. Code: || | | || And the healthbar: Code: ☐☐ Combined it should look like this: Code: || |☐☐| || But how to combine it without flickering? Currently I have (_createHealthGemoetry ist nearly the same like _createBackgroundGemoetry, but smaller so it fit into the other): Code: HealthBar::HealthBar() { this-setMode(osg::Billboard::POINT_ROT_EYE); _health = 1; _maxHealth = 1; this-_setBillBoardStateSet(); this-addDrawable(_createBackgroundGemoetry()); this-addDrawable(_createHealthGemoetry()); } void HealthBar::_setBillBoardStateSet() { osg::StateSet* billBoardStateSet = new osg::StateSet(); billBoardStateSet-setMode( GL_LIGHTING, osg::StateAttribute::OFF ); billBoardStateSet-setAttributeAndModes( new osg::BlendFunc, osg::StateAttribute::ON ); billBoardStateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); // Make sure the geometry has the correct state this-setStateSet(billBoardStateSet); } osg::Drawable* HealthBar::_createBackgroundGemoetry() { float width = 0.8f; float height = 0.12f; osg::Geometry* backgroundGeometry = new osg::Geometry(); osg::Texture2D* backgroundTexture = AssetLibrary::instance()-getTexture(healthbar/test.png); // Declare and initialize geometry backgroundGeometry = new osg::Geometry(); //add vertices and texture osg::Vec3Array* verts = new osg::Vec3Array(4); (*verts)[0] = osg::Vec3( -width/2, 0, -height/2); (*verts)[1] = osg::Vec3( +width/2, 0, -height/2); (*verts)[2] = osg::Vec3( +width/2, 0, +height/2); (*verts)[3] = osg::Vec3( -width/2, 0, +height/2); backgroundGeometry-setVertexArray(verts); osg::Vec2Array* texCoords = new osg::Vec2Array(4); (*texCoords)[0].set(0.0f, 0.0f); (*texCoords)[1].set(1.0f, 0.0f); (*texCoords)[2].set(1.0f, 1.0f); (*texCoords)[3].set(0.0f, 1.0f); backgroundGeometry-setTexCoordArray(0, texCoords); osg::StateSet* stateSet = new osg::StateSet(); stateSet-setTextureAttributeAndModes(0, backgroundTexture, osg::StateAttribute::ON); backgroundGeometry-setStateSet(stateSet); // Add a primitive set (QUADS) to the geometry backgroundGeometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4)); osg::Vec4Array* colors = new osg::Vec4Array; colors-push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); backgroundGeometry-setColorArray(colors); backgroundGeometry-setColorBinding(osg::Geometry::BIND_OVERALL); return backgroundGeometry; } Thank you! Cheers, Heiko -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37364#37364 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Billboard with two layer
Hi, Heiko You can use PolygonOffset state attribute on one of your drawables to beat flickering. Cheers, Sergey. 05.03.2011, 14:18, Heiko Thiel osgfo...@tevs.eu: Hi, currently I create a healthbar for a minion. So I use a billboard for it. But now I have a problem: I want give the billboard a background. So I have following both gemoetries: A colored border, filled with another which is a little bit transparent. Code: || | | || And the healthbar: Code: ☐☐ Combined it should look like this: Code: || |☐☐ | || But how to combine it without flickering? Currently I have (_createHealthGemoetry ist nearly the same like _createBackgroundGemoetry, but smaller so it fit into the other): Code: HealthBar::HealthBar() { this-setMode(osg::Billboard::POINT_ROT_EYE); _health = 1; _maxHealth = 1; this-_setBillBoardStateSet(); this-addDrawable(_createBackgroundGemoetry()); this-addDrawable(_createHealthGemoetry()); } void HealthBar::_setBillBoardStateSet() { osg::StateSet* billBoardStateSet = new osg::StateSet(); billBoardStateSet-setMode( GL_LIGHTING, osg::StateAttribute::OFF ); billBoardStateSet-setAttributeAndModes( new osg::BlendFunc, osg::StateAttribute::ON ); billBoardStateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); // Make sure the geometry has the correct state this-setStateSet(billBoardStateSet); } osg::Drawable* HealthBar::_createBackgroundGemoetry() { float width = 0.8f; float height = 0.12f; osg::Geometry* backgroundGeometry = new osg::Geometry(); osg::Texture2D* backgroundTexture = AssetLibrary::instance()-getTexture(healthbar/test.png); // Declare and initialize geometry backgroundGeometry = new osg::Geometry(); //add vertices and texture osg::Vec3Array* verts = new osg::Vec3Array(4); (*verts)[0] = osg::Vec3( -width/2, 0, -height/2); (*verts)[1] = osg::Vec3( +width/2, 0, -height/2); (*verts)[2] = osg::Vec3( +width/2, 0, +height/2); (*verts)[3] = osg::Vec3( -width/2, 0, +height/2); backgroundGeometry-setVertexArray(verts); osg::Vec2Array* texCoords = new osg::Vec2Array(4); (*texCoords)[0].set(0.0f, 0.0f); (*texCoords)[1].set(1.0f, 0.0f); (*texCoords)[2].set(1.0f, 1.0f); (*texCoords)[3].set(0.0f, 1.0f); backgroundGeometry-setTexCoordArray(0, texCoords); osg::StateSet* stateSet = new osg::StateSet(); stateSet-setTextureAttributeAndModes(0, backgroundTexture, osg::StateAttribute::ON); backgroundGeometry-setStateSet(stateSet); // Add a primitive set (QUADS) to the geometry backgroundGeometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4)); osg::Vec4Array* colors = new osg::Vec4Array; colors-push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); backgroundGeometry-setColorArray(colors); backgroundGeometry-setColorBinding(osg::Geometry::BIND_OVERALL); return backgroundGeometry; } Thank you! Cheers, Heiko -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37364#37364 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem in opening multiple files while using VBO
Hi Lalit, This problem is probably due to the new windows attempting to resuse GL object ID's for the previous context. The osgViewer library has mechanisms for internally cleaning up all the ID's, my guess is you own windowing implementation bypasses this. In include/osg/GLObjects header file you'll find the method: /** Discard all OpenGL objects. * Note, unlike deleteAllObjectObjects discard does not * do any OpenGL calls so can be called from any thread, but as a consequence it * also doesn't remove the associated OpenGL resource so discard should only be * called when the associated graphics context is being/has been closed. */ extern OSG_EXPORT void discardAllGLObjects(unsigned int contextID); Call this after you close your first graphics context. Robert. On Sat, Mar 5, 2011 at 6:34 AM, Lalit Manchwari manchwari.la...@gmail.com wrote: Hi, I made a MDI application using MFC with the help of OSGMDI project, which displays the point data. I am using VBO in my application using these two lines: geometry-setUseDisplayList( false ); //Disable display lists geometry-setUseVertexBufferObjects( true ); //Enable VBO Now the problem is, when I open a file the application works well and on close the child window it releases the memory. But when I open another file without closing the main window, it breaks. But when I comment these two lines then program working well for multiple files but it becomes slow. I can’t understand the problem please help me. Thank you! Cheers, Lalit -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=37359#37359 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org