Changeset 333
- Timestamp:
- Mar 11, 2012, 8:35:06 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/extViewer.cpp
r332 r333 46 46 "void main() \n" 47 47 "{ \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 "" 50 54 " \n" 51 55 "} \n"; … … 61 65 "void main(void) \n" 62 66 "{\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" 66 75 "}\n"; 67 76 osg::Shader* fShader = new osg::Shader( osg::Shader::FRAGMENT, fragmentSource ); … … 137 146 138 147 // Set coordinates for second texcoords array (if applyIntensityMapAsColours==true) 139 if (texcoords1) texcoords1->push_back( texcoord ); 148 if (texcoords1) 149 texcoords1->push_back( texcoord ); 140 150 } 141 151 } … … 149 159 150 160 geom->setTexCoordArray(0,texcoords0); 151 if (texcoords1) geom->setTexCoordArray(1,texcoords1); 161 if (texcoords1) 162 geom->setTexCoordArray(1,texcoords1); 152 163 153 164 // osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES); … … 168 179 { 169 180 configureShaders( geom->getOrCreateStateSet() ); 170 geom->setInitialBound( osg::BoundingBox(origin, origin+widthVector+heightVector) );171 181 } 172 182 … … 216 226 return; 217 227 } 218 228 219 229 // Set up projection Matrix as it is done in View::setUpViewOnSingleScreen( 220 230 double fovy, aspectRatio, zNear, zFar; … … 273 283 // distortion correction set up. 274 284 { 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 281 288 // StateSet to contain the Texture StateAttribute. 282 289 osg::StateSet* stateset = geode->getOrCreateStateSet(); … … 284 291 stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 285 292 286 293 osg::TexMat* texmat = new osg::TexMat; 287 294 texmat->setScaleByTextureRectangleSize(true); 288 295 stateset->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON); 289 296 290 if (!applyIntensityMapAsColours && intensityMap) 297 // If the intensityMap is used but not applyIntensityMapAsColours: Apply intensityMap as intensityMapTexture on unit 1 298 if (!applyIntensityMapAsColours && intensityMap) 291 299 { 292 300 stateset->setTextureAttributeAndModes(1, new osg::Texture2D(intensityMap), osg::StateAttribute::ON); 293 301 } 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 294 307 295 308 osg::ref_ptr<osg::Camera> camera = new osg::Camera; … … 309 322 camera->setViewMatrix(osg::Matrix::identity()); 310 323 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 ); 318 328 osg::ref_ptr<osg::Group> root = new osg::Group; 319 329 root->addChild(geode); 320 root->addChild(selector->createVertexHighlighter());321 addEventHandler( selector.get() );330 //root->addChild(selector->createVertexHighlighter()); 331 //addEventHandler( selector.get() ); 322 332 camera->addChild(root); 323 // Avoid that the highlighter is culled away324 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) ); 326 336 327 337
Note: See TracChangeset
for help on using the changeset viewer.