Show
Ignore:
Timestamp:
01/08/10 12:32:55 (5 years ago)
Author:
robert
Message:

From Rob Radtke, "I recently ran into some issues trying to save/load a scene graph as a .ive file. The problems came about because the scene graph contained depth textures in it. I have attached a patch (against the current revision: 10919) that fixes the issues that I encountered. Both attachments contain the same patch--one is a .zip file that contains the modified files and the other is a text patch file. Here is a summary of the changes I made:

1) Add getShadowComparison() accessor function to osg::Texture class
2) Modify ReaderWriterTiff::writeTifStream() and _readColor() (in Image.cpp) to handle pixelFormat==GL_DEPTH_COMPONENT as if it were GL_LUMINANCE
3) Modify the Texture classes of the ive and osg plug-ins so that they save/load the following Texture members: _use_shadow_comparison, _shadow_compare_func and _shadow_texture_mode
"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/osg/Texture.cpp

    r9475 r10934  
    2727bool Texture_matchSourceTypeStr(const char* str,int& value); 
    2828const char* Texture_getSourceTypeStr(int value); 
     29bool Texture_matchShadowCompareFuncStr(const char* str,Texture::ShadowCompareFunc& value); 
     30const char* Texture_getShadowCompareFuncStr(Texture::ShadowCompareFunc value); 
     31bool Texture_matchShadowTextureModeStr(const char* str,Texture::ShadowTextureMode& value); 
     32const char* Texture_getShadowTextureModeStr(Texture::ShadowTextureMode value); 
    2933 
    3034// register the read and write functions with the osgDB::Registry. 
     
    202206    } 
    203207 
     208    if (fr[0].matchWord("shadowComparison")) 
     209    { 
     210        if (fr[1].matchWord("TRUE"))  
     211        { 
     212            texture.setShadowComparison(true); 
     213            fr +=2 ; 
     214            iteratorAdvanced = true; 
     215        } 
     216        else if (fr[1].matchWord("FALSE"))  
     217        { 
     218            texture.setShadowComparison(false); 
     219            fr +=2 ; 
     220            iteratorAdvanced = true; 
     221        } 
     222    } 
     223 
     224    if (fr[0].matchWord("shadowCompareFunc")) 
     225    { 
     226        Texture::ShadowCompareFunc value; 
     227        if (Texture_matchShadowCompareFuncStr(fr[1].getStr(),value)) 
     228        { 
     229            texture.setShadowCompareFunc(value); 
     230            fr+=2; 
     231            iteratorAdvanced = true; 
     232        } 
     233    } 
     234 
     235    if (fr[0].matchWord("shadowTextureMode")) 
     236    { 
     237        Texture::ShadowTextureMode value; 
     238        if (Texture_matchShadowTextureModeStr(fr[1].getStr(),value)) 
     239        { 
     240            texture.setShadowTextureMode(value); 
     241            fr+=2; 
     242            iteratorAdvanced = true; 
     243        } 
     244    } 
     245 
    204246    return iteratorAdvanced; 
    205247} 
     
    254296 
    255297    fw.indent() << "resizeNonPowerOfTwo "<< (texture.getResizeNonPowerOfTwoHint()?"TRUE":"FALSE") << std::endl; 
     298 
     299    fw.indent() << "shadowComparison "<< (texture.getShadowComparison()?"TRUE":"FALSE") << std::endl; 
     300 
     301    fw.indent() << "shadowCompareFunc " << Texture_getShadowCompareFuncStr(texture.getShadowCompareFunc()) << std::endl; 
     302 
     303    fw.indent() << "shadowTextureMode " << Texture_getShadowTextureModeStr(texture.getShadowTextureMode()) << std::endl; 
    256304 
    257305    return true; 
     
    427475} 
    428476 
    429  
    430477const char* Texture_getSourceTypeStr(int value) 
    431478{ 
     
    442489    return NULL; 
    443490} 
     491 
     492bool Texture_matchShadowCompareFuncStr(const char* str, Texture::ShadowCompareFunc& value) 
     493{ 
     494    if (     strcmp(str,"GL_LEQUAL")==0) value = Texture::LEQUAL; 
     495    else if (strcmp(str,"GL_GEQUAL")==0) value = Texture::GEQUAL; 
     496    else return false; 
     497 
     498    return true; 
     499} 
     500 
     501const char* Texture_getShadowCompareFuncStr(Texture::ShadowCompareFunc value) 
     502{ 
     503    switch(value) 
     504    { 
     505    case( Texture::LEQUAL ): return "GL_LEQUAL"; 
     506    case( Texture::GEQUAL ): return "GL_GEQUAL"; 
     507    } 
     508    return NULL; 
     509} 
     510 
     511bool Texture_matchShadowTextureModeStr(const char* str,Texture::ShadowTextureMode& value) 
     512{ 
     513    if (     strcmp(str,"GL_LUMINANCE")==0) value = Texture::LUMINANCE; 
     514    else if (strcmp(str,"GL_INTENSITY")==0) value = Texture::INTENSITY; 
     515    else if (strcmp(str,"GL_ALPHA")==0) value = Texture::ALPHA; 
     516    else return false; 
     517 
     518    return true; 
     519} 
     520 
     521const char* Texture_getShadowTextureModeStr(Texture::ShadowTextureMode value) 
     522{ 
     523    switch(value) 
     524    { 
     525        case( Texture::LUMINANCE ): return "GL_LUMINANCE"; 
     526        case( Texture::INTENSITY ): return "GL_INTENSITY"; 
     527        case( Texture::ALPHA ): return "GL_ALPHA"; 
     528    } 
     529    return NULL; 
     530}