Re: [osg-users] [osgPlugins] Loading an image to a texture
Again your using single back ssahes in you file name string for the textures either use '\\' or '/' Gordon Product Manager 3d __ Gordon Tomlinson Email : gtomlinson @ overwatch.textron.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Giering Joseph Sent: Saturday, October 03, 2009 10:18 AM To: osg-users@lists.openscenegraph.org Subject: [osg-users] [osgPlugins] Loading an image to a texture Hi, I have a problem to load an image to a texture by using this code. // create drawable geometry object osg::Geometry* pGeo = new osg::Geometry; // add 4 vertices creating a quad osg::Vec3Array* pVerts = new osg::Vec3Array; pVerts-push_back( osg::Vec3( 0, 0, 0 ) ); pVerts-push_back( osg::Vec3( 1, 0, 0 ) ); pVerts-push_back( osg::Vec3( 1, 0, 1 ) ); pVerts-push_back( osg::Vec3( 0, 0, 1 ) ); pGeo-setVertexArray( pVerts ); // create a primitive set osg::DrawElementsUInt* pPrimitiveSet = new osg::DrawElementsUInt( osg::PrimitiveSet::QUADS, 0 ); pPrimitiveSet-push_back( 3 ); pPrimitiveSet-push_back( 2 ); pPrimitiveSet-push_back( 1 ); pPrimitiveSet-push_back( 0 ); pGeo-addPrimitiveSet( pPrimitiveSet ); // create an arraw for texture coordinates osg::Vec2Array* pTexCoords = new osg::Vec2Array( 4 ); (*pTexCoords)[0].set( 0.0f, 0.0f ); (*pTexCoords)[1].set( 1.0f, 0.0f ); (*pTexCoords)[2].set( 1.0f, 1.0f ); (*pTexCoords)[3].set( 0.0f, 1.0f ); pGeo-setTexCoordArray( 0, pTexCoords ); // create geometry node that will contain all our drawables osg::Geode* pGeode = new osg::Geode; osg::StateSet* pStateSet = pGeode-getOrCreateStateSet(); pStateSet-setMode( GL_LIGHTING, osg::StateAttribute::OFF ); pGeode-addDrawable( pGeo ); // load and set texture attribute and mode osg::Texture2D* pTex = new osg::Texture2D; //osg::Image* pImage = osgDB::readImageFile ( HUD_Maennchen.jpeg ); osg::Image* pImage = osgDB::readImageFile( C:\Programme\ADTF\\2.1.1\lib\OpenSceneGraph-2.6.1\bin\HUD_Maennchen.jpe g ); if(!pImage) { std::cout Error: Couldn't find texture! std::endl; } pTex-setImage( pImage ); pStateSet-setTextureAttributeAndModes( 0, pTex, osg::StateAttribute::ON ); pGeo-setStateSet(pStateSet); m_pTransform-addChild(pGeode); GetRoot()-addChild(m_pTransform.get()); The image can't be found by readNodeFile. Where needs the image-file to be stored? Must I compile the jpeg-plugin? How can I compile this plugin? Thank you! Cheers, GI Jo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17828#17828 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] Loading an image to a texture
Hi, I have a problem to load an image to a texture by using this code. // create drawable geometry object osg::Geometry* pGeo = new osg::Geometry; // add 4 vertices creating a quad osg::Vec3Array* pVerts = new osg::Vec3Array; pVerts-push_back( osg::Vec3( 0, 0, 0 ) ); pVerts-push_back( osg::Vec3( 1, 0, 0 ) ); pVerts-push_back( osg::Vec3( 1, 0, 1 ) ); pVerts-push_back( osg::Vec3( 0, 0, 1 ) ); pGeo-setVertexArray( pVerts ); // create a primitive set osg::DrawElementsUInt* pPrimitiveSet = new osg::DrawElementsUInt( osg::PrimitiveSet::QUADS, 0 ); pPrimitiveSet-push_back( 3 ); pPrimitiveSet-push_back( 2 ); pPrimitiveSet-push_back( 1 ); pPrimitiveSet-push_back( 0 ); pGeo-addPrimitiveSet( pPrimitiveSet ); // create an arraw for texture coordinates osg::Vec2Array* pTexCoords = new osg::Vec2Array( 4 ); (*pTexCoords)[0].set( 0.0f, 0.0f ); (*pTexCoords)[1].set( 1.0f, 0.0f ); (*pTexCoords)[2].set( 1.0f, 1.0f ); (*pTexCoords)[3].set( 0.0f, 1.0f ); pGeo-setTexCoordArray( 0, pTexCoords ); // create geometry node that will contain all our drawables osg::Geode* pGeode = new osg::Geode; osg::StateSet* pStateSet = pGeode-getOrCreateStateSet(); pStateSet-setMode( GL_LIGHTING, osg::StateAttribute::OFF ); pGeode-addDrawable( pGeo ); // load and set texture attribute and mode osg::Texture2D* pTex = new osg::Texture2D; //osg::Image* pImage = osgDB::readImageFile ( HUD_Maennchen.jpeg ); osg::Image* pImage = osgDB::readImageFile( C:\Programme\ADTF\\2.1.1\lib\OpenSceneGraph-2.6.1\bin\HUD_Maennchen.jpeg ); if(!pImage) { std::cout Error: Couldn't find texture! std::endl; } pTex-setImage( pImage ); pStateSet-setTextureAttributeAndModes( 0, pTex,osg::StateAttribute::ON ); pGeo-setStateSet(pStateSet); m_pTransform-addChild(pGeode); GetRoot()-addChild(m_pTransform.get()); The image can't be found by readNodeFile. Where needs the image-file to be stored? Must I compile the jpeg-plugin? How can I compile this plugin? Thank you! Cheers, GI Jo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=17828#17828 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Loading an image to a texture
Hello Joseph, The image can't be found by readNodeFile. Where needs the image-file to be stored? Must I compile the jpeg-plugin? How can I compile this plugin? See the answers to your similar thread where you tried to load an obj file. Please don't post questions twice (these are the same question). About plugins, in general OSG will be compiled with some basic input/output plugins. The JPEG, PNG, OBJ, 3DS, etc. plugins are normally part of this set. You can't do much without these. Other plugins are optional, either because they require uncommon third-party dependencies or because not many people need them. To compile these, you need to get the OSG sources, get the dependencies, configure OSG so it detects that you have the dependencies and enables the plugins, and then recompile OSG with those plugins enabled. There are pages on the Wiki about this, please refer to it for more information. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org