From 5163c4a762ede182cfa26352bb978ee1480982d3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 6 Oct 2006 14:16:11 +0000 Subject: [PATCH] First cut at class interfaces and stubs for implementations for the new osgShadow NodeKit --- Make/makedirdefs | 8 +- VisualStudio/OpenSceneGraph.dsw | 48 ++ VisualStudio/osgShadow/osgShadow.dsp | 226 ++++++++ .../osgShadow/wrapper_osgShadow.dsp | 137 +++++ examples/osgshadow/GNUmakefile | 17 + examples/osgshadow/GNUmakefile.inst | 14 + examples/osgshadow/osgshadow.cpp | 506 ++++++++++++++++++ include/osgShadow/Export | 47 ++ include/osgShadow/ParallelSplitShadowMap | 41 ++ include/osgShadow/ShadowMap | 41 ++ include/osgShadow/ShadowTechnique | 47 ++ include/osgShadow/ShadowTexture | 41 ++ include/osgShadow/ShadowVolume | 41 ++ include/osgShadow/ShadowedScene | 62 +++ include/osgShadow/Version | 46 ++ src/osgShadow/GNUmakefile | 21 + src/osgShadow/ParallelSplitShadowMap.cpp | 27 + src/osgShadow/ShadowMap.cpp | 27 + src/osgShadow/ShadowTechnique.cpp | 25 + src/osgShadow/ShadowTexture.cpp | 27 + src/osgShadow/ShadowVolume.cpp | 27 + src/osgShadow/ShadowedScene.cpp | 58 ++ src/osgShadow/Version.cpp | 12 + .../osgShadow/ParallelSplitShadowMap.cpp | 35 ++ src/osgWrappers/osgShadow/ShadowTechnique.cpp | 35 ++ src/osgWrappers/osgShadow/ShadowVolume.cpp | 35 ++ src/osgWrappers/osgShadow/ShadowedScene.cpp | 49 ++ 27 files changed, 1697 insertions(+), 3 deletions(-) create mode 100644 VisualStudio/osgShadow/osgShadow.dsp create mode 100644 VisualStudio/osgWrappers/osgShadow/wrapper_osgShadow.dsp create mode 100644 examples/osgshadow/GNUmakefile create mode 100644 examples/osgshadow/GNUmakefile.inst create mode 100644 examples/osgshadow/osgshadow.cpp create mode 100644 include/osgShadow/Export create mode 100644 include/osgShadow/ParallelSplitShadowMap create mode 100644 include/osgShadow/ShadowMap create mode 100644 include/osgShadow/ShadowTechnique create mode 100644 include/osgShadow/ShadowTexture create mode 100644 include/osgShadow/ShadowVolume create mode 100644 include/osgShadow/ShadowedScene create mode 100644 include/osgShadow/Version create mode 100644 src/osgShadow/GNUmakefile create mode 100644 src/osgShadow/ParallelSplitShadowMap.cpp create mode 100644 src/osgShadow/ShadowMap.cpp create mode 100644 src/osgShadow/ShadowTechnique.cpp create mode 100644 src/osgShadow/ShadowTexture.cpp create mode 100644 src/osgShadow/ShadowVolume.cpp create mode 100644 src/osgShadow/ShadowedScene.cpp create mode 100644 src/osgShadow/Version.cpp create mode 100644 src/osgWrappers/osgShadow/ParallelSplitShadowMap.cpp create mode 100644 src/osgWrappers/osgShadow/ShadowTechnique.cpp create mode 100644 src/osgWrappers/osgShadow/ShadowVolume.cpp create mode 100644 src/osgWrappers/osgShadow/ShadowedScene.cpp diff --git a/Make/makedirdefs b/Make/makedirdefs index 668196140..9b1ca631a 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -20,6 +20,7 @@ SRC_DIRS = \ osgParticle \ osgText \ osgFX \ + osgShadow \ osgSim ifeq ($(PRODUCER_INSTALLED),yes) @@ -200,15 +201,14 @@ ifeq ($(PRODUCER_INSTALLED),yes) osgbillboard \ osgblendequation \ osgcallback \ - osgcatch \ osgcamera \ osgcameragroup \ + osgcatch \ osgclip \ osgcluster \ osgcopy \ osgcubemap \ osgdelaunay \ - osgdepthshadow \ osgdepthpartition \ osgdistortion \ osgforest \ @@ -227,8 +227,8 @@ ifeq ($(PRODUCER_INSTALLED),yes) osglogo \ osgmotionblur \ osgmovie \ - osgmultitexture \ osgmultiplecameras \ + osgmultitexture \ osgoccluder \ osgpagedlod \ osgparametric \ @@ -247,7 +247,9 @@ ifeq ($(PRODUCER_INSTALLED),yes) osgsequence \ osgshaders \ osgshaderterrain \ + osgshadow \ osgshadowtexture \ + osgdepthshadow \ osgshape \ osgsimple \ osgsimplepager \ diff --git a/VisualStudio/OpenSceneGraph.dsw b/VisualStudio/OpenSceneGraph.dsw index e73db382b..9727b0fd2 100644 --- a/VisualStudio/OpenSceneGraph.dsw +++ b/VisualStudio/OpenSceneGraph.dsw @@ -99,6 +99,24 @@ Package=<4> ############################################################################### +Project: "Core osgShadow"=.\osgShadow\osgShadow.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name Core osg + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgUtil + End Project Dependency +}}} + +############################################################################### + Project: "Core osgParticle"=.\osgParticle\osgParticle.dsp - Package Owner=<4> Package=<5> @@ -1842,6 +1860,36 @@ Package=<4> ############################################################################### +Project: "Example osgshadow"=.\examples\osgshadow\osgshadow.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name Core osg + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgDB + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgGA + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgProducer + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgUtil + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgShadow + End Project Dependency +}}} + +############################################################################### + Project: "Example osgslice"=.\examples\osgslice\osgslice.dsp - Package Owner=<4> Package=<5> diff --git a/VisualStudio/osgShadow/osgShadow.dsp b/VisualStudio/osgShadow/osgShadow.dsp new file mode 100644 index 000000000..546348c04 --- /dev/null +++ b/VisualStudio/osgShadow/osgShadow.dsp @@ -0,0 +1,226 @@ +# Microsoft Developer Studio Project File - Name="Core osgShadow" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=Core osgShadow - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "osgShadow.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "osgShadow.mak" CFG="Core osgShadow - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Core osgShadow - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Core osgShadow - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Core osgShadow - Win32 Release Static" (based on "Win32 (x86) Static Library") +!MESSAGE "Core osgShadow - Win32 Debug Static" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Core osgShadow - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "../../lib" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "osgShadow_LIBRARY" /D "WIN32" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 OpenThreadsWin32.lib opengl32.lib glu32.lib /nologo /dll /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgShadow.dll" /implib:"../../lib/$(PlatformName)/osgShadow.lib" /libpath:"../../lib/$(PlatformName)" /libpath:"../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../Producer/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib" + +!ELSEIF "$(CFG)" == "Core osgShadow - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "../../lib" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /vmg /GR /GX /Zi /Od /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "osgShadow_LIBRARY" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /Zm200 /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 OpenThreadsWin32d.lib opengl32.lib glu32.lib /nologo /dll /debug /machine:I386 /out:"$(OutDir)/osgShadowd.dll" /pdbtype:sept /implib:"../../lib/$(PlatformName)/osgShadowd.lib" /libpath:"../../lib/$(PlatformName)" /libpath:"../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../Producer/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib" +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "Core osgShadow - Win32 Release Static" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "../../lib" +# PROP BASE Intermediate_Dir "Release_Static" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../../lib/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "OSG_LIBRARY_STATIC" "OT_LIBRARY_STATIC" "PR_LIBRARY_STATIC" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "NDEBUG" /D "_MBCS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "WIN32" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgShadow_s.lib" + +!ELSEIF "$(CFG)" == "Core osgShadow - Win32 Debug Static" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "../../lib" +# PROP BASE Intermediate_Dir "Debug_Static" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../../lib/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "OSG_LIBRARY_STATIC" "OT_LIBRARY_STATIC" "PR_LIBRARY_STATIC" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /vmg /GR /GX /Z7 /Od /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /Zm200 /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgShadowd_s.lib" +# SUBTRACT LIB32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "Core osgShadow - Win32 Release" +# Name "Core osgShadow - Win32 Debug" +# Name "Core osgShadow - Win32 Release Static" +# Name "Core osgShadow - Win32 Debug Static" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\src\osgShadow\ShadowedScene.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgShadow\ShadowTechnique.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgShadow\ShadowTexture.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgShadow\ShadowMap.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgShadow\ShadowVolume.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgShadow\ParallelSplitShadowMap.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgShadow\Version.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter ";h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\include\osgShadow\Export +# End Source File +# Begin Source File + +SOURCE=..\..\include\osgShadow\ShadowedScene +# End Source File +# Begin Source File + +SOURCE=..\..\include\osgShadow\ShadowTechnique +# End Source File +# Begin Source File + +SOURCE=..\..\include\osgShadow\ShadowTexture +# End Source File +# Begin Source File + +SOURCE=..\..\include\osgShadow\ShadowMap +# End Source File +# Begin Source File + +SOURCE=..\..\include\osgShadow\ShadowVolume +# End Source File +# Begin Source File + +SOURCE=..\..\include\osgShadow\ParallelSplitShadowMap +# End Source File +# Begin Source File + +SOURCE=..\..\include\osgShadow\Version +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/VisualStudio/osgWrappers/osgShadow/wrapper_osgShadow.dsp b/VisualStudio/osgWrappers/osgShadow/wrapper_osgShadow.dsp new file mode 100644 index 000000000..54ce1cde9 --- /dev/null +++ b/VisualStudio/osgWrappers/osgShadow/wrapper_osgShadow.dsp @@ -0,0 +1,137 @@ +# Microsoft Developer Studio Project File - Name="osgWrapper osgShadow" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=osgWrapper osgShadow - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "wrapper_osgShadow.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "wrapper_osgShadow.mak" CFG="osgWrapper osgShadow - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "osgWrapper osgShadow - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "osgWrapper osgShadow - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "osgWrapper osgShadow - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../../../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 opengl32.lib OpenThreadsWin32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /opt:ref /opt:icf /out:"$(OutDir)/osgwrapper_osgShadow.dll" /implib:"../../../lib/$(PlatformName)/osgwrapper_osgShadow.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" +# SUBTRACT LINK32 /nodefaultlib + +!ELSEIF "$(CFG)" == "osgWrapper osgShadow - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../../../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /vmg /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 opengl32.lib OpenThreadsWin32d.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"$(OutDir)/osgwrapper_osgShadowd.dll" /pdbtype:sept /implib:"../../../lib/$(PlatformName)/osgwrapper_osgShadowd.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" +# SUBTRACT LINK32 /pdb:none /nodefaultlib + +!ENDIF + +# Begin Target + +# Name "osgWrapper osgShadow - Win32 Release" +# Name "osgWrapper osgShadow - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osgShadow\Export.cpp +# End Source File + +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osgShadow\ParallelSplitShadowMap.cpp +# End Source File + +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osgShadow\ShadowMap.cpp +# End Source File + +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osgShadow\ShadowTechnique.cpp +# End Source File + +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osgShadow\ShadowTexture.cpp +# End Source File + +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osgShadow\ShadowVolume.cpp +# End Source File + +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osgShadow\ShadowedScene.cpp +# End Source File + +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project + diff --git a/examples/osgshadow/GNUmakefile b/examples/osgshadow/GNUmakefile new file mode 100644 index 000000000..c135b4e4d --- /dev/null +++ b/examples/osgshadow/GNUmakefile @@ -0,0 +1,17 @@ +TOPDIR = ../.. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + osgshadow.cpp\ + +LIBS += -losgProducer -lProducer -losgShadow -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) + +INSTFILES = \ + $(CXXFILES)\ + GNUmakefile.inst=GNUmakefile + +EXEC = osgshadow + +INC += $(X_INC) + +include $(TOPDIR)/Make/makerules diff --git a/examples/osgshadow/GNUmakefile.inst b/examples/osgshadow/GNUmakefile.inst new file mode 100644 index 000000000..04826b526 --- /dev/null +++ b/examples/osgshadow/GNUmakefile.inst @@ -0,0 +1,14 @@ +TOPDIR = ../.. +include $(TOPDIR)/Make/makedefs + +CXXFILES =\ + osgshadow.cpp\ + +LIBS += -losgProducer -lProducer -losgShadow -losgText -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) + +EXEC = osgshadow + +INC += $(PRODUCER_INCLUDE_DIR) $(X_INC) +LDFLAGS += $(PRODUCER_LIB_DIR) + +include $(TOPDIR)/Make/makerules diff --git a/examples/osgshadow/osgshadow.cpp b/examples/osgshadow/osgshadow.cpp new file mode 100644 index 000000000..d5a6d1a14 --- /dev/null +++ b/examples/osgshadow/osgshadow.cpp @@ -0,0 +1,506 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +using namespace osg; + +class LightTransformCallback: public osg::NodeCallback +{ + +public: + + LightTransformCallback(float angular_velocity, float height, float radius): + _angular_velocity(angular_velocity), + _height(height), + _radius(radius), + _previous_traversal_number(-1), + _previous_time(-1.0f), + _angle(0) + { + } + + void operator()(Node* node, NodeVisitor* nv); + +protected: + + float _angular_velocity; + float _height; + float _radius; + int _previous_traversal_number; + double _previous_time; + float _angle; +}; + + +void +LightTransformCallback::operator()(Node* node, NodeVisitor* nv) +{ + MatrixTransform* transform = dynamic_cast(node); + if (nv && transform) + { + const FrameStamp* fs = nv->getFrameStamp(); + if (!fs) return; // not frame stamp, no handle on the time so can't move. + + double new_time = fs->getReferenceTime(); + if (nv->getTraversalNumber() != _previous_traversal_number) + { + _angle += _angular_velocity * (new_time - _previous_time); + + Matrix matrix = Matrix::rotate(atan(_height / _radius), -X_AXIS) * + Matrix::rotate(PI_2, Y_AXIS) * + Matrix::translate(Vec3(_radius, 0, 0)) * + Matrix::rotate(_angle, Y_AXIS) * + Matrix::translate(Vec3(0, _height, 0)); + + // update the specified transform + transform->setMatrix(matrix); + + _previous_traversal_number = nv->getTraversalNumber(); + } + + _previous_time = new_time; + } + + // must call any nested node callbacks and continue subgraph traversal. + traverse(node,nv); + +} + + +ref_ptr _create_lights() +{ + ref_ptr transform_0 = new MatrixTransform; + + // create a spot light. + ref_ptr light_0 = new Light; + light_0->setLightNum(0); + light_0->setPosition(Vec4(0, 0, 0, 1.0f)); + light_0->setAmbient(Vec4(0.0f, 0.0f, 0.0f, 1.0f)); + light_0->setDiffuse(Vec4(1.0f, 0.8f, 0.8f, 1.0f)); + light_0->setSpotCutoff(60.0f); + light_0->setSpotExponent(2.0f); + + ref_ptr light_source_0 = new LightSource; + light_source_0->setLight(light_0.get()); + light_source_0->setLocalStateSetModes(StateAttribute::ON); + transform_0->setUpdateCallback(new LightTransformCallback(inDegrees(90.0f), 8, 5)); + transform_0->addChild(light_source_0.get()); + + ref_ptr geode = new Geode; + + ref_ptr shape; + ref_ptr hints = new TessellationHints; + hints->setDetailRatio(0.3f); + shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 0.0f), 0.15f), hints.get()); + shape->setColor(Vec4(1.0f, 0.5f, 0.5f, 1.0f)); + geode->addDrawable(shape.get()); + shape = new ShapeDrawable(new Cylinder(Vec3(0.0f, 0.0f, -0.4f), 0.05f, 0.8f), hints.get()); + shape->setColor(Vec4(1.0f, 0.5f, 0.5f, 1.0f)); + geode->addDrawable(shape.get()); + + + geode->getOrCreateStateSet()->setMode(GL_LIGHTING, StateAttribute::OFF); + transform_0->addChild(geode.get()); + + return transform_0; +} + +ref_ptr _create_scene() +{ + ref_ptr scene = new Group; + ref_ptr geode_1 = new Geode; + scene->addChild(geode_1.get()); + + ref_ptr geode_2 = new Geode; + ref_ptr transform_2 = new MatrixTransform; + transform_2->addChild(geode_2.get()); + transform_2->setUpdateCallback(new osg::AnimationPathCallback(Vec3(0, 0, 0), Y_AXIS, inDegrees(45.0f))); + scene->addChild(transform_2.get()); + + ref_ptr geode_3 = new Geode; + ref_ptr transform_3 = new MatrixTransform; + transform_3->addChild(geode_3.get()); + transform_3->setUpdateCallback(new osg::AnimationPathCallback(Vec3(0, 0, 0), Y_AXIS, inDegrees(-22.5f))); + scene->addChild(transform_3.get()); + + const float radius = 0.8f; + const float height = 1.0f; + ref_ptr hints = new TessellationHints; + hints->setDetailRatio(2.0f); + ref_ptr shape; + + shape = new ShapeDrawable(new Box(Vec3(0.0f, -2.0f, 0.0f), 10, 0.1f, 10), hints.get()); + shape->setColor(Vec4(0.5f, 0.5f, 0.7f, 1.0f)); + geode_1->addDrawable(shape.get()); + + shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 0.0f), radius * 2), hints.get()); + shape->setColor(Vec4(0.8f, 0.8f, 0.8f, 1.0f)); + geode_1->addDrawable(shape.get()); + + shape = new ShapeDrawable(new Sphere(Vec3(-3.0f, 0.0f, 0.0f), radius), hints.get()); + shape->setColor(Vec4(0.6f, 0.8f, 0.8f, 1.0f)); + geode_2->addDrawable(shape.get()); + + shape = new ShapeDrawable(new Box(Vec3(3.0f, 0.0f, 0.0f), 2 * radius), hints.get()); + shape->setColor(Vec4(0.4f, 0.9f, 0.3f, 1.0f)); + geode_2->addDrawable(shape.get()); + + shape = new ShapeDrawable(new Cone(Vec3(0.0f, 0.0f, -3.0f), radius, height), hints.get()); + shape->setColor(Vec4(0.2f, 0.5f, 0.7f, 1.0f)); + geode_2->addDrawable(shape.get()); + + shape = new ShapeDrawable(new Cylinder(Vec3(0.0f, 0.0f, 3.0f), radius, height), hints.get()); + shape->setColor(Vec4(1.0f, 0.3f, 0.3f, 1.0f)); + geode_2->addDrawable(shape.get()); + + shape = new ShapeDrawable(new Box(Vec3(0.0f, 3.0f, 0.0f), 2, 0.1f, 2), hints.get()); + shape->setColor(Vec4(0.8f, 0.8f, 0.4f, 1.0f)); + geode_3->addDrawable(shape.get()); + + // material + ref_ptr matirial = new Material; + matirial->setColorMode(Material::DIFFUSE); + matirial->setAmbient(Material::FRONT_AND_BACK, Vec4(0, 0, 0, 1)); + matirial->setSpecular(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1)); + matirial->setShininess(Material::FRONT_AND_BACK, 64.0f); + scene->getOrCreateStateSet()->setAttributeAndModes(matirial.get(), StateAttribute::ON); + + return scene; +} + + +class UpdateCameraAndTexGenCallback : public osg::NodeCallback +{ + public: + + UpdateCameraAndTexGenCallback(osg::MatrixTransform* light_transform, osg::CameraNode* cameraNode, osg::TexGenNode* texgenNode): + _light_transform(light_transform), + _cameraNode(cameraNode), + _texgenNode(texgenNode) + { + } + + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + // first update subgraph to make sure objects are all moved into postion + traverse(node,nv); + + // now compute the camera's view and projection matrix to point at the shadower (the camera's children) + osg::BoundingSphere bs; + for(unsigned int i=0; i<_cameraNode->getNumChildren(); ++i) + { + bs.expandBy(_cameraNode->getChild(i)->getBound()); + } + + if (!bs.valid()) + { + osg::notify(osg::WARN) << "bb invalid"<<_cameraNode.get()<getMatrix().getTrans(); + + float centerDistance = (position-bs.center()).length(); + + float znear = centerDistance-bs.radius(); + float zfar = centerDistance+bs.radius(); + float zNearRatio = 0.001f; + if (znearsetReferenceFrame(osg::CameraNode::ABSOLUTE_RF); + _cameraNode->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar); + _cameraNode->setViewMatrixAsLookAt(position,bs.center(),osg::Vec3(0.0f,1.0f,0.0f)); + + // compute the matrix which takes a vertex from local coords into tex coords + // will use this later to specify osg::TexGen.. + osg::Matrix MVPT = _cameraNode->getViewMatrix() * + _cameraNode->getProjectionMatrix() * + osg::Matrix::translate(1.0,1.0,1.0) * + osg::Matrix::scale(0.5f,0.5f,0.5f); + + _texgenNode->getTexGen()->setMode(osg::TexGen::EYE_LINEAR); + _texgenNode->getTexGen()->setPlanesFromMatrix(MVPT); + + } + + protected: + + virtual ~UpdateCameraAndTexGenCallback() {} + + osg::ref_ptr _light_transform; + osg::ref_ptr _cameraNode; + osg::ref_ptr _texgenNode; + +}; + +////////////////////////////////////////////////////////////////// +// fragment shader +// +char fragmentShaderSource_noBaseTexture[] = + "uniform sampler2DShadow shadowTexture; \n" + "uniform vec2 ambientBias; \n" + "\n" + "void main(void) \n" + "{ \n" + " gl_FragColor = gl_Color * (ambientBias.x + shadow2DProj( shadowTexture, gl_TexCoord[0] ) * ambientBias.y); \n" + "}\n"; + +////////////////////////////////////////////////////////////////// +// fragment shader +// +char fragmentShaderSource_withBaseTexture[] = + "uniform sampler2D baseTexture; \n" + "uniform sampler2DShadow shadowTexture; \n" + "uniform vec2 ambientBias; \n" + "\n" + "void main(void) \n" + "{ \n" + " vec4 color = gl_Color * texture2D( baseTexture, gl_TexCoord[0].xy ); \n" + " gl_FragColor = color * (ambientBias.x + shadow2DProj( shadowTexture, gl_TexCoord[1] ) * ambientBias.y); \n" + "}\n"; + + +osg::Group* createShadowedScene(osg::Node* shadowed,osg::MatrixTransform* light_transform, unsigned int unit) +{ + osg::Group* group = new osg::Group; + + unsigned int tex_width = 1024; + unsigned int tex_height = 1024; + + osg::Texture2D* texture = new osg::Texture2D; + texture->setTextureSize(tex_width, tex_height); + + texture->setInternalFormat(GL_DEPTH_COMPONENT); + texture->setShadowComparison(true); + texture->setShadowTextureMode(Texture::LUMINANCE); + texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); + texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); + + // set up the render to texture camera. + { + + // create the camera + osg::CameraNode* camera = new osg::CameraNode; + + camera->setClearMask(GL_DEPTH_BUFFER_BIT); + camera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); + camera->setComputeNearFarMode(osg::CameraNode::DO_NOT_COMPUTE_NEAR_FAR); + + // set viewport + camera->setViewport(0,0,tex_width,tex_height); + + osg::StateSet* _local_stateset = camera->getOrCreateStateSet(); + + _local_stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + + + float factor = 0.0f; + float units = 1.0f; + + ref_ptr polygon_offset = new PolygonOffset; + polygon_offset->setFactor(factor); + polygon_offset->setUnits(units); + _local_stateset->setAttribute(polygon_offset.get(), StateAttribute::ON | StateAttribute::OVERRIDE); + _local_stateset->setMode(GL_POLYGON_OFFSET_FILL, StateAttribute::ON | StateAttribute::OVERRIDE); + + ref_ptr cull_face = new CullFace; + cull_face->setMode(CullFace::FRONT); + _local_stateset->setAttribute(cull_face.get(), StateAttribute::ON | StateAttribute::OVERRIDE); + _local_stateset->setMode(GL_CULL_FACE, StateAttribute::ON | StateAttribute::OVERRIDE); + + + // set the camera to render before the main camera. + camera->setRenderOrder(osg::CameraNode::PRE_RENDER); + + // tell the camera to use OpenGL frame buffer object where supported. + camera->setRenderTargetImplementation(osg::CameraNode::FRAME_BUFFER_OBJECT); + + // attach the texture and use it as the color buffer. + camera->attach(osg::CameraNode::DEPTH_BUFFER, texture); + + // add subgraph to render + camera->addChild(shadowed); + + group->addChild(camera); + + // create the texgen node to project the tex coords onto the subgraph + osg::TexGenNode* texgenNode = new osg::TexGenNode; + texgenNode->setTextureUnit(unit); + group->addChild(texgenNode); + + // set an update callback to keep moving the camera and tex gen in the right direction. + group->setUpdateCallback(new UpdateCameraAndTexGenCallback(light_transform, camera, texgenNode)); + } + + + // set the shadowed subgraph so that it uses the texture and tex gen settings. + { + osg::Group* shadowedGroup = new osg::Group; + shadowedGroup->addChild(shadowed); + group->addChild(shadowedGroup); + + osg::StateSet* stateset = shadowedGroup->getOrCreateStateSet(); + stateset->setTextureAttributeAndModes(unit,texture,osg::StateAttribute::ON); + stateset->setTextureMode(unit,GL_TEXTURE_GEN_S,osg::StateAttribute::ON); + stateset->setTextureMode(unit,GL_TEXTURE_GEN_T,osg::StateAttribute::ON); + stateset->setTextureMode(unit,GL_TEXTURE_GEN_R,osg::StateAttribute::ON); + + stateset->setTextureMode(unit,GL_TEXTURE_GEN_Q,osg::StateAttribute::ON); + + osg::Program* program = new osg::Program; + stateset->setAttribute(program); + + if (unit==0) + { + osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource_noBaseTexture); + program->addShader(fragment_shader); + + osg::Uniform* shadowTextureSampler = new osg::Uniform("shadowTexture",(int)unit); + stateset->addUniform(shadowTextureSampler); + } + else + { + osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource_withBaseTexture); + program->addShader(fragment_shader); + + osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0); + stateset->addUniform(baseTextureSampler); + + osg::Uniform* shadowTextureSampler = new osg::Uniform("shadowTexture",(int)unit); + stateset->addUniform(shadowTextureSampler); + } + + osg::Uniform* ambientBias = new osg::Uniform("ambientBias",osg::Vec2(0.3f,1.2f)); + stateset->addUniform(ambientBias); + + } + + // add the shadower and shadowed. + group->addChild(light_transform); + + return group; +} + + +int main(int argc, char** argv) +{ + // use an ArgumentParser object to manage the program arguments. + ArgumentParser arguments(&argc, argv); + + // set up the usage document, in case we need to print out how to use this program. + arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " is the example which demonstrates using of GL_ARB_shadow extension implemented in osg::Texture class"); + arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()); + arguments.getApplicationUsage()->addCommandLineOption("-h or --help", "Display this information"); + arguments.getApplicationUsage()->addCommandLineOption("--with-base-texture", "Adde base texture to shadowed model."); + arguments.getApplicationUsage()->addCommandLineOption("--no-base-texture", "Adde base texture to shadowed model."); + + // construct the viewer. + osgProducer::Viewer viewer(arguments); + + // set up the value with sensible default event handlers. + viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); + + // get details on keyboard and mouse bindings used by the viewer. + viewer.getUsage(*arguments. getApplicationUsage()); + + bool withBaseTexture = true; + while(arguments.read("--with-base-texture")) { withBaseTexture = true; } + while(arguments.read("--no-base-texture")) { withBaseTexture = false; } + + // if user request help write it out to cout. + if (arguments.read("-h") || arguments.read("--help")) + { + arguments.getApplicationUsage()->write(std::cout); + return 1; + } + + // any option left unread are converted into errors to write out later. + arguments.reportRemainingOptionsAsUnrecognized(); + + // report any errors if they have occured when parsing the program aguments. + if (arguments.errors()) + { + arguments.writeErrorMessages(std::cout); + return 1; + } + + ref_ptr scene = new MatrixTransform; + scene->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(125.0),1.0,0.0,0.0)); + + ref_ptr shadowed_scene = _create_scene(); + if (!shadowed_scene.valid()) return 1; + + ref_ptr light_transform = _create_lights(); + if (!light_transform.valid()) return 1; + + ref_ptr shadowedScene; + + + if (withBaseTexture) + { + shadowed_scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")), osg::StateAttribute::ON); + shadowedScene = createShadowedScene(shadowed_scene.get(),light_transform.get(),1); + } + else + { + shadowedScene = createShadowedScene(shadowed_scene.get(),light_transform.get(),0); + } + + scene->addChild(shadowedScene.get()); + + viewer.setSceneData(scene.get()); + + // create the windows and run the threads. + viewer.realize(); + + while (!viewer.done()) + { + // wait for all cull and draw threads to complete. + viewer.sync(); + + // update the scene by traversing it with the the update visitor which will + // call all node update callbacks and animations. + viewer.update(); + + // fire off the cull and draw traversals of the scene. + viewer.frame(); + } + + // wait for all cull and draw threads to complete. + viewer.sync(); + + // run a clean up frame to delete all OpenGL objects. + viewer.cleanup_frame(); + + // wait for all the clean up frame to complete. + viewer.sync(); + + return 0; +} diff --git a/include/osgShadow/Export b/include/osgShadow/Export new file mode 100644 index 000000000..e4b181d4a --- /dev/null +++ b/include/osgShadow/Export @@ -0,0 +1,47 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_EXPORT_ +#define OSGSHADOW_EXPORT_ 1 + +#if defined(_MSC_VER) + #pragma warning( disable : 4244 ) + #pragma warning( disable : 4251 ) + #pragma warning( disable : 4267 ) + #pragma warning( disable : 4275 ) + #pragma warning( disable : 4290 ) + #pragma warning( disable : 4786 ) + #pragma warning( disable : 4305 ) + #pragma warning( disable : 4996 ) +#endif + +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) + # if defined( OSG_LIBRARY_STATIC ) + # define OSGSHADOW_EXPORT + # elif defined( OSGSHADOW_LIBRARY ) + # define OSGSHADOW_EXPORT __declspec(dllexport) + # else + # define OSGSHADOW_EXPORT __declspec(dllimport) + # endif +#else + # define OSGSHADOW_EXPORT +#endif + +/** + +\namespace osgShadow + +The osgShadow is a NodeKit library that extends the core scene graph to add support for a range of shadow techniques. +*/ + +#endif diff --git a/include/osgShadow/ParallelSplitShadowMap b/include/osgShadow/ParallelSplitShadowMap new file mode 100644 index 000000000..36446c8b6 --- /dev/null +++ b/include/osgShadow/ParallelSplitShadowMap @@ -0,0 +1,41 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_PARALLELSPLITSHADOWMAP +#define OSGSHADOW_PARALLELSPLITSHADOWMAP 1 + +#include + +#include + +namespace osgShadow { + +/** ShadowedTexture provides an implementation of shadow textures.*/ +class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique +{ + public : + ParallelSplitShadowMap(); + + ParallelSplitShadowMap(const ParallelSplitShadowMap& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); + + META_Object(osgShadow, ParallelSplitShadowMap); + + protected : + + virtual ~ParallelSplitShadowMap() {} + +}; + +} + +#endif diff --git a/include/osgShadow/ShadowMap b/include/osgShadow/ShadowMap new file mode 100644 index 000000000..75cc32323 --- /dev/null +++ b/include/osgShadow/ShadowMap @@ -0,0 +1,41 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_SHADOWEDTEXTURE +#define OSGSHADOW_SHADOWEDTEXTURE 1 + +#include + +#include + +namespace osgShadow { + +/** ShadowedTexture provides an implementation of shadow textures.*/ +class OSGSHADOW_EXPORT ShadowMap : public ShadowTechnique +{ + public : + ShadowMap(); + + ShadowMap(const ShadowMap& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); + + META_Object(osgShadow, ShadowMap); + + protected : + + virtual ~ShadowMap() {} + +}; + +} + +#endif diff --git a/include/osgShadow/ShadowTechnique b/include/osgShadow/ShadowTechnique new file mode 100644 index 000000000..3302d2fc4 --- /dev/null +++ b/include/osgShadow/ShadowTechnique @@ -0,0 +1,47 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_SHADOWEDTECHNIQUE +#define OSGSHADOW_SHADOWEDTECHNIQUE 1 + +#include +#include +#include +#include + +#include + +namespace osgShadow { + +// forward declare ShadowedScene +class ShadowedScene; + +/** ShadowedScene provides a mechansim for decorating a scene that the needs to have shadows cast upon it.*/ +class OSGSHADOW_EXPORT ShadowTechnique : public osg::Object +{ + public : + ShadowTechnique(); + + ShadowTechnique(const ShadowTechnique& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); + + META_Object(osgShadow, ShadowTechnique); + + protected : + + virtual ~ShadowTechnique() {} + +}; + +} + +#endif diff --git a/include/osgShadow/ShadowTexture b/include/osgShadow/ShadowTexture new file mode 100644 index 000000000..a79cf3194 --- /dev/null +++ b/include/osgShadow/ShadowTexture @@ -0,0 +1,41 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_SHADOWEDTEXTURE +#define OSGSHADOW_SHADOWEDTEXTURE 1 + +#include + +#include + +namespace osgShadow { + +/** ShadowedTexture provides an implementation of shadow textures.*/ +class OSGSHADOW_EXPORT ShadowTexture : public ShadowTechnique +{ + public : + ShadowTexture(); + + ShadowTexture(const ShadowTexture& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); + + META_Object(osgShadow, ShadowTexture); + + protected : + + virtual ~ShadowTexture() {} + +}; + +} + +#endif diff --git a/include/osgShadow/ShadowVolume b/include/osgShadow/ShadowVolume new file mode 100644 index 000000000..ad926ea9b --- /dev/null +++ b/include/osgShadow/ShadowVolume @@ -0,0 +1,41 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_SHADOWVOLUME +#define OSGSHADOW_SHADOWVOLUME 1 + +#include + +#include + +namespace osgShadow { + +/** ShadowedTexture provides an implementation of shadow textures.*/ +class OSGSHADOW_EXPORT ShadowVolume : public ShadowTechnique +{ + public : + ShadowVolume(); + + ShadowVolume(const ShadowVolume& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); + + META_Object(osgShadow, ShadowVolume); + + protected : + + virtual ~ShadowVolume() {} + +}; + +} + +#endif diff --git a/include/osgShadow/ShadowedScene b/include/osgShadow/ShadowedScene new file mode 100644 index 000000000..956093889 --- /dev/null +++ b/include/osgShadow/ShadowedScene @@ -0,0 +1,62 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_SHADOWEDSCENE +#define OSGSHADOW_SHADOWEDSCENE 1 + +#include +#include +#include +#include + +#include + +namespace osgShadow { + +/** ShadowedScene provides a mechansim for decorating a scene that the needs to have shadows cast upon it.*/ +class OSGSHADOW_EXPORT ShadowedScene : public osg::Group +{ + public : + ShadowedScene(); + + ShadowedScene(const ShadowedScene& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); + + META_Node(osgShadow, ShadowedScene); + + virtual void traverse(osg::NodeVisitor& nv); + + void setRecievesShadowTraversalMask(unsigned int mask) { _recievesShadowTraversalMask = mask; } + unsigned int getRecievesShadowTraversalMask() const { return _recievesShadowTraversalMask; } + + void setCastsShadowTraversalMask(unsigned int mask) { _castsShadowTraversalMask = mask; } + unsigned int getCastsShadowTraversalMask() const { return _castsShadowTraversalMask; } + + void setShadowTechnique(ShadowTechnique* technique); + ShadowTechnique* getShadowTechnique() { return _shadowTechnique.get(); } + const ShadowTechnique* getShadowTechnique() const { return _shadowTechnique.get(); } + + + protected : + + virtual ~ShadowedScene() {} + + unsigned int _recievesShadowTraversalMask; + unsigned int _castsShadowTraversalMask; + + osg::ref_ptr _shadowTechnique; + +}; + +} + +#endif diff --git a/include/osgShadow/Version b/include/osgShadow/Version new file mode 100644 index 000000000..89aceafc0 --- /dev/null +++ b/include/osgShadow/Version @@ -0,0 +1,46 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGSHADOW_VERSION +#define OSGSHADOW_VERSION 1 + +#include + +extern "C" { + +/** + * osgShadowGetVersion() returns the library version number. + * Numbering convention : OpenSceneGraph-1.0 will return 1.0 from osgShadowGetVersion. + * + * This C function can be also used to check for the existence of the OpenSceneGraph + * library using autoconf and its m4 macro AC_CHECK_LIB. + * + * Here is the code to add to your configure.in: + \verbatim + # + # Check for the OpenSceneGraph (OSG) library + # + AC_CHECK_LIB(osg, osgShadowGetVersion, , + [AC_MSG_ERROR(OpenSceneGraph library not found. See http://www.openscenegraph.org)],) + \endverbatim +*/ +extern OSGSHADOW_EXPORT const char* osgShadowGetVersion(); + +/** + * osgShadowGetLibraryName() returns the library name in human friendly form. +*/ +extern OSGSHADOW_EXPORT const char* osgShadowGetLibraryName(); + +} + +#endif diff --git a/src/osgShadow/GNUmakefile b/src/osgShadow/GNUmakefile new file mode 100644 index 000000000..a8a954cba --- /dev/null +++ b/src/osgShadow/GNUmakefile @@ -0,0 +1,21 @@ +TOPDIR = ../.. +include $(TOPDIR)/Make/makedefs + + +CXXFILES = \ + ShadowedScene.cpp\ + ShadowTechnique.cpp\ + ShadowMap.cpp\ + ShadowTexture.cpp\ + ShadowVolume.cpp\ + ParallelSplitShadowMap.cpp\ + Version.cpp\ + +DEF += -DOSGTEXT_LIBRARY + +LIBS += -losgDB -losg $(GL_LIBS) $(OTHER_LIBS) + +TARGET_BASENAME = osgText +LIB = $(LIB_PREFIX)$(TARGET_BASENAME).$(LIB_EXT) + +include $(TOPDIR)/Make/makerules diff --git a/src/osgShadow/ParallelSplitShadowMap.cpp b/src/osgShadow/ParallelSplitShadowMap.cpp new file mode 100644 index 000000000..0ec3b7acf --- /dev/null +++ b/src/osgShadow/ParallelSplitShadowMap.cpp @@ -0,0 +1,27 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include +#include + +using namespace osgShadow; + +ParallelSplitShadowMap::ParallelSplitShadowMap() +{ + osg::notify(osg::NOTICE)<<"Warning: osgShadow::ParallelSplitShadowMap technique not implemented yet."< +#include + +using namespace osgShadow; + +ShadowMap::ShadowMap() +{ + osg::notify(osg::NOTICE)<<"Warning: osgShadow::ShadowMap technique not implemented yet."< + +using namespace osgShadow; + +ShadowTechnique::ShadowTechnique() +{ +} + +ShadowTechnique::ShadowTechnique(const ShadowTechnique& copy, const osg::CopyOp& copyop): + osg::Object(copy,copyop) +{ +} diff --git a/src/osgShadow/ShadowTexture.cpp b/src/osgShadow/ShadowTexture.cpp new file mode 100644 index 000000000..6f3ec6003 --- /dev/null +++ b/src/osgShadow/ShadowTexture.cpp @@ -0,0 +1,27 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include +#include + +using namespace osgShadow; + +ShadowTexture::ShadowTexture() +{ + osg::notify(osg::NOTICE)<<"Warning: osgShadow::ShadowTexture technique not implemented yet."< +#include + +using namespace osgShadow; + +ShadowVolume::ShadowVolume() +{ + osg::notify(osg::NOTICE)<<"Warning: osgShadow::ShadowVolume technique not implemented yet."< +#include +#include +#include + +#include +#include + +using namespace osgShadow; +using namespace osg; + +ShadowedScene::ShadowedScene() +{ + setNumChildrenRequiringUpdateTraversal(1); +} + +ShadowedScene::ShadowedScene(const ShadowedScene& copy, const osg::CopyOp& copyop): + osg::Group(copy,copyop) +{ + setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); +} + +void ShadowedScene::traverse(osg::NodeVisitor& nv) +{ + if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR) + { + Group::traverse(nv); + return; + } + + if (nv.getVisitorType() != osg::NodeVisitor::CULL_VISITOR) + { + Group::traverse(nv); + return; + } + + osgUtil::CullVisitor* cv = dynamic_cast(&nv); + if (!cv) + { + Group::traverse(nv); + return; + } + + Group::traverse(nv); +} diff --git a/src/osgShadow/Version.cpp b/src/osgShadow/Version.cpp new file mode 100644 index 000000000..5c13223d4 --- /dev/null +++ b/src/osgShadow/Version.cpp @@ -0,0 +1,12 @@ +#include + +const char* osgShadowGetVersion() +{ + return "1.2"; +} + + +const char* osgShaodowGetLibraryName() +{ + return "OpenSceneGraph Shadow Library"; +} diff --git a/src/osgWrappers/osgShadow/ParallelSplitShadowMap.cpp b/src/osgWrappers/osgShadow/ParallelSplitShadowMap.cpp new file mode 100644 index 000000000..702b02eea --- /dev/null +++ b/src/osgWrappers/osgShadow/ParallelSplitShadowMap.cpp @@ -0,0 +1,35 @@ +// *************************************************************************** +// +// Generated automatically by genwrapper. +// Please DO NOT EDIT this file! +// +// *************************************************************************** + +#include +#include +#include +#include + +#include +#include +#include + +// Must undefine IN and OUT macros defined in Windows headers +#ifdef IN +#undef IN +#endif +#ifdef OUT +#undef OUT +#endif + +BEGIN_OBJECT_REFLECTOR(osgShadow::ParallelSplitShadowMap) + I_BaseType(osgShadow::ShadowTechnique); + I_Constructor0(); + I_ConstructorWithDefaults2(IN, const osgShadow::ParallelSplitShadowMap &, es, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); + I_Method0(osg::Object *, cloneType); + I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop); + I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj); + I_Method0(const char *, libraryName); + I_Method0(const char *, className); +END_REFLECTOR + diff --git a/src/osgWrappers/osgShadow/ShadowTechnique.cpp b/src/osgWrappers/osgShadow/ShadowTechnique.cpp new file mode 100644 index 000000000..d52544fa9 --- /dev/null +++ b/src/osgWrappers/osgShadow/ShadowTechnique.cpp @@ -0,0 +1,35 @@ +// *************************************************************************** +// +// Generated automatically by genwrapper. +// Please DO NOT EDIT this file! +// +// *************************************************************************** + +#include +#include +#include +#include + +#include +#include +#include + +// Must undefine IN and OUT macros defined in Windows headers +#ifdef IN +#undef IN +#endif +#ifdef OUT +#undef OUT +#endif + +BEGIN_OBJECT_REFLECTOR(osgShadow::ShadowTechnique) + I_BaseType(osg::Object); + I_Constructor0(); + I_ConstructorWithDefaults2(IN, const osgShadow::ShadowTechnique &, es, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); + I_Method0(osg::Object *, cloneType); + I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop); + I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj); + I_Method0(const char *, libraryName); + I_Method0(const char *, className); +END_REFLECTOR + diff --git a/src/osgWrappers/osgShadow/ShadowVolume.cpp b/src/osgWrappers/osgShadow/ShadowVolume.cpp new file mode 100644 index 000000000..8da63e570 --- /dev/null +++ b/src/osgWrappers/osgShadow/ShadowVolume.cpp @@ -0,0 +1,35 @@ +// *************************************************************************** +// +// Generated automatically by genwrapper. +// Please DO NOT EDIT this file! +// +// *************************************************************************** + +#include +#include +#include +#include + +#include +#include +#include + +// Must undefine IN and OUT macros defined in Windows headers +#ifdef IN +#undef IN +#endif +#ifdef OUT +#undef OUT +#endif + +BEGIN_OBJECT_REFLECTOR(osgShadow::ShadowVolume) + I_BaseType(osgShadow::ShadowTechnique); + I_Constructor0(); + I_ConstructorWithDefaults2(IN, const osgShadow::ShadowVolume &, es, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); + I_Method0(osg::Object *, cloneType); + I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop); + I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj); + I_Method0(const char *, libraryName); + I_Method0(const char *, className); +END_REFLECTOR + diff --git a/src/osgWrappers/osgShadow/ShadowedScene.cpp b/src/osgWrappers/osgShadow/ShadowedScene.cpp new file mode 100644 index 000000000..1fe43ced5 --- /dev/null +++ b/src/osgWrappers/osgShadow/ShadowedScene.cpp @@ -0,0 +1,49 @@ +// *************************************************************************** +// +// Generated automatically by genwrapper. +// Please DO NOT EDIT this file! +// +// *************************************************************************** + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +// Must undefine IN and OUT macros defined in Windows headers +#ifdef IN +#undef IN +#endif +#ifdef OUT +#undef OUT +#endif + +BEGIN_OBJECT_REFLECTOR(osgShadow::ShadowedScene) + I_BaseType(osg::Group); + I_Constructor0(); + I_ConstructorWithDefaults2(IN, const osgShadow::ShadowedScene &, es, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY); + I_Method0(osg::Object *, cloneType); + I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop); + I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj); + I_Method0(const char *, className); + I_Method0(const char *, libraryName); + I_Method1(void, accept, IN, osg::NodeVisitor &, nv); + I_Method1(void, traverse, IN, osg::NodeVisitor &, nv); + I_Method1(void, setRecievesShadowTraversalMask, IN, unsigned int, mask); + I_Method0(unsigned int, getRecievesShadowTraversalMask); + I_Method1(void, setCastsShadowTraversalMask, IN, unsigned int, mask); + I_Method0(unsigned int, getCastsShadowTraversalMask); + I_Method1(void, setShadowTechnique, IN, osgShadow::ShadowTechnique *, technique); + I_Method0(osgShadow::ShadowTechnique *, getShadowTechnique); + I_Method0(const osgShadow::ShadowTechnique *, getShadowTechnique); + I_Property(unsigned int, CastsShadowTraversalMask); + I_Property(unsigned int, RecievesShadowTraversalMask); + I_Property(osgShadow::ShadowTechnique *, ShadowTechnique); +END_REFLECTOR +