Changeset 12174 for OpenSceneGraph/trunk/examples/osgshadow/osgshadow.cpp
- Timestamp:
- 02/20/11 10:55:20 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgshadow/osgshadow.cpp
r12159 r12174 596 596 return 1; 597 597 } 598 599 bool postionalLight = true; 600 while (arguments.read("--positionalLight")) postionalLight = true; 601 while (arguments.read("--directionalLight")) postionalLight = false; 598 599 float fov = 0.0; 600 while (arguments.read("--fov",fov)) {} 601 602 osg::Vec4 lightpos(0.0,0.0,1,0.0); 603 while (arguments.read("--positionalLight")) { lightpos.set(0.5,0.5,1.5,1.0); } 604 while (arguments.read("--directionalLight")) { lightpos.set(0.0,0.0,1,0.0); } 605 606 while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z(), lightpos.w())) {} 607 while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=1.0; } 608 while ( arguments.read("--light-dir", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=0.0; } 609 602 610 603 611 while (arguments.read("--castsShadowMask", CastsShadowTraversalMask )); … … 642 650 viewer.addEventHandler(new osgViewer::RecordCameraPathHandler); 643 651 652 // add the window size toggle handler 653 viewer.addEventHandler(new osgViewer::WindowSizeHandler); 654 644 655 // add the threading handler 645 656 viewer.addEventHandler( new osgViewer::ThreadingHandler() ); … … 786 797 osg::BoundingBox bb = cbbv.getBoundingBox(); 787 798 788 osg::Vec4 lightpos; 789 790 if (postionalLight) 791 { 792 lightpos.set(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius()*2.0f ,1.0f); 793 } 794 else 795 { 796 lightpos.set(0.5f,0.25f,0.8f,0.0f); 797 } 798 799 799 if (lightpos.w()==1.0) 800 { 801 lightpos.x() = bb.xMin()+(bb.xMax()-bb.xMin())*lightpos.x(); 802 lightpos.y() = bb.yMin()+(bb.yMax()-bb.yMin())*lightpos.y(); 803 lightpos.z() = bb.zMin()+(bb.zMax()-bb.zMin())*lightpos.z(); 804 } 805 800 806 if ( arguments.read("--base")) 801 807 { … … 856 862 // create the windows and run the threads. 857 863 viewer.realize(); 864 865 if (fov!=0.0) 866 { 867 double fovy, aspectRatio, zNear, zFar; 868 viewer.getCamera()->getProjectionMatrix().getPerspective(fovy, aspectRatio, zNear, zFar); 869 870 std::cout << "Setting FOV to " << fov << std::endl; 871 viewer.getCamera()->getProjectionMatrix().makePerspective(fov, aspectRatio, zNear, zFar); 872 } 858 873 859 874 // it is done after viewer.realize() so that the windows are already initialized … … 910 925 float t = viewer.getFrameStamp()->getSimulationTime(); 911 926 912 if ( postionalLight)927 if (lightpos.w()==1.0) 913 928 { 914 929 lightpos.set(bb.center().x()+sinf(t)*bb.radius(), bb.center().y() + cosf(t)*bb.radius(), bb.zMax() + bb.radius()*3.0f ,1.0f);
