Moved include/osgTerrain/DataSet/.cpp, gdal plugin and osgdem out into the VirtualPlaneBuilder project.
Updated examples to remove DataSet/GDAL dependency. Updated wrappers
This commit is contained in:
@@ -13,7 +13,6 @@ COLLADA_INSTALLED ?= no
|
||||
COLLADA_DAE_HOME ?= /usr/local
|
||||
COLLADA_DEBUG_LIBS ?= yes
|
||||
|
||||
GDAL_INSTALLED ?= no
|
||||
JASPER_INSTALLED ?= no
|
||||
|
||||
FREETYPE_INSTALLED ?= yes
|
||||
|
||||
@@ -215,9 +215,6 @@ ifeq ($(OS),SunOS)
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
|
||||
XINE_INCLUDES = `xine-config --cflags`
|
||||
XINE_LIBS = `xine-config --libs`
|
||||
|
||||
@@ -308,9 +305,6 @@ ifeq ($(OS),IRIX)
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
|
||||
XINE_INCLUDES = `xine-config --cflags`
|
||||
XINE_LIBS = `xine-config --libs`
|
||||
|
||||
@@ -405,9 +399,6 @@ endif
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
|
||||
XINE_INCLUDES = `xine-config --cflags`
|
||||
XINE_LIBS = `xine-config --libs`
|
||||
|
||||
@@ -460,9 +451,6 @@ ifeq ($(OS),FreeBSD)
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
|
||||
XINE_INCLUDES = `xine-config --cflags`
|
||||
XINE_LIBS = `xine-config --libs`
|
||||
|
||||
@@ -549,9 +537,6 @@ ifeq ($(OS),Darwin)
|
||||
FREETYPE_INCLUDE = -I$(SDKPATH)/usr/X11R6/include -I$(SDKPATH)/usr/X11R6/include/freetype2
|
||||
FREETYPE_LIB = -L$(SDKPATH)/usr/X11R6/lib -lfreetype
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
|
||||
XINE_INCLUDES = `xine-config --cflags`
|
||||
XINE_LIBS = `xine-config --libs`
|
||||
|
||||
@@ -591,10 +576,6 @@ ifeq ($(OS),CYGWIN)
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
GDAL_LIBS += `gdal-config --dep-libs`
|
||||
|
||||
XINE_INCLUDES = `xine-config --cflags`
|
||||
XINE_LIBS = `xine-config --libs`
|
||||
|
||||
@@ -654,9 +635,6 @@ ifeq ($(OS),MINGW)
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES =
|
||||
GDAL_LIBS = -lgdal -ljpeg -lgeotiff -ltiff -lpng -lz
|
||||
|
||||
XINE_INCLUDES = `xine-config --cflags`
|
||||
XINE_LIBS = `xine-config --libs`
|
||||
|
||||
@@ -720,9 +698,6 @@ ifeq ($(OS),HP-UX)
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
|
||||
INSTXCMD = install -c -m 755
|
||||
INSTRCMD = install -c -m 644
|
||||
|
||||
@@ -766,9 +741,6 @@ ifeq ($(OS),AIX)
|
||||
FREETYPE_INCLUDE = `freetype-config --cflags`
|
||||
FREETYPE_LIB = `freetype-config --libs`
|
||||
|
||||
GDAL_INCLUDES = `gdal-config --cflags`
|
||||
GDAL_LIBS = `gdal-config --libs`
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
||||
@@ -23,11 +23,9 @@ SRC_DIRS = \
|
||||
osgFX \
|
||||
osgShadow \
|
||||
osgSim \
|
||||
osgManipulator
|
||||
osgManipulator \
|
||||
osgTerrain \
|
||||
|
||||
ifeq ($(GDAL_INSTALLED),yes)
|
||||
SRC_DIRS += osgTerrain
|
||||
endif
|
||||
|
||||
ifeq ($(COMPILE_INTROSPECTION),yes)
|
||||
SRC_DIRS += \
|
||||
@@ -51,11 +49,7 @@ WRAPPER_DIRS = \
|
||||
osgText \
|
||||
osgUtil \
|
||||
osgViewer \
|
||||
|
||||
|
||||
ifeq ($(GDAL_INSTALLED),yes)
|
||||
WRAPPER_DIRS += osgTerrain
|
||||
endif
|
||||
|
||||
|
||||
################################################################
|
||||
@@ -105,10 +99,6 @@ PLUGIN_DIRS = \
|
||||
zip \
|
||||
|
||||
|
||||
ifeq ($(GDAL_INSTALLED),yes)
|
||||
PLUGIN_DIRS += gdal
|
||||
endif
|
||||
|
||||
ifeq ($(COLLADA_INSTALLED),yes)
|
||||
PLUGIN_DIRS += dae
|
||||
endif
|
||||
@@ -186,10 +176,6 @@ APPLICATION_DIRS += osgarchive \
|
||||
osgconv \
|
||||
osgviewer \
|
||||
|
||||
ifeq ($(GDAL_INSTALLED),yes)
|
||||
APPLICATION_DIRS += osgdem
|
||||
endif
|
||||
|
||||
EXAMPLE_DIRS = \
|
||||
osganimate \
|
||||
osgautotransform \
|
||||
@@ -265,19 +251,15 @@ EXAMPLE_DIRS = \
|
||||
osgvolume \
|
||||
osgwindows \
|
||||
osgmanipulator \
|
||||
osgphotoalbum \
|
||||
osgsimulation \
|
||||
osgfadetext
|
||||
|
||||
|
||||
ifeq ($(COMPILE_INTROSPECTION),yes)
|
||||
EXAMPLE_DIRS += osgintrospection
|
||||
endif
|
||||
|
||||
ifeq ($(GDAL_INSTALLED),yes)
|
||||
EXAMPLE_DIRS += osgphotoalbum
|
||||
EXAMPLE_DIRS += osgbluemarble
|
||||
EXAMPLE_DIRS += osgsimulation
|
||||
EXAMPLE_DIRS += osgfadetext
|
||||
endif
|
||||
|
||||
ifeq ($(GLUT_INSTALLED),yes)
|
||||
EXAMPLE_DIRS += osgGLUTsimple
|
||||
EXAMPLE_DIRS += osgGLUTkeyboardmouse
|
||||
|
||||
@@ -300,36 +300,6 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Application osgdem"=.\applications\osgdem\osgdem.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 osgViewer
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgUtil
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgTerrain
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Application osgversion"=.\applications\osgversion\osgversion.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
@@ -486,30 +456,6 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Example osgbluemarble"=.\examples\osgbluemarble\osgbluemarble.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 osgViewer
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgUtil
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Example osgcallback"=.\examples\osgcallback\osgcallback.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
@@ -3111,27 +3057,6 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin gdal"=.\osgPlugins\gdal\gdal.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 osgUtil
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin geo"=.\osgPlugins\geo\geo.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="Example osgbluemarble" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=Example osgbluemarble - 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 "osgbluemarble.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 "osgbluemarble.mak" CFG="Example osgbluemarble - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Example osgbluemarble - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Example osgbluemarble - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Example osgbluemarble - 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 ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c
|
||||
# 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 OpenThreadsWin32.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgbluemarble.exe" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "Example osgbluemarble - 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 ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /Zm200 /c
|
||||
# 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 OpenThreadsWin32d.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"$(OutDir)/osgbluemarbled.exe" /pdbtype:sept /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
|
||||
# SUBTRACT LINK32 /incremental:no
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Example osgbluemarble - Win32 Release"
|
||||
# Name "Example osgbluemarble - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\examples\osgbluemarble\osgbluemarble.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\icons\osg_icon.rc
|
||||
# End Source File
|
||||
# End Target
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Project
|
||||
@@ -1,172 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="osgPlugin gdal" - 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=osgPlugin gdal - 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 "gdal.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 "gdal.mak" CFG="osgPlugin gdal - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "osgPlugin gdal - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "osgPlugin gdal - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "osgPlugin gdal - Win32 Release Static" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "osgPlugin gdal - 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)" == "osgPlugin gdal - 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 "../../../../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 OpenThreadsWin32.lib gdal_i.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /opt:ref /opt:icf /out:"$(OutDir)/osgdb_gdal.dll" /implib:"../../../lib/$(PlatformName)/osgdb_gdal.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin gdal - 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 "../../../../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 OpenThreadsWin32d.lib gdal_i.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"$(OutDir)/osgdb_gdald.dll" /pdbtype:sept /implib:"../../../lib/$(PlatformName)/osgdb_gdald.lib" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin gdal - 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 "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "WIN32" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /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
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgdb_gdal_s.lib"
|
||||
# SUBTRACT LIB32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin gdal - 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 "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /vmg /GR /GX /Z7 /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_MBCS" /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
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgdb_gdald_s.lib"
|
||||
# SUBTRACT LIB32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "osgPlugin gdal - Win32 Release"
|
||||
# Name "osgPlugin gdal - Win32 Debug"
|
||||
# Name "osgPlugin gdal - Win32 Release Static"
|
||||
# Name "osgPlugin gdal - 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\osgPlugins\gdal\ReaderWriterGDAL.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;gdal;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -155,10 +155,6 @@ LIB32=link.exe -lib
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgTerrain\DataSet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgTerrain\HeightFieldNode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -175,10 +171,6 @@ SOURCE=..\..\src\osgTerrain\Version.cpp
|
||||
# PROP Default_Filter ";h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgTerrain\DataSet
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgTerrain\Export
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -96,7 +96,7 @@ LINK32=link.exe
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
|
||||
# Begin Source File
|
||||
SOURCE=..\..\..\src\osgWrappers\osgTerrain\DataSet.cpp
|
||||
SOURCE=..\..\..\src\osgWrappers\osgTerrain\Export.cpp
|
||||
# End Source File
|
||||
|
||||
# Begin Source File
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>osgbluemarble</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.MySoftwareCompany.osgbluemarble</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.2.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>osgdem</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.MySoftwareCompany.osgdem</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.2.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,18 +0,0 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
osgbluemarble.cpp\
|
||||
|
||||
LIBS += -losgViewer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
INSTFILES = \
|
||||
$(CXXFILES)\
|
||||
GNUmakefile.inst=GNUmakefile
|
||||
|
||||
EXEC = osgbluemarble
|
||||
|
||||
INC += $(X_INC)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
osgbluemarble.cpp\
|
||||
|
||||
LIBS += -losgViewer -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
EXEC = osgbluemarble
|
||||
|
||||
INC += $(X_INC)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
@@ -1,456 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This application is open source and may be redistributed and/or modified
|
||||
* freely and without restriction, both in commericial and non commericial applications,
|
||||
* as long as this copyright notice is maintained.
|
||||
*
|
||||
* This application 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.
|
||||
*/
|
||||
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/State>
|
||||
#include <osg/ClusterCullingCallback>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgDB/ImageOptions>
|
||||
#include <osgDB/FileNameUtils>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgUtil/TriStripVisitor>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class MyGraphicsContext {
|
||||
public:
|
||||
MyGraphicsContext()
|
||||
{
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = 1;
|
||||
traits->height = 1;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = false;
|
||||
traits->sharedContext = 0;
|
||||
traits->pbuffer = true;
|
||||
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
if (!_gc)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl;
|
||||
|
||||
traits->pbuffer = false;
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
}
|
||||
|
||||
if (_gc.valid())
|
||||
|
||||
|
||||
{
|
||||
_gc->realize();
|
||||
_gc->makeCurrent();
|
||||
std::cout<<"Realized window"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool valid() const { return _gc.valid() && _gc->isRealized(); }
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::GraphicsContext> _gc;
|
||||
};
|
||||
|
||||
|
||||
osg::Vec3 computePosition(bool leftHemisphere, double x, double y)
|
||||
{
|
||||
double latitude = osg::PI*x;
|
||||
double longitude = osg::PI*y;
|
||||
double sin_longitude = sin(longitude);
|
||||
|
||||
if (leftHemisphere) return osg::Vec3(cos(latitude)*sin_longitude,sin(latitude)*sin_longitude,-cos(longitude));
|
||||
else return osg::Vec3(-cos(latitude)*sin_longitude,-sin(latitude)*sin_longitude,-cos(longitude));
|
||||
}
|
||||
|
||||
bool useCompressedTextures = true;
|
||||
bool use565 = true;
|
||||
|
||||
osg::Node* createTile(const std::string& filename, bool leftHemisphere, double x, double y, double w,double h)
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
|
||||
osg::StateSet* stateset = new osg::StateSet();
|
||||
|
||||
|
||||
osg::ref_ptr<osgDB::ImageOptions> options = new osgDB::ImageOptions;
|
||||
options->_sourceImageWindowMode = osgDB::ImageOptions::RATIO_WINDOW;
|
||||
options->_sourceRatioWindow.set(x,1-(y+h),w,h);
|
||||
|
||||
options->_destinationImageWindowMode = osgDB::ImageOptions::PIXEL_WINDOW;
|
||||
options->_destinationPixelWindow.set(0,0,256,256);
|
||||
|
||||
osgDB::ImageOptions::TexCoordRange* texCoordRange = 0;
|
||||
|
||||
osgDB::Registry::instance()->setOptions(options.get());
|
||||
osg::Image* image = osgDB::readImageFile(filename.c_str());
|
||||
if (image)
|
||||
{
|
||||
texCoordRange = dynamic_cast<osgDB::ImageOptions::TexCoordRange*>(image->getUserData());
|
||||
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
texture->setImage(image);
|
||||
texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
|
||||
texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
|
||||
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
||||
texture->setMaxAnisotropy(8);
|
||||
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
|
||||
if (useCompressedTextures)
|
||||
{
|
||||
texture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT3_COMPRESSION);
|
||||
|
||||
osg::ref_ptr<osg::State> state = new osg::State;
|
||||
texture->apply(*state);
|
||||
|
||||
image->readImageFromCurrentTexture(0,true);
|
||||
|
||||
texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
|
||||
|
||||
} else if (use565)
|
||||
{
|
||||
|
||||
image->scaleImage(image->s(),image->t(),image->r(),GL_UNSIGNED_SHORT_5_6_5);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
geode->setStateSet( stateset );
|
||||
|
||||
// unsigned int numColumns = 10;
|
||||
// unsigned int numRows = 10;
|
||||
unsigned int numColumns = 10;
|
||||
unsigned int numRows = 10;
|
||||
unsigned int r;
|
||||
unsigned int c;
|
||||
|
||||
osg::Geometry* geometry = new osg::Geometry;
|
||||
|
||||
osg::Vec3Array& v = *(new osg::Vec3Array(numColumns*numRows));
|
||||
osg::Vec3Array& n = *(new osg::Vec3Array(numColumns*numRows));
|
||||
osg::Vec2Array& t = *(new osg::Vec2Array(numColumns*numRows));
|
||||
osg::Vec4ubArray& color = *(new osg::Vec4ubArray(1));
|
||||
|
||||
color[0].set(255,255,255,255);
|
||||
|
||||
|
||||
|
||||
osg::Vec2 tex_orig(0.0f,0.0f);
|
||||
|
||||
float rowTexDelta = 1.0f/(float)(numRows-1);
|
||||
float columnTexDelta = 1.0f/(float)(numColumns-1);
|
||||
|
||||
if (texCoordRange)
|
||||
{
|
||||
tex_orig.set(texCoordRange->_x,texCoordRange->_y);
|
||||
rowTexDelta = texCoordRange->_h/(float)(numRows-1);
|
||||
columnTexDelta = texCoordRange->_w/(float)(numColumns-1);
|
||||
|
||||
std::cout<<"setting tex values to use texCoordRange"<<std::endl;
|
||||
std::cout<<" tex_orig="<<tex_orig<<std::endl;
|
||||
std::cout<<" rowTexDelta"<<rowTexDelta<<std::endl;
|
||||
std::cout<<" columnTexDelta"<<columnTexDelta<<std::endl;
|
||||
}
|
||||
|
||||
double orig_latitude = osg::PI*x;
|
||||
double delta_latitude = osg::PI*w/(double)(numColumns-1);
|
||||
|
||||
// measure as 0 at south pole, postive going north
|
||||
double orig_longitude = osg::PI*y;
|
||||
double delta_longitude = osg::PI*h/(double)(numRows-1);
|
||||
|
||||
osg::Vec2 tex(tex_orig);
|
||||
int vi=0;
|
||||
double longitude = orig_longitude;
|
||||
osg::Vec3 normal;
|
||||
for(r=0;r<numRows;++r)
|
||||
{
|
||||
double latitude = orig_latitude;
|
||||
|
||||
tex.x() = tex_orig.x();
|
||||
for(c=0;c<numColumns;++c)
|
||||
{
|
||||
double sin_longitude = sin(longitude);
|
||||
if (leftHemisphere)
|
||||
{
|
||||
normal.set(cos(latitude)*sin_longitude,sin(latitude)*sin_longitude,-cos(longitude));
|
||||
}
|
||||
else
|
||||
{
|
||||
normal.set(-cos(latitude)*sin_longitude,-sin(latitude)*sin_longitude,-cos(longitude));
|
||||
}
|
||||
v[vi] = normal;
|
||||
n[vi] = normal;
|
||||
|
||||
t[vi].set(tex.x(),tex.y());
|
||||
latitude+=delta_latitude;
|
||||
tex.x()+=columnTexDelta;
|
||||
++vi;
|
||||
}
|
||||
longitude += delta_longitude;
|
||||
tex.y() += rowTexDelta;
|
||||
}
|
||||
|
||||
geometry->setVertexArray(&v);
|
||||
geometry->setNormalArray(&n);
|
||||
geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
geometry->setColorArray(&color);
|
||||
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geometry->setTexCoordArray(0,&t);
|
||||
|
||||
for(r=0;r<numRows-1;++r)
|
||||
{
|
||||
osg::DrawElementsUShort& drawElements = *(new osg::DrawElementsUShort(GL_QUAD_STRIP,2*numColumns));
|
||||
geometry->addPrimitiveSet(&drawElements);
|
||||
int ei=0;
|
||||
for(c=0;c<numColumns;++c)
|
||||
{
|
||||
drawElements[ei++] = (r+1)*numColumns+c;
|
||||
drawElements[ei++] = (r)*numColumns+c;
|
||||
}
|
||||
}
|
||||
|
||||
osgUtil::TriStripVisitor tsv;
|
||||
tsv.stripify(*geometry);
|
||||
|
||||
//geometry->setUseVertexBufferObjects(true);
|
||||
|
||||
geometry->setUseDisplayList(false);
|
||||
geometry->setUseVertexBufferObjects(false);
|
||||
|
||||
|
||||
{
|
||||
osg::Vec3 center = computePosition(leftHemisphere, x+w*0.5, y+h*0.5);
|
||||
osg::Vec3 normal = center;
|
||||
osg::Vec3 n00 = computePosition(leftHemisphere, x, y);
|
||||
osg::Vec3 n10 = computePosition(leftHemisphere, x+w, y);
|
||||
osg::Vec3 n11 = computePosition(leftHemisphere, x+w, y+h);
|
||||
osg::Vec3 n01 = computePosition(leftHemisphere, x, y+h);
|
||||
|
||||
float radius = (center-n00).length();
|
||||
radius = osg::maximum((center-n10).length(),radius);
|
||||
radius = osg::maximum((center-n11).length(),radius);
|
||||
radius = osg::maximum((center-n01).length(),radius);
|
||||
|
||||
float min_dot = normal*n00;
|
||||
min_dot = osg::minimum(normal*n10,min_dot);
|
||||
min_dot = osg::minimum(normal*n11,min_dot);
|
||||
min_dot = osg::minimum(normal*n01,min_dot);
|
||||
|
||||
float angle = acosf(min_dot)+osg::PI*0.5f;
|
||||
float deviation = (angle<osg::PI) ? cosf(angle) : -1.0f;
|
||||
|
||||
osg::ClusterCullingCallback* ccc = new osg::ClusterCullingCallback;
|
||||
ccc->setControlPoint(center);
|
||||
ccc->setNormal(normal);
|
||||
ccc->setRadius(radius);
|
||||
ccc->setDeviation(deviation);
|
||||
geometry->setCullCallback(ccc);
|
||||
}
|
||||
|
||||
|
||||
geode->addDrawable(geometry);
|
||||
|
||||
return geode;
|
||||
}
|
||||
|
||||
osg::Node* createTileAndRecurse(const std::string& filename, const std::string& basename, const std::string& extension, bool leftHemisphere, unsigned int noTilesX, unsigned int noTilesY, double x, double y, double w,double h, unsigned int numLevelsLeft)
|
||||
{
|
||||
osg::Group* group = new osg::Group;
|
||||
|
||||
double dx = w / (double) noTilesX;
|
||||
double dy = h / (double) noTilesY;
|
||||
|
||||
|
||||
if (numLevelsLeft>0)
|
||||
{
|
||||
|
||||
float cut_off_distance = 4.0f*dy*osg::PI;
|
||||
float max_visible_distance = 1e7;
|
||||
|
||||
// create current layer, and write to disk.
|
||||
unsigned int numTiles = 0;
|
||||
double lx = x;
|
||||
for(unsigned i=0;i<noTilesX;++i,lx+=dx)
|
||||
{
|
||||
double ly = y;
|
||||
for(unsigned j=0;j<noTilesY;++j,ly+=dy)
|
||||
{
|
||||
// create name for tile.
|
||||
char char_num = 'A'+numTiles;
|
||||
std::string lbasename = basename+"_"+char_num;
|
||||
|
||||
// create the subtiles and write out to disk.
|
||||
{
|
||||
osg::ref_ptr<osg::Node> node = createTileAndRecurse(filename,lbasename,extension,leftHemisphere,2,2,lx,ly,dx,dy,numLevelsLeft-1);
|
||||
osgDB::writeNodeFile(*node, lbasename+extension);
|
||||
}
|
||||
|
||||
// create PagedLOD for tile.
|
||||
osg::PagedLOD* pagedlod = new osg::PagedLOD;
|
||||
osg::Node* tile = createTile(filename,leftHemisphere,lx,ly,dx,dy);
|
||||
pagedlod->addChild(tile, cut_off_distance,max_visible_distance);
|
||||
pagedlod->setRange(1,0.0f,cut_off_distance);
|
||||
pagedlod->setFileName(1,lbasename+extension);
|
||||
pagedlod->setCenter(computePosition(leftHemisphere,lx+dx*0.5,ly+dy*0.5));
|
||||
|
||||
group->addChild(pagedlod);
|
||||
|
||||
// increment number of tiles.
|
||||
++numTiles;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
double lx = x;
|
||||
for(unsigned i=0;i<noTilesX;++i,lx+=dx)
|
||||
{
|
||||
double ly = y;
|
||||
for(unsigned j=0;j<noTilesY;++j,ly+=dy)
|
||||
{
|
||||
group->addChild(createTile(filename,leftHemisphere,lx,ly,dx,dy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return group;
|
||||
|
||||
}
|
||||
|
||||
bool createWorld(const std::string& left_hemisphere, const std::string& right_hemisphere, const std::string& baseName, unsigned int numLevels)
|
||||
{
|
||||
|
||||
osgDB::ReaderWriter* readerWriter = osgDB::Registry::instance()->getReaderWriterForExtension("gdal");
|
||||
if (!readerWriter)
|
||||
{
|
||||
std::cout<<"Error: GDAL plugin not available, cannot preceed with database creation"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
osg::Timer timer;
|
||||
osg::Timer_t start_tick = timer.tick();
|
||||
|
||||
// create the world
|
||||
|
||||
|
||||
std::string path = osgDB::getFilePath(baseName);
|
||||
std::string base = path.empty()?osgDB::getStrippedName(baseName):
|
||||
path +'/'+ osgDB::getStrippedName(baseName);
|
||||
std::string extension = '.'+osgDB::getLowerCaseFileExtension(baseName);
|
||||
|
||||
std::cout << "baseName = "<<baseName<<std::endl;
|
||||
std::cout << "base = "<<base<<std::endl;
|
||||
std::cout << "extension = "<<extension<<std::endl;
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||
group->addChild(createTileAndRecurse(left_hemisphere, base+"_west", extension, true, 5,5, 0.0, 0.0, 1.0, 1.0, numLevels));
|
||||
group->addChild(createTileAndRecurse(right_hemisphere, base+"_east", extension, false, 5,5, 0.0, 0.0, 1.0, 1.0, numLevels));
|
||||
|
||||
osg::StateSet* stateset = group->getOrCreateStateSet();
|
||||
stateset->setMode(GL_CULL_FACE,osg::StateAttribute::ON);
|
||||
|
||||
osgDB::writeNodeFile(*group, baseName);
|
||||
|
||||
|
||||
osg::Timer_t end_tick = timer.tick();
|
||||
std::cout << "Time to create world "<<timer.delta_s(start_tick,end_tick)<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an example which creates and paged database from the Nase blue marble hemisphere's.");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-e <filename>","Specify the east hemisphere input file to process");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-w <filename>","Specify the west hemisphere input file to process");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-o <outputfile>","Specify the output master file to generate");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-l <numOfLevels>","Specify the number of PagedLOD levels to generate");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--compressed","Create compressed textures (default)");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--565","Create R5G5B5A1 textures");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--RGB","Create R8G8B8 textures");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
|
||||
std::string west_hemisphere("land_shallow_topo_west.tif");
|
||||
while (arguments.read("-w",west_hemisphere)) {}
|
||||
|
||||
std::string east_hemisphere("land_shallow_topo_east.tif");
|
||||
while (arguments.read("-e",east_hemisphere)) {}
|
||||
|
||||
std::string basename("bluemarble.ive");
|
||||
while (arguments.read("-o",basename)) {}
|
||||
|
||||
float numLevels=4;
|
||||
while (arguments.read("-l",numLevels)) {}
|
||||
|
||||
while (arguments.read("--compressed")) { useCompressedTextures = true; use565 = false; }
|
||||
while (arguments.read("--565")) { useCompressedTextures = false; use565 = true;}
|
||||
while (arguments.read("--RGB")) { useCompressedTextures = false; use565 = 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;
|
||||
}
|
||||
|
||||
// if (arguments.argc()<=1)
|
||||
// {
|
||||
// arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
|
||||
// create a graphics context to allow us to use OpenGL to compress textures.
|
||||
MyGraphicsContext gfx;
|
||||
|
||||
if (!gfx.valid() && useCompressedTextures)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Disabling texture compression due to inability to create OpenGL graphics context."<<std::endl;
|
||||
useCompressedTextures = false;
|
||||
}
|
||||
|
||||
createWorld(west_hemisphere,east_hemisphere,basename,(unsigned int)numLevels);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
|
||||
CXXFILES =\
|
||||
osgfadetext.cpp\
|
||||
|
||||
LIBS += -losgTerrain -losgFX -losgViewer -losgSim -losgText -losgGA -losgDB -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
LIBS += -losgFX -losgViewer -losgSim -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
INSTFILES = \
|
||||
$(CXXFILES)\
|
||||
|
||||
@@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
|
||||
CXXFILES =\
|
||||
osgfadetext.cpp\
|
||||
|
||||
LIBS += -losgViewer -losgDB -losgSim -losgText -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
LIBS += -losgViewer -losgDB -losgSim -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
EXEC = osgfadetext
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
#include <osgText/FadeText>
|
||||
|
||||
#include <osgTerrain/DataSet>
|
||||
|
||||
#include <osgSim/OverlayNode>
|
||||
#include <osgSim/SphereSegment>
|
||||
|
||||
@@ -23,95 +21,25 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class MyGraphicsContext {
|
||||
public:
|
||||
MyGraphicsContext()
|
||||
{
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = 1;
|
||||
traits->height = 1;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = false;
|
||||
traits->sharedContext = 0;
|
||||
traits->pbuffer = true;
|
||||
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
if (!_gc)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl;
|
||||
|
||||
traits->pbuffer = false;
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
}
|
||||
|
||||
if (_gc.valid())
|
||||
|
||||
|
||||
{
|
||||
_gc->realize();
|
||||
_gc->makeCurrent();
|
||||
std::cout<<"Realized window"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool valid() const { return _gc.valid() && _gc->isRealized(); }
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::GraphicsContext> _gc;
|
||||
};
|
||||
|
||||
osg::Node* createEarth()
|
||||
{
|
||||
osg::ref_ptr<osg::Node> scene;
|
||||
osg::TessellationHints* hints = new osg::TessellationHints;
|
||||
hints->setDetailRatio(5.0f);
|
||||
|
||||
|
||||
{
|
||||
std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg");
|
||||
|
||||
// make osgTerrain::DataSet quieter..
|
||||
osgTerrain::DataSet::setNotifyOffset(1);
|
||||
|
||||
osg::ref_ptr<osgTerrain::DataSet> dataSet = new osgTerrain::DataSet;
|
||||
|
||||
// register the source imagery
|
||||
{
|
||||
osgTerrain::DataSet::Source* source = new osgTerrain::DataSet::Source(osgTerrain::DataSet::Source::IMAGE, filename);
|
||||
|
||||
source->setCoordinateSystemPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS);
|
||||
source->setCoordinateSystem(osgTerrain::DataSet::coordinateSystemStringToWTK("WGS84"));
|
||||
|
||||
source->setGeoTransformPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS_BUT_SCALE_BY_FILE_RESOLUTION);
|
||||
source->setGeoTransformFromRange(-180.0, 180.0, -90.0, 90.0);
|
||||
|
||||
dataSet->addSource(source);
|
||||
}
|
||||
|
||||
// set up destination database paramters.
|
||||
dataSet->setDatabaseType(osgTerrain::DataSet::LOD_DATABASE);
|
||||
dataSet->setConvertFromGeographicToGeocentric(true);
|
||||
dataSet->setDestinationName("test.osg");
|
||||
|
||||
// load the source data and record sizes.
|
||||
dataSet->loadSources();
|
||||
|
||||
MyGraphicsContext context;
|
||||
dataSet->createDestination(30);
|
||||
|
||||
if (dataSet->getDatabaseType()==osgTerrain::DataSet::LOD_DATABASE) dataSet->buildDestination();
|
||||
else dataSet->writeDestination();
|
||||
|
||||
scene = dataSet->getDestinationRootNode();
|
||||
|
||||
// now we must get rid of all the old OpenGL objects before we start using the scene graph again
|
||||
// otherwise it'll end up in an inconsistent state.
|
||||
scene->releaseGLObjects(dataSet->getState());
|
||||
osg::Texture::flushAllDeletedTextureObjects(0);
|
||||
osg::Drawable::flushAllDeletedDisplayLists(0);
|
||||
}
|
||||
|
||||
return scene.release();
|
||||
osg::ShapeDrawable* sd = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0,0.0,0.0), osg::WGS_84_RADIUS_POLAR), hints);
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(sd);
|
||||
|
||||
std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg");
|
||||
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readImageFile(filename)));
|
||||
|
||||
osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
|
||||
csn->setEllipsoidModel(new osg::EllipsoidModel());
|
||||
csn->addChild(geode);
|
||||
|
||||
return csn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
|
||||
CXXFILES =\
|
||||
osgsimulation.cpp\
|
||||
|
||||
LIBS += -losgViewer -losgTerrain -losgFX -losgParticle -losgSim -losgText -losgGA -losgDB -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
LIBS += -losgViewer -losgFX -losgParticle -losgSim -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
INSTFILES = \
|
||||
$(CXXFILES)\
|
||||
|
||||
@@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
|
||||
CXXFILES =\
|
||||
osgsimulation.cpp\
|
||||
|
||||
LIBS += -losgViewer -losgDB -losgParticle -losgSim -losgText -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
LIBS += -losgViewer -losgDB -losgSim -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
EXEC = osgsimulation
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <osgText/Text>
|
||||
|
||||
#include <osgTerrain/DataSet>
|
||||
#include <osg/CoordinateSystemNode>
|
||||
|
||||
#include <osgSim/OverlayNode>
|
||||
#include <osgSim/SphereSegment>
|
||||
@@ -40,95 +40,25 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class MyGraphicsContext {
|
||||
public:
|
||||
MyGraphicsContext()
|
||||
{
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = 1;
|
||||
traits->height = 1;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = false;
|
||||
traits->sharedContext = 0;
|
||||
traits->pbuffer = true;
|
||||
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
if (!_gc)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl;
|
||||
|
||||
traits->pbuffer = false;
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
}
|
||||
|
||||
if (_gc.valid())
|
||||
|
||||
|
||||
{
|
||||
_gc->realize();
|
||||
_gc->makeCurrent();
|
||||
std::cout<<"Realized window"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool valid() const { return _gc.valid() && _gc->isRealized(); }
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::GraphicsContext> _gc;
|
||||
};
|
||||
|
||||
osg::Node* createEarth()
|
||||
{
|
||||
osg::ref_ptr<osg::Node> scene;
|
||||
osg::TessellationHints* hints = new osg::TessellationHints;
|
||||
hints->setDetailRatio(5.0f);
|
||||
|
||||
|
||||
{
|
||||
std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg");
|
||||
|
||||
// make osgTerrain::DataSet quieter..
|
||||
osgTerrain::DataSet::setNotifyOffset(1);
|
||||
|
||||
osg::ref_ptr<osgTerrain::DataSet> dataSet = new osgTerrain::DataSet;
|
||||
|
||||
// register the source imagery
|
||||
{
|
||||
osgTerrain::DataSet::Source* source = new osgTerrain::DataSet::Source(osgTerrain::DataSet::Source::IMAGE, filename);
|
||||
|
||||
source->setCoordinateSystemPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS);
|
||||
source->setCoordinateSystem(osgTerrain::DataSet::coordinateSystemStringToWTK("WGS84"));
|
||||
|
||||
source->setGeoTransformPolicy(osgTerrain::DataSet::Source::PREFER_CONFIG_SETTINGS_BUT_SCALE_BY_FILE_RESOLUTION);
|
||||
source->setGeoTransformFromRange(-180.0, 180.0, -90.0, 90.0);
|
||||
|
||||
dataSet->addSource(source);
|
||||
}
|
||||
|
||||
// set up destination database paramters.
|
||||
dataSet->setDatabaseType(osgTerrain::DataSet::LOD_DATABASE);
|
||||
dataSet->setConvertFromGeographicToGeocentric(true);
|
||||
dataSet->setDestinationName("test.osg");
|
||||
|
||||
// load the source data and record sizes.
|
||||
dataSet->loadSources();
|
||||
|
||||
MyGraphicsContext context;
|
||||
dataSet->createDestination(30);
|
||||
|
||||
if (dataSet->getDatabaseType()==osgTerrain::DataSet::LOD_DATABASE) dataSet->buildDestination();
|
||||
else dataSet->writeDestination();
|
||||
|
||||
scene = dataSet->getDestinationRootNode();
|
||||
|
||||
// now we must get rid of all the old OpenGL objects before we start using the scene graph again
|
||||
// otherwise it'll end up in an inconsistent state.
|
||||
scene->releaseGLObjects(dataSet->getState());
|
||||
osg::Texture::flushAllDeletedTextureObjects(0);
|
||||
osg::Drawable::flushAllDeletedDisplayLists(0);
|
||||
}
|
||||
|
||||
return scene.release();
|
||||
osg::ShapeDrawable* sd = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0,0.0,0.0), osg::WGS_84_RADIUS_POLAR), hints);
|
||||
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(sd);
|
||||
|
||||
std::string filename = osgDB::findDataFile("Images/land_shallow_topo_2048.jpg");
|
||||
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, new osg::Texture2D(osgDB::readImageFile(filename)));
|
||||
|
||||
osg::CoordinateSystemNode* csn = new osg::CoordinateSystemNode;
|
||||
csn->setEllipsoidModel(new osg::EllipsoidModel());
|
||||
csn->addChild(geode);
|
||||
|
||||
return csn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,17 +0,0 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
ReaderWriterGDAL.cpp\
|
||||
|
||||
|
||||
INC += $(GDAL_INCLUDES)
|
||||
|
||||
LIBS += $(OSG_LIBS) $(GDAL_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = gdal
|
||||
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
@@ -1,738 +0,0 @@
|
||||
#include <osg/Image>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GL>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ImageOptions>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/ReentrantMutex>
|
||||
|
||||
#include <gdal_priv.h>
|
||||
|
||||
#define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
|
||||
|
||||
// From easyrgb.com
|
||||
float Hue_2_RGB( float v1, float v2, float vH )
|
||||
{
|
||||
if ( vH < 0 ) vH += 1;
|
||||
if ( vH > 1 ) vH -= 1;
|
||||
if ( ( 6 * vH ) < 1 ) return ( v1 + ( v2 - v1 ) * 6 * vH );
|
||||
if ( ( 2 * vH ) < 1 ) return ( v2 );
|
||||
if ( ( 3 * vH ) < 2 ) return ( v1 + ( v2 - v1 ) * ( ( 2 / 3 ) - vH ) * 6 );
|
||||
return ( v1 );
|
||||
}
|
||||
|
||||
class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
{
|
||||
public:
|
||||
virtual const char* className() const { return "GDAL Image Reader"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) const
|
||||
{
|
||||
return osgDB::equalCaseInsensitive(extension,"gdal") || osgDB::equalCaseInsensitive(extension,"gdal");
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
|
||||
return const_cast<ReaderWriterGDAL*>(this)->local_readImage(fileName, options);
|
||||
}
|
||||
|
||||
virtual ReadResult readHeightField(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex);
|
||||
return const_cast<ReaderWriterGDAL*>(this)->local_readHeightField(fileName, options);
|
||||
}
|
||||
|
||||
virtual ReadResult local_readImage(const std::string& file, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
// Looks like gdal's GDALRasterBand::GetColorInterpretation()
|
||||
// is not giving proper values for ecw images. There is small
|
||||
// hack to get around
|
||||
bool ecwLoad = osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"ecw");
|
||||
|
||||
//if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
osg::notify(osg::INFO) << "GDAL : " << file << std::endl;
|
||||
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
initGDAL();
|
||||
|
||||
std::auto_ptr<GDALDataset> dataset((GDALDataset*)GDALOpen(fileName.c_str(),GA_ReadOnly));
|
||||
if (!dataset.get()) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
int dataWidth = dataset->GetRasterXSize();
|
||||
int dataHeight = dataset->GetRasterYSize();
|
||||
|
||||
int windowX = 0;
|
||||
int windowY = 0;
|
||||
int windowWidth = dataWidth;
|
||||
int windowHeight = dataHeight;
|
||||
|
||||
int destX = 0;
|
||||
int destY = 0;
|
||||
int destWidth = osg::minimum(dataWidth,1024);
|
||||
int destHeight = osg::minimum(dataHeight,1024);
|
||||
// int destWidth = osg::minimum(dataWidth,4096);
|
||||
// int destHeight = osg::minimum(dataHeight,4096);
|
||||
|
||||
|
||||
osgDB::ImageOptions::TexCoordRange* texCoordRange = 0;
|
||||
|
||||
osgDB::ImageOptions* imageOptions = dynamic_cast<osgDB::ImageOptions*>(const_cast<osgDB::ReaderWriter::Options*>(options));
|
||||
if (imageOptions)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"Got ImageOptions"<<std::endl;
|
||||
|
||||
int margin = 0;
|
||||
switch(imageOptions->_sourceImageWindowMode)
|
||||
{
|
||||
case(osgDB::ImageOptions::RATIO_WINDOW):
|
||||
{
|
||||
double desiredX = (double)dataWidth * imageOptions->_sourceRatioWindow.windowX;
|
||||
double desiredY = (double)dataHeight * imageOptions->_sourceRatioWindow.windowY;
|
||||
double desiredWidth = (double)dataWidth * imageOptions->_sourceRatioWindow.windowWidth;
|
||||
double desiredHeight = (double)dataHeight * imageOptions->_sourceRatioWindow.windowHeight;
|
||||
|
||||
windowX = osg::maximum((int)(floor(desiredX))-margin,0);
|
||||
windowY = osg::maximum((int)(floor(desiredY))-margin,0);
|
||||
windowWidth = osg::minimum((int)(ceil(desiredX + desiredWidth))+margin,dataWidth)-windowX;
|
||||
windowHeight = osg::minimum((int)(ceil(desiredY + desiredHeight))+margin,dataHeight)-windowY;
|
||||
|
||||
texCoordRange = new osgDB::ImageOptions::TexCoordRange;
|
||||
texCoordRange->set((desiredX-(double)windowX)/(double)windowWidth,
|
||||
((double)(windowY+windowHeight) -(desiredY+desiredHeight))/(double)windowHeight,
|
||||
(desiredWidth)/(double)windowWidth,
|
||||
(desiredHeight)/(double)windowHeight);
|
||||
osg::notify(osg::INFO)<<"tex coord range "<<texCoordRange->_x<<" "<<texCoordRange->_y<<" "<<texCoordRange->_w<<" "<<texCoordRange->_h<<std::endl;
|
||||
}
|
||||
break;
|
||||
case(osgDB::ImageOptions::PIXEL_WINDOW):
|
||||
windowX = imageOptions->_sourcePixelWindow.windowX;
|
||||
windowY = imageOptions->_sourcePixelWindow.windowY;
|
||||
windowWidth = imageOptions->_sourcePixelWindow.windowWidth;
|
||||
windowHeight = imageOptions->_sourcePixelWindow.windowHeight;
|
||||
break;
|
||||
default:
|
||||
// leave source window dimensions as whole image.
|
||||
break;
|
||||
}
|
||||
|
||||
// reapply the window coords to the pixel window so that calling code
|
||||
// knows the original pixel size
|
||||
imageOptions->_sourcePixelWindow.windowX = windowX;
|
||||
imageOptions->_sourcePixelWindow.windowY = windowY;
|
||||
imageOptions->_sourcePixelWindow.windowWidth = windowWidth;
|
||||
imageOptions->_sourcePixelWindow.windowHeight = windowHeight;
|
||||
|
||||
switch(imageOptions->_destinationImageWindowMode)
|
||||
{
|
||||
case(osgDB::ImageOptions::RATIO_WINDOW):
|
||||
destX = (unsigned int)(floor((double)dataWidth * imageOptions->_destinationRatioWindow.windowX));
|
||||
destY = (unsigned int)(floor((double)dataHeight * imageOptions->_destinationRatioWindow.windowY));
|
||||
destWidth = (unsigned int)(ceil((double)dataWidth * (imageOptions->_destinationRatioWindow.windowX + imageOptions->_destinationRatioWindow.windowWidth)))-windowX;
|
||||
destHeight = (unsigned int)(ceil((double)dataHeight * (imageOptions->_destinationRatioWindow.windowY + imageOptions->_destinationRatioWindow.windowHeight)))-windowY;
|
||||
break;
|
||||
case(osgDB::ImageOptions::PIXEL_WINDOW):
|
||||
destX = imageOptions->_destinationPixelWindow.windowX;
|
||||
destY = imageOptions->_destinationPixelWindow.windowY;
|
||||
destWidth = imageOptions->_destinationPixelWindow.windowWidth;
|
||||
destHeight = imageOptions->_destinationPixelWindow.windowHeight;
|
||||
break;
|
||||
default:
|
||||
// leave source window dimensions as whole image.
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// windowX = 0;
|
||||
// windowY = 0;
|
||||
// windowWidth = destWidth;
|
||||
// windowHeight = destHeight;
|
||||
|
||||
osg::notify(osg::INFO) << " windowX = "<<windowX<<std::endl;
|
||||
osg::notify(osg::INFO) << " windowY = "<<windowY<<std::endl;
|
||||
osg::notify(osg::INFO) << " windowWidth = "<<windowWidth<<std::endl;
|
||||
osg::notify(osg::INFO) << " windowHeight = "<<windowHeight<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << " destX = "<<destX<<std::endl;
|
||||
osg::notify(osg::INFO) << " destY = "<<destY<<std::endl;
|
||||
osg::notify(osg::INFO) << " destWidth = "<<destWidth<<std::endl;
|
||||
osg::notify(osg::INFO) << " destHeight = "<<destHeight<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << " GetRaterCount() "<< dataset->GetRasterCount()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetProjectionRef() "<< dataset->GetProjectionRef()<<std::endl;
|
||||
|
||||
|
||||
double geoTransform[6];
|
||||
if (dataset->GetGeoTransform(geoTransform)==CE_None)
|
||||
{
|
||||
osg::notify(osg::INFO) << " GetGeoTransform "<< std::endl;
|
||||
osg::notify(osg::INFO) << " Origin = "<<geoTransform[0]<<" "<<geoTransform[3]<<std::endl;
|
||||
osg::notify(osg::INFO) << " Pixel X = "<<geoTransform[1]<<" "<<geoTransform[4]<<std::endl;
|
||||
osg::notify(osg::INFO) << " Pixel Y = "<<geoTransform[2]<<" "<<geoTransform[5]<<std::endl;
|
||||
}
|
||||
|
||||
int numBands = dataset->GetRasterCount();
|
||||
|
||||
|
||||
GDALRasterBand* bandGray = 0;
|
||||
GDALRasterBand* bandRed = 0;
|
||||
GDALRasterBand* bandGreen = 0;
|
||||
GDALRasterBand* bandBlue = 0;
|
||||
GDALRasterBand* bandAlpha = 0;
|
||||
GDALRasterBand* bandPalette = 0;
|
||||
|
||||
int internalFormat = GL_LUMINANCE;
|
||||
unsigned int pixelFormat = GL_LUMINANCE;
|
||||
unsigned int dataType = 0;
|
||||
unsigned int numBytesPerPixel = 0;
|
||||
|
||||
GDALDataType targetGDALType = GDT_Byte;
|
||||
|
||||
for(int b=1;b<=numBands;++b)
|
||||
{
|
||||
|
||||
GDALRasterBand* band = dataset->GetRasterBand(b);
|
||||
|
||||
osg::notify(osg::INFO) << " Band "<<b<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << " GetOverviewCount() = "<< band->GetOverviewCount()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetColorTable() = "<< band->GetColorTable()<<std::endl;
|
||||
osg::notify(osg::INFO) << " DataTypeName() = "<< GDALGetDataTypeName(band->GetRasterDataType())<<std::endl;
|
||||
osg::notify(osg::INFO) << " ColorIntepretationName() = "<< GDALGetColorInterpretationName(band->GetColorInterpretation())<<std::endl;
|
||||
|
||||
bool bandNotHandled = true;
|
||||
if (ecwLoad)
|
||||
{
|
||||
bandNotHandled = false;
|
||||
switch (b)
|
||||
{
|
||||
case 1:
|
||||
bandRed = band;
|
||||
break;
|
||||
case 2:
|
||||
bandGreen = band;
|
||||
break;
|
||||
case 3:
|
||||
bandBlue = band;
|
||||
break;
|
||||
default:
|
||||
bandNotHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bandNotHandled)
|
||||
{
|
||||
if (band->GetColorInterpretation()==GCI_GrayIndex) bandGray = band;
|
||||
else if (band->GetColorInterpretation()==GCI_RedBand) bandRed = band;
|
||||
else if (band->GetColorInterpretation()==GCI_GreenBand) bandGreen = band;
|
||||
else if (band->GetColorInterpretation()==GCI_BlueBand) bandBlue = band;
|
||||
else if (band->GetColorInterpretation()==GCI_AlphaBand) bandAlpha = band;
|
||||
else if (band->GetColorInterpretation()==GCI_PaletteIndex) bandPalette = band;
|
||||
else bandGray = band;
|
||||
}
|
||||
|
||||
if (bandPalette)
|
||||
{
|
||||
osg::notify(osg::INFO) << " Palette Interpretation: " << GDALGetPaletteInterpretationName(band->GetColorTable()->GetPaletteInterpretation()) << std::endl;
|
||||
}
|
||||
|
||||
// int gotMin,gotMax;
|
||||
// double minmax[2];
|
||||
//
|
||||
// minmax[0] = band->GetMinimum(&gotMin);
|
||||
// minmax[1] = band->GetMaximum(&gotMax);
|
||||
// if (!(gotMin && gotMax))
|
||||
// {
|
||||
// osg::notify(osg::INFO)<<" computing min max"<<std::endl;
|
||||
// GDALComputeRasterMinMax(band,TRUE,minmax);
|
||||
// }
|
||||
//
|
||||
// osg::notify(osg::INFO) << " min "<<minmax[0]<<std::endl;
|
||||
// osg::notify(osg::INFO) << " max "<<minmax[1]<<std::endl;
|
||||
|
||||
if (dataType==0)
|
||||
{
|
||||
targetGDALType = band->GetRasterDataType();
|
||||
switch(band->GetRasterDataType())
|
||||
{
|
||||
case(GDT_Byte): dataType = GL_UNSIGNED_BYTE; numBytesPerPixel = 1; break;
|
||||
case(GDT_UInt16): dataType = GL_UNSIGNED_SHORT; numBytesPerPixel = 2; break;
|
||||
case(GDT_Int16): dataType = GL_SHORT; numBytesPerPixel = 2; break;
|
||||
case(GDT_UInt32): dataType = GL_UNSIGNED_INT; numBytesPerPixel = 4; break;
|
||||
case(GDT_Int32): dataType = GL_INT; numBytesPerPixel = 4; break;
|
||||
case(GDT_Float32): dataType = GL_FLOAT; numBytesPerPixel = 4; break;
|
||||
case(GDT_Float64): dataType = GL_DOUBLE; numBytesPerPixel = 8; break; // not handled
|
||||
default: dataType = 0; numBytesPerPixel = 0; break; // not handled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int s = destWidth;
|
||||
int t = destHeight;
|
||||
int r = 1;
|
||||
|
||||
|
||||
if (dataType==0)
|
||||
{
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
numBytesPerPixel = 1;
|
||||
targetGDALType = GDT_Byte;
|
||||
}
|
||||
|
||||
unsigned char* imageData = 0;
|
||||
|
||||
if (bandRed && bandGreen && bandBlue)
|
||||
{
|
||||
if (bandAlpha)
|
||||
{
|
||||
// RGBA
|
||||
|
||||
int pixelSpace=4*numBytesPerPixel;
|
||||
int lineSpace=destWidth * pixelSpace;
|
||||
|
||||
imageData = new unsigned char[destWidth * destHeight * pixelSpace];
|
||||
pixelFormat = GL_RGBA;
|
||||
internalFormat = GL_RGBA;
|
||||
|
||||
osg::notify(osg::INFO) << "reading RGBA"<<std::endl;
|
||||
|
||||
bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
bandBlue->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+2),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
bandAlpha->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+3),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// RGB
|
||||
|
||||
int pixelSpace=3*numBytesPerPixel;
|
||||
int lineSpace=destWidth * pixelSpace;
|
||||
|
||||
imageData = new unsigned char[destWidth * destHeight * pixelSpace];
|
||||
pixelFormat = GL_RGB;
|
||||
internalFormat = GL_RGB;
|
||||
|
||||
osg::notify(osg::INFO) << "reading RGB"<<std::endl;
|
||||
|
||||
bandRed->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
bandGreen->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
bandBlue->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+2),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
|
||||
}
|
||||
}
|
||||
else if (bandGray)
|
||||
{
|
||||
if (bandAlpha)
|
||||
{
|
||||
// Luminance alpha
|
||||
int pixelSpace=2*numBytesPerPixel;
|
||||
int lineSpace=destWidth * pixelSpace;
|
||||
|
||||
imageData = new unsigned char[destWidth * destHeight * pixelSpace];
|
||||
pixelFormat = GL_LUMINANCE_ALPHA;
|
||||
internalFormat = GL_LUMINANCE_ALPHA;
|
||||
|
||||
osg::notify(osg::INFO) << "reading grey + alpha"<<std::endl;
|
||||
|
||||
bandGray->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
bandAlpha->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+1),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Luminance map
|
||||
int pixelSpace=1*numBytesPerPixel;
|
||||
int lineSpace=destWidth * pixelSpace;
|
||||
|
||||
imageData = new unsigned char[destWidth * destHeight * pixelSpace];
|
||||
pixelFormat = GL_LUMINANCE;
|
||||
internalFormat = GL_LUMINANCE;
|
||||
|
||||
osg::notify(osg::INFO) << "reading grey"<<std::endl;
|
||||
|
||||
bandGray->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
}
|
||||
}
|
||||
else if (bandAlpha)
|
||||
{
|
||||
// alpha map
|
||||
int pixelSpace=1*numBytesPerPixel;
|
||||
int lineSpace=destWidth * pixelSpace;
|
||||
|
||||
imageData = new unsigned char[destWidth * destHeight * pixelSpace];
|
||||
pixelFormat = GL_ALPHA;
|
||||
internalFormat = GL_ALPHA;
|
||||
|
||||
osg::notify(osg::INFO) << "reading alpha"<<std::endl;
|
||||
|
||||
bandAlpha->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(imageData+0),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
|
||||
}
|
||||
else if (bandPalette)
|
||||
{
|
||||
// Paletted map
|
||||
int pixelSpace=1*numBytesPerPixel;
|
||||
int lineSpace=destWidth * pixelSpace;
|
||||
|
||||
unsigned char *rawImageData;
|
||||
rawImageData = new unsigned char[destWidth * destHeight * pixelSpace];
|
||||
imageData = new unsigned char[destWidth * destHeight * 4/*RGBA*/];
|
||||
pixelFormat = GL_RGBA;
|
||||
internalFormat = GL_RGBA;
|
||||
|
||||
osg::notify(osg::INFO) << "reading palette"<<std::endl;
|
||||
osg::notify(osg::INFO) << "numBytesPerPixel: " << numBytesPerPixel << std::endl;
|
||||
|
||||
bandPalette->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(rawImageData),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace);
|
||||
|
||||
// Map the indexes to an actual RGBA Value.
|
||||
for (int i = 0; i < destWidth * destHeight; i++)
|
||||
{
|
||||
const GDALColorEntry *colorEntry = bandPalette->GetColorTable()->GetColorEntry(rawImageData[i]);
|
||||
GDALPaletteInterp interp = bandPalette->GetColorTable()->GetPaletteInterpretation();
|
||||
if (!colorEntry)
|
||||
{
|
||||
//FIXME: What to do here?
|
||||
|
||||
//osg::notify(osg::INFO) << "NO COLOR ENTRY FOR COLOR " << rawImageData[i] << std::endl;
|
||||
imageData[4*i+0] = 255;
|
||||
imageData[4*i+1] = 0;
|
||||
imageData[4*i+2] = 0;
|
||||
imageData[4*i+3] = 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (interp == GPI_RGB)
|
||||
{
|
||||
imageData[4*i+0] = colorEntry->c1;
|
||||
imageData[4*i+1] = colorEntry->c2;
|
||||
imageData[4*i+2] = colorEntry->c3;
|
||||
imageData[4*i+3] = colorEntry->c4;
|
||||
}
|
||||
else if (interp == GPI_CMYK)
|
||||
{
|
||||
// from wikipedia.org
|
||||
short C = colorEntry->c1;
|
||||
short M = colorEntry->c2;
|
||||
short Y = colorEntry->c3;
|
||||
short K = colorEntry->c4;
|
||||
imageData[4*i+0] = 255 - C*(255 - K) - K;
|
||||
imageData[4*i+1] = 255 - M*(255 - K) - K;
|
||||
imageData[4*i+2] = 255 - Y*(255 - K) - K;
|
||||
imageData[4*i+3] = 255;
|
||||
}
|
||||
else if (interp == GPI_HLS)
|
||||
{
|
||||
// from easyrgb.com
|
||||
float H = colorEntry->c1;
|
||||
float S = colorEntry->c3;
|
||||
float L = colorEntry->c2;
|
||||
float R, G, B;
|
||||
if ( S == 0 ) //HSL values = 0 - 1
|
||||
{
|
||||
R = L; //RGB results = 0 - 1
|
||||
G = L;
|
||||
B = L;
|
||||
}
|
||||
else
|
||||
{
|
||||
float var_2, var_1;
|
||||
if ( L < 0.5 )
|
||||
var_2 = L * ( 1 + S );
|
||||
else
|
||||
var_2 = ( L + S ) - ( S * L );
|
||||
|
||||
var_1 = 2 * L - var_2;
|
||||
|
||||
R = Hue_2_RGB( var_1, var_2, H + ( 1 / 3 ) );
|
||||
G = Hue_2_RGB( var_1, var_2, H );
|
||||
B = Hue_2_RGB( var_1, var_2, H - ( 1 / 3 ) );
|
||||
}
|
||||
imageData[4*i+0] = static_cast<unsigned char>(R*255.0f);
|
||||
imageData[4*i+1] = static_cast<unsigned char>(G*255.0f);
|
||||
imageData[4*i+2] = static_cast<unsigned char>(B*255.0f);
|
||||
imageData[4*i+3] = static_cast<unsigned char>(255.0f);
|
||||
}
|
||||
else if (interp == GPI_Gray)
|
||||
{
|
||||
imageData[4*i+0] = static_cast<unsigned char>(colorEntry->c1*255.0f);
|
||||
imageData[4*i+1] = static_cast<unsigned char>(colorEntry->c1*255.0f);
|
||||
imageData[4*i+2] = static_cast<unsigned char>(colorEntry->c1*255.0f);
|
||||
imageData[4*i+3] = static_cast<unsigned char>(255.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] rawImageData;
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::INFO) << "not found any usable bands in file."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
//GDALOpen(dataset);
|
||||
|
||||
if (imageData)
|
||||
{
|
||||
osg::Image* image = new osg::Image;
|
||||
image->setFileName(fileName.c_str());
|
||||
image->setImage(s,t,r,
|
||||
internalFormat,
|
||||
pixelFormat,
|
||||
dataType,
|
||||
(unsigned char *)imageData,
|
||||
osg::Image::USE_NEW_DELETE);
|
||||
|
||||
if (texCoordRange) image->setUserData(texCoordRange);
|
||||
|
||||
image->flipVertical();
|
||||
|
||||
return image;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
ReadResult local_readHeightField(const std::string& fileName, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
//std::string ext = osgDB::getFileExtension(fileName);
|
||||
//if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
initGDAL();
|
||||
|
||||
std::auto_ptr<GDALDataset> dataset((GDALDataset*)GDALOpen(fileName.c_str(),GA_ReadOnly));
|
||||
if (!dataset.get()) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
int dataWidth = dataset->GetRasterXSize();
|
||||
int dataHeight = dataset->GetRasterYSize();
|
||||
|
||||
int windowX = 0;
|
||||
int windowY = 0;
|
||||
int windowWidth = dataWidth;
|
||||
int windowHeight = dataHeight;
|
||||
|
||||
int destX = 0;
|
||||
int destY = 0;
|
||||
int destWidth = osg::minimum(dataWidth,1024);
|
||||
int destHeight = osg::minimum(dataHeight,1024);
|
||||
|
||||
osgDB::ImageOptions::TexCoordRange* texCoordRange = 0;
|
||||
|
||||
const osgDB::ImageOptions* imageOptions = dynamic_cast<const osgDB::ImageOptions*>(options);
|
||||
if (imageOptions)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"Got ImageOptions"<<std::endl;
|
||||
|
||||
int margin = 0;
|
||||
switch(imageOptions->_sourceImageWindowMode)
|
||||
{
|
||||
case(osgDB::ImageOptions::RATIO_WINDOW):
|
||||
{
|
||||
double desiredX = (double)dataWidth * imageOptions->_sourceRatioWindow.windowX;
|
||||
double desiredY = (double)dataHeight * imageOptions->_sourceRatioWindow.windowY;
|
||||
double desiredWidth = (double)dataWidth * imageOptions->_sourceRatioWindow.windowWidth;
|
||||
double desiredHeight = (double)dataHeight * imageOptions->_sourceRatioWindow.windowHeight;
|
||||
|
||||
windowX = osg::maximum((int)(floor(desiredX))-margin,0);
|
||||
windowY = osg::maximum((int)(floor(desiredY))-margin,0);
|
||||
windowWidth = osg::minimum((int)(ceil(desiredX + desiredWidth))+margin,dataWidth)-windowX;
|
||||
windowHeight = osg::minimum((int)(ceil(desiredY + desiredHeight))+margin,dataHeight)-windowY;
|
||||
|
||||
texCoordRange = new osgDB::ImageOptions::TexCoordRange;
|
||||
texCoordRange->set((desiredX-(double)windowX)/(double)windowWidth,
|
||||
((double)(windowY+windowHeight) -(desiredY+desiredHeight))/(double)windowHeight,
|
||||
(desiredWidth)/(double)windowWidth,
|
||||
(desiredHeight)/(double)windowHeight);
|
||||
osg::notify(osg::INFO)<<"tex coord range "<<texCoordRange->_x<<" "<<texCoordRange->_y<<" "<<texCoordRange->_w<<" "<<texCoordRange->_h<<std::endl;
|
||||
}
|
||||
break;
|
||||
case(osgDB::ImageOptions::PIXEL_WINDOW):
|
||||
windowX = imageOptions->_sourcePixelWindow.windowX;
|
||||
windowY = imageOptions->_sourcePixelWindow.windowY;
|
||||
windowWidth = imageOptions->_sourcePixelWindow.windowWidth;
|
||||
windowHeight = imageOptions->_sourcePixelWindow.windowHeight;
|
||||
break;
|
||||
default:
|
||||
// leave source window dimensions as whole image.
|
||||
break;
|
||||
}
|
||||
|
||||
switch(imageOptions->_destinationImageWindowMode)
|
||||
{
|
||||
case(osgDB::ImageOptions::RATIO_WINDOW):
|
||||
destX = (unsigned int)(floor((double)dataWidth * imageOptions->_destinationRatioWindow.windowX));
|
||||
destY = (unsigned int)(floor((double)dataHeight * imageOptions->_destinationRatioWindow.windowY));
|
||||
destWidth = (unsigned int)(ceil((double)dataWidth * (imageOptions->_destinationRatioWindow.windowX + imageOptions->_destinationRatioWindow.windowWidth)))-windowX;
|
||||
destHeight = (unsigned int)(ceil((double)dataHeight * (imageOptions->_destinationRatioWindow.windowY + imageOptions->_destinationRatioWindow.windowHeight)))-windowY;
|
||||
break;
|
||||
case(osgDB::ImageOptions::PIXEL_WINDOW):
|
||||
destX = imageOptions->_destinationPixelWindow.windowX;
|
||||
destY = imageOptions->_destinationPixelWindow.windowY;
|
||||
destWidth = imageOptions->_destinationPixelWindow.windowWidth;
|
||||
destHeight = imageOptions->_destinationPixelWindow.windowHeight;
|
||||
break;
|
||||
default:
|
||||
// leave source window dimensions as whole image.
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// windowX = 0;
|
||||
// windowY = 0;
|
||||
// windowWidth = destWidth;
|
||||
// windowHeight = destHeight;
|
||||
|
||||
osg::notify(osg::INFO) << " windowX = "<<windowX<<std::endl;
|
||||
osg::notify(osg::INFO) << " windowY = "<<windowY<<std::endl;
|
||||
osg::notify(osg::INFO) << " windowWidth = "<<windowWidth<<std::endl;
|
||||
osg::notify(osg::INFO) << " windowHeight = "<<windowHeight<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << " destX = "<<destX<<std::endl;
|
||||
osg::notify(osg::INFO) << " destY = "<<destY<<std::endl;
|
||||
osg::notify(osg::INFO) << " destWidth = "<<destWidth<<std::endl;
|
||||
osg::notify(osg::INFO) << " destHeight = "<<destHeight<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << " GetRaterCount() "<< dataset->GetRasterCount()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetProjectionRef() "<< dataset->GetProjectionRef()<<std::endl;
|
||||
|
||||
|
||||
double geoTransform[6];
|
||||
osg::notify(osg::INFO) << " GetGeoTransform == "<< dataset->GetGeoTransform(geoTransform)<<" == CE_None"<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetGeoTransform "<< std::endl;
|
||||
osg::notify(osg::INFO) << " Origin = "<<geoTransform[0]<<" "<<geoTransform[3]<<std::endl;
|
||||
osg::notify(osg::INFO) << " Pixel X = "<<geoTransform[1]<<" "<<geoTransform[4]<<std::endl;
|
||||
osg::notify(osg::INFO) << " Pixel Y = "<<geoTransform[2]<<" "<<geoTransform[5]<<std::endl;
|
||||
|
||||
|
||||
double TopLeft[2],BottomLeft[2],BottomRight[2],TopRight[2];
|
||||
TopLeft[0] = geoTransform[0];
|
||||
TopLeft[1] = geoTransform[1];
|
||||
BottomLeft[0] = TopLeft[0]+geoTransform[2]*(dataHeight-1);
|
||||
BottomLeft[1] = TopLeft[1]+geoTransform[5]*(dataHeight-1);
|
||||
BottomRight[0] = BottomLeft[0]+geoTransform[1]*(dataWidth-1);
|
||||
BottomRight[1] = BottomLeft[1]+geoTransform[4]*(dataWidth-1);
|
||||
TopRight[0] = TopLeft[0]+geoTransform[1]*(dataWidth-1);
|
||||
TopRight[1] = TopLeft[1]+geoTransform[4]*(dataWidth-1);
|
||||
|
||||
|
||||
osg::notify(osg::INFO) << "TopLeft "<<TopLeft[0]<<"\t"<<TopLeft[1]<<std::endl;
|
||||
osg::notify(osg::INFO) << "BottomLeft "<<BottomLeft[0]<<"\t"<<BottomLeft[1]<<std::endl;
|
||||
osg::notify(osg::INFO) << "BottomRight "<<BottomRight[0]<<"\t"<<BottomRight[1]<<std::endl;
|
||||
osg::notify(osg::INFO) << "TopRight "<<TopRight[0]<<"\t"<<TopRight[1]<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO)<<" GDALGetGCPCount "<<dataset->GetGCPCount()<<std::endl;
|
||||
|
||||
int numBands = dataset->GetRasterCount();
|
||||
|
||||
|
||||
GDALRasterBand* bandGray = 0;
|
||||
GDALRasterBand* bandRed = 0;
|
||||
GDALRasterBand* bandGreen = 0;
|
||||
GDALRasterBand* bandBlue = 0;
|
||||
GDALRasterBand* bandAlpha = 0;
|
||||
|
||||
for(int b=1;b<=numBands;++b)
|
||||
{
|
||||
|
||||
GDALRasterBand* band = dataset->GetRasterBand(b);
|
||||
|
||||
osg::notify(osg::INFO) << " Band "<<b<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO) << " GetOverviewCount() = "<< band->GetOverviewCount()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetColorTable() = "<< band->GetColorTable()<<std::endl;
|
||||
osg::notify(osg::INFO) << " DataTypeName() = "<< GDALGetDataTypeName(band->GetRasterDataType())<<std::endl;
|
||||
osg::notify(osg::INFO) << " ColorIntepretationName() = "<< GDALGetColorInterpretationName(band->GetColorInterpretation())<<std::endl;
|
||||
|
||||
|
||||
osg::notify(osg::INFO) << std::endl;
|
||||
osg::notify(osg::INFO) << " GetNoDataValue() = "<< band->GetNoDataValue()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetMinimum() = "<< band->GetMinimum()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetMaximum() = "<< band->GetMaximum()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetOffset() = "<< band->GetOffset()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetScale() = "<< band->GetScale()<<std::endl;
|
||||
osg::notify(osg::INFO) << " GetUnitType() = '"<< band->GetUnitType()<<"'"<<std::endl;
|
||||
|
||||
|
||||
if (band->GetColorInterpretation()==GCI_GrayIndex) bandGray = band;
|
||||
else if (band->GetColorInterpretation()==GCI_RedBand) bandRed = band;
|
||||
else if (band->GetColorInterpretation()==GCI_GreenBand) bandGreen = band;
|
||||
else if (band->GetColorInterpretation()==GCI_BlueBand) bandBlue = band;
|
||||
else if (band->GetColorInterpretation()==GCI_AlphaBand) bandAlpha = band;
|
||||
else bandGray = band;
|
||||
|
||||
}
|
||||
|
||||
|
||||
GDALRasterBand* bandSelected = 0;
|
||||
if (!bandSelected && bandGray) bandSelected = bandGray;
|
||||
else if (!bandSelected && bandAlpha) bandSelected = bandAlpha;
|
||||
else if (!bandSelected && bandRed) bandSelected = bandRed;
|
||||
else if (!bandSelected && bandGreen) bandSelected = bandGreen;
|
||||
else if (!bandSelected && bandBlue) bandSelected = bandBlue;
|
||||
|
||||
if (bandSelected)
|
||||
{
|
||||
osg::HeightField* hf = new osg::HeightField;
|
||||
hf->allocate(destWidth,destHeight);
|
||||
|
||||
bandSelected->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*)(&(hf->getHeightList().front())),destWidth,destHeight,GDT_Float32,0,0);
|
||||
|
||||
// now need to flip since the OSG's origin is in lower left corner.
|
||||
osg::notify(osg::INFO)<<"flipping"<<std::endl;
|
||||
unsigned int copy_r = hf->getNumRows()-1;
|
||||
for(unsigned int r=0;r<copy_r;++r,--copy_r)
|
||||
{
|
||||
for(unsigned int c=0;c<hf->getNumColumns();++c)
|
||||
{
|
||||
float temp = hf->getHeight(c,r);
|
||||
hf->setHeight(c,r,hf->getHeight(c,copy_r));
|
||||
hf->setHeight(c,copy_r,temp);
|
||||
}
|
||||
}
|
||||
|
||||
return hf;
|
||||
}
|
||||
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
}
|
||||
|
||||
void initGDAL()
|
||||
{
|
||||
static bool s_initialized = false;
|
||||
if (!s_initialized)
|
||||
{
|
||||
s_initialized = true;
|
||||
GDALAllRegister();
|
||||
}
|
||||
}
|
||||
|
||||
mutable OpenThreads::ReentrantMutex _serializerMutex;
|
||||
|
||||
};
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriterGDAL> g_readerWriter_GDAL_Proxy;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@ include $(TOPDIR)/Make/makedefs
|
||||
|
||||
|
||||
CXXFILES = \
|
||||
DataSet.cpp\
|
||||
HeightFieldNode.cpp\
|
||||
HeightFieldRenderer.cpp\
|
||||
Version.cpp\
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@ TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
DataSet.cpp\
|
||||
Export.cpp\
|
||||
HeightFieldNode.cpp\
|
||||
HeightFieldRenderer.cpp\
|
||||
|
||||
|
||||
@@ -724,5 +724,7 @@ END_REFLECTOR
|
||||
|
||||
STD_MAP_REFLECTOR(std::map< osg::ref_ptr< osgText::Font::GlyphTexture > COMMA osgText::Text::GlyphQuads >);
|
||||
|
||||
STD_VECTOR_REFLECTOR(std::vector< osg::Vec2 >);
|
||||
|
||||
STD_VECTOR_REFLECTOR(std::vector< osgText::Font::Glyph * >);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user