Hi,
also see the code for osgSim OverlayNode.
jp
Pablo Perez wrote:
Hi Robert and osg-users,
I have added a TexGenNode but i´m a newbie in OSG and i dont know why it
cant works. This is the code that i have added.When I execute the
osgviewer with this code, it only shows the terrain model and without
lighting.
osg::Group* root = new osg::Group();
osg::ref_ptr<osg::Node> loadedModel =
osgDB::readNodeFile("C:\\osg\\Terrain.osg");
osg::Image* loadedImage = osgDB::readImageFile( "C:\\OSG\\overlay.png" );
osg::Texture2D* texture = new osg::Texture2D(loadedImage);
osg::StateSet* stateset=new osg::StateSet();
stateset->setTextureAttributeAndModes(1,texture, osg::StateAttribute::ON);
stateset->setTextureMode(1, GL_TEXTURE_2D,osg::StateAttribute::ON);
osg::TexGen* texgen = new osg::TexGen;
texgen->setMode(osg::TexGen::OBJECT_LINEAR);
texgen->setPlane(osg::TexGen::R, osg::Plane(0.0f,0.0f,0.0f,0.2f));
osg::TexGenNode* texgenNode = new osg::TexGenNode;
texgenNode->getTexGen()->setMode(osg::TexGen::OBJECT_LINEAR);
texgenNode->setTextureUnit(1);
texgenNode->setTexGen(texgen);
texgenNode->setStateSet(stateset);
texgenNode->addChild(loadedModel.get());
root->addChild(texgenNode);
Regards,
Pablo
2008/8/26 Robert Osfield <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
Hi Pablo,
What is missing from your code is the generate of texture coordinates.
The way to do this is to use a TexGenNode to positioning the mapping
between vertex position to texture coordinates.
Robert.
On Tue, Aug 26, 2008 at 1:54 PM, Pablo Perez <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
> This is the part of osgviewer where I try to load the new texture:
>
> osg::Group* root = new osg::Group();
>
> osg::ref_ptr<osg::Node> loadedModel =
> osgDB::readNodeFile("C:\\osg\\Terrain.ive");
> osg::Image* loadedImage = osgDB::readImageFile(
"C:\\OSG\\overlay.png" );
> osg::Texture2D* texture = new osg::Texture2D(loadedImage);
>
loadedModel->getOrCreateStateSet()->setTextureAttributeAndModes(1,texture,
> osg::StateAttribute::ON);
> loadedModel->getOrCreateStateSet()->setTextureMode(1,
> GL_TEXTURE_2D,osg::StateAttribute::ON);
>
> root->addChild(loadedModel.get());
>
> 2008/8/26 Pablo Perez <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
>>
>> Hi Robert,
>>
>> I´m trying to overlay another texture ontop of the existing
tiles. I´m
>> working
>> in a GIS and I want to add layers like highways,.... from a WMS.
>>
>> Thanks,
>>
>> Pablo
>>
>>
>> 2008/8/26 Robert Osfield <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
>>>
>>> Hi Pablo,
>>>
>>> >From your email I can't quite work out what you are trying to
achieve.
>>> Is that you want to replace the existing texture present in each
>>> tile that is loaded, or overlay another texture ontop of the
existing
>>> tiles?
>>>
>>> Robert.
>>>
>>> On Tue, Aug 26, 2008 at 12:18 AM, Pablo Perez
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>>> > Hi,
>>> >
>>> > I have built a PageLOD terrain database with osgdem and now I
want to
>>> > modify
>>> > osgviewer to add diferents images for each terrain tile and
LOD. I try
>>> > to
>>> > add a texture2D to the root->getChild Node but only can see the
>>> > texture2D in
>>> > the areas where there aren´t terrain images.
>>> >
>>> > _______________________________________________
>>> > osg-users mailing list
>>> > [email protected]
<mailto:[email protected]>
>>> >
>>> >
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>> >
>>> >
>>> _______________________________________________
>>> osg-users mailing list
>>> [email protected]
<mailto:[email protected]>
>>>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
<mailto:[email protected]>
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
<mailto:[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
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org