Hi Robert,

If you think default behaviour is to have no tile then the
WriterNodeVisitor::Material::texture_no_tile should be initialised to true.

WriterNodeVisitor::Material::Material(WriterNodeVisitor & writerNodeVisitor,
osg::StateSet * stateset, osg::Material* mat, osg::Texture* tex, int index)
:
    index(index),
    diffuse(1,1,1,1),
    ambient(0.2,0.2,0.2,1),
    specular(0,0,0,1),
    shininess(0),
    transparency(0),
    double_sided(false),
    image(NULL),
    texture_transparency(false),
    texture_no_tile(true)

Your correction works fine for me and as you said it doesn't assume any
default settings on the lib3ds tex.flags.

Regards

Joan Abadie


2011/5/24 Robert Osfield <[email protected]>

> Hi Joan,
>
> I've just done a review and look at the bit mask definition in
> src/osgPlugins/3ds/lib3ds/lib3ds.h the flags setting of 0x10 is
> LIB3DS_TEXTURE_NO_TILE which is fine for most textures, it's only when
> the Texture wrap mode is set to repeat should
> this be set to 0x0.   I suspect the code on the OSG side is what is at
> fault, and it shouldn't be making assumptions about the
> flag settings.  The code in src/osgPlugins/WriterNodeVisitor.cpp is:
>
>                Lib3dsTextureMap & tex = mat3ds->texture1_map;
>                strcpy(tex.name, path.c_str());
>                // Here we don't assume anything about initial flags
> state (actually it is set to LIB3DS_TEXTURE_NO_TILE by lib3DS, but
> this is subject to change)
>                if (mat.texture_transparency) tex.flags |=
> LIB3DS_TEXTURE_ALPHA_SOURCE;
>                else tex.flags &= ~LIB3DS_TEXTURE_ALPHA_SOURCE;
>                if (mat.texture_no_tile) tex.flags |=
> LIB3DS_TEXTURE_NO_TILE;
>                else tex.flags &= ~LIB3DS_TEXTURE_NO_TILE;
>
>
> I'm a bit surprised that the code doesn't just reset the tex.flags to
> 0x0 and then explictly set everything that is required rather than
> have the convoluted code above.  Even with being a bit convouted it
> would seem to me if the mat.texture_no_tile was set correctly then
> it'd all work correctly without any mods to the orignal lib3ds source.
>
> I'm keen to avoid modifying the lib3ds source as the next time we
> merge fixes in from the original project we'll risk unding any fixes
> we've made to it.
>
> Could you have a look at the setting of
> theWriterNodeVisitor::Material::texture_no_tile to see why it seems to
> be going astray.
>
> Robert.
>
>
>
> Robert.
>
>
> On Tue, May 17, 2011 at 4:18 PM, jOan <[email protected]> wrote:
> > Hello,
> > Here is a small fix for 3DS plugin.
> > Texture repeat (or tiling) is lost when writing to .3DS file
> > For testing here is an ive sample with texture repeat (tiling).
> > Correction :
> > lib3ds_material.c
> > static void
> > initialize_texture_map(Lib3dsTextureMap *map) {
> >     map->flags = 0x00;
> >     map->percent = 1.0f;
> >     map->scale[0] = 1.0f;
> >     map->scale[1] = 1.0f;
> > }
> > regards
> > --
> > M. Joan Abadie
> >
> > _______________________________________________
> > osg-submissions mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
> >
> >
> _______________________________________________
> osg-submissions mailing list
> [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>



-- 
jOan
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to