Show
Ignore:
Timestamp:
12/19/14 09:27:30 (less than one hour ago)
Author:
robert
Message:

Added if () block to avoid script variables set to NOT-Found being used in searching

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp

    r12835 r13204  
    116116} 
    117117 
    118 struct ModulateAlphaByLuminanceOperator 
    119 { 
    120     ModulateAlphaByLuminanceOperator() {} 
    121  
    122     inline void luminance(float&) const {} 
    123     inline void alpha(float&) const {} 
    124     inline void luminance_alpha(float& l,float& a) const { a*= l; } 
    125     inline void rgb(float&,float&,float&) const {} 
    126     inline void rgba(float& r,float& g,float& b,float& a) const { float l = (r+g+b)*0.3333333; a *= l;} 
    127 }; 
    128  
    129  
    130118struct ScaleOperator 
    131119{ 
     
    309297 
    310298 
    311 } 
    312  
    313 enum ColourSpaceOperation 
    314 { 
    315     NO_COLOUR_SPACE_OPERATION, 
    316     MODULATE_ALPHA_BY_LUMINANCE, 
    317     MODULATE_ALPHA_BY_COLOUR, 
    318     REPLACE_ALPHA_WITH_LUMINANCE, 
    319     REPLACE_RGB_WITH_LUMINANCE 
    320 }; 
    321  
    322 struct ModulateAlphaByColourOperator 
    323 { 
    324     ModulateAlphaByColourOperator(const osg::Vec4& colour):_colour(colour) { _lum = _colour.length(); } 
    325  
    326     osg::Vec4 _colour; 
    327     float _lum; 
    328  
    329     inline void luminance(float&) const {} 
    330     inline void alpha(float&) const {} 
    331     inline void luminance_alpha(float& l,float& a) const { a*= l*_lum; } 
    332     inline void rgb(float&,float&,float&) const {} 
    333     inline void rgba(float& r,float& g,float& b,float& a) const { a = (r*_colour.r()+g*_colour.g()+b*_colour.b()+a*_colour.a()); } 
    334 }; 
    335  
    336 struct ReplaceAlphaWithLuminanceOperator 
    337 { 
    338     ReplaceAlphaWithLuminanceOperator() {} 
    339  
    340     inline void luminance(float&) const {} 
    341     inline void alpha(float&) const {} 
    342     inline void luminance_alpha(float& l,float& a) const { a= l; } 
    343     inline void rgb(float&,float&,float&) const { } 
    344     inline void rgba(float& r,float& g,float& b,float& a) const { float l = (r+g+b)*0.3333333; a = l; } 
    345 }; 
    346  
    347 osg::Image* doColourSpaceConversion(ColourSpaceOperation op, osg::Image* image, osg::Vec4& colour) 
    348 { 
    349     switch(op) 
    350     { 
    351         case (MODULATE_ALPHA_BY_LUMINANCE): 
    352         { 
    353             std::cout<<"doing conversion MODULATE_ALPHA_BY_LUMINANCE"<<std::endl; 
    354             osg::modifyImage(image,ModulateAlphaByLuminanceOperator()); 
    355             return image; 
    356         } 
    357         case (MODULATE_ALPHA_BY_COLOUR): 
    358         { 
    359             std::cout<<"doing conversion MODULATE_ALPHA_BY_COLOUR"<<std::endl; 
    360             osg::modifyImage(image,ModulateAlphaByColourOperator(colour)); 
    361             return image; 
    362         } 
    363         case (REPLACE_ALPHA_WITH_LUMINANCE): 
    364         { 
    365             std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANCE"<<std::endl; 
    366             osg::modifyImage(image,ReplaceAlphaWithLuminanceOperator()); 
    367             return image; 
    368         } 
    369         case (REPLACE_RGB_WITH_LUMINANCE): 
    370         { 
    371             std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANCE"<<std::endl; 
    372             osg::Image* newImage = new osg::Image; 
    373             newImage->allocateImage(image->s(), image->t(), image->r(), GL_LUMINANCE, image->getDataType()); 
    374             osg::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(), 
    375                         newImage, 0, 0, 0, false); 
    376             return newImage; 
    377         } 
    378         default: 
    379             return image; 
    380     } 
    381299} 
    382300 
     
    672590 
    673591    // set up colour space operation. 
    674     ColourSpaceOperation colourSpaceOperation = NO_COLOUR_SPACE_OPERATION; 
     592    osg::ColorSpaceOperation colourSpaceOperation = osg::NO_COLOUR_SPACE_OPERATION; 
    675593    osg::Vec4 colourModulate(0.25f,0.25f,0.25f,0.25f); 
    676     while(arguments.read("--modulate-alpha-by-luminance")) { colourSpaceOperation = MODULATE_ALPHA_BY_LUMINANCE; } 
    677     while(arguments.read("--modulate-alpha-by-colour", colourModulate.x(),colourModulate.y(),colourModulate.z(),colourModulate.w() )) { colourSpaceOperation = MODULATE_ALPHA_BY_COLOUR; } 
    678     while(arguments.read("--replace-alpha-with-luminance")) { colourSpaceOperation = REPLACE_ALPHA_WITH_LUMINANCE; } 
    679     while(arguments.read("--replace-rgb-with-luminance")) { colourSpaceOperation = REPLACE_RGB_WITH_LUMINANCE; } 
     594    while(arguments.read("--modulate-alpha-by-luminance")) { colourSpaceOperation = osg::MODULATE_ALPHA_BY_LUMINANCE; } 
     595    while(arguments.read("--modulate-alpha-by-colour", colourModulate.x(),colourModulate.y(),colourModulate.z(),colourModulate.w() )) { colourSpaceOperation = osg::MODULATE_ALPHA_BY_COLOUR; } 
     596    while(arguments.read("--replace-alpha-with-luminance")) { colourSpaceOperation = osg::REPLACE_ALPHA_WITH_LUMINANCE; } 
     597    while(arguments.read("--replace-rgb-with-luminance")) { colourSpaceOperation = osg::REPLACE_RGB_WITH_LUMINANCE; } 
    680598 
    681599 
     
    1019937 
    1020938 
    1021     if (colourSpaceOperation!=NO_COLOUR_SPACE_OPERATION) 
     939    if (colourSpaceOperation!=osg::NO_COLOUR_SPACE_OPERATION) 
    1022940    { 
    1023941        for(Images::iterator itr = images.begin(); 
     
    1025943            ++itr) 
    1026944        { 
    1027             (*itr) = doColourSpaceConversion(colourSpaceOperation, itr->get(), colourModulate); 
     945            (*itr) = osg::colorSpaceConversion(colourSpaceOperation, itr->get(), colourModulate); 
    1028946        } 
    1029947    }