Hi Pablo,

For this type of work you'll want to use EYE_LINEAR texgen.  You'll
need to set up the texgen plans correctly as well.  Have a look at
online or book documentation on OpenGL texgen to understand what will
be required, the OSG just wraps it up.

Robert.

On Wed, Aug 27, 2008 at 4:52 PM, Pablo Perez <[EMAIL PROTECTED]> 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]>
>>
>> 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]> 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]>
>> >>
>> >> 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]>
>> >>>
>> >>> 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]>
>> >>> 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]
>> >>> >
>> >>> >
>> >>> > 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
>> >>
>> >
>> >
>> > _______________________________________________
>> > 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
>
>
> _______________________________________________
> 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

Reply via email to