[osg-users] Using multiples texture for a geometry
Robert Osfield
robert.osfield at gmail.com
Thu May 5 00:49:58 PDT 2016
Hi Florian,
State inheritance won't typically cause problems like you describe.
My recommendation is start aftresh and create a minimal testbed example
purely for the purpose of building up a scene graph with the geometry and
state that will give the result you want. This testbed should contain
nothing extra, no clever ways of building stuff, just direct creation
osg::Geometry all the the arrays and primitives, osg::StateSet,
osg::Texture etc. Keep it simple. Just with single texturing, then add the
second texture unit.
WIth such a small little testbed it should be possible for you to see what
is going on, and give you space to just learn the basic OSG classes and how
to use without complications of mapping it to something more complicated,
then when you are happy compare the scene graph you've generated with what
your original code was outputting.
On the review of the scene graph front it's use to write the scene graph
out to .osgt form so you can review the actual scene graph you've created
rather than what you think you've created.
Robert.
On 4 May 2016 at 22:03, Florian GOLESTIN <florian.golestin at gmail.com> wrote:
> Hi Robert,
>
> I tried without the SmoothingVisitor but it does not change anything.
>
>
> However during my tests today I put a "Axes" object (the axes.osgt model
> from the OpenSceneGraph examples) and some part of the texture on the block
> below the object just appeared but really dark.
> So it it make me think that it's not a texture problem but maybe a light
> problem.
>
> I've tried then to use a full ambiant light:
>
> Code:
>
> osg::ref_ptr<osg::Node> createLightSource( unsigned int num,
> const osg::Vec3& trans,
> const osg::Vec4& color )
> {
> osg::ref_ptr<osg::Light> light = new osg::Light;
> light->setLightNum( num );
> light->setDiffuse( color );
>
> /* full scene lightened: */
> light->setAmbient(osg::Vec4(1.0,1.0,1.0,1.0));
> light->setSpecular(osg::Vec4(1,1,1,1)); // some examples don't have
> this one
>
>
> light->setPosition( osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f) );
> osg::ref_ptr<osg::LightSource> lightSource = new
> osg::LightSource;
> lightSource->setLight( light );
> osg::ref_ptr<osg::MatrixTransform> sourceTrans = new
> osg::MatrixTransform;
> sourceTrans->setMatrix( osg::Matrix::translate(trans) );
> sourceTrans->addChild( lightSource.get() );
> return sourceTrans;
> }
>
> int main(int argc, char **argv)
> {
> osg::ArgumentParser arguments(&argc,argv);
>
> osg::ref_ptr<osg::Group> root = new osg::Group;
>
> root->addChild(createLightSource(0, osg::Vec3(0, -2.0, 0),
> osg::Vec4(1.0, 1.0, 1.0, 1.0)));
> root->addChild(createLightSource(1, osg::Vec3(0, -16.0, 10.0),
> osg::Vec4(1.0, 1.0, 1.0, 1.0)));
>
> root->getOrCreateStateSet()->setMode( GL_LIGHT0, osg::StateAttribute::ON
> );
> root->getOrCreateStateSet()->setMode( GL_LIGHT1, osg::StateAttribute::ON
> );
>
>
>
>
>
> Now the texture appears but are really dark such as there is no light.
>
> Is it something related to states and inheritance?
>
> Thanks,
> Florian
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=67051#67051
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160505/20a09d0a/attachment-0002.htm>
More information about the osg-users
mailing list