Changeset 12743 for OpenSceneGraph/trunk/examples/osgshadow/osgshadow.cpp
- Timestamp:
- 08/07/11 17:54:21 (23 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgshadow/osgshadow.cpp
r12529 r12743 44 44 #include <osgShadow/LightSpacePerspectiveShadowMap> 45 45 #include <osgShadow/StandardShadowMap> 46 #include <osgShadow/ViewDependentShadowMap> 46 47 47 48 #include <osgDB/ReadFile> … … 651 652 652 653 osg::Vec4 lightpos(0.0,0.0,1,0.0); 654 bool spotlight = false; 653 655 while (arguments.read("--positionalLight")) { lightpos.set(0.5,0.5,1.5,1.0); } 654 656 while (arguments.read("--directionalLight")) { lightpos.set(0.0,0.0,1,0.0); } 655 656 while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z(), lightpos.w())) {} 657 while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=1.0; } 658 while ( arguments.read("--light-dir", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=0.0; } 657 while (arguments.read("--spotLight")) { lightpos.set(0.5,0.5,1.5,1.0); spotlight = true; } 658 659 bool keepLightPos = false; 660 osg::Vec3 spotLookat(0.0,0.0,0.0); 661 while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z(), lightpos.w())) { keepLightPos = true; } 662 while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=1.0; keepLightPos = true; } 663 while ( arguments.read("--light-dir", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=0.0; keepLightPos = true; } 664 while ( arguments.read("--spot-lookat", spotLookat.x(), spotLookat.y(), spotLookat.z())) { } 659 665 660 666 … … 806 812 msm = new osgShadow::MinimalDrawBoundsShadowMap; 807 813 } 814 else if( arguments.read("--vdsm") ) 815 { 816 osg::ref_ptr<osgShadow::ViewDependentShadowMap> vdsm = new osgShadow::ViewDependentShadowMap; 817 shadowedScene->setShadowTechnique(vdsm.get()); 818 } 808 819 else /* if (arguments.read("--sm")) */ 809 820 { … … 861 872 osg::BoundingBox bb = cbbv.getBoundingBox(); 862 873 863 if (lightpos.w()==1.0 )874 if (lightpos.w()==1.0 && !keepLightPos) 864 875 { 865 876 lightpos.x() = bb.xMin()+(bb.xMax()-bb.xMin())*lightpos.x(); … … 890 901 ls->getLight()->setPosition(lightpos); 891 902 892 bool spotlight = false; 893 if (arguments.read("--spotLight")) 894 { 895 spotlight = true; 896 897 osg::Vec3 center = bb.center(); 903 if (spotlight) 904 { 905 osg::Vec3 center = spotLookat; 898 906 osg::Vec3 lightdir = center - osg::Vec3(lightpos.x(), lightpos.y(), lightpos.z()); 899 907 lightdir.normalize();
