Hi Neil,

As Eric has suggested, osg-submissions doesn't allow posts for those
not subscribed to the osg-submissions list.  This policy is a sad
consequence of deluge of spam that attacks us all every day.

I haven't spotted you submissions on osg-submissions yet so I presume
you haven't posted yet.  When you do make sure the changes are are a
complete file and attached as a separate attachment.  See:

http://www.openscenegraph.org/index.php?page=Support.SubmissionsProtocol

Cheers,
Robert.

On 12/30/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi Robert,

I tried to make the following submission but it bounced me back. Could you tell 
me what I've done wrong please ? Alternatively could you take the submission 
from the content of this email.

Many thanks

Neil.

>
> From: [EMAIL PROTECTED]
> Date: 2006/12/30 Sat PM 08:58:00 GMT
> To: [EMAIL PROTECTED]
> Subject: 3DS Material Name
>
> You are not allowed to post to this mailing list, and your message has
> been automatically rejected.  If you think that your messages are
> being rejected in error, contact the mailing list owner at
> [EMAIL PROTECTED]
>
>
>



---------- Forwarded message ----------
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Sat, 30 Dec 2006 20:57:51 +0000
Subject: 3DS Material Name
Hi Robert,

I trust you've had a good break. I'm hoping this is the correct address to 
submit a bug fix to be patched in to the OSG code base.

I'm working a lot with the 3DS loader, and one of the bugs I've come across is that when 
a 3DS file is read into the OSG world, the material name on the geometries is not 
maintained within the OSG world. This is a little odd as there is a "Name" 
field for a material object within OSG. Hence the request that this be fixed.

I've taken the liberty of embedding the corrected function below.  This is 
taken from the ReaderWriter3DS.cpp file. I confess to not having the latest 
version of OSG, mine is 1.0, however I suspect from the mail list that this 
hasn't been spotted by anyone else.

I've prefixed the line I would like added with some comment lines. I assume 
that you will remove unnecessary bits.

Regards

Neil Hughes

Following from ReaderWriter3DS.cpp

osg::StateSet* ReaderWriter3DS::ReaderObject::createStateSet(Lib3dsMaterial 
*mat, const osgDB::ReaderWriter::Options* options)
{
    if (mat==NULL) return NULL;

    osg::StateSet* stateset = new osg::StateSet;

    osg::Material* material = new osg::Material;

    float transparency = mat->transparency;
    float alpha = 1.0f-transparency;

    osg::Vec4 ambient(mat->ambient[0],mat->ambient[1],mat->ambient[2],alpha);
    osg::Vec4 diffuse(mat->diffuse[0],mat->diffuse[1],mat->diffuse[2],alpha);
    osg::Vec4 
specular(mat->specular[0],mat->specular[1],mat->specular[2],alpha);
    specular *= mat->shin_strength;

    float shininess = mat->shininess;

        // NAH Correction to transfer name of 3DS material to
        // OSG material structure.
        material->setName(mat->name);
    material->setAmbient(osg::Material::FRONT_AND_BACK,ambient);
    material->setDiffuse(osg::Material::FRONT_AND_BACK,diffuse);
    material->setSpecular(osg::Material::FRONT_AND_BACK,specular);
    material->setShininess(osg::Material::FRONT_AND_BACK,shininess*128.0f);

    stateset->setAttribute(material);

    bool textureTransparancy=false;
    osg::Texture2D* texture1_map = 
createTexture(&(mat->texture1_map),"texture1_map",textureTransparancy, options);
    if (texture1_map)
    {
        
stateset->setTextureAttributeAndModes(0,texture1_map,osg::StateAttribute::ON);

        if (!textureTransparancy)
        {
            // from an email from Eric Hamil, September 30, 2003.
            // According to the 3DS spec, and other
            // software (like Max, Lightwave, and Deep Exploration) a 3DS 
material that has
            // a non-white diffuse base color and a 100% opaque bitmap texture, 
will show the
            // texture with no influence from the base color.

            // so we'll override material back to white.
            // and no longer require the decal hack below...
#if 0
            // Eric orignal fallback
            osg::Vec4 white(1.0f,1.0f,1.0f,alpha);
            material->setAmbient(osg::Material::FRONT_AND_BACK,white);
            material->setDiffuse(osg::Material::FRONT_AND_BACK,white);
            material->setSpecular(osg::Material::FRONT_AND_BACK,white);
#else
            // try alternative to avoid staturating with white
            // setting white as per OpenGL defaults.
            
material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(0.2f,0.2f,0.2f,alpha));
            
material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(0.8f,0.8f,0.8f,alpha));
            
material->setSpecular(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,0.0f,alpha));
#endif
        }

// no longer required...
//         bool decal = false;
//
//         // not sure exactly how to interpret what is best for .3ds
//         // but the default text env MODULATE doesn't work well, and
//         // DECAL seems to work better.
//         osg::TexEnv* texenv = new osg::TexEnv;
//         if (decal)
//         {
//             texenv->setMode(osg::TexEnv::DECAL);
//         }
//         else
//         {
//             texenv->setMode(osg::TexEnv::MODULATE);
//         }
//        stateset->setTextureAttribute(0,texenv);
    }

    if (transparency>0.0f || textureTransparancy)
    {
        stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
        stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
    }

/*
    osg::ref_ptr<osg::Texture> texture1_mask = 
createTexture(&(mat->texture1_mask),"texture1_mask",textureTransparancy);
    osg::ref_ptr<osg::Texture> texture2_map = 
createTexture(&(mat->texture2_map),"texture2_map",textureTransparancy);
    osg::ref_ptr<osg::Texture> texture2_mask = 
createTexture(&(mat->texture2_mask),"texture2_mask",textureTransparancy);
    osg::ref_ptr<osg::Texture> opacity_map = 
createTexture(&(mat->opacity_map),"opacity_map",textureTransparancy);
    osg::ref_ptr<osg::Texture> opacity_mask = 
createTexture(&(mat->opacity_mask),"opacity_mask",textureTransparancy);
    osg::ref_ptr<osg::Texture> bump_map = 
createTexture(&(mat->bump_map),"bump_map",textureTransparancy);
    osg::ref_ptr<osg::Texture> bump_mask = 
createTexture(&(mat->bump_mask),"bump_mask",textureTransparancy);
    osg::ref_ptr<osg::Texture> specular_map = 
createTexture(&(mat->specular_map),"specular_map",textureTransparancy);
    osg::ref_ptr<osg::Texture> specular_mask = 
createTexture(&(mat->specular_mask),"specular_mask",textureTransparancy);
    osg::ref_ptr<osg::Texture> shininess_map = 
createTexture(&(mat->shininess_map),"shininess_map",textureTransparancy);
    osg::ref_ptr<osg::Texture> shininess_mask = 
createTexture(&(mat->shininess_mask),"shininess_mask",textureTransparancy);
    osg::ref_ptr<osg::Texture> self_illum_map = 
createTexture(&(mat->self_illum_map),"self_illum_map",textureTransparancy);
    osg::ref_ptr<osg::Texture> self_illum_mask = 
createTexture(&(mat->self_illum_mask),"self_illum_mask",textureTransparancy);
    osg::ref_ptr<osg::Texture> reflection_map = 
createTexture(&(mat->reflection_map),"reflection_map",textureTransparancy);
    osg::ref_ptr<osg::Texture> reflection_mask = 
createTexture(&(mat->reflection_mask),"reflection_mask",textureTransparancy);
*/
    return stateset;
}









_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to