Changeset 13041 for OpenSceneGraph/trunk/src/osgShadow/ShadowVolume.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgShadow/ShadowVolume.cpp
r11478 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 39 39 { 40 40 // _drawMode = osgShadow::ShadowVolumeGeometry::GEOMETRY; 41 41 42 42 OSG_INFO<<"Warning: osgShadow::ShadowVolume technique is still in development, with current limitations that make it unsuitable for deployment. Please contact the osg-users for an update of developements."<<std::endl; 43 43 } … … 57 57 { 58 58 if (_drawMode == drawMode) return; 59 59 60 60 _drawMode = drawMode; 61 61 62 62 dirty(); 63 63 } … … 72 72 { 73 73 if (!_shadowedScene) return; 74 75 // get the bounds of the model. 74 75 // get the bounds of the model. 76 76 osg::ComputeBoundsVisitor cbbv; 77 77 _shadowedScene->osg::Group::traverse(cbbv); … … 118 118 geode->addDrawable(_shadowVolume.get()); 119 119 } 120 120 121 121 { 122 122 … … 133 133 _ambientLight->setDiffuse(zero_colour); 134 134 _ss1->setAttributeAndModes(_ambientLight.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 135 135 136 136 _ss1->setMode(GL_LIGHTING, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 137 137 } … … 149 149 { 150 150 _shadowVolumeStateSet = new osg::StateSet; 151 151 152 152 osg::Depth* depth = new osg::Depth; 153 153 depth->setWriteMask(false); … … 228 228 229 229 } 230 230 231 231 _dirty = false; 232 232 } … … 264 264 265 265 if (shadowVolumeBin.valid()) 266 { 266 { 267 267 original_bin->setStateSet(_ss1.get()); 268 268 … … 277 277 new_rs->setReadBuffer(orig_rs->getReadBuffer(), orig_rs->getReadBufferApplyMask()); 278 278 new_rs->setColorMask(orig_rs->getColorMask()); 279 279 280 280 osg::Vec4 lightpos; 281 281 282 282 osg::ref_ptr<osgUtil::PositionalStateContainer> ps = new osgUtil::PositionalStateContainer; 283 283 new_rs->setPositionalStateContainer(ps.get()); … … 296 296 if (matrix) lightpos = light->getPosition() * (*matrix); 297 297 else lightpos = light->getPosition(); 298 298 299 299 selectLight = light; 300 300 } 301 301 else 302 302 { 303 ps->addPositionedAttribute(itr->second.get(), itr->first.get()); 303 ps->addPositionedAttribute(itr->second.get(), itr->first.get()); 304 304 } 305 305 } 306 306 307 307 _ambientLight->setPosition(lightpos); 308 308 309 309 orig_rs->addPositionedAttribute(0,_ambientLight.get()); 310 310 311 311 _diffuseLight->setPosition(lightpos); 312 312 if (selectLight) 313 313 { 314 314 _ambientLight->setAmbient(selectLight->getAmbient()); 315 315 316 316 _diffuseLight->setDiffuse(selectLight->getDiffuse()); 317 317 _diffuseLight->setSpecular(selectLight->getSpecular()); … … 324 324 } 325 325 ps->addPositionedAttribute(0, _diffuseLight.get()); 326 326 327 327 if (_lightpos != lightpos && _dynamicShadowVolumes) 328 328 { … … 331 331 osg::Matrix eyeToWorld; 332 332 eyeToWorld.invert(*cv.getModelViewMatrix()); 333 333 334 334 _occluder->computeShadowVolumeGeometry(lightpos * eyeToWorld, *_shadowVolume); 335 335 } 336 336 337 337 if (shadowVolumeBin.valid()) 338 338 { … … 347 347 } 348 348 349 349 350 350 } 351 351
