Changeset 333 for experimental


Ignore:
Timestamp:
Mar 11, 2012, 8:35:06 PM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r332 r333  
    4646        "void main() \n"
    4747        "{ \n"
    48         "    gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; \n"
    49                 "        gl_FrontColor = osg_Color;\n"
     48        //"    gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; \n"
     49                "    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"       
     50                "        gl_FrontColor = gl_Color;\n"
     51                "        gl_TexCoord[0] = gl_MultiTexCoord0;    \n"
     52//              "        gl_TexCoord[1] = gl_MultiTexCoord1;    \n"
     53                ""
    5054                " \n"
    5155        "} \n";
     
    6165        "void main(void) \n"
    6266        "{\n"
    63                 "        vec2 texcoord0 = vec2( gl_TexCoord[0] );\n"
    64                 "        vec2 texcoord1 = vec2( gl_TexCoord[1] );\n"
    65         "    gl_FragColor = texture2D( sceneTexture, texcoord0) * texture2D( sceneTexture, texcoord0); \n"
     67                "       vec4 distortColor;      \n"
     68                "       vec4 blendColor;        \n"
     69                "\n"
     70                "       distortColor = texture2D(sceneTexture, gl_TexCoord[0]); \n"
     71                //"     blendColor = texture2D(intensityMapTexture, gl_TexCoord[1].st); \n"
     72                "       blendColor = texture2D(intensityMapTexture, gl_FragCoord);      \n"
     73                //"    gl_FragColor = vec4( 1.,1.,1.,1.); \n"
     74                "gl_FragColor =  blendColor;    \n"
    6675        "}\n";
    6776    osg::Shader* fShader = new osg::Shader( osg::Shader::FRAGMENT, fragmentSource );
     
    137146
    138147                        // Set coordinates for second texcoords array (if applyIntensityMapAsColours==true)
    139                         if (texcoords1) texcoords1->push_back( texcoord );
     148                        if (texcoords1)
     149                                texcoords1->push_back( texcoord );
    140150                }
    141151        }
     
    149159
    150160    geom->setTexCoordArray(0,texcoords0);
    151     if (texcoords1) geom->setTexCoordArray(1,texcoords1);
     161    if (texcoords1)
     162                geom->setTexCoordArray(1,texcoords1);
    152163
    153164 //   osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
     
    168179        {
    169180                configureShaders( geom->getOrCreateStateSet() );
    170                 geom->setInitialBound( osg::BoundingBox(origin, origin+widthVector+heightVector) );
    171181        }
    172182
     
    216226        return;
    217227    }
    218        
     228
    219229        // Set up projection Matrix as it is done in View::setUpViewOnSingleScreen(
    220230        double fovy, aspectRatio, zNear, zFar;
     
    273283    // distortion correction set up.
    274284    {
    275         osg::Geode* geode = new osg::Geode();
    276                 //geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 1, 0.45, intensityMap, projectorMatrix));
    277                 osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, intensityMap, applyIntensityMapAsColours, projectorMatrix);
    278                 geode->addDrawable(distortionMesh);
    279 
    280         // new we need to add the scene texture to the mesh, we do so by creating a
     285                osg::Geode* geode = new osg::Geode();
     286
     287                // new we need to add the scene texture to the mesh, we do so by creating a
    281288        // StateSet to contain the Texture StateAttribute.
    282289        osg::StateSet* stateset = geode->getOrCreateStateSet();
     
    284291        stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
    285292
    286         osg::TexMat* texmat = new osg::TexMat;
     293                osg::TexMat* texmat = new osg::TexMat;
    287294        texmat->setScaleByTextureRectangleSize(true);
    288295        stateset->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON);
    289296
    290         if (!applyIntensityMapAsColours && intensityMap)
     297                // If the intensityMap is used but not applyIntensityMapAsColours: Apply intensityMap as intensityMapTexture on unit 1
     298                if (!applyIntensityMapAsColours && intensityMap)
    291299        {
    292300            stateset->setTextureAttributeAndModes(1, new osg::Texture2D(intensityMap), osg::StateAttribute::ON);
    293301        }
     302
     303        //geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 1, 0.45, intensityMap, projectorMatrix));
     304                osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, intensityMap, applyIntensityMapAsColours, projectorMatrix);
     305                geode->addDrawable(distortionMesh);
     306
    294307
    295308        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
     
    309322        camera->setViewMatrix(osg::Matrix::identity());
    310323
    311         // add subgraph to render
    312         //camera->addChild(geode);
    313 
    314                 // selector
    315                 geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
    316                 geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) );
    317                 osg::ref_ptr<distortionHandler> selector = new distortionHandler( camera, distortionMesh );
     324                //// selector
     325                //geode->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
     326                //geode->getOrCreateStateSet()->setAttributeAndModes( new osg::PolygonOffset(1.0f, 1.0f) );
     327                //osg::ref_ptr<distortionHandler> selector = new distortionHandler( camera, distortionMesh );
    318328                osg::ref_ptr<osg::Group> root = new osg::Group;
    319329                root->addChild(geode);
    320                 root->addChild(selector->createVertexHighlighter());
    321                 addEventHandler( selector.get() );
     330                //root->addChild(selector->createVertexHighlighter());
     331                //addEventHandler( selector.get() );
    322332                camera->addChild(root);
    323                 // Avoid that the highlighter is culled away
    324                 osg::CullSettings::CullingMode mode = camera->getCullingMode();
    325                 camera->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) );
     333                //// Avoid that the highlighter is culled away
     334                //osg::CullSettings::CullingMode mode = camera->getCullingMode();
     335                //camera->setCullingMode( mode & (~osg::CullSettings::SMALL_FEATURE_CULLING) );
    326336
    327337
Note: See TracChangeset for help on using the changeset viewer.