Show
Ignore:
Timestamp:
06/29/04 16:58:24 (13 years ago)
Author:
robert
Message:

Improved the handling of normal lighting

Files:
1 modified

Legend:

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

    r3091 r3092  
    458458} 
    459459 
    460 osg::Node* createModel(osg::Image* image_3d, bool createNormalMap) 
     460osg::Node* createModel(osg::ref_ptr<osg::Image>& image_3d, bool createNormalMap) 
    461461{ 
    462462    unsigned int diffuse_unit = createNormalMap ? 1 : 0; 
     
    547547        texture3D->setInternalFormatMode(osg::Texture3D::USE_USER_DEFINED_FORMAT); 
    548548        texture3D->setInternalFormat(GL_INTENSITY); 
    549         texture3D->setImage(image_3d); 
     549        texture3D->setImage(image_3d.get()); 
    550550 
    551551        stateset->setTextureAttributeAndModes(diffuse_unit,texture3D,osg::StateAttribute::ON); 
     
    559559    else 
    560560    { 
    561         osg::ref_ptr<osg::Image> bumpmap_3d = createNormalMapTexture(image_3d); 
     561        osg::ref_ptr<osg::Image> bumpmap_3d = createNormalMapTexture(image_3d.get()); 
    562562        osg::Texture3D* bump_texture3D = new osg::Texture3D; 
    563563        bump_texture3D->setFilter(osg::Texture3D::MIN_FILTER,osg::Texture3D::LINEAR); 
     
    566566        bump_texture3D->setWrap(osg::Texture3D::WRAP_S,osg::Texture3D::CLAMP); 
    567567        bump_texture3D->setWrap(osg::Texture3D::WRAP_T,osg::Texture3D::CLAMP); 
    568         bump_texture3D->setInternalFormatMode(osg::Texture3D::USE_USER_DEFINED_FORMAT); 
    569         bump_texture3D->setInternalFormat(GL_INTENSITY); 
     568        //bump_texture3D->setInternalFormatMode(osg::Texture3D::USE_USER_DEFINED_FORMAT); 
     569        //bump_texture3D->setInternalFormat(GL_INTENSITY); 
    570570        bump_texture3D->setImage(bumpmap_3d.get()); 
    571571 
     
    592592        stateset->setTextureMode(bumpmap_unit,GL_TEXTURE_GEN_T,osg::StateAttribute::ON); 
    593593        stateset->setTextureMode(bumpmap_unit,GL_TEXTURE_GEN_R,osg::StateAttribute::ON); 
     594 
     595        image_3d = bumpmap_3d; 
    594596    } 
    595597  
     
    678680     
    679681    // create a model from the images. 
    680     osg::Node* rootNode = createModel(image_3d.get(), createNormalMap); 
     682    osg::Node* rootNode = createModel(image_3d, createNormalMap); 
    681683 
    682684    if (!outputFile.empty()) 
     
    702704            std::cout<<"Extension not support for file output, not file written."<<std::endl; 
    703705        } 
     706         
     707        return 0; 
    704708    } 
    705709 
     
    711715        viewer.setSceneData(rootNode); 
    712716         
    713         // the construct state uses gl commands to resize images so we are forced 
    714         // to only call it once a valid graphics context has been established, 
    715         // for that we use a realize callback. 
    716 //        viewer.setRealizeCallback(new ConstructStateCallback(rootNode, imageList)); 
    717  
    718717        // create the windows and run the threads. 
    719718        viewer.realize(); 
    720  
    721         // osgDB::writeNodeFile(*rootNode,"test.ive"); 
    722719 
    723720        while( !viewer.done() )