[osg-users] Issues with Material Visitor when dealing with models which have color layers

Darko Radiceski radiceski at gmail.com
Wed Apr 27 07:01:16 PDT 2011

Hi all,

I seem to be having some issues with models that have color layers when i do the IVE generation from 3ds.

I have a MaterialVisitor class that essentialy does this to make sure we use the material colors. And also i need this to make sure the lighting settings are passed to the models correctly. If i dont have this the texture models are really really dark ( close to black)

void Material_Visitor::SetUseMaterialColors(osg::StateSet *stateset)
                                osg::Material *mat;
		unsigned int i=0;

		while((mat = (osg::Material *)stateset->getAttribute(osg::StateAttribute::MATERIAL, i)))
			if(mat->getColorMode() == osg::Material::OFF)


I read the 3ds model and i apply the visitor:

Material_Visitor mv;

If the 3ds model has image textures associated with it then it is all good.

However if i have a 3ds model that has color layers associated with it and not image textures then after the model is saved into an IVE all the colors are gone and the model is all white.

Any advice on what i am doing wrong?

Thank you!


Read this topic online here:

More information about the osg-users mailing list