Compare commits

..

3 Commits

Author SHA1 Message Date
Robert Osfield
de44c21d99 Fixed URL 2008-04-03 15:45:34 +00:00
Robert Osfield
a6dbd537e8 Changed the svn:externals to link to OpenThreads-2.2 2008-04-03 15:43:36 +00:00
Robert Osfield
42db377ddb Release OpenSceneGraph-2.0.0 2007-06-15 17:05:58 +00:00
636 changed files with 11565 additions and 34535 deletions

View File

@@ -1,6 +1,6 @@
OpenSceneGraph Library 2.2.0
OpenSceneGraph Library 1.9.9
281 Contributors:
264 Contributors:
Firstname Surname
-----------------
@@ -11,11 +11,10 @@ Mike Weiblen
Eric Wing
Brede Johansen
Geoff Michel
Paul Martz
Farshid Lashkari
Stephan Huber
Paul Martz
Bob Kuehne
Martin Lavery
Stephan Huber
Ulrich Hertlein
Eric Sokolowsky
Tree
@@ -23,28 +22,25 @@ Mike Wittman
Luigi Calori
Trajce Nikolov
Pavel Moloshtan
Martin Lavery
Tom Jolley
Mathias Fr<46>hlich
Norman Vine
David Callu
Alberto Farre
Roger James
Andr<EFBFBD> Garneau
Ruben Lopez
Randall Hopper
Roger James
Olaf Flebbe
Gideon May
Don Tidrow
Romano Jos<6F> Magacho da Silva
Michael Gronager
Daniel Sj<53>lie
Colin McDonald
Chris Hanson
Jean-Sebastien Guay
David Spilling
Andy Skinner
Daniel Sj<53>lie
Per Fahlberg
Mathias Fr<46>hlich
Joran Jessurun
Anr<EFBFBD> Garneau
Frederic Marmond
David Fries
Boris Bralo
@@ -52,40 +48,30 @@ Yefei He
Sondra Iverson
Rune Schmidt Jensen
Neil Salter
Mike Connell
Jeremy Moles
Jason Daly
Jason Beverage
David Spilling
David Callu
Ben Discoe
Sasa Bistrovic
Rainer Oder
Paul Melis
Mike Connell
Martin Naylor
Martin Aumueller
Markus Trenkwalder
Loic Dachary
Joakim Simonsson
Jan Peciva
Jan Ciger
Jeremy Moles
Gordon Tomlinson
Brad Colbert
Art Tevs
Andreas Ekstrand
Vivek Rajan
Stephane Simon
Sherman Wilcox
Sean Spicer
Ravi Mathur
Nikolaus Hanekamp
Michael Platings
Michael Hartman
Laurens Voerman
Loic Dachary
Joseph Steel
John Shue
David Guthrie
Corbin Holtz
Brad Christiansen
Adrian Egli
Toshiyuki Takahei
Thom DeCarlo
Terry Welsh
@@ -93,24 +79,25 @@ Simon Julier
Sebastien Grignard
Romano Magacho
Paul de Repentigny
Mihai Radu
Luc Frauciel
Nikolaus Hanekamp
Michael Hartman
Leandro Motta Barros
Jos<EFBFBD> Delport
Laurens Voerman
Carlo Camporesi
Bryan Thrall
Bruce Clay
Brad Colbert
Brad Christiansen
Alberto Barbati
Vladimir Shabanov
Uwe Woessner
Sohey Yamamoto
Serge Lages
Phil Atkin
Mattias Linde
Paul Melis
Mathieu Marache
Maria Ten
Ken Sewell
Julian Ortiz
John Shue
John Kelso
Jeremy Bell
James French
@@ -119,23 +106,20 @@ Donn Mielcarek
Domenico Mangieri
Daniel Larimer
Charles Cole
Blake Williams
Antoine Hue
Anders Backman
Bryan Thrall
Andre Garneau
Ali Botorabi
Zach Deedler
Yuzhong Shen
Tugkan Calapoglu
Tony Horrobin
Tim Daoust
Thibault Genessay
Terrex
Steve Lunsford
Stephan Eilemann
Stanislav Blinov
Roland Smeenk
Riccardo Corsi
Rafa Giatan
Philip Lowman
Peter Hrenka
Perry Miller
@@ -147,9 +131,12 @@ Mathew May
Martijn Kragtwijk
Kevin Moiule
Keith Steffen
Jos<EFBFBD> Delport
Joseph Winston
John Aughey
Johan Nouvel
Jean-Sebastien Guay
Jan Ciger
Igor Kravtchenko
Gerrick Bivins
George Tarantilis
@@ -158,11 +145,13 @@ Fabio Mierlo
Edgar Ellis
David Ergo
Daniel Trstenjak
Csaba Halasz
Blake Williams
Antoine Hue
Andy Skinner
Andrew Sampson
Andrew Lorino
Andreas Goebel
Alberto Luaces
Anders Backman
Zbigniew Sroczynski
Yuri Vilmanis
Wojciech Lewandowski
@@ -178,32 +167,30 @@ Vaclav Bilek
Tyge
Troy Yee
Tino Schwarze
Tim Moore
Thom Carlo
Tery Welsh
Tanguy Fautr<74>
Sylvan Marie
Sylvain Marie
Sherman Wilcox
Shane Arnott
Sebastien Kuntz
Rudolf Wiedemann
Ronny Krueger
Robert Swain
Rick Pingry
Reinhard Sainitzer
Rein Kadijk
Ralf Kern
Rafa Giatan
Radu Mihai
Qing Shen
Philipp Siemoleit
Paul Fredrikson
Parag Chaudhur
Orhun Birsoy
Ole-Morten Duesund
Nicolas Brodu
Nathan Cournia
Morn<EFBFBD> Pistorius
Mirko Viviani
Morné Pistorius
Mikkel Gjøl
Mihai Radu
Michael Polak
Michael Morrison
Michael Logan
@@ -212,12 +199,13 @@ Mauricio Hofmam
Matthew May
Matt Green
Matt Burke
Mathias Froelich
Mathia Walker
Mason Menninger
Martin Spott
Martin Amueller
Mario Valle
Marin Lavery
Maria Ten
Louis Hamilton
Lewis Harmon
Kristopher Bixler
@@ -232,16 +220,16 @@ Joakim Simmonsson
Jay Zuckerman
Jason Howlett
Jason Ballenger
Jan Peciva
J.E. Hoffmann
Henrique Bucher
Gustavo Wagner
Guillaume Millet
Graeme Harkness
Glenn Waldrom
Gian Lorenzetto
George Papagiannakis
Gary Quinn
Galen Faidley
Frauciel Luc
Frashid Lashkari
Frank Warmerdam
Frank Lindeman
@@ -260,28 +248,23 @@ Donny Cipperly
Dean Iverson
David Jung
David Gurhrie
Dan Minor
Clay Fowler
Chuck Sembroski
Chuck Seberion
Chris McGlone
Carlos Garcea
Bruno Herbelin
Brian Keener
Brandon Hamm
Brad Anderegg
Bora Utka
Blasius Czink
Ben van Basten
Bart Gallet
Axel Volley
Andrew Reyonolds
Andreas Jochens
Almalric Alexandre
Allen Bierbaum
Alexandre Amalric
Alberto Jaspe
Alan Purvis
Alan Ott
Alan Harris
Adrian Egli
Adam Richard

View File

@@ -15,25 +15,14 @@ ENDIF(WIN32)
PROJECT(OpenSceneGraph)
SET(OPENSCENEGRAPH_MAJOR_VERSION 2)
SET(OPENSCENEGRAPH_MINOR_VERSION 2)
SET(OPENSCENEGRAPH_MINOR_VERSION 0)
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
SET(OPENSCENEGRAPH_SOVERSION 25)
SET(OPENSCENEGRAPH_SOVERSION 11)
SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION})
SET(OSG_PLUGINS osgPlugins-${OPENSCENEGRAPH_VERSION})
SET(OSG_PLUGIN_PREFIX "")
IF (CYGWIN)
SET(OSG_PLUGIN_PREFIX "cygwin_")
ENDIF(CYGWIN)
IF(MINGW)
SET(OSG_PLUGIN_PREFIX "mingw_")
ENDIF(MINGW)
# We want to build SONAMES shared librariess
SET(OPENSCENEGRAPH_SONAMES TRUE)
SET(OPENTHREADS_SONAMES TRUE)
@@ -98,64 +87,14 @@ INCLUDE_DIRECTORIES(
#ADD_DEFINITIONS(-D)
# Platform specific definitions
IF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT OFF)
IF (CMAKE_SYSTEM MATCHES "AIX.*")
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON)
ENDIF(CMAKE_SYSTEM MATCHES "AIX.*")
IF (APPLE)
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON)
ENDIF(APPLE)
ENDIF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
OPTION(OSG_GLU_TESS_CALLBACK_TRIPLEDOT "Set to ON to build build with (...) version of GLU tesselator callback" ${DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT})
IF (OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
ADD_DEFINITIONS(-DGLU_TESS_CALLBACK_TRIPLEDOT)
ENDIF(OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
IF(WIN32)
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
#needed for net plugin
SET (OSG_SOCKET_LIBS wsock32)
SET (OSG_SOCKET_LIBS wsock32.lib)
# Both Cygwin and Msys need -DNOMINMAX ???
IF(UNIX)
ADD_DEFINITIONS(-DNOMINMAX)
ENDIF(UNIX)
########################################################################################################
# the foolowing options are MSVC specific,
# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
# fron bin folder without requiring installation step.
# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
# it also use a hack to get rid of Debug and Release folder in MSVC projects
# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
#
# the second option disable incremental linking in debug build , that is enabled by default by CMake
##########################################################################################################
IF(MSVC)
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
MESSAGE("Warning: disabling versioned options 2.4.6 exibits inconsintencies in .pdb naming, at least under MSVC, suggested upgrading at least to 2.4.7")
SET(OSG_MSVC_VERSIONED_DLL OFF)
SET(OSG_MSVC_DEBUG_INCREMENTAL_LINK ON)
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
OPTION(OSG_MSVC_VERSIONED_DLL "Set to ON to build OpenSceneGraph with versioned dll names" ON)
MARK_AS_ADVANCED(OSG_MSVC_VERSIONED_DLL)
OPTION(OSG_MSVC_DEBUG_INCREMENTAL_LINK "Set to OFF to build OpenSceneGraph without incremental linking in debug (release is off by default)" ON)
MARK_AS_ADVANCED(OSG_MSVC_DEBUG_INCREMENTAL_LINK)
IF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO")
ENDIF(NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK)
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
ENDIF(MSVC)
ENDIF(WIN32)
########################################################################################################
@@ -201,7 +140,6 @@ FIND_PACKAGE(FreeType)
FIND_PACKAGE(FLTK)
FIND_PACKAGE(GLUT)
FIND_PACKAGE(SDL)
FIND_PACKAGE(FOX)
FIND_PACKAGE(Inventor)
FIND_PACKAGE(Jasper)
FIND_PACKAGE(COLLADA)
@@ -209,33 +147,15 @@ FIND_PACKAGE(Xine)
FIND_PACKAGE(OpenVRML)
FIND_PACKAGE(Performer)
FIND_PACKAGE(ZLIB)
FIND_PACKAGE(GDAL)
# SET(DESIRED_QT_VERSION 3)
# FIND_PACKAGE(Qt)
FIND_PACKAGE(Qt3)
FIND_PACKAGE(Qt4)
SET(wxWidgets_USE_LIBS base core gl net)
FIND_PACKAGE(wxWidgets)
# To select a specific version of QT define DESIRED_QT_VERSION
# via cmake -DDESIRED_QT_VERSION=4
IF (DESIRED_QT_VERSION)
IF (DESIRED_QT_VERSION MATCHES 4)
FIND_PACKAGE(Qt4)
ELSE(DESIRED_QT_VERSION MATCHES 4)
FIND_PACKAGE(Qt3)
ENDIF(DESIRED_QT_VERSION MATCHES 4)
ELSE(DESIRED_QT_VERSION)
FIND_PACKAGE(Qt4)
IF (NOT QT4_FOUND)
FIND_PACKAGE(Qt3)
ENDIF(NOT QT4_FOUND)
ENDIF(DESIRED_QT_VERSION)
# Platform specific:
# (We can approach this one of two ways. We can try to FIND everything
# and simply check if we found the packages before actually building
@@ -296,9 +216,7 @@ SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
MAKE_DIRECTORY(${OUTPUT_LIBDIR})
IF(NOT MSVC)
MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
ENDIF(NOT MSVC)
MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
@@ -371,15 +289,13 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
# errors instead of warnings for certain issues, including superfluous
# semicolons and commas, and the use of long long. -fpermissive seems
# to be the workaround.
SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive")
SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wnewline-eof -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive")
ELSE(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
# FIXME: What are good aggressive warning flags for Visual Studio?
# And do we need to further subcase this for different versions of VS?
# CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
SET(OSG_AGGRESSIVE_WARNING_FLAGS "/Wall /W4")
ELSE(MSVC)
# CMake lacks an elseif, so other non-gcc, non-VS compilers need
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should

View File

@@ -52,7 +52,7 @@ ENDMACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGS
MACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
FIND_DEPENDENCY(TIFF tiff.h libtiff ${OSG_3RDPARTY_BIN} "D")
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype219;freetype234;freetype234MT" ${OSG_3RDPARTY_BIN} "_D")
FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype219;freetype234MT" ${OSG_3RDPARTY_BIN} "_D")
IF(FREETYPE_FOUND)
#forcing subsequent FindFreeType stuff to not search for other variables.... kind of a hack
SET(FREETYPE_INCLUDE_DIR_ft2build ${FREETYPE_INCLUDE_DIR} CACHE PATH "")

View File

@@ -1,74 +0,0 @@
# Locate gdal
# This module defines
# FOX_LIBRARY
# FOX_FOUND, if false, do not try to link to gdal
# FOX_INCLUDE_DIR, where to find the headers
#
# $FOX_DIR is an environment variable that would
# correspond to the ./configure --prefix=$FOX_DIR
#
# Created by Robert Osfield.
FIND_PATH(FOX_INCLUDE_DIR fx.h
$ENV{FOX_DIR}/include/fox-1.6
$ENV{FOX_DIR}/fox-1.6
$ENV{OSGDIR}/include/fox-1.6
$ENV{OSGDIR}/fox-1.6
$ENV{OSG_ROOT}/include/fox-1.6
~/Library/Frameworks/fox-1.6
/Library/Frameworks/fox-1.6
/usr/local/include/fox-1.6
/usr/include/fox-1.6
/sw/include/fox-1.6 # Fink
/opt/local/include/fox-1.6 # DarwinPorts
/opt/csw/include/fox-1.6 # Blastwave
/opt/include/fox-1.6
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include/fox-1.6
/usr/freeware/include/fox-1.6
$ENV{FOX_DIR}/include
$ENV{FOX_DIR}
$ENV{OSGDIR}/include
$ENV{OSGDIR}
$ENV{OSG_ROOT}/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
/usr/freeware/include
)
MACRO(FIND_FOX_LIBRARY MYLIBRARY MYLIBRARYNAME)
FIND_LIBRARY(${MYLIBRARY}
NAMES ${MYLIBRARYNAME}
PATHS
$ENV{FOX_DIR}/lib
$ENV{FOX_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
ENDMACRO(FIND_FOX_LIBRARY LIBRARY LIBRARYNAME)
FIND_FOX_LIBRARY(FOX_LIBRARY FOX-1.6)
SET(FOX_FOUND "NO")
IF(FOX_LIBRARY AND FOX_INCLUDE_DIR)
SET(FOX_FOUND "YES")
ENDIF(FOX_LIBRARY AND FOX_INCLUDE_DIR)

View File

@@ -1,58 +0,0 @@
# Locate gdal
# This module defines
# GDAL_LIBRARY
# GDAL_FOUND, if false, do not try to link to gdal
# GDAL_INCLUDE_DIR, where to find the headers
#
# $GDAL_DIR is an environment variable that would
# correspond to the ./configure --prefix=$GDAL_DIR
#
# Created by Robert Osfield.
FIND_PATH(GDAL_INCLUDE_DIR gdal.h
${GDAL_DIR}/include
$ENV{GDAL_DIR}/include
$ENV{GDAL_DIR}
$ENV{OSGDIR}/include
$ENV{OSGDIR}
$ENV{OSG_ROOT}/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/usr/include/gdal
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
/usr/freeware/include
)
FIND_LIBRARY(GDAL_LIBRARY
NAMES gdal gdal_i gdal1.4.0 gdal1.3.2
PATHS
${GDAL_DIR}/lib
$ENV{GDAL_DIR}/lib
$ENV{GDAL_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
SET(GDAL_FOUND "NO")
IF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR)
SET(GDAL_FOUND "YES")
ENDIF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR)

View File

@@ -1,9 +1,8 @@
# - Locate Inventor
# This module defines:
# INVENTOR_FOUND, if false, do not try to link against Inventor.
# INVENTOR_INCLUDE_DIR, where to find headers.
# INVENTOR_LIBRARY, the library to link against.
# INVENTOR_LIBRARY_DEBUG, the debug library to link against.
# INVENTOR_INCLUDE_DIR, where to find headers.
FIND_PATH(INVENTOR_INCLUDE_DIR Inventor/So.h
/usr/local/include
@@ -12,11 +11,10 @@ FIND_PATH(INVENTOR_INCLUDE_DIR Inventor/So.h
/opt/local/include
/opt/csw/include
/opt/include
$ENV{COINDIR}/include
)
FIND_LIBRARY(INVENTOR_LIBRARY
NAMES coin2 Coin
NAMES Coin
PATHS
/usr/local/lib
/usr/lib
@@ -24,7 +22,6 @@ FIND_LIBRARY(INVENTOR_LIBRARY
/opt/local/lib
/opt/csw/lib
/opt/lib
$ENV{COINDIR}/lib
)
IF(NOT INVENTOR_LIBRARY)
# If we can't find libCoin try libInventor
@@ -40,23 +37,6 @@ IF(NOT INVENTOR_LIBRARY)
)
ENDIF(NOT INVENTOR_LIBRARY)
FIND_LIBRARY(INVENTOR_LIBRARY_DEBUG
NAMES coin2d
PATHS
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
$ENV{COINDIR}/lib
)
IF(NOT INVENTOR_LIBRARY_DEBUG)
IF(INVENTOR_LIBRARY)
SET(INVENTOR_LIBRARY_DEBUG INVENTOR_LIBRARY)
ENDIF(INVENTOR_LIBRARY)
ENDIF(NOT INVENTOR_LIBRARY_DEBUG)
SET(INVENTOR_FOUND "NO")
IF(INVENTOR_INCLUDE_DIR AND INVENTOR_LIBRARY)
SET(INVENTOR_FOUND "YES")

View File

@@ -1,65 +0,0 @@
# Locate gdal
# This module defines
# OSG_LIBRARY
# OSG_FOUND, if false, do not try to link to gdal
# OSG_INCLUDE_DIR, where to find the headers
#
# $OSG_DIR is an environment variable that would
# correspond to the ./configure --prefix=$OSG_DIR
#
# Created by Robert Osfield.
FIND_PATH(OSG_INCLUDE_DIR osg/Node
$ENV{OSG_DIR}/include
$ENV{OSG_DIR}
$ENV{OSGDIR}/include
$ENV{OSGDIR}
$ENV{OSG_ROOT}/include
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
/usr/freeware/include
)
MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
FIND_LIBRARY(${MYLIBRARY}
NAMES ${MYLIBRARYNAME}
PATHS
$ENV{OSG_DIR}/lib
$ENV{OSG_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
ENDMACRO(FIND_OSG_LIBRARY LIBRARY LIBRARYNAME)
FIND_OSG_LIBRARY(OSG_LIBRARY osg)
FIND_OSG_LIBRARY(OSGUTIL_LIBRARY osgUtil)
FIND_OSG_LIBRARY(OSGDB_LIBRARY osgDB)
FIND_OSG_LIBRARY(OSGTEXT_LIBRARY osgText)
FIND_OSG_LIBRARY(OSGTERRAIN_LIBRARY osgTerrain)
FIND_OSG_LIBRARY(OSGFX_LIBRARY osgFX)
FIND_OSG_LIBRARY(OSGVIEWER_LIBRARY osgViewer)
SET(OSG_FOUND "NO")
IF(OSG_LIBRARY AND OSG_INCLUDE_DIR)
SET(OSG_FOUND "YES")
ENDIF(OSG_LIBRARY AND OSG_INCLUDE_DIR)

View File

@@ -8,7 +8,6 @@
# correspond to the ./configure --prefix=$OPENVRML_DIR
#
# Created by Robert Osfield.
# Modified for the debug library by Jean-S<>bastien Guay.
FIND_PATH(OPENVRML_INCLUDE_DIR openvrml/openvrml/common.h
$ENV{OPENVRML_DIR}/include
@@ -48,26 +47,6 @@ FIND_LIBRARY(OPENVRML_LIBRARY
/usr/freeware/lib64
)
FIND_LIBRARY(OPENVRML_LIBRARY_DEBUG
NAMES openvrmld
PATHS
$ENV{OPENVRML_DIR}/lib
$ENV{OPENVRML_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
SET(OPENVRML_FOUND "NO")
IF(OPENVRML_LIBRARY AND OPENVRML_INCLUDE_DIR)
SET(OPENVRML_FOUND "YES")

View File

@@ -10,8 +10,6 @@
# Created by Robert Osfield.
FIND_PATH(PERFORMER_INCLUDE_DIR Performer/pfdu.h
$ENV{PFROOT}/include
$ENV{PFROOT}
$ENV{PERFORMER_DIR}/include
$ENV{PERFORMER_DIR}
$ENV{OSGDIR}/include
@@ -29,51 +27,25 @@ FIND_PATH(PERFORMER_INCLUDE_DIR Performer/pfdu.h
/usr/freeware/include
)
IF(MSVC)
FIND_LIBRARY(PERFORMER_LIBRARY
NAMES libpf
PATHS
$ENV{PFROOT}/lib
$ENV{PFROOT}
$ENV{PERFORMER_DIR}/lib
$ENV{PERFORMER_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
ELSE(MSVC)
FIND_LIBRARY(PERFORMER_LIBRARY
NAMES pf
PATHS
$ENV{PFROOT}/lib
$ENV{PFROOT}
$ENV{PERFORMER_DIR}/lib
$ENV{PERFORMER_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
ENDIF(MSVC)
FIND_LIBRARY(PERFORMER_LIBRARY
NAMES pf
PATHS
$ENV{PERFORMER_DIR}/lib
$ENV{PERFORMER_DIR}
$ENV{OSGDIR}/lib
$ENV{OSGDIR}
$ENV{OSG_ROOT}/lib
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
/usr/freeware/lib64
)
SET(PERFORMER_FOUND "NO")
IF(PERFORMER_LIBRARY AND PERFORMER_INCLUDE_DIR)

View File

@@ -21,9 +21,6 @@ SOURCE_GROUP(
FILES ${LIB_PUBLIC_HEADERS}
)
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
HANDLE_MSVC_DLL()
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
INSTALL(
TARGETS ${LIB_NAME}

View File

@@ -22,17 +22,7 @@ ENDMACRO(LINK_WITH_VARIABLES TRGTNAME)
MACRO(LINK_INTERNAL TRGTNAME)
FOREACH(LINKLIB ${ARGN})
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
#when using versioned names, the .dll name differ from .lib name, there is a problem with that:
#CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX for computing linkage info to use into projects,
# so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies
#to library targets used
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
ENDFOREACH(LINKLIB)
ENDMACRO(LINK_INTERNAL TRGTNAME)
@@ -92,21 +82,16 @@ MACRO(SETUP_LINK_LIBRARIES)
ENDIF(TO_INSERT)
ENDFOREACH(LINKLIB)
# FOREACH(LINKLIB ${TARGET_LIBRARIES})
# TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
# ENDFOREACH(LINKLIB)
LINK_INTERNAL(${TARGET_TARGETNAME} ${TARGET_LIBRARIES})
FOREACH(LINKLIB ${TARGET_LIBRARIES})
TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} optimized ${LINKLIB} debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDFOREACH(LINKLIB)
FOREACH(LINKLIB ${TARGET_EXTERNAL_LIBRARIES})
TARGET_LINK_LIBRARIES(${TARGET_TARGETNAME} ${LINKLIB})
ENDFOREACH(LINKLIB)
IF(TARGET_LIBRARIES_VARS)
LINK_WITH_VARIABLES(${TARGET_TARGETNAME} ${TARGET_LIBRARIES_VARS})
ENDIF(TARGET_LIBRARIES_VARS)
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
#when using full path name to specify linkage, it seems that already linked libs must be specified
LINK_EXTERNAL(${TARGET_TARGETNAME} ${OPENGL_LIBRARIES})
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
ENDMACRO(SETUP_LINK_LIBRARIES)
############################################################################################
@@ -136,28 +121,9 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
ADD_LIBRARY(${TARGET_TARGETNAME} STATIC ${TARGET_SRC} ${TARGET_H})
ENDIF(DYNAMIC_OPENSCENEGRAPH)
#not sure if needed, but for plugins only Msvc need the d suffix
#not sure if needed, but for plugins only msvc need the d suffix
IF(NOT MSVC)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
ELSE(NOT MSVC)
IF(OSG_MSVC_VERSIONED_DLL)
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
#changing bin to something else breaks this hack
#the dll are placed in bin/${OSG_PLUGINS}
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/")
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES IMPORT_PREFIX "../")
ELSE(OSG_MSVC_VERSIONED_DLL)
#in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
#here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
ENDIF(OSG_MSVC_VERSIONED_DLL)
ENDIF(NOT MSVC)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
@@ -165,7 +131,7 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
IF(WIN32)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib/${OSG_PLUGINS} LIBRARY DESTINATION bin/${OSG_PLUGINS} )
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION bin )
ELSE(WIN32)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} )
ENDIF(WIN32)
@@ -223,9 +189,7 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../")
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
SETUP_LINK_LIBRARIES()
ENDMACRO(SETUP_EXE)
@@ -276,33 +240,3 @@ MACRO(SETUP_COMMANDLINE_EXAMPLE EXAMPLE_NAME)
SETUP_EXAMPLE(${EXAMPLE_NAME} 1)
ENDMACRO(SETUP_COMMANDLINE_EXAMPLE)
# Takes two optional arguments -- osg prefix and osg version
MACRO(HANDLE_MSVC_DLL)
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
#changing bin to something else breaks this hack
#the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
# LIB_PREFIX: use "osg" by default, else whatever we've been given.
IF(${ARGC} GREATER 0)
SET(LIB_PREFIX ${ARGV0})
ELSE(${ARGC} GREATER 0)
SET(LIB_PREFIX osg)
ENDIF(${ARGC} GREATER 0)
# LIB_SOVERSION: use OSG's soversion by default, else whatever we've been given
IF(${ARGC} GREATER 1)
SET(LIB_SOVERSION ${ARGV1})
ELSE(${ARGC} GREATER 1)
SET(LIB_SOVERSION ${OPENSCENEGRAPH_SOVERSION})
ENDIF(${ARGC} GREATER 1)
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/${LIB_PREFIX}${LIB_SOVERSION}-")
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
# SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-")
# SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
ENDMACRO(HANDLE_MSVC_DLL)

2680
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@@ -1,62 +1,6 @@
OSG News
========
= OpenSceneGraph 2.2 release adds support for advanced displays, soft and parallel split shadow maps and easier builds =
PERTHSHIRE, Scotland - 4th October 2007 - !OpenSceneGraph Professional Services announces the release of !OpenSceneGraph 2.2, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. !OpenSceneGraph 2.2 written entirely in Standard C++ and built upon OpenGL, offers developers working in the visual simulation, game development, virtual reality, scientific visualization and modeling markets - a real-time visualization tool which eclipses commercial scene graph toolkits in functionality, stability and performance. !OpenSceneGraph 2.2 runs on all Microsoft Windows platforms, Apple OS/X, GNU/Linux, IRIX, Solaris, HP-UX, AIX and !FreeBSD operating systems.
=== Open-source development delivers industry-leading features and performance ===
The !OpenSceneGraph 2.2 release is the culmination of 8 years of work by the lead developers and the open-source community that has grown up around the project. The real-time graphics industry and academia embraced it from the very beginning, deploying it in real-world applications, and actively participating in its development, testing and refinement. The end result is a high-quality library with a feature set relevant to application developers' needs.
=== Updates include: ===
* Improved build support under Windows including versioning of dll's to avoid problems with mixing !OpenSceneGraph versions on a single system.
* Support for Texture2DArray and integer texture OpenGL extensions.
* Support for spherical displays.
* Support for checkerboard stereo displays.
* Soft Shadows and Parallel Split Shadow Maps now supported.
* Viewer configuration file support
* Writer support for Inventor, OBJ 3D formats
* Writer support for HDR imagery
* Viewer Configuration file support
* Unification of threading models and viewer event handlers so that all now work for both Viewer and !CompositeViewer classes.
* GDAL plugin for support for a wide range of geospatial imagery and digital elevation maps formats.
* A wide range of build and bug fixes.
=== Downloads and Licensing ===
!OpenSceneGraph is open-source so full source code is provided, and can be copied, modified and used free of charge for commercial and non-commercial use. Access to the source allows end users greater flexibility in how they develop, debug and deploy their applications. They gain productivity and freedom by being able to leverage the tool chain in accordance with their own release cycles. Downloads of binaries and source can be found in the [http://www.openscenegraph.org/projects/osg/wiki/Downloads Downloads] section of the openscenegraph.org website. [Downloads Downloads]
!OpenSceneGraph is released under the [http://www.openscenegraph.org/projects/osg/wiki/Legal OpenSceneGraph Public License], which is based on the Lesser GNU Public License (LGPL), permitting the software to be used free of charge across the full spectrum of commercial and open-source applications. Furthermore, it allows both static and dynamic linking of the !OpenSceneGraph libraries without restricting the licensing of the user's software.
=== !OpenSceneGraph Books now available ===
The !OpenSceneGraph Quick Start Guide is now available in Chinese as well as English, and alongside the Reference Manual books can be found at [http://www.osgbooks.com OsgBooks].
=== Professional support and services ===
!OpenSceneGraph project is backed up with professional services by [http://openscenegraph.com OpenSceneGraph Professional Services], based in Scotland, and [http://www.skew-matrix.com Skew-Matrix] and [http://www.blue-newt.com Blue-Newt Software] both based in the USA.
* Confidential Professional Support
* Bespoke development
* Consultancy
* Training
=== Community support and contributions ===
The diverse and growing community of over 1700 developers is centered around the public osg-users mailing list, where members discuss how best to use !OpenSceneGraph, provide mutual support, and coordinate development of new features and bug fixes. Members of this community come from many different countries with backgrounds ranging from some of the world's largest aerospace companies, game companies, and visual simulation specialists to university researchers, students and hobbyists.
The !OpenSceneGraph project owes a great deal to the community for its development and support, in particular we wish to thank the [http://www.openscenegraph.org/projects/osg/wiki/Support/Contributors/TwoPointTwo 282 individuals] from around the world that have directly contributed to the development and refinement of the !OpenSceneGraph code base.
----
About !OpenSceneGraph:[[BR]]
!OpenSceneGraph Project was founded in September 1999 by Don Burns and Robert Osfield.
Further information, screenshots, downloads, documentation, and support links can be found on the !OpenSceneGraph project website http://www.openscenegraph.org.
About !OpenSceneGraph Professional Services:[[BR]]
!OpenSceneGraph Professional Services, founded by project lead Robert Osfield in April 2001, is based in Callander, Perhshire, Scotland, and provides professional services on top of !OpenSceneGraph. Further information about the services it provides can be found at http://www.openscenegraph.com.
--------------------------------------------------------------------------------
!!![=OpenSceneGraph=] 2.0 release improves ease-of-use and scalability, introducing new osgViewer, osgShadow and osgManipulator libraries, new build system, improved multi-core, multi-GPU support.
@@ -113,8 +57,6 @@ The [=OpenSceneGraph=] project owes a great deal to the community for its develo
Robert Osfield\\
Project Lead and Proprietor [=OpenSceneGraph=] Professional Services
--------------------------------------------------------------------------------
!!![=OpenSceneGraph=] 1.2 release introduces Windows 64bit and AIX support, COLLADA support, processor affinity and texture atlas builder.

View File

@@ -10,7 +10,7 @@ For the impatient, read the simplified build notes below.
Robert Osfield.
Project Lead.
3rd October 2007.
15th June 2007.
--
@@ -24,10 +24,7 @@ checks for installed dependenciesand then generates the appropriate
build system.
If you don't already have CMake installed on your system you can grab
it from http://www.cmake.org, use version 2.4.6 or later. Details on the
OpenSceneGraph's CMake build can be found at:
http://www.openscenegraph.org/projects/osg/wiki/Build/CMake
it from http://www.cmake.org, use version 2.4.6 or later.
Under unices (i.e. Linux, IRIX, Solaris, Free-BSD, HP-Ux, AIX, OSX)
use the cmake or ccmake command-line utils, or use the included tiny
@@ -35,10 +32,10 @@ configure script that'll run cmake for you. The configure script
simply runs 'cmake . -DCMAKE_BUILD_TYPE=Release' to ensure that you
get the best performance from your final libraries/applications.
cd OpenSceneGraph
./configure
make
sudo make install
cd OpenSceneGraph
./configure
make
sudo make install
Alternatively, you can create an out-of-source build directory and run
cmake or ccmake from there. The advantage to this approach is that the
@@ -47,23 +44,22 @@ source directory, and also makes it possible to have multiple
independent build targets by creating multiple build directories. In a
directory alongside the OpenSceneGraph use:
mkdir build
cd build
cmake ../OpenSceneGraph -DCMAKE_BUILD_TYPE=Release
make
sudo make install
mkdir build
cd build
cmake ../OpenSceneGraph -DCMAKE_BUILD_TYPE=Release
make
sudo make install
Under Windows use the GUI tool CMakeSetup to build your VisualStudio
files. The following page on our wiki dedicated to the CMake build
system should help guide you through the process:
http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/VisualStudio
http://www.openscenegraph.com/index.php?page=Build.CMake
Under OSX you can either use the CMake build system above, or use the
Xcode projects that you will find in the OpenSceneGraph/Xcode
directory.
For further details on compilation, installation and platform-specific
information read "Getting Started" guide:
http://www.openscenegraph.org/projects/osg/wiki/Support/GettingStarted
information read "Getting Started" at http://www.openscenegraph.org,
under "Documentation".

View File

@@ -8,7 +8,7 @@
# script. This just copies all the already built binaries
# into a structure that is near-ready for distribution.
#
# Usage: You should run this from the directory above the OSG-projects
# Usage: You should run this from the directory above the 3-projects
# ("AnyDirectory" in the picture below)
# bash OpenSceneGraph/Xcode/Misc/ArrangeDMG.sh
#
@@ -40,14 +40,12 @@
# CpMac is deprecated now that cp works properly in Tiger
#COPY="/Developer/Tools/CpMac -r"
COPY="/bin/cp -R"
SVN="svn"
#COPY="mv -f"
#BUILDACTION="clean build"
#CONFIGURATION="Development"
CONFIGURATION="Deployment"
#GDAL_LOCATION="/Library/Frameworks"
GDAL_LOCATION="/Library/Frameworks"
# Clean up from previous builds?
echo "Deleteing PackageDir to begin anew"
@@ -67,20 +65,17 @@ mkdir -p PackageDir/XcodeTemplates
mkdir -p PackageDir/Resources
mkdir -p PackageDir/.background
# Everything should be built now. Move all the things to be distrubuted
# to the PackageDir with the appropriate layout.
echo "Copying Frameworks..."
#$COPY OpenThreads/Xcode/OpenThreads/build/$CONFIGURATION/OpenThreads.framework PackageDir/Frameworks
#$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/osg*.framework PackageDir/Frameworks/
$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/*.framework PackageDir/Frameworks/
$COPY OpenThreads/Xcode/OpenThreads/build/$CONFIGURATION/OpenThreads.framework PackageDir/Frameworks
$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/osg*.framework PackageDir/Frameworks/
# Copy the gdal framework
#$COPY $GDAL_LOCATION/gdal.framework PackageDir/Frameworks
$COPY $GDAL_LOCATION/gdal.framework PackageDir/Frameworks
echo "Copying PlugIns..."
$COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/*.so PackageDir/PlugIns/
@@ -91,18 +86,14 @@ $COPY OpenSceneGraph/Xcode/OpenSceneGraph/build/$CONFIGURATION/*.app PackageDir/
echo "Copying Xcode templates..."
$COPY OpenSceneGraph/Xcode/XcodeTemplates PackageDir
# If we are in CVS, all the CVS junk got copied in so we need to remove it
#find -d PackageDir/XcodeTemplates -name CVS -exec rm -rf {} \;
find -d PackageDir/XcodeTemplates -name .svn -exec rm -rf {} \;
find -d PackageDir/XcodeTemplates -name CVS -exec rm -rf {} \;
echo "Copying License and ReadMe files..."
#$COPY OpenThreads/COPYING.txt PackageDir/LICENSE_OpenThreads.txt
$COPY OpenThreads/COPYING.txt PackageDir/LICENSE_OpenThreads.txt
$COPY OpenSceneGraph/LICENSE.txt PackageDir/LICENSE_OSG.txt
$COPY OpenSceneGraph/Xcode/OSX_OSG_README.rtf PackageDir
# Copy the background image and .DS_Store for 'fancy' DMG
$COPY OpenSceneGraph/Xcode/Packaging/Resources/instlogo.pdf PackageDir/.background
$COPY OpenSceneGraph/Xcode/Misc/DSStoreForDMG PackageDir/.DS_Store
# Sorry, I think this is bourne only
@@ -117,40 +108,21 @@ echo "Setting up symbolic links for the .app's..."
)
done
)
echo "Testing for OpenSceneGraph-Data..."
#echo ""
# If OpenSceneGraph-Data/ resides next to OpenSceneGraph/, then use it
if [ -d OpenSceneGraph-Data ]; then
echo "Found OpenSceneGraph-Data and will copy into PackageDir/Resources."
# Determine if it is a subversion copy or not; we don't want the repo info
if [ -d OpenSceneGraph-Data/.svn ]; then
$SVN export --force OpenSceneGraph-Data PackageDir/Resources
else
$COPY OpenSceneGraph-Data PackageDir/Resources
fi
# Not sure how to find the OSG data, so it has to be done manually
# Would Spotlight help?
echo "Next, you must (manually) copy all the OSG-data to PackageDir/Resources and the LICENCE_GDAL.rtf to PackageDir."
echo "Creating DMG using:"
echo "hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg"
/usr/bin/hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg
echo "Looking up location for OpenSceneGraph-Data"
#/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl
/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single
echo "Looking up location for LICENSE_GDAL.rtf"
/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single LICENSE_GDAL.rtf
else
# Not sure how to find the OSG data, so it has to be done manually
# Would Spotlight help?
#echo "Next, you must (manually) copy all the OSG-data to PackageDir/Resources and the LICENCE_GDAL.rtf to PackageDir."
echo "Did not find OpenSceneGraph-Data/ aside OpenSceneGraph/."
echo "Next, you must (manually) copy all the OSG-data to PackageDir/Resources."
echo "Looking up possible location for OpenSceneGraph-Data"
#/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl
/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single
#echo "Looking up location for LICENSE_GDAL.rtf"
#/usr/bin/perl OpenSceneGraph/Xcode/Misc/FindOSGData.pl --single LICENSE_GDAL.rtf
echo "After you copy the remaining resources, you will want to package up the DMG. You can use the following line as the basis:"
echo "hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg"
fi
echo "After you copy the remaining resources, you will want to package up the DMG. You can use the following line as the basis:"
echo "hdiutil create -ov -fs HFS+ -volname OpenSceneGraph -srcfolder PackageDir OpenSceneGraph.dmg"
# Now we want to package up everything into a .dmg

Binary file not shown.

View File

@@ -1,4 +1,4 @@
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf440
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Oblique;
\f3\fmodern\fcharset77 Courier;\f4\fnil\fcharset77 Monaco;}
{\colortbl;\red255\green255\blue255;}
@@ -15,49 +15,24 @@ This is the readme for the entire OpenThreads/OpenSceneGraph distribution for th
\
The source code is available at {\field{\*\fldinst{HYPERLINK "http://www.openscenegraph.org/"}}{\fldrslt http://www.openscenegraph.org/}}\
\
Also included is a framework for GDAL. You can get the source code and the full GDAL package at {\field{\*\fldinst{HYPERLINK "http://www.gdal.org/"}}{\fldrslt http://www.gdal.org/}}\
\
\
\f0\b \
Quick Start:
\f1\b0 \
Screencasts of how to install and get going with OSG for Mac OS X can be found here:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
{\field{\*\fldinst{HYPERLINK "http://www.openscenegraph.org/projects/osg/wiki/Support/TipsAndTricks"}}{\fldrslt \cf0 http://www.openscenegraph.org/projects/osg/wiki/Support/TipsAndTricks}}\
\
\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b \cf0 What's New in this release:
\f0\b What's New in this release:
\f1\b0 \
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\ql\qnatural\pardirnatural
\ls1\ilvl0\cf0 {\listtext \'a5 }OpenThreads now uses Subversion 'externals' to make it look like part of the OSG source distribution.\
{\listtext \'a5 }Producer has been removed from the distribution. osgViewer is supposed to replace it. The Mac OS X backend is currently Carbon based.\
{\listtext \'a5 }GDAL has been removed as it is no longer a dependency.\
{\listtext \'a5 }osgviewerCocoa (previously osgsimpleviewerCocoa in CVS) is an example program demonstrating tight integration between OpenSceneGraph and Cocoa. It demonstrates many of the things you should consider in building a first-class OS X application that uses OSG.\
{\listtext \'a5 }Dwarf debugging format\
{\listtext \'a5 }osgsimpleviewerSDL\
\ls1\ilvl0\cf0 {\listtext \'a5 }Dwarf debugging format\
{\listtext \'a5 }osgsimpleviewerCocoa and osgsimpleviewerSDL\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 \
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b Notes for 2.0 release:\
\f0\b \cf0 Notes for 1.2 release:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f1\b0 OSG has changed its versioning number scheme. 2.0 is the stable release following 1.2.\
\
Producer has been removed from the distribution with osgViewer as its intended replacement.\
\
GDAL has also been removed from the distribution as it is no longer a dependency.\
\
OSG is in the process to moving to a new CMake based build system. Once the remaining Mac OS X support needed is implemented in CMake, the Xcode projects will be removed in favor of the new unified CMake system.\
\
With Leopard on the horizon, the need to deal with 64-bit readiness and deprecated APIs is becoming more critical. In a nutshell, we need a Cocoa based version of osgViewer, and the QuickTime plugin needs to be replaced. Currently, there is a new ImageIO based plugin to assume the image reading/writing duties of the old qt plugin. We are in need of a QTKit based plugin to assume the movie responsibilities of the old plugin. And we are in need of volunteers to write the Cocoa osgViewer backend. Currently, the example osgviewerCocoa demonstrates a lot of similar functionality and could be used as a reference. However, the example needs to be turned 'inside-out'. The example is an NSView class that contains OSG classes; the osgViewer needs to be the opposite where the OSG class needs to contain the NSView class.\
\
\
\
\f0\b Notes for 1.2 release:\
\f1\b0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
\f1\b0 \cf0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
\
Since the 1.1 release, we have learned of serious problems (freezing of the window manager) on the (Intel) MacBook Pros using osgText. We believe the problem is with a serious driver bug for ATI in OS X 10.4.7. We believe the bug affects the ATI Radeon X1600. (You can get this string by calling glGetString(GL_RENDERER) when you have a valid OpenGL Context. The string returned to us on affected MacBook Pros is "ATI Radeon X1600 OpenGL Engine".)\
\
@@ -123,16 +98,16 @@ Don't forget to link against Carbon (-framework Carbon) if you use Gestalt.\
\
If you are affected by this, please file a bug report at {\field{\*\fldinst{HYPERLINK "https://bugreport.apple.com"}}{\fldrslt https://bugreport.apple.com}}. Apple lives and dies by the bug report system. If anything is to get done, it must be in the bug reporter. And they keep count of how many people file the same bug, so duplicates are good.\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f2\i \cf0 (Note: We believe this has been fixed in 10.4.8)
\f2\i (Note: We believe this has been fixed in 10.4.8)
\f1\i0 \
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b \cf0 Notes for 1.1 release:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f1\b0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
\f1\b0 \cf0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
The Xcode projects are also set to build as Universal Binaries for both Development and Deployment\
targets. If you do not need this and want to save build time, you should change the architecture option\
to your desired setting (most likely to $(NATIVE_ARCH)). It is overridden in the top-level "OpenSceneGraph" project in the Group & Files panel. Don't forget to change OpenThreads \
@@ -153,8 +128,9 @@ PlugIns, the file size shrunk from about 1GB to about 100MB.\
We have stopped maintaining the Xcode 1.5/2.0 projects.\
\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b Notes for 1.0 release:
\f0\b \cf0 Notes for 1.0 release:
\f1\b0 \
These projects were primarily developed with gcc 4.0.1 under Tiger 10.4.3 using Xcode 2.2. Starting with gcc 4.0, Apple no longer statically links in the C++ runtime. Apple has made available the g++ 4.0 dynamic runtime for Panther under the 10.3.9 release. To run under Panther, your system must have this update (or you must recompile the binaries for your system).\
\
@@ -254,8 +230,9 @@ Also remember that OSG will still respond to standard OSG environmental variable
\
\f0\b Prebinding Addresses:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f1\b0 \
\f1\b0 \cf0 \
These are now obsolete. Prebinding is now disabled. The old addresses were:\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
@@ -338,8 +315,9 @@ If you are compiling under Xcode 1.5 and are using our Xcode 1.5/2.0 projects, t
{\listtext \'a5 }I noticed that for some reason, Xcode has problems compiling the Carbon header with the OpenThreads framework when autovectorization and precompiled headers were enabled. You might try disabling precompiled headers if it is not already. If the problem persists, you may also need to delete the entry that enables autovectorization. In the Groups and Files panel (left side panel), open the Info inspector for the project (top item) and click on the Build tab. Scroll down to the bottom, and remove the autovectorization option. \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b Universal Binaries:
\f0\b \cf0 Universal Binaries:
\f1\b0 \
\
Be aware, when building you're own Universal Binaries and you use the 10.4 SDK, you must explicitly\
@@ -383,4 +361,4 @@ On the topic of feature requests, another potentially useful thing to have is a
ewing 2121 - at - yahoo (in the commercial domain)\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
{\field{\*\fldinst{HYPERLINK "http://www.create.ucsb.edu/OSG/"}}{\fldrslt \cf0 http://www.create.ucsb.edu/OSG/}}\
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +1,24 @@
echo Copy Examples
cp -r ../OpenSceneGraph/build/Deployment/*.app Binary/Examples/
cp -r ../OpenSceneGraph/build/Development/*.app Binary/Examples/
echo Copy Applications
mv Binary/Examples/osgviewer.app Binary/Applications
mv Binary/Examples/osgarchive.app Binary/Applications
mv Binary/Examples/osgversion.app Binary/Applications
mv Binary/Examples/osgconv.app Binary/Applications
cp Binary/Applications/*.app Binary/Applictions/Bundles/
cp Binary/Applications/osgviewer.app/Contents/MacOS/osgviewer Binary/Applications
cp Binary/Applications/osgarchive.app/Contents/MacOS/osgarchive Binary/Applications
cp Binary/Applications/osgversion.app/Contents/MacOS/osgversion Binary/Applications
cp Binary/Applications/osgconv.app/Contents/MacOS/osgconv Binary/Applications
mv Binary/Applications/osg*.app Binary/Applications/Bundles/
mv Binary/Applications/osgviewer.app/Contents/MacOS/osgviewer Binary/Applications
mv Binary/Applications/osgarchive.app/Contents/MacOS/osgarchive Binary/Applications
mv Binary/Applications/osgversion.app/Contents/MacOS/osgversion Binary/Applications
mv Binary/Applications/osgconv.app/Contents/MacOS/osgconv Binary/Applications
rm -rf Binary/Applications/osg*.app
echo Copy Frameworks
cp -r ../OpenSceneGraph/build/Deployment/*.framework Binary/Frameworks/
cp -r ../OpenSceneGraph/build/Development/*.framework Binary/Frameworks/
echo Copy Plugins
cp ../OpenSceneGraph/build/Deployment/*.so Binary/Plugins/
cp ../OpenSceneGraph/build/Development/*.so Binary/Plugins/
cp ../OpenSceneGraph/build/Development/osgtext Binary/Plugins/
cp ../OpenSceneGraph/build/Development/osgpick Binary/Plugins/
echo Copying Complete
@@ -28,5 +28,4 @@ open OpenSceneGraph.pmproj
open Packages/Examples.pmproj
open Packages/PlugIns.pmproj
open Packages/Frameworks.pmproj
open Packages/ApplicationsBundles.pmproj
open Packages/ApplicationsCmdline.pmproj
open Packages/Applications.pmproj

View File

@@ -11,7 +11,7 @@
\f0\b\fs24 \cf0 OpenSceneGraph on Mac OS X
\f1\b0 \
\
This is the readme for the entire OpenThreads/OpenSceneGraph distribution for the OS X frameworks and Xcode projects. This readme was originally written for the binary distribution, but there is a lot of useful information in here so it has also been included with the source code in the Xcode section. This was sync'd with the OSG 2.0 release.\
This is the readme for the entire OpenThreads/OpenSceneGraph distribution for the OS X frameworks and Xcode projects. This readme was originally written for the binary distribution, but there is a lot of useful information in here so it has also been included with the source code in the Xcode section. This was sync'd with the OSG 1.2 release.\
\
The source code is available at {\field{\*\fldinst{HYPERLINK "http://www.openscenegraph.org/"}}{\fldrslt http://www.openscenegraph.org/}}\
\
@@ -21,42 +21,18 @@ Also included is a framework for GDAL. You can get the source code and the full
\f0\b What's New in this release:
\f1\b0 \
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\ls1\ilvl0\cf0 The theme for the 2.0 release has been making the OpenSceneGraph easier to use, yet more flexible and powerful.\
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\ql\qnatural\pardirnatural
\ls1\ilvl0\cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 Features include:\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li400\fi-400\ql\qnatural\pardirnatural
\cf0 * New unified build system using CMake, which simplifies the build process, automatically detecting installed dependencies and providing build configuration as well as support for a wide range of development tools.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 * New libraries:\
* osgViewer - replacing Producer as a windowing toolkit\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li760\fi-760\ql\qnatural\pardirnatural
\cf0 * osgManipulator - provides a set of interactive manipulators for scaling, rotating and moving objects in the scene.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 * osgShadow - provides an extensible framework for adding dynamic shadows to your scene. \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li400\fi-400\ql\qnatural\pardirnatural
\cf0 * New low-level extensible intersection framework that includes support for line, plane and polytope intersections.\
* New high-level intersection classes that support paged databases, LineOfSight, HeightAboveTerrain and ElevationSlice.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 * View-dependent overlay\
* what does this do? \
* Plugins\
* Improvements to the OpenFlight, COLLADA and AC3D? plugins\
* New TXF texture font reader. \
* Easier 3rd party windowing integration\
* With examples showing integration with GLUT, SDL, Qt, WxWidgets and MFC. \
* OpenThreads is moved into the core of OpenSceneGraph and is no longer an external dependency.\
* Producer is no longer a dependency \
\
\ls1\ilvl0\cf0 {\listtext \'a5 }Dwarf debugging format\
{\listtext \'a5 }osgsimpleviewerCocoa and osgsimpleviewerSDL\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 \
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b \cf0 Notes for 1.2 release:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f1\b0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
\f1\b0 \cf0 1.2 was originally intended as a bug fix release for 1.1 (going for 1.1.1), but OSG broke ABI again so the number was bumped to 1.2. There are no significant changes to the Xcode projects or significant OS X specific changes.\
\
Since the 1.1 release, we have learned of serious problems (freezing of the window manager) on the (Intel) MacBook Pros using osgText. We believe the problem is with a serious driver bug for ATI in OS X 10.4.7. We believe the bug affects the ATI Radeon X1600. (You can get this string by calling glGetString(GL_RENDERER) when you have a valid OpenGL Context. The string returned to us on affected MacBook Pros is "ATI Radeon X1600 OpenGL Engine".)\
\
@@ -122,16 +98,16 @@ Don't forget to link against Carbon (-framework Carbon) if you use Gestalt.\
\
If you are affected by this, please file a bug report at {\field{\*\fldinst{HYPERLINK "https://bugreport.apple.com"}}{\fldrslt https://bugreport.apple.com}}. Apple lives and dies by the bug report system. If anything is to get done, it must be in the bug reporter. And they keep count of how many people file the same bug, so duplicates are good.\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f2\i \cf0 (Note: We believe this has been fixed in 10.4.8)
\f2\i (Note: We believe this has been fixed in 10.4.8)
\f1\i0 \
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b \cf0 Notes for 1.1 release:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f1\b0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
\f1\b0 \cf0 We are now distributing Universal Binaries. These binaries were built using Xcode 2.3 and gcc 4.0.1.\
The Xcode projects are also set to build as Universal Binaries for both Development and Deployment\
targets. If you do not need this and want to save build time, you should change the architecture option\
to your desired setting (most likely to $(NATIVE_ARCH)). It is overridden in the top-level "OpenSceneGraph" project in the Group & Files panel. Don't forget to change OpenThreads \
@@ -152,8 +128,9 @@ PlugIns, the file size shrunk from about 1GB to about 100MB.\
We have stopped maintaining the Xcode 1.5/2.0 projects.\
\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b Notes for 1.0 release:
\f0\b \cf0 Notes for 1.0 release:
\f1\b0 \
These projects were primarily developed with gcc 4.0.1 under Tiger 10.4.3 using Xcode 2.2. Starting with gcc 4.0, Apple no longer statically links in the C++ runtime. Apple has made available the g++ 4.0 dynamic runtime for Panther under the 10.3.9 release. To run under Panther, your system must have this update (or you must recompile the binaries for your system).\
\
@@ -253,8 +230,9 @@ Also remember that OSG will still respond to standard OSG environmental variable
\
\f0\b Prebinding Addresses:\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f1\b0 \
\f1\b0 \cf0 \
These are now obsolete. Prebinding is now disabled. The old addresses were:\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
@@ -337,8 +315,9 @@ If you are compiling under Xcode 1.5 and are using our Xcode 1.5/2.0 projects, t
{\listtext \'a5 }I noticed that for some reason, Xcode has problems compiling the Carbon header with the OpenThreads framework when autovectorization and precompiled headers were enabled. You might try disabling precompiled headers if it is not already. If the problem persists, you may also need to delete the entry that enables autovectorization. In the Groups and Files panel (left side panel), open the Info inspector for the project (top item) and click on the Build tab. Scroll down to the bottom, and remove the autovectorization option. \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\cf0 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
\f0\b Universal Binaries:
\f0\b \cf0 Universal Binaries:
\f1\b0 \
\
Be aware, when building you're own Universal Binaries and you use the 10.4 SDK, you must explicitly\
@@ -382,4 +361,4 @@ On the topic of feature requests, another potentially useful thing to have is a
ewing 2121 - at - yahoo (in the commercial domain)\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
{\field{\*\fldinst{HYPERLINK "http://www.create.ucsb.edu/OSG/"}}{\fldrslt \cf0 http://www.create.ucsb.edu/OSG/}}\
}
}

View File

@@ -8,9 +8,8 @@
\fs24 \
\
This installer will install the OpenSceneGraph Applications, Examples, Frameworks and Plugins in:\
/usr/local/bin (Executable Applications) \
/Applications/OpenSceneGraph/Applications/ (Bundled Applications)\
/Applications/OpenSceneGraph/Examples/\
/usr/local/bin\
/OpenSceneGraph/Examples\
/Library/Frameworks\
/Library/Application\\ Support/OpenSceneGraph/PlugIns/\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

View File

@@ -26,7 +26,6 @@
#include <OpenThreads/Mutex>
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Thread>
#include <OpenThreads/ReentrantMutex>
#include <osg/AlphaFunc>
#include <osg/AnimationPath>
@@ -147,6 +146,7 @@
#include <osg/TriangleFunctor>
#include <osg/TriangleIndexFunctor>
#include <osg/Uniform>
#include <osg/UnitTestFramework>
#include <osg/Vec2>
#include <osg/Vec2b>
#include <osg/Vec2d>
@@ -186,6 +186,7 @@
#include <osgDB/ParameterOutput>
#include <osgDB/ReadFile>
#include <osgDB/ReaderWriter>
#include <osgDB/ReentrantMutex>
#include <osgDB/Registry>
#include <osgDB/SharedStateManager>
#include <osgDB/Version>
@@ -212,9 +213,11 @@
#include <osgGA/GUIActionAdapter>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIEventHandler>
#include <osgGA/GUIEventHandlerVisitor>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/MatrixManipulator>
#include <osgGA/NodeTrackerManipulator>
#include <osgGA/SetSceneViewVisitor>
#include <osgGA/StateSetManipulator>
#include <osgGA/TerrainManipulator>
#include <osgGA/TrackballManipulator>
@@ -316,10 +319,8 @@
* you should comment out this block.
*/
#include <osgTerrain/Export>
#include <osgTerrain/Layer>
#include <osgTerrain/Locator>
#include <osgTerrain/TerrainNode>
#include <osgTerrain/GeometryTechnique>
#include <osgTerrain/HeightFieldNode>
#include <osgTerrain/HeightFieldRenderer>
#include <osgTerrain/Version>
#include <osgText/Export>

View File

@@ -17,7 +17,6 @@ SET(OPENSCENEGRAPH_APPLICATION_DIR ${PROJECT_SOURCE_DIR})
SET(TARGET_DEFAULT_PREFIX "application_")
SET(TARGET_DEFAULT_LABEL_PREFIX "Applications")
SET(TARGET_COMMON_LIBRARIES
OpenThreads
osg
osgDB
osgUtil

View File

@@ -58,12 +58,6 @@ Node* OrientationConverter::convert( Node *node )
transform->setDataVariance(osg::Object::STATIC);
transform->setMatrix( C * R * S * T );
if (!S.isIdentity())
{
// Add a normalize state. This will be removed if the FlattenStaticTransformsVisitor works
transform->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
}
root->addChild(transform);
transform->addChild(node);

View File

@@ -20,8 +20,6 @@
#include <osgUtil/Optimizer>
#include <osgUtil/SmoothingVisitor>
#include <osgViewer/GraphicsWindow>
#include <iostream>
#include "OrientationConverter.h"
@@ -53,17 +51,12 @@ class MyGraphicsContext {
}
if (_gc.valid())
{
_gc->realize();
_gc->makeCurrent();
if (dynamic_cast<osgViewer::GraphicsWindow*>(_gc.get()))
{
std::cout<<"Realized graphics window for OpenGL operations."<<std::endl;
}
else
{
std::cout<<"Realized pbuffer for OpenGL operations."<<std::endl;
}
std::cout<<"Realized window"<<std::endl;
}
}
@@ -671,7 +664,7 @@ int main( int argc, char **argv )
}
}
osgDB::ReaderWriter::WriteResult result = osgDB::Registry::instance()->writeNode(*root,fileNameOut,osgDB::Registry::instance()->getOptions());
osgDB::ReaderWriter::WriteResult result = osgDB::Registry::instance()->writeNode(*root,fileNameOut);
if (result.success())
{
osg::notify(osg::NOTICE)<<"Data written to '"<<fileNameOut<<"'."<< std::endl;

View File

@@ -1,8 +1,7 @@
SET(TARGET_SRC osgversion.cpp )
#this file is automatically generated
SET(TARGET_COMMON_LIBRARIES
OpenThreads
osg
)
SET(TARGET_SRC osgversion.cpp )
#### end var setup ###
SETUP_COMMANDLINE_APPLICATION(osgversion)

View File

@@ -1,7 +1,6 @@
#include <osg/Version>
#include <osg/ArgumentParser>
#include <osg/ApplicationUsage>
#include <OpenThreads/Version>
#include <set>
#include <vector>
@@ -34,7 +33,6 @@ bool validName(const std::string& first)
if (first.size()>=2 && (first[1]<'a' || first[1]>'z') && (first[1]!='.') && (first[1]!=',')) return false;
if (first=="Xcode") return false;
if (first=="Added") return false;
if (first=="Camera") return false;
if (first=="CameraNode") return false;
@@ -51,9 +49,6 @@ bool validName(const std::string& first)
if (first=="SpotExponent") return false;
if (first=="Framstamp") return false;
if (first=="Stats") return false;
if (first=="Group") return false;
if (first=="Texture") return false;
if (first=="Texture2DArray") return false;
if (first=="Creator") return false;
if (first=="CullVisitor") return false;
if (first=="Drawable") return false;
@@ -203,8 +198,6 @@ bool validName(const std::string& first)
if (first=="CullVistor") return false;
if (first=="SimpleViewer") return false;
if (first=="TexMat(Matrix") return false;
if (first=="GraphicsWindowX11") return false;
if (first=="OperationThread") return false;
return true;
}
@@ -216,17 +209,6 @@ std::string typoCorrection(const std::string& name)
if (name=="") return "";
if (name=="") return "";
#endif
if (name=="Martsz") return "Martz";
if (name=="Froenlich") return "Fr<EFBFBD>hlich";
if (name=="Froelich") return "Fr<EFBFBD>hlich";
if (name=="Fruciel") return "Frauciel";
if (name=="Hebelin") return "Herbelin";
if (name=="Jea-Sebastien") return "Jean-Sebastien";
if (name=="Robet") return "Robert";
if (name=="Morné") return "Morn<EFBFBD>";
if (name=="Adndre") return "Andre";
if (name=="Mellis") return "Melis";
if (name=="Rajce") return "Trajce";
if (name=="Trastenjak") return "Trstenjak";
if (name=="Baverage") return "Beverage";
if (name=="Bistroviae") return "Bistrovic";
@@ -276,7 +258,6 @@ std::string typoCorrection(const std::string& name)
if (name=="Moloshton") return "Moloshtan";
if (name=="Moule") return "Moiule";
if (name=="Nicklov") return "Nikolov";
if (name=="Nickolov") return "Nikolov";
if (name=="Olad") return "Olaf";
if (name=="Olar") return "Olaf";
if (name=="Oritz") return "Ortiz";
@@ -302,10 +283,9 @@ std::string typoCorrection(const std::string& name)
if (name=="Yefrei") return "Yefei";
if (name=="Yfei") return "Yefei";
if (name=="Antonoine") return "Antoine";
if (name=="Antione") return "Antoine";
if (name=="Andew") return "Andrew";
if (name=="Daneil") return "Daniel";
if (name=="André") return "Andr<EFBFBD>";
if (name=="André") return "Anr<EFBFBD>";
if (name=="García") return "Garcea";
if (name=="Sjölie") return "Sj<EFBFBD>lie";
if (name=="José") return "Jos<EFBFBD>";
@@ -313,9 +293,6 @@ std::string typoCorrection(const std::string& name)
if (name=="Froehlich") return "Fr<EFBFBD>hlich";
if (name=="Eileman") return "Eilemann";
if (name=="Skinnder") return "Skinner";
if (name=="Mihair") return "Mihai";
if (name=="Mahai") return "Mihai";
if (name=="SimpleViewer") return "";
return name;
@@ -323,26 +300,6 @@ std::string typoCorrection(const std::string& name)
void nameCorrection(NamePair& name)
{
if (name.first=="Radu" && name.second=="Mihai")
{
name.first = "Mihai";
name.second = "Radu";
}
if (name.first=="Art" && name.second=="Trevs")
{
name.first = "Art";
name.second = "Tevs";
}
if (name.first=="Tim" && name.second=="More")
{
name.first = "Tim";
name.second = "Moore";
}
if (name.first=="Andre" && name.second=="Garneau")
{
name.first = "Andr<EFBFBD>";
name.second = "Garneau";
}
if (name.first=="Eric" && name.second=="Hammil")
{
name.first = "Chris";
@@ -420,11 +377,6 @@ void nameCorrection(NamePair& name)
name.first = "Trajce";
name.second = "Nikolov";
}
if (name.first=="Frauciel" && name.second=="Luc")
{
name.first = "Luc";
name.second = "Frauciel";
}
}
void lastValidCharacter(const std::string& name, unsigned int& pos,char c)
@@ -649,7 +601,6 @@ void buildContributors(NameMap& names)
++names[NamePair("Marco","Jez")];
++names[NamePair("Mike","Weiblen")];
++names[NamePair("Geoff","Michel")];
++names[NamePair("Ben","van Basten")];
// contributors that don't appear in the ChangeLog due to their contributions
// being before CVS started for the OSG, or before the name logging began.
@@ -669,9 +620,6 @@ int main( int argc, char **argv)
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--entries","Print out number of entries into the ChangeLog file for each contributor.");
arguments.getApplicationUsage()->addCommandLineOption("--version-number","Print out version number only");
arguments.getApplicationUsage()->addCommandLineOption("--soversion-number","Print out shared object version number only");
arguments.getApplicationUsage()->addCommandLineOption("--openthreads-version-number","Print out version number for OpenThreads only");
arguments.getApplicationUsage()->addCommandLineOption("--openthreads-soversion-number","Print out shared object version number for OpenThreads only");
arguments.getApplicationUsage()->addCommandLineOption("-r <file> or --read <file>","Read the ChangeLog to generate an estimated contributors list.");
if (arguments.read("--version-number"))
@@ -680,63 +628,6 @@ int main( int argc, char **argv)
return 0;
}
if (arguments.read("--major-number"))
{
std::cout<<OPENSCENEGRAPH_MAJOR_VERSION<<std::endl;
return 0;
}
if (arguments.read("--minor-number"))
{
std::cout<<OPENSCENEGRAPH_MINOR_VERSION<<std::endl;
return 0;
}
if (arguments.read("--patch-number"))
{
std::cout<<OPENSCENEGRAPH_PATCH_VERSION<<std::endl;
return 0;
}
if (arguments.read("--soversion-number"))
{
std::cout<<osgGetSOVersion()<<std::endl;
return 0;
}
if (arguments.read("--openthreads-version-number"))
{
std::cout<<OpenThreadsGetVersion()<<std::endl;
return 0;
}
if (arguments.read("--openthreads-major-number"))
{
std::cout<<OPENTHREADS_MAJOR_VERSION<<std::endl;
return 0;
}
if (arguments.read("--openthreads-minor-number"))
{
std::cout<<OPENTHREADS_MINOR_VERSION<<std::endl;
return 0;
}
if (arguments.read("--openthreads-patch-number"))
{
std::cout<<OPENTHREADS_PATCH_VERSION<<std::endl;
return 0;
}
if (arguments.read("--openthreads-soversion-number"))
{
std::cout<<OpenThreadsGetSOVersion()<<std::endl;
return 0;
}
std::cout<<osgGetLibraryName()<< " "<< osgGetVersion()<<std::endl<<std::endl;
bool printContributors = false;

View File

@@ -143,8 +143,5 @@ int main(int argc, char** argv)
viewer.setSceneData( loadedModel.get() );
viewer.realize();
viewer.run();
return viewer.run();
}

View File

@@ -29,7 +29,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgcubemap)
ADD_SUBDIRECTORY(osgdelaunay)
ADD_SUBDIRECTORY(osgdepthpartition)
ADD_SUBDIRECTORY(osgdepthpeeling)
ADD_SUBDIRECTORY(osgdepthshadow)
ADD_SUBDIRECTORY(osgdistortion)
ADD_SUBDIRECTORY(osgfadetext)
ADD_SUBDIRECTORY(osgforest)
@@ -70,6 +70,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgsequence)
ADD_SUBDIRECTORY(osgshaders)
ADD_SUBDIRECTORY(osgshaderterrain)
ADD_SUBDIRECTORY(osgshadowtexture)
ADD_SUBDIRECTORY(osgshadow)
ADD_SUBDIRECTORY(osgshape)
ADD_SUBDIRECTORY(osgsimplifier)
@@ -104,10 +105,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgviewerSDL)
ENDIF(SDL_FOUND)
IF (FOX_FOUND)
ADD_SUBDIRECTORY(osgviewerFOX)
ENDIF(FOX_FOUND)
IF (wxWidgets_FOUND)
ADD_SUBDIRECTORY(osgviewerWX)
ENDIF(wxWidgets_FOUND)

View File

@@ -34,7 +34,6 @@
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/StateSetManipulator>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/CompositeViewer>
@@ -137,19 +136,15 @@ int main( int argc, char **argv )
if (!scene) return 1;
// construct the viewer.
osgViewer::CompositeViewer viewer(arguments);
osgViewer::CompositeViewer viewer;
if (arguments.read("-1"))
{
{
osgViewer::View* view = new osgViewer::View;
view->setSceneData(osgDB::readNodeFile("fountain.osg"));
view->addEventHandler( new osgViewer::StatsHandler );
view->setUpViewAcrossAllScreens();
view->setCameraManipulator(new osgGA::TrackballManipulator);
viewer.addView(view);
@@ -184,9 +179,6 @@ int main( int argc, char **argv )
view->setSceneData(scene.get());
view->setCameraManipulator(new osgGA::TrackballManipulator);
view->addEventHandler( new osgViewer::StatsHandler );
// add the handler for doing the picking
view->addEventHandler(new PickHandler());
}
@@ -245,12 +237,6 @@ int main( int argc, char **argv )
statesetManipulator->setStateSet(view->getCamera()->getOrCreateStateSet());
view->addEventHandler( statesetManipulator.get() );
view->addEventHandler( new osgViewer::StatsHandler );
view->addEventHandler( new osgViewer::HelpHandler );
view->addEventHandler( new osgViewer::WindowSizeHandler );
view->addEventHandler( new osgViewer::ThreadingHandler );
view->addEventHandler( new osgViewer::RecordCameraPathHandler );
}
// view two
@@ -282,11 +268,10 @@ int main( int argc, char **argv )
}
}
while (arguments.read("-s")) { viewer.setThreadingModel(osgViewer::CompositeViewer::SingleThreaded); }
while (arguments.read("-g")) { viewer.setThreadingModel(osgViewer::CompositeViewer::CullDrawThreadPerContext); }
while (arguments.read("-c")) { viewer.setThreadingModel(osgViewer::CompositeViewer::CullThreadPerCameraDrawThreadPerContext); }
while (arguments.read("-g")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerContext); }
while (arguments.read("-c")) { viewer.setThreadingModel(osgViewer::CompositeViewer::ThreadPerCamera); }
// run the viewer's main frame loop
return viewer.run();

View File

@@ -1,15 +0,0 @@
SET(TARGET_SRC
DePee.cpp
DePeePass.cpp
Utility.cpp
osgdepthpeeling.cpp
)
SET(TARGET_H
DePee.h
DePeePass.h
Utility.h
)
#### end var setup ###
SETUP_EXAMPLE(osgdepthpeeling)

View File

@@ -1,669 +0,0 @@
/*
Steffen Frey
Fachpraktikum Graphik-Programmierung 2007
Institut fuer Visualisierung und Interaktive Systeme
Universitaet Stuttgart
*/
//export OSG_NOTIFY_LEVEL=DEBUG_INFO
#include "DePee.h"
#include <osg/GLExtensions>
#include <osg/Node>
#include <osg/MatrixTransform>
#include <osg/Projection>
#include <osg/Geode>
#include "Utility.h"
#include <osg/ShapeDrawable>
#include <osg/Geometry>
#include <assert.h>
#include <iostream>
DePee::DePee(osg::Group* parent, osg::Group* subgraph, unsigned width, unsigned height)
{
_renderToFirst = false;
_isSketchy =false;
_isColored = false;
_isEdgy = true;
_isCrayon = false;
_normalDepthMapProgram = Utility::createProgram("shaders/depthpeel_normaldepthmap.vert","shaders/depthpeel_normaldepthmap.frag");
_colorMapProgram = Utility::createProgram("shaders/depthpeel_colormap.vert","shaders/depthpeel_colormap.frag" );
_edgeMapProgram = Utility::createProgram("shaders/depthpeel_edgemap.vert", "shaders/depthpeel_edgemap.frag");
_parent = new osg::Group;
parent->addChild(_parent.get());
_subgraph = subgraph;
_width = width;
_height = height;
_texWidth = width;
_texHeight = height;
assert(parent);
assert(subgraph);
_fps = 0;
_colorCamera = 0;
_sketchy = new osg::Uniform("sketchy", false);
_colored = new osg::Uniform("colored", false);
_edgy = new osg::Uniform("edgy", true);
_sketchiness = new osg::Uniform("sketchiness", (float) 1.0);
_normalDepthMap0 = Utility::newColorTexture2D(_texWidth, _texHeight, 32);
_normalDepthMap1 = Utility::newColorTexture2D(_texWidth, _texHeight, 32);
_edgeMap = Utility::newColorTexture2D(_texWidth, _texHeight, 8);
_colorMap = Utility::newColorTexture2D(_texWidth, _texHeight, 8);
//create a noise map...this doesn't end up in a new rendering pass
(void) createMap(NOISE_MAP);
//the viewport aligned quad
_quadGeode = Utility::getCanvasQuad(_width, _height);
//!!!Getting problems if assigning unit to texture in depth peeling subraph and removing depth peeling steps!!!
//That's why it is done here
osg::StateSet* stateset = _parent->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(1, _normalDepthMap0.get(), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(2, _normalDepthMap1.get(), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(3, _edgeMap.get(), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(4, _colorMap.get(), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::ON);
// render the final thing
(void) createFinal();
//take one step initially
addDePeePass();
//render head up display
(void) createHUD();
}
DePee::~DePee()
{
}
void DePee::setSketchy(bool sketchy)
{
_sketchy->set(sketchy);
_isSketchy = sketchy;
}
void DePee::setCrayon(bool crayon)
{
if(_isCrayon != crayon)
{
_isCrayon = crayon;
createMap(NOISE_MAP);
}
}
void DePee::setSketchiness(double sketchiness)
{
_sketchiness->set((float)sketchiness);
}
void DePee::setColored(bool colored)
{
if(colored == !_isColored)
{
if(colored)
{
(void) createMap(COLOR_MAP, false);
}
else
{
_dePeePasses.back()->remRenderPass(COLOR_MAP);
}
_colored->set(colored);
_isColored = colored;
}
}
void DePee::setEdgy(bool edgy)
{
if(edgy != _isEdgy)
{
_isEdgy = edgy;
unsigned int n = 0;
while(remDePeePass())
{
++n;
}
if(edgy)
{
(void) createMap(EDGE_MAP,_dePeePasses.size() == 1);
}
else
{
_dePeePasses.back()->remRenderPass(EDGE_MAP);
}
for(unsigned int i=0; i < n; i++)
{
addDePeePass();
}
}
_edgy->set(edgy);
}
void DePee::setFPS(double* fps)
{
_fps = fps;
}
unsigned int DePee::getNumberOfRenderPasses()
{
unsigned int n = 0;
for(unsigned int i=0; i < _dePeePasses.size();i++)
n += _dePeePasses.at(i)->Cameras.size();
// add one pass for final rendering pass and one for hud
return n+2;
}
bool DePee::addDePeePass()
{
if(_isColored)
{
//remove previous color pass
_dePeePasses.back()->remRenderPass(COLOR_MAP);
}
_dePeePasses.push_back(new DePeePass());
_parent->addChild(_dePeePasses.back()->root.get());
//need to create a depth map in every case
(void) createMap(NORMAL_DEPTH_MAP, _dePeePasses.size() == 1);
if(_isEdgy)
{
(void) createMap(EDGE_MAP,_dePeePasses.size() == 1);
}
if(_isColored)
{
(void) createMap(COLOR_MAP, false);
}
return true;
}
bool DePee::remDePeePass()
{
if(_dePeePasses.size() < 2)
return false;
_parent->removeChild(_dePeePasses.back()->root.get());
delete _dePeePasses.back();
_dePeePasses.pop_back();
_renderToFirst = !_renderToFirst;
if(_isColored)
{
(void) createMap(COLOR_MAP, false);
}
return true;
}
//create noise map with values ranging from 0 to 255
bool DePee::createNoiseMap()
{
{
osg::StateSet* stateset = _parent->getOrCreateStateSet();
_noiseMap = new osg::Texture2D;
_noiseMap->setTextureSize(_width, _height);
_noiseMap->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
_noiseMap->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::ON);
}
osg::Image* image = new osg::Image;
unsigned char* data = new unsigned char[_width*_height];
unsigned char* tmpData = new unsigned char[_width*_height];
int random=rand() % 5000;
for(unsigned y=0; y < _height; y++)
for(unsigned x=0; x < _width; x++)
data[y*_width + x] = (unsigned char) (0.5 * 255.0 + Utility::getNoise(x, y, random) * 0.5 * 255.0);
//if style isn't crayon style, smooth the noise map
if(!_isCrayon)
{
for(unsigned i=0; i < 4; i++)
{
for(unsigned y=0; y < _height; y++)
for(unsigned x=0; x < _width; x++)
tmpData[y*_width + x] = (unsigned char)Utility::smoothNoise(_width, _height,x,y, data);
for(unsigned y=0; y < _height; y++)
for(unsigned x=0; x < _width; x++)
data[y*_width + x] = (unsigned char)Utility::smoothNoise(_width, _height, x,y, tmpData);
}
}
image->setImage(_width, _height, 1,
1, GL_LUMINANCE, GL_UNSIGNED_BYTE,
data,
osg::Image::USE_NEW_DELETE);
_noiseMap->setImage(image);
return true;
}
bool DePee::createHUD()
{
osg::Geode* geode = new osg::Geode();
std::string timesFont("fonts/arial.ttf");
// turn lighting off for the text and disable depth test to ensure its always ontop.
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(1, _normalDepthMap0.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(2, _normalDepthMap1.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(3, _edgeMap.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(4, _colorMap.get(), osg::StateAttribute::OFF);
stateset->setTextureAttributeAndModes(5, _noiseMap.get(), osg::StateAttribute::OFF);
osg::Vec3 position(5.0f,7.0f,0.0f);
osg::Vec3 delta(0.0f,-120.0f,0.0f);
_hudText = new osgText::Text;
{
geode->addDrawable( _hudText );
_hudText->setDataVariance(osg::Object::DYNAMIC);
_hudText->setFont(timesFont);
_hudText->setPosition(position);
_hudText->setText("Head Up Display");
_hudText->setColor(osg::Vec4(0.5, 0.5, 0.5, 1.0));
_hudText->setCharacterSize(20.0);
position += delta;
}
{
osg::BoundingBox bb;
for(unsigned int i=0;i<geode->getNumDrawables();++i)
{
bb.expandBy(geode->getDrawable(i)->getBound());
}
osg::Geometry* geom = new osg::Geometry;
osg::Vec3Array* vertices = new osg::Vec3Array;
float depth = bb.zMin()-0.1;
vertices->push_back(osg::Vec3(bb.xMin(),bb.yMax(),depth));
vertices->push_back(osg::Vec3(bb.xMin(),bb.yMin(),depth));
vertices->push_back(osg::Vec3(bb.xMax(),bb.yMin(),depth));
vertices->push_back(osg::Vec3(bb.xMax(),bb.yMax(),depth));
geom->setVertexArray(vertices);
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(0.0f,0.0,0.0f,0.3f));
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
//geode->addDrawable(geom);
}
osg::Camera* camera = new osg::Camera;
// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);
camera->addChild(geode);
_parent->addChild(camera);
return true;
}
// then create the first camera node to do the render to texture
// render normal and depth map color map
bool DePee::createMap(MapMode mapMode, bool first)
{
switch(mapMode)
{
case EDGE_MAP:
return createEdgeMap(first);
case NOISE_MAP:
return createNoiseMap();
case NORMAL_DEPTH_MAP:
case COLOR_MAP:
return createNormalDepthColorMap(mapMode, first);
default:
std::cerr << "mapMode not recognized!!!\n";
return false;
}
}
bool DePee::createFinal()
{
osg::Projection* screenAlignedProjectionMatrix = new osg::Projection;
screenAlignedProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,_width,0,_height));
screenAlignedProjectionMatrix->setCullingActive(false);
osg::MatrixTransform* screenAlignedModelViewMatrix = new osg::MatrixTransform;
screenAlignedModelViewMatrix->setMatrix(osg::Matrix::identity());
// Make sure the model view matrix is not affected by any transforms
// above it in the scene graph:
screenAlignedModelViewMatrix->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
// new we need to add the texture to the Drawable, we do so by creating a
// StateSet to contain the Texture StateAttribute.
osg::StateSet* stateset = new osg::StateSet;
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
_quadGeode->setStateSet(stateset);
_parent->addChild(screenAlignedProjectionMatrix);
screenAlignedProjectionMatrix->addChild(screenAlignedModelViewMatrix);
screenAlignedModelViewMatrix->addChild(_quadGeode.get());
//setup shader
std::string vertSource;
if(!Utility::readFile("shaders/depthpeel_final.vert", vertSource))
{
printf("shader source not found\n");
return false;
}
std::string fragSource;
if(!Utility::readFile("shaders/depthpeel_final.frag", fragSource))
{
printf("shader source not found\n");
return false;
}
osg::ref_ptr<osg::Program> program = new osg::Program;
program->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource.c_str() ) );
program->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource.c_str() ) );
//choose map to display
stateset->addUniform( new osg::Uniform("normalDepthMap0", 1));
stateset->addUniform( new osg::Uniform("normalDepthMap1", 2));
stateset->addUniform(new osg::Uniform("edgeMap", 3));
stateset->addUniform( new osg::Uniform("colorMap", 4));
stateset->addUniform( new osg::Uniform("noiseMap", 5));
stateset->addUniform(_sketchy);
stateset->addUniform(_colored);
stateset->addUniform(_edgy);
stateset->addUniform(_sketchiness);
stateset->setAttributeAndModes( program.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
//switch lighting off
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
return true;
}
bool DePee::createEdgeMap(bool first)
//create the edge map of the first normal and depth map
{
_dePeePasses.back()->newRenderPass(EDGE_MAP);
// set up the background color and clear mask.
_dePeePasses.back()->Cameras[EDGE_MAP]->setClearColor(osg::Vec4(0.3,0.3f,0.3f,1.0f));
_dePeePasses.back()->Cameras[EDGE_MAP]->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const osg::BoundingSphere& bs = _quadGeode->getBound();
if (!bs.valid())
{
return false;
}
float znear = 1.0f*bs.radius();
float zfar = 3.0f*bs.radius();
znear *= 0.9f;
zfar *= 1.1f;
// set up projection.
//_dePeePasses.back()->Cameras.top()->setProjectionMatrixAsFrustum(-proj_right,proj_right,-proj_top,proj_top,znear,zfar);
_dePeePasses.back()->Cameras[EDGE_MAP]->setProjectionMatrixAsOrtho(0,_width,0,_height,znear,zfar);
//set view
_dePeePasses.back()->Cameras[EDGE_MAP]->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
_dePeePasses.back()->Cameras[EDGE_MAP]->setViewMatrixAsLookAt(osg::Vec3(0.0f,0.0f,2.0f)*bs.radius(), osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0f,1.0f,0.0f));
// set viewport
_dePeePasses.back()->Cameras[EDGE_MAP]->setViewport(0,0,_texWidth,_texHeight);
// set the camera to render before the main camera.
_dePeePasses.back()->Cameras[EDGE_MAP]->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object
_dePeePasses.back()->Cameras[EDGE_MAP]->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER);
//switch lighting off
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
if(_renderToFirst)
{
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
}
else
{
stateset->addUniform(new osg::Uniform("normalDepthMap", 2));
}
_dePeePasses.back()->Cameras[EDGE_MAP]->attach(osg::Camera::COLOR_BUFFER, _edgeMap.get());
stateset->addUniform( new osg::Uniform("edgeMap", 3));
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
osg::StateAttribute::OFF);
//setup shader
stateset->setAttributeAndModes(_edgeMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("width", (float) _width));
stateset->addUniform(new osg::Uniform("height", (float) _height));
if(first)
{
stateset->addUniform(new osg::Uniform("first", (float)1.0));
}
else
{
stateset->addUniform(new osg::Uniform("first", (float)0.0));
}
_dePeePasses.back()->settingNodes[EDGE_MAP]->setStateSet(stateset.get());
// add subgraph to render
assert(_dePeePasses.size() > 0);
_dePeePasses.back()->settingNodes[EDGE_MAP]->addChild(_quadGeode.get());
return true;
}
bool DePee::createNormalDepthColorMap(MapMode mapMode, bool first)
{
DePeePass* pass;
pass = _dePeePasses.back();
pass->newRenderPass(mapMode);
//
// setup camera
//
// set up the background color and clear mask
pass->Cameras[mapMode]->setClearColor(osg::Vec4(0.f,0.f,1.f,1.f));
pass->Cameras[mapMode]->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const osg::BoundingSphere& bs = _subgraph->getBound();
if (!bs.valid())
{
return false;
}
float znear = 1.0f*bs.radius();
float zfar = 3.0f*bs.radius();
// 2:1 aspect ratio as per flag geomtry below.
float projTop = 0.25f*znear;
float projRight = projTop * ((double)_width/(double)_height);
znear *= 0.9f;
zfar *= 1.1f;
// set up projection.
pass->Cameras[mapMode]->setProjectionMatrixAsFrustum(-projRight,projRight,-projTop,projTop, znear,zfar);
// setup view
pass->Cameras[mapMode]->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
pass->Cameras[mapMode]->setViewMatrixAsLookAt(bs.center()-osg::Vec3(0.0f,2.0f,0.0f)*bs.radius(),
bs.center(),
osg::Vec3(0.0f,0.0f,1.0f));
// set viewport
pass->Cameras[mapMode]->setViewport(0,0,_texWidth,_texHeight);
// set the camera to render before the main camera.
pass->Cameras[mapMode]->setRenderOrder(osg::Camera::PRE_RENDER);
pass->Cameras[mapMode]->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
//
// setup stateset
//
//switch lighting off
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE |
osg::StateAttribute::OFF);
switch(mapMode)
{
case NORMAL_DEPTH_MAP:
_renderToFirst = !_renderToFirst;
if(_renderToFirst)
{
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _normalDepthMap0.get());
stateset->addUniform(new osg::Uniform("normalDepthMap", 2));
}
else
{
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _normalDepthMap1.get());
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
}
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
stateset->setAttributeAndModes(_normalDepthMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
break;
case COLOR_MAP:
assert(pass == _dePeePasses.back());
pass->Cameras[mapMode]->attach(osg::Camera::COLOR_BUFFER, _colorMap.get());
if(_renderToFirst)
{
stateset->addUniform(new osg::Uniform("normalDepthMap", 1));
}
else
{
stateset->addUniform(new osg::Uniform("normalDepthMap", 2));
}
pass->Cameras[mapMode]->setClearColor(osg::Vec4(1.f,1.f,1.f,1.f));
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
stateset->setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
stateset->setAttributeAndModes(_colorMapProgram.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("tex", 0));
break;
default:
return false;
};
// add subgraph to render
pass->settingNodes[mapMode]->addChild(_subgraph.get());
stateset->addUniform(new osg::Uniform("first", first));
stateset->addUniform(new osg::Uniform("width", (float) _width));
stateset->addUniform(new osg::Uniform("height", (float) _height));
stateset->addUniform(new osg::Uniform("znear", znear));
stateset->addUniform(new osg::Uniform("zfar", zfar));
pass->settingNodes[mapMode]->setStateSet(stateset.get());
return true;
}
bool DePee::updateHUDText()
{
if(!_fps)
return false;
std::string str;
std::string tmp = Utility::toString(*_fps);
unsigned i = tmp.find_first_of('.');
tmp = tmp.substr(0, i + 3);
_hudText->setText(Utility::toString(_dePeePasses.size())
+ " Depth Peeling Pass" + (_dePeePasses.size() == 1 ? " " : "es ")
+ "((a)dd; (r)emove) "
+ (_isEdgy ? "+" : "-") + "(E)dgy " +
+ (_isSketchy ? "+" : "-") + "(S)ketchy " +
+ (_isColored ? "+" : "-") + "(C)olored " +
+ "-> "+Utility::toString(getNumberOfRenderPasses())+ " Rendering Passes "
+ "@ "
+ tmp + " fps");
return true;
}

View File

@@ -1,170 +0,0 @@
/*
Steffen Frey
Fachpraktikum Graphik-Programmierung 2007
Institut fuer Visualisierung und Interaktive Systeme
Universitaet Stuttgart
*/
#ifndef _DEPEE_H_
#define _DEPEE_H_
#include <osg/Node>
#include <osg/Camera>
#include <osg/Group>
#include <osg/Texture2D>
#include <osgText/Text>
#include <string>
#include <stack>
#include "DePeePass.h"
/*!
The DePee class is main class for setting up and managing depth peeling.
A DePee object can be seen as a virtual node, that has one parent and one child. The rendering of every child and subchil of this child is managed by the the DePee node. Besides that, it handles a head up display.
*/
class DePee : public osg::Referenced
{
public:
/*!
The constructor is initialized by giving it a parent and child node (subgraph), as well as the width and height in pixels of the output window. Additionally a subgraph can be added whose children aren't depth peeled but combined with de depth peeled scene
*/
DePee(osg::Group* parent, osg::Group* subgraph, unsigned width, unsigned height);
/*!
Takes care of clean removal of DePee
*/
~DePee();
/*!
The head up display shows information like internal status and current frames per second. This function needs to be called in the rendering loop to keep the information updated.
*/
bool updateHUDText();
/*!
Sets whether sketchiness is activated or deactivated
*/
void setSketchy(bool sketchy);
/*!
If sketchiness is enabled, sets whether a crayon should be used
*/
void setCrayon(bool crayon);
/*!
Sets whether color display is activated or deactivated
*/
void setColored(bool colored);
/*!
Sets whether edges are displayed or not
*/
void setEdgy(bool edgy);
/*!
Sets how sketchy lines and colors should be displayed (standard is 1.0)
*/
void setSketchiness(double sketchiness);
/*!
Set the pointer to the double variable containing the current fps for displaying it on the head up display
*/
void setFPS(double* fps);
/*!
Add a depth peeling pass and adjust the render passes accordingly
*/
bool addDePeePass();
/*!
Remove a depth peeling pass and adjust the render passes accordingly
*/
bool remDePeePass();
private:
/*!
Create a map. This is a function for convenience and calls either
createNoiseMap(), createEdgeMap() or createNormalDepthColorMap().
Apart from NOISE_MAP, for every texture generation
one rendering pass is needed.
The boolean first is used to indicate whether this rendering pass
belongs to the first depth peeling pass.
*/
bool createMap(MapMode mapMode, bool first=false);
/*!
Creates a two dimensional noise map and initalizes _noiseMap with it
*/
bool createNoiseMap();
/*!
Depending on the chosen MapMode, it either creates a new rendering
pass for creaeting a normal, depth or color map. The created rendering
pass is added to the current depth peeling pass.
*/
bool createNormalDepthColorMap(MapMode mapMode, bool first);
/*!
Create an edge map. A previous depth and normal rendering pass in this
depth peeling pass is required for that.
*/
bool createEdgeMap(bool first);
/*!
Creates the final rendering pass for depth peeling. Color and edge map are
added up here and sketchiness is applied.
*/
bool createFinal();
/*!
Create the rendering pass for the head up display
*/
bool createHUD();
/*
Returns the number of rendering passes of the depth peeling object
*/
unsigned int getNumberOfRenderPasses();
unsigned _texWidth;
unsigned _texHeight;
unsigned _width;
unsigned _height;
osg::ref_ptr<osg::Group> _parent;
osg::ref_ptr<osg::Group> _subgraph;
osg::ref_ptr<osg::Texture2D> _noiseMap;
osg::ref_ptr<osg::Texture2D> _normalDepthMap0;
osg::ref_ptr<osg::Texture2D> _normalDepthMap1;
osg::ref_ptr<osg::Texture2D> _edgeMap;
osg::ref_ptr<osg::Texture2D> _colorMap;
osg::ref_ptr<osg::Geode> _quadGeode;
osgText::Text* _hudText;
double* _fps;
std::vector<DePeePass*> _dePeePasses;
osg::Uniform* _sketchy;
osg::Uniform* _colored;
osg::Uniform* _edgy;
osg::Uniform* _sketchiness;
bool _isSketchy;
bool _isColored;
bool _isEdgy;
bool _isCrayon;
osg::Camera* _colorCamera;
//shader programs
osg::ref_ptr<osg::Program> _normalDepthMapProgram;
osg::ref_ptr<osg::Program> _colorMapProgram;
osg::ref_ptr<osg::Program> _edgeMapProgram;
bool _renderToFirst;
};
#endif

View File

@@ -1,49 +0,0 @@
/*
Steffen Frey
Fachpraktikum Graphik-Programmierung 2007
Institut fuer Visualisierung und Interaktive Systeme
Universitaet Stuttgart
*/
#include "DePeePass.h"
#include <iostream>
#include <assert.h>
DePeePass::DePeePass()
{
root = new osg::Group;
}
DePeePass::~DePeePass()
{
root->releaseGLObjects();
assert(Cameras.size() == settingNodes.size());
while(!Cameras.empty())
{
remRenderPass((*Cameras.begin()).first);
}
}
void DePeePass::newRenderPass(MapMode mapMode)
{
Cameras[mapMode] = new osg::Camera;
settingNodes[mapMode] = new osg::Group;
root->addChild(Cameras[mapMode].get());
Cameras[mapMode]->addChild(settingNodes[mapMode].get());
}
void DePeePass::remRenderPass(MapMode mapMode)
{
assert(Cameras.find(mapMode) != Cameras.end());
Cameras[mapMode]->releaseGLObjects();
settingNodes[mapMode]->releaseGLObjects();
Cameras[mapMode]->removeChild(settingNodes[mapMode].get());
//setting Nodes have exactly one child
assert(settingNodes[mapMode]->getNumChildren() == 1);
settingNodes[mapMode]->removeChild(0,1);
Cameras.erase(Cameras.find(mapMode));
settingNodes.erase(settingNodes.find(mapMode));
}

View File

@@ -1,56 +0,0 @@
/*
Steffen Frey
Fachpraktikum Graphik-Programmierung 2007
Institut fuer Visualisierung und Interaktive Systeme
Universitaet Stuttgart
*/
#ifndef _DEPEEPASS_H_
#define _DEPEEPASS_H_
#include <map>
#include <osg/Node>
#include <osg/Camera>
#include <osg/Group>
/*!
MapMode specifies the kind of texture maps that can be generated for later
usage
*/
enum MapMode {NORMAL_DEPTH_MAP, COLOR_MAP, EDGE_MAP, NOISE_MAP};
/*!
DePeePass can be seen as a mera data structure and typically used by
the class DePee. It represents one depth peeling pass and is initialized
by functions in the DePee class, but cleans itself up.
Please note, that no texture generation mode is allowed to appear twice
*/
class DePeePass
{
public:
/*!
Constructor
*/
DePeePass();
/*!
Desctructor cleans the whole depth peeling pass
*/
~DePeePass();
/*!
Make data structure ready for incorporating a new rendering pass
*/
void newRenderPass(MapMode mapMode);
/*!
Clean up the specified rendering pass
*/
void remRenderPass(MapMode mapMode);
osg::ref_ptr<osg::Group> root;
std::map<MapMode, osg::ref_ptr<osg::Camera> > Cameras;
std::map<MapMode, osg::ref_ptr<osg::Group> > settingNodes;
};
#endif

View File

@@ -1,152 +0,0 @@
/*
Steffen Frey
Fachpraktikum Graphik-Programmierung 2007
Institut fuer Visualisierung und Interaktive Systeme
Universitaet Stuttgart
*/
#include "Utility.h"
#include <assert.h>
#include <iostream>
#include <fstream>
#include <osg/Geometry>
#include <osg/Geode>
#include <osgDB/FileUtils>
bool Utility::readFile(char* fName, std::string& s)
{
std::string foundFile = osgDB::findDataFile(fName);
if (foundFile.empty()) return false;
std::ifstream is;//(fName);
is.open(foundFile.c_str());
if (is.fail())
{
std::cerr << "Could not open " << fName << " for reading.\n";
return false;
}
char ch = is.get();
while (!is.eof())
{
s += ch;
ch = is.get();
}
is.close();
return true;
}
std::string Utility::toString(double d)
{
std::stringstream ostr;
ostr << d;
return ostr.str();
}
osg::Program* Utility::createProgram(std::string vs, std::string fs)
{
//setup shader
std::string vertSource;
if(!readFile((char*)vs.c_str(), vertSource))
{
printf("shader source not found\n");
return false;
}
std::string fragSource;
if(!readFile((char*)fs.c_str(), fragSource))
{
printf("shader source not found\n");
return false;
}
osg::Program* program = new osg::Program;
program->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource.c_str() ) );
program->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource.c_str() ) );
return program;
}
double Utility::getNoise(unsigned x, unsigned y, unsigned random)
{
int n = x + y * 57 + random * 131;
n = (n<<13) ^ n;
double noise = (1.0f - ( (n * (n * n * 15731 + 789221) +
1376312589)&0x7fffffff)* 0.000000000931322574615478515625f);
return noise;
}
double Utility::smoothNoise(unsigned width, unsigned height, unsigned x, unsigned y, unsigned char* noise)
{
assert(noise);
if(x==0 || x > width -2
|| y==0 || y > height -2)
return noise[x + y*width];
double corners = (noise[x-1 + (y-1) *width]
+noise[x+1 + (y-1)*width]
+noise[x-1 + (y+1) * width]
+noise[x+1 + (y+1) * width]) / 16.0;
double sides = (noise[x-1 + y*width]
+noise[x+1 + y*width]
+noise[x + (y-1)*width]
+noise[x + (y+1)*width]) / 8.0;
double center = noise[x + y*width] / 4.0;
return corners + sides + center;
}
osg::Texture2D* Utility::newColorTexture2D(unsigned width, unsigned height, unsigned accuracy)
{
osg::Texture2D* texture2D = new osg::Texture2D;
texture2D->setTextureSize(width, height);
if(accuracy == 32)
{
texture2D->setInternalFormat(GL_RGBA32F_ARB);
texture2D->setSourceFormat(GL_RGBA);
}
else if(accuracy == 8)
{
texture2D->setInternalFormat(GL_RGBA);
}
texture2D->setSourceType(GL_FLOAT);
texture2D->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture2D->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
return texture2D;
}
osg::Geode* Utility::getCanvasQuad(unsigned width, unsigned height, double depth)
{
osg::Vec3Array* vertices = new osg::Vec3Array;
osg::Vec2Array* texCoords = new osg::Vec2Array;
vertices->push_back(osg::Vec3(0,0,depth));
texCoords->push_back(osg::Vec2(0,0));
vertices->push_back(osg::Vec3(width,0,depth));
texCoords->push_back(osg::Vec2(1,0));
vertices->push_back(osg::Vec3(0,height,depth));
texCoords->push_back(osg::Vec2(0,1));
vertices->push_back(osg::Vec3(width,height,depth));
texCoords->push_back(osg::Vec2(1,1));
osg::Geometry* quad = new osg::Geometry;
quad->setVertexArray(vertices);
quad->setTexCoordArray(1,texCoords);
quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,vertices->size()));
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
quad->setColorArray(colors);
quad->setColorBinding(osg::Geometry::BIND_OVERALL);
osg::Geode* geode = new osg::Geode();
geode->addDrawable(quad);
return geode;
}

View File

@@ -1,57 +0,0 @@
/*
Steffen Frey
Fachpraktikum Graphik-Programmierung 2007
Institut fuer Visualisierung und Interaktive Systeme
Universitaet Stuttgart
*/
#ifndef _UTILITY_H_
#define _UTILITY_H_
#include <string>
#include <sstream>
#include <osg/Program>
#include <osg/Texture2D>
namespace Utility
{
/*!
Reads a file and returns a string
*/
bool readFile(char* fName, std::string& s);
/*!
Converts a number to a string
*/
std::string toString(double d);
/*!
Create a osg shader program consisting of a vertex shader and a
fragment shader
*/
osg::Program* createProgram(std::string vs, std::string fs);
/*!
This is a random generator to generate noise patterns.
The returned values range from -1 to 1
*/
double getNoise(unsigned x, unsigned y, unsigned random);
/*!
Returns a smoothed noise version of the value that is read from the noise
texture
*/
double smoothNoise(unsigned width, unsigned height, unsigned x, unsigned y, unsigned char* noise);
/*!
Creates a two dimensional color texture and apply some standard settings
*/
osg::Texture2D* newColorTexture2D(unsigned width, unsigned height, unsigned accuracy);
/*!
Get a quad with screen size in order to show a texture full screen
*/
osg::Geode* getCanvasQuad(unsigned width, unsigned height, double depth=-1);
}
#endif

View File

@@ -1,328 +0,0 @@
/*
Steffen Frey
Fachpraktikum Graphik-Programmierung 2007
Institut fuer Visualisierung und Interaktive Systeme
Universitaet Stuttgart
*/
#include <osg/GLExtensions>
#include <osg/Node>
#include <osg/Geometry>
#include <osg/Notify>
#include <osg/MatrixTransform>
#include <osg/AnimationPath>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
#include <iostream>
#include "DePee.h"
/*!
Handles keyboard events.
Maintains a copy of the DePee object and part of its internal state
Used for example to set sketchiness, color, add or remove a depth peeling pass
*/
class KeyboardEventHandler : public osgGA::GUIEventHandler
{
public:
KeyboardEventHandler(DePee* dePee)
{
_apc = 0;
_dePee = dePee;
_sketchy = false;
_sketchiness = 1.0;
_colored = false;
_edgy = true;
_crayon = false;
_dePee->setSketchy(_sketchy);
_dePee->setColored(_colored);
}
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Space)
{
if(_apc)
_apc->setPause(!_apc->getPause());
return true;
}
else if (ea.getKey() == 'a')
{
_dePee->addDePeePass();
return true;
}
else if (ea.getKey() == 'r')
{
_dePee->remDePeePass();
return true;
}
else if (ea.getKey() == 'c')
{
_colored = !_colored;
_dePee->setColored(_colored);
return true;
}
else if (ea.getKey() == 's')
{
_sketchy = !_sketchy;
_dePee->setSketchy(_sketchy);
return true;
}
else if (ea.getKey() == 'e')
{
_edgy = !_edgy;
_dePee->setEdgy(_edgy);
return true;
}
else if (ea.getKey() == 'f')
{
return true;
}
else if (ea.getKey() == '+')
{
_sketchiness += 0.5;
_dePee->setSketchiness(_sketchiness);
}
else if (ea.getKey() == '-')
{
_sketchiness -= 0.5;
if(_sketchiness < 0.0)
_sketchiness = 0.0;
_dePee->setSketchiness(_sketchiness);
}
else if (ea.getKey() == 'y')
{
_crayon = !_crayon;
_dePee->setCrayon(_crayon);
}
break;
}
default:
break;
}
return false;
}
void registerAnimationPathCallback(osg::AnimationPathCallback* apc)
{
_apc = apc;
}
private:
DePee* _dePee;
bool _sketchy;
bool _colored;
bool _edgy;
bool _crayon;
double _sketchiness;
osg::AnimationPathCallback* _apc;
};
/*!
Handles mouse events.
Maintains a copy of the DePee object and part of its internal state
Used to rotate the object
*/
class MouseEventHandler : public osgGA::GUIEventHandler
{
public:
MouseEventHandler(DePee* dePee)
{
_dePee = dePee;
}
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
switch(ea.getEventType())
{
//mouse
case(osgGA::GUIEventAdapter::DRAG):
{
rotate(ea.getXnormalized(), ea.getYnormalized());
break;
}
case(osgGA::GUIEventAdapter::MOVE):
_prevX = ea.getXnormalized();
_prevY = ea.getYnormalized();
break;
default:
break;
}
return false;
}
void registerModelGroupTransform(osg::MatrixTransform* modelGroupTransform)
{
_modelGroupTransform = modelGroupTransform;
_rotCenter = modelGroupTransform->getBound().center();
}
private:
void rotate(float x, float y)
{
osg::Matrixd baseMatrix = _modelGroupTransform->getMatrix();
osg::Matrixd preTransMatrix;
osg::Matrixd postTransMatrix;
osg::Matrixd rotMatrixX;
osg::Matrixd rotMatrixZ;
preTransMatrix.makeTranslate(_rotCenter);
postTransMatrix.makeTranslate(-_rotCenter);
rotMatrixZ.makeRotate((x - _prevX) * 3., osg::Vec3d(0.0, 0.0,1.0));
baseMatrix.preMult(preTransMatrix);
baseMatrix.preMult(rotMatrixZ);
baseMatrix.preMult(postTransMatrix);
rotMatrixX.makeRotate(-(y - _prevY) * 3., (baseMatrix * osg::Vec3d(1.0, 0.0,0.0)));
baseMatrix.preMult(preTransMatrix);
baseMatrix.preMult(rotMatrixX);
baseMatrix.preMult(postTransMatrix);
_modelGroupTransform->setMatrix(baseMatrix);
_prevX = x;
_prevY = y;
};
DePee* _dePee;
float _prevX;
float _prevY;
osg::Vec3 _rotCenter;
osg::MatrixTransform* _modelGroupTransform;
};
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()->setDescription(arguments.getApplicationName()+" is the example which demonstrates Depth Peeling");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" filename");
// construct the viewer
osgViewer::Viewer viewer(arguments);
// 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.argc() > 3)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
//only displays a textured quad
viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
// read the model to do depth peeling with
osg::Node* loadedModel = osgDB::readNodeFile(arguments.argv()[1]);
if (!loadedModel)
return 1;
// create a transform to spin the model.
osg::MatrixTransform* modelGroupTransform = new osg::MatrixTransform;
osg::Group* modelGroup = new osg::Group;
modelGroupTransform->addChild(modelGroup);
modelGroup->addChild(loadedModel);
osg::Group* rootNode = new osg::Group();
// add model to the viewer.
viewer.setSceneData(rootNode);
// Depth peel example only works on a single graphics context right now
// so open up viewer on single screen to prevent problems
viewer.setUpViewOnSingleScreen(0);
// create the windows and run the threads.
viewer.realize();
unsigned int width = 1280;
unsigned int height = 1280;
osgViewer::Viewer::Windows windows;
viewer.getWindows(windows);
if (!windows.empty())
{
width = windows.front()->getTraits()->width;
height = windows.front()->getTraits()->height;
}
osg::ref_ptr<DePee> dePee = new DePee(rootNode,
modelGroupTransform,
width,
height);
//create event handlers
KeyboardEventHandler* keyboardEventHandler = new KeyboardEventHandler(dePee.get());
MouseEventHandler* mouseEventHandler = new MouseEventHandler(dePee.get());
viewer.addEventHandler(keyboardEventHandler);
viewer.addEventHandler(mouseEventHandler);
//viewer.setCameraManipulator(new osgGA::TrackballManipulator);
osg::StateSet* stateset = modelGroupTransform->getOrCreateStateSet();
stateset->setMode(GL_BLEND, osg::StateAttribute::OFF);
//create new animation callback for autmatic object rotation
osg::AnimationPathCallback* apc = new osg::AnimationPathCallback(modelGroupTransform->getBound().center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(45.0f));
apc->setPause(true);
modelGroupTransform->setUpdateCallback(apc);
keyboardEventHandler->registerAnimationPathCallback(apc);
mouseEventHandler->registerModelGroupTransform(modelGroupTransform);
//setup stuff that is necessary for measuring fps
osg::Timer_t current_tick, previous_tick = 1;
double* fps = new double;
dePee->setFPS(fps);
while(!viewer.done())
{
current_tick = osg::Timer::instance()->tick();
*fps = 1.0/osg::Timer::instance()->delta_s(previous_tick,current_tick);
dePee->updateHUDText();
previous_tick = current_tick;
// fire off the cull and draw traversals of the scene.
viewer.frame();
}
return 0;
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgdepthshadow.cpp )
SET(TARGET_ADDED_LIBRARIES osgShadow )
#### end var setup ###
SETUP_EXAMPLE(osgdepthshadow)

View File

@@ -0,0 +1,521 @@
/* OpenSceneGraph example, osgdepthshadow.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <osgViewer/Viewer>
#include <osg/Projection>
#include <osg/Geometry>
#include <osg/Texture>
#include <osg/TexGen>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osg/PolygonOffset>
#include <osg/Texture2D>
#include <osg/MatrixTransform>
#include <osg/Light>
#include <osg/LightSource>
#include <osg/PolygonOffset>
#include <osg/CullFace>
#include <osg/Material>
#include <osg/TexEnvCombine>
#include <osg/TexEnv>
#include <osg/AnimationPath>
#include <osg/TexGenNode>
#include <osgDB/ReadFile>
#include <osgShadow/ShadowedScene>
#include <osgShadow/ShadowMap>
#include <iostream>
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<MatrixTransform*>(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->getSimulationTime();
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<MatrixTransform> _create_lights()
{
ref_ptr<MatrixTransform> transform_0 = new MatrixTransform;
// create a spot light.
ref_ptr<Light> 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<LightSource> 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> geode = new Geode;
ref_ptr<ShapeDrawable> shape;
ref_ptr<TessellationHints> 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<Group> _create_scene()
{
ref_ptr<Group> scene = new Group;
ref_ptr<Geode> geode_1 = new Geode;
scene->addChild(geode_1.get());
ref_ptr<Geode> geode_2 = new Geode;
ref_ptr<MatrixTransform> 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> geode_3 = new Geode;
ref_ptr<MatrixTransform> 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<TessellationHints> hints = new TessellationHints;
hints->setDetailRatio(2.0f);
ref_ptr<ShapeDrawable> 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<Material> 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::Camera* Camera, osg::TexGenNode* texgenNode):
_light_transform(light_transform),
_Camera(Camera),
_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<_Camera->getNumChildren(); ++i)
{
bs.expandBy(_Camera->getChild(i)->getBound());
}
if (!bs.valid())
{
osg::notify(osg::WARN) << "bb invalid"<<_Camera.get()<<std::endl;
return;
}
osg::Vec3 position = _light_transform->getMatrix().getTrans();
float centerDistance = (position-bs.center()).length();
float znear = centerDistance-bs.radius();
float zfar = centerDistance+bs.radius();
float zNearRatio = 0.001f;
if (znear<zfar*zNearRatio) znear = zfar*zNearRatio;
#if 0
// hack to illustrate the precision problems of excessive gap between near far range.
znear = 0.00001*zfar;
#endif
float top = (bs.radius()/centerDistance)*znear;
float right = top;
_Camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
_Camera->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
_Camera->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 = _Camera->getViewMatrix() *
_Camera->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<osg::MatrixTransform> _light_transform;
osg::ref_ptr<osg::Camera> _Camera;
osg::ref_ptr<osg::TexGenNode> _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::Camera* camera = new osg::Camera;
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
camera->setComputeNearFarMode(osg::Camera::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<PolygonOffset> 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<CullFace> 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::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
// attach the texture and use it as the color buffer.
camera->attach(osg::Camera::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.
osgViewer::Viewer viewer;
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;
}
if (arguments.read("--sm"))
{
osgShadow::ShadowMap* sm = new osgShadow::ShadowMap;
sm->setTextureUnit( withBaseTexture ? 1 : 0 );
osg::ref_ptr<osgShadow::ShadowedScene> shadowedScene = new osgShadow::ShadowedScene(sm);
ref_ptr<Group> created_scene = _create_scene();
if (!created_scene.valid()) return 1;
shadowedScene->addChild(_create_scene().get());
ref_ptr<MatrixTransform> scene = new MatrixTransform;
scene->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(125.0),1.0,0.0,0.0));
scene->addChild(_create_lights().get());
scene->addChild(shadowedScene.get());
if (withBaseTexture)
{
scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")), osg::StateAttribute::ON);
}
viewer.setSceneData(scene.get());
}
else
{
ref_ptr<MatrixTransform> scene = new MatrixTransform;
scene->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(125.0),1.0,0.0,0.0));
ref_ptr<Group> created_scene = _create_scene();
if (!created_scene.valid()) return 1;
ref_ptr<MatrixTransform> light_transform = _create_lights();
if (!light_transform.valid()) return 1;
ref_ptr<Group> shadowedScene;
if (withBaseTexture)
{
scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0, new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")), osg::StateAttribute::ON);
shadowedScene = createShadowedScene(created_scene.get(),light_transform.get(),1);
}
else
{
shadowedScene = createShadowedScene(created_scene.get(),light_transform.get(),0);
}
scene->addChild(shadowedScene.get());
viewer.setSceneData(scene.get());
}
// viewer.setUpViewOnSingleScreen();
return viewer.run();
}

View File

@@ -698,16 +698,6 @@ int main(int argc, char** argv)
viewer.setSceneData( distortionNode );
}
while (arguments.read("--sky-light"))
{
viewer.setLightingMode(osg::View::SKY_LIGHT);
}
if (viewer.getLightingMode()==osg::View::HEADLIGHT)
{
viewer.getLight()->setPosition(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
}
// load the nodes from the commandline arguments.
if (!viewer.getSceneData())

View File

@@ -38,9 +38,9 @@ std::string createLibraryNameForWrapper(const std::string& ext)
#if defined(WIN32)
// !! recheck evolving Cygwin DLL extension naming protocols !! NHV
#ifdef __CYGWIN__
return "cygwin_osgwrapper_"+ext+".dll";
return "cygosgwrapper_"+ext+".dll";
#elif defined(__MINGW32__)
return "mingw_osgwrapper_"+ext+".dll";
return "libosgwrapper_"+ext+".dll";
#else
#ifdef _DEBUG
return "osgwrapper_"+ext+"d.dll";

View File

@@ -17,7 +17,6 @@
*/
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osg/io_utils>
#include <osg/MatrixTransform>
@@ -359,7 +358,6 @@ void KeyboardModel::createKeyboard()
class KeyboardEventHandler : public osgGA::GUIEventHandler
{
public:
@@ -369,34 +367,6 @@ public:
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
#if 1
// osg::notify(osg::NOTICE)<<"Mouse "<<ea.getButtonMask()<<std::endl;
#define PRINT(mask) osg::notify(osg::NOTICE)<<#mask<<" ="<<(ea.getModKeyMask() & mask)<<std::endl;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
case(osgGA::GUIEventAdapter::KEYUP):
{
osg::notify(osg::NOTICE)<<std::endl;
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_SHIFT);
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_SHIFT);
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_ALT);
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_ALT);
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_CTRL);
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_CTRL);
PRINT(osgGA::GUIEventAdapter::MODKEY_LEFT_META);
PRINT(osgGA::GUIEventAdapter::MODKEY_RIGHT_META);
PRINT(osgGA::GUIEventAdapter::MODKEY_NUM_LOCK);
PRINT(osgGA::GUIEventAdapter::MODKEY_CAPS_LOCK);
break;
}
default:
break;
}
#endif
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
@@ -425,8 +395,6 @@ int main(int , char **)
osg::ref_ptr<KeyboardModel> keyboardModel = new KeyboardModel;
viewer.addEventHandler(new osgViewer::StatsHandler);
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new KeyboardEventHandler(keyboardModel.get()));
viewer.setSceneData( keyboardModel->getScene() );

View File

@@ -237,7 +237,7 @@ int runApp(std::string xapp)
} // end printList()
void readConfFile(const char* confFile) // read confFile 1
void readConfFile(char* confFile) // read confFile 1
{
osg::notify(osg::INFO) << "Start reading confFile" << std::endl;
@@ -418,7 +418,6 @@ int main( int argc, char **argv )
osgViewer::Viewer viewer;
osg::ref_ptr<osgText::Text> updateText = new osgText::Text;
updateText->setDataVariance(osg::Object::DYNAMIC);
// add the handler for doing the picking
viewer.addEventHandler(new PickHandler(&viewer,updateText.get()));

View File

@@ -267,16 +267,14 @@ void MovieEventHandler::getUsage(osg::ApplicationUsage& usage) const
}
osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,float height, osg::Image* image, bool useTextureRectangle, bool xyPlane, bool option_flip)
osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,float height, osg::Image* image, bool useTextureRectangle)
{
bool flip = image->getOrigin()==osg::Image::TOP_LEFT;
if (option_flip) flip = !flip;
if (useTextureRectangle)
{
osg::Geometry* pictureQuad = osg::createTexturedQuadGeometry(pos,
osg::Vec3(width,0.0f,0.0f),
xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height),
osg::Vec3(0.0f,0.0f,height),
0.0f, flip ? image->t() : 0.0, image->s(), flip ? 0.0 : image->t());
osg::TextureRectangle* texture = new osg::TextureRectangle(image);
@@ -294,7 +292,7 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo
{
osg::Geometry* pictureQuad = osg::createTexturedQuadGeometry(pos,
osg::Vec3(width,0.0f,0.0f),
xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height),
osg::Vec3(0.0f,0.0f,height),
0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f);
osg::Texture2D* texture = new osg::Texture2D(image);
@@ -311,6 +309,324 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo
}
}
class DomeModel
{
public:
DomeModel(osg::ArgumentParser& arguments):
sphere_radius(1.0),
collar_radius(0.45),
rotationDegrees(180.0),
distance(0.0),
flip(false),
texcoord_flip(false)
{
if (arguments.read("--radius", sphere_radius)) {}
if (arguments.read("--collar", collar_radius)) {}
if (arguments.read("--rotation", rotationDegrees)) {}
distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
if (arguments.read("--distance", distance)) {}
if (arguments.read("--flip")) { flip = true; }
}
double sphere_radius;
double collar_radius;
double rotationDegrees;
double distance;
bool flip;
bool texcoord_flip;
};
osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, DomeModel& domeModel)
{
osg::Vec3d center(0.0,0.0,0.0);
osg::Vec3d eye(0.0,0.0,0.0);
bool centerProjection = false;
osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, domeModel.distance);
osg::notify(osg::NOTICE)<<"Projector position = "<<projector<<std::endl;
osg::notify(osg::NOTICE)<<"distance = "<<domeModel.distance<<std::endl;
// create the quad to visualize.
osg::Geometry* geometry = new osg::Geometry();
geometry->setSupportsDisplayList(false);
osg::Vec3 xAxis(widthVector);
float width = widthVector.length();
xAxis /= width;
osg::Vec3 yAxis(heightVector);
float height = heightVector.length();
yAxis /= height;
int noSteps = 160;
osg::Vec3Array* vertices = new osg::Vec3Array;
osg::Vec2Array* texcoords = new osg::Vec2Array;
osg::Vec4Array* colors = new osg::Vec4Array;
osg::Vec3 bottom = origin;
osg::Vec3 dx = xAxis*(width/((float)(noSteps-2)));
osg::Vec3 dy = yAxis*(height/((float)(noSteps-1)));
osg::Vec3 top = origin + yAxis*height;
osg::Vec3d screenCenter = origin + widthVector*0.5f + heightVector*0.5f;
float screenRadius = heightVector.length() * 0.5f;
double rotation = osg::DegreesToRadians(domeModel.rotationDegrees);
osg::Vec3 cursor = bottom;
int i,j;
int midSteps = noSteps/2;
for(i=0;i<midSteps;++i)
{
osg::Vec3 cursor = bottom+dy*(float)i;
for(j=0;j<midSteps;++j)
{
osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
double theta = atan2(delta.x(), -delta.y());
theta += 2*osg::PI;
double phi = osg::PI_2 * delta.length() / screenRadius;
if (phi > osg::PI_2) phi = osg::PI_2;
double f = domeModel.distance * sin(phi);
double e = domeModel.distance * cos(phi) + sqrt( domeModel.sphere_radius*domeModel.sphere_radius - f*f);
double l = e * cos(phi);
double h = e * sin(phi);
double gamma = atan2(h, l-domeModel.distance);
osg::Vec2 texcoord(theta/(2.0*osg::PI), 1.0-gamma/osg::PI);
// osg::notify(osg::NOTICE)<<"cursor = "<<cursor<< " theta = "<<theta<< "phi="<<phi<<" gamma = "<<gamma<<" texcoord="<<texcoord<<std::endl;
if (domeModel.flip)
vertices->push_back(osg::Vec3(cursor.x(), top.y()-(cursor.y()-origin.y()),cursor.z()));
else
vertices->push_back(cursor);
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
texcoords->push_back( domeModel.texcoord_flip ? osg::Vec2(texcoord.x(), 1.0f - texcoord.y()) : texcoord);
if (j+1<midSteps) cursor += dx;
}
for(;j<noSteps;++j)
{
osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
double theta = atan2(delta.x(), -delta.y());
double phi = osg::PI_2 * delta.length() / screenRadius;
if (phi > osg::PI_2) phi = osg::PI_2;
double f = domeModel.distance * sin(phi);
double e = domeModel.distance * cos(phi) + sqrt( domeModel.sphere_radius*domeModel.sphere_radius - f*f);
double l = e * cos(phi);
double h = e * sin(phi);
double gamma = atan2(h, l-domeModel.distance);
osg::Vec2 texcoord(theta/(2.0*osg::PI), 1.0-gamma/osg::PI);
// osg::notify(osg::NOTICE)<<"cursor = "<<cursor<< " theta = "<<theta<< "phi="<<phi<<" gamma = "<<gamma<<" texcoord="<<texcoord<<std::endl;
if (domeModel.flip)
vertices->push_back(osg::Vec3(cursor.x(), top.y()-(cursor.y()-origin.y()),cursor.z()));
else
vertices->push_back(cursor);
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
texcoords->push_back( domeModel.texcoord_flip ? osg::Vec2(texcoord.x(), 1.0f - texcoord.y()) : texcoord);
cursor += dx;
}
// osg::notify(osg::NOTICE)<<std::endl;
}
for(;i<noSteps;++i)
{
osg::Vec3 cursor = bottom+dy*(float)i;
for(j=0;j<noSteps;++j)
{
osg::Vec2 delta(cursor.x() - screenCenter.x(), cursor.y() - screenCenter.y());
double theta = atan2(delta.x(), -delta.y());
if (theta<0.0) theta += 2*osg::PI;
double phi = osg::PI_2 * delta.length() / screenRadius;
if (phi > osg::PI_2) phi = osg::PI_2;
double f = domeModel.distance * sin(phi);
double e = domeModel.distance * cos(phi) + sqrt( domeModel.sphere_radius*domeModel.sphere_radius - f*f);
double l = e * cos(phi);
double h = e * sin(phi);
double gamma = atan2(h, l-domeModel.distance);
osg::Vec2 texcoord(theta/(2.0*osg::PI), 1.0-gamma/osg::PI);
// osg::notify(osg::NOTICE)<<"cursor = "<<cursor<< " theta = "<<theta<< "phi="<<phi<<" gamma = "<<gamma<<" texcoord="<<texcoord<<std::endl;
if (domeModel.flip)
vertices->push_back(osg::Vec3(cursor.x(), top.y()-(cursor.y()-origin.y()),cursor.z()));
else
vertices->push_back(cursor);
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
texcoords->push_back( domeModel.texcoord_flip ? osg::Vec2(texcoord.x(), 1.0f - texcoord.y()) : texcoord);
cursor += dx;
}
// osg::notify(osg::NOTICE)<<std::endl;
}
// pass the created vertex array to the points geometry object.
geometry->setVertexArray(vertices);
geometry->setColorArray(colors);
geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
geometry->setTexCoordArray(0,texcoords);
for(i=0;i<noSteps-1;++i)
{
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP);
for(j=0;j<noSteps;++j)
{
elements->push_back(j+(i+1)*noSteps);
elements->push_back(j+(i)*noSteps);
}
geometry->addPrimitiveSet(elements);
}
return geometry;
}
void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
{
// enforce single threading right now to avoid double buffering of RTT texture
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
}
unsigned int screenNum = 0;
while (arguments.read("--screen",screenNum)) {}
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(screenNum), width, height);
while (arguments.read("--width",width)) {}
while (arguments.read("--height",height)) {}
DomeModel domeModel(arguments);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->screenNum = screenNum;
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc)
{
osg::notify(osg::NOTICE)<<"GraphicsWindow has not been created successfully."<<std::endl;
return;
}
osg::Texture* texture = 0;
for(int i=1;i<arguments.argc() && !texture;++i)
{
if (arguments.isString(i))
{
osg::Image* image = osgDB::readImageFile(arguments[i]);
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
if (imagestream) imagestream->play();
if (image)
{
domeModel.texcoord_flip = image->getOrigin()==osg::Image::TOP_LEFT;
#if 1
texture = new osg::TextureRectangle(image);
#else
texture = new osg::Texture2D(image);
#endif
}
}
}
if (!texture)
{
return;
}
// distortion correction set up.
{
osg::Geode* geode = new osg::Geode();
geode->addDrawable( createDomeDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), domeModel) );
// new we need to add the texture to the mesh, we do so by creating a
// StateSet to contain the Texture StateAttribute.
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
texture->setMaxAnisotropy(16.0f);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
#if 1
osg::TexMat* texmat = new osg::TexMat;
texmat->setScaleByTextureRectangleSize(true);
stateset->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON);
#endif
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setGraphicsContext(gc.get());
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
camera->setClearColor( osg::Vec4(0.1,0.1,1.0,1.0) );
camera->setViewport(new osg::Viewport(0, 0, width, height));
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
camera->setAllowEventFocus(false);
//camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE);
//camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
camera->setProjectionMatrixAsOrtho2D(0,width,0,height);
camera->setViewMatrix(osg::Matrix::identity());
// add subgraph to render
// camera->addChild(geode);
camera->setName("DistortionCorrectionCamera");
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), true);
viewer.setSceneData(geode);
}
viewer.getCamera()->setNearFarRatio(0.0001f);
}
int main(int argc, char** argv)
{
// use an ArgumentParser object to manage the program arguments.
@@ -323,14 +639,13 @@ int main(int argc, char** argv)
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--texture2D","Use Texture2D rather than TextureRectangle.");
arguments.getApplicationUsage()->addCommandLineOption("--shader","Use shaders to post process the video.");
arguments.getApplicationUsage()->addCommandLineOption("--interactive","Use camera manipulator to allow movement around movie.");
arguments.getApplicationUsage()->addCommandLineOption("--flip","Flip the movie so top becomes bottom.");
arguments.getApplicationUsage()->addCommandLineOption("--dome","Use full dome distortion correction.");
bool useTextureRectangle = true;
bool useShader = false;
// construct the viewer.
osgViewer::Viewer viewer(arguments);
osgViewer::Viewer viewer;
if (arguments.argc()<=1)
{
@@ -348,89 +663,89 @@ int main(int argc, char** argv)
return 1;
}
bool fullscreen = !arguments.read("--interactive");
bool flip = arguments.read("--flip");
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
if (useShader)
{
//useTextureRectangle = false;
static const char *shaderSourceTextureRec = {
"uniform vec4 cutoff_color;\n"
"uniform samplerRect movie_texture;\n"
"void main(void)\n"
"{\n"
" vec4 texture_color = textureRect(movie_texture, gl_TexCoord[0]); \n"
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
" gl_FragColor = texture_color;\n"
"}\n"
};
static const char *shaderSourceTexture2D = {
"uniform vec4 cutoff_color;\n"
"uniform sampler2D movie_texture;\n"
"void main(void)\n"
"{\n"
" vec4 texture_color = texture2D(movie_texture, gl_TexCoord[0]); \n"
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
" gl_FragColor = texture_color;\n"
"}\n"
};
osg::Program* program = new osg::Program;
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
useTextureRectangle ? shaderSourceTextureRec : shaderSourceTexture2D));
stateset->addUniform(new osg::Uniform("cutoff_color",osg::Vec4(0.1f,0.1f,0.1f,1.0f)));
stateset->addUniform(new osg::Uniform("movie_texture",0));
stateset->setAttribute(program);
if (arguments.read("--dome") || arguments.read("--puffer") )
{
setDomeCorrection(viewer, arguments);
}
osg::Vec3 pos(0.0f,0.0f,0.0f);
osg::Vec3 topleft = pos;
osg::Vec3 bottomright = pos;
bool xyPlane = fullscreen;
for(int i=1;i<arguments.argc();++i)
else
{
if (arguments.isString(i))
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
osg::Vec3 pos(0.0f,0.0f,0.0f);
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
if (useShader)
{
osg::Image* image = osgDB::readImageFile(arguments[i]);
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
if (imagestream) imagestream->play();
//useTextureRectangle = false;
if (image)
static const char *shaderSourceTextureRec = {
"uniform vec4 cutoff_color;\n"
"uniform samplerRect movie_texture;\n"
"void main(void)\n"
"{\n"
" vec4 texture_color = textureRect(movie_texture, gl_TexCoord[0]); \n"
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
" gl_FragColor = texture_color;\n"
"}\n"
};
static const char *shaderSourceTexture2D = {
"uniform vec4 cutoff_color;\n"
"uniform sampler2D movie_texture;\n"
"void main(void)\n"
"{\n"
" vec4 texture_color = texture2D(movie_texture, gl_TexCoord[0]); \n"
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
" gl_FragColor = texture_color;\n"
"}\n"
};
osg::Program* program = new osg::Program;
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
useTextureRectangle ? shaderSourceTextureRec : shaderSourceTexture2D));
stateset->addUniform(new osg::Uniform("cutoff_color",osg::Vec4(0.1f,0.1f,0.1f,1.0f)));
stateset->addUniform(new osg::Uniform("movie_texture",0));
stateset->setAttribute(program);
}
for(int i=1;i<arguments.argc();++i)
{
if (arguments.isString(i))
{
geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip));
bottomright = pos + osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f);
osg::Image* image = osgDB::readImageFile(arguments[i]);
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
if (imagestream) imagestream->play();
pos.y() += image->t()*1.5f;
if (image)
{
geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle));
pos.z() += image->t()*1.5f;
}
else
{
std::cout<<"Unable to read file "<<arguments[i]<<std::endl;
}
}
else
{
std::cout<<"Unable to read file "<<arguments[i]<<std::endl;
}
}
// set the scene to render
viewer.setSceneData(geode.get());
if (viewer.getSceneData()==0)
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
}
// set the scene to render
viewer.setSceneData(geode.get());
if (viewer.getSceneData()==0)
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// pass the model to the MovieEventHandler so it can pick out ImageStream's to manipulate.
MovieEventHandler* meh = new MovieEventHandler();
@@ -447,22 +762,10 @@ int main(int argc, char** argv)
return 1;
}
if (fullscreen)
{
viewer.realize();
viewer.getCamera()->setViewMatrix(osg::Matrix::identity());
viewer.getCamera()->setProjectionMatrixAsOrtho2D(topleft.x(),bottomright.x(),topleft.y(),bottomright.y());
while(!viewer.done())
{
viewer.frame();
}
return 0;
}
else
{
// create the windows and run the threads.
return viewer.run();
}
// create the windows and run the threads.
return viewer.run();
}

View File

@@ -404,7 +404,7 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->addCommandLineOption("--texture-rectangle","Use osg::TextureRectangle for doing the render to texure to.");
// construct the viewer.
osgViewer::Viewer viewer(arguments);
osgViewer::Viewer viewer;
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))

View File

@@ -258,17 +258,20 @@ osg::Node* createScene()
return scene;
}
class TestSupportOperation: public osg::GraphicsOperation
class TestSupportOperation: public osg::Operation
{
public:
TestSupportOperation():
osg::GraphicsOperation("TestSupportOperation",false),
osg::Operation("TestSupportOperation",false),
_supported(true),
_errorMessage() {}
virtual void operator () (osg::GraphicsContext* gc)
virtual void operator () (osg::Object* object)
{
osg::GraphicsContext* gc = dynamic_cast<osg::GraphicsContext*>(object);
if (!gc) return;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
unsigned int contextID = gc->getState()->getContextID();

View File

@@ -39,8 +39,6 @@
#include <osgShadow/ShadowVolume>
#include <osgShadow/ShadowTexture>
#include <osgShadow/ShadowMap>
#include <osgShadow/SoftShadowMap>
#include <osgShadow/ParallelSplitShadowMap>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
@@ -492,22 +490,9 @@ int main(int argc, char** argv)
arguments.getApplicationUsage()->addCommandLineOption("--noUpdate", "Disable the updating the of light source.");
arguments.getApplicationUsage()->addCommandLineOption("--base", "Add a base geometry to test shadows.");
arguments.getApplicationUsage()->addCommandLineOption("--sv", "Select ShadowVolume implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--ssm", "Select SoftShadowMap implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--sm", "Select ShadowMap implementation.");
// arguments.getApplicationUsage()->addCommandLineOption("--pssm", "Select ParallelSplitShadowMap implementation.");
arguments.getApplicationUsage()->addCommandLineOption("--pssm", "Select ParallelSplitShadowMap implementation.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--mapcount", "ParallelSplitShadowMap texture count.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--mapres", "ParallelSplitShadowMap texture resolution.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--debug-color", "ParallelSplitShadowMap display debugging color (only the first 3 maps are color r=0,g=1,b=2.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--minNearSplit", "ParallelSplitShadowMap shadow map near offset.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--maxFarDist", "ParallelSplitShadowMap max far distance to shadow.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--moveVCamFactor", "ParallelSplitShadowMap move the virtual frustum behind the real camera, (also back ground object can cast shadow).");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--NVidea", "ParallelSplitShadowMap set default PolygonOffset for NVidea.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Factor", "ParallelSplitShadowMap set PolygonOffset factor.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Unit", "ParallelSplitShadowMap set PolygonOffset unit.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--CullFaceFront", "ParallelSplitShadowMap add a cull face: front.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("-1", "Use test model one.");
arguments.getApplicationUsage()->addCommandLineOption("-2", "Use test model two.");
arguments.getApplicationUsage()->addCommandLineOption("-3", "Use test model three.");
@@ -516,7 +501,7 @@ int main(int argc, char** argv)
// construct the viewer.
osgViewer::Viewer viewer(arguments);
osgViewer::Viewer viewer;
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
@@ -577,8 +562,31 @@ int main(int argc, char** argv)
// add stats
viewer.addEventHandler( new osgViewer::StatsHandler() );
// add the record camera path handler
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
if (model.valid())
{
model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask);
}
else
{
model = createTestModel(arguments);
}
// get the bounds of the model.
osg::ComputeBoundsVisitor cbbv;
model->accept(cbbv);
osg::BoundingBox bb = cbbv.getBoundingBox();
osg::Vec4 lightpos;
if (postionalLight)
{
lightpos.set(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius() ,1.0f);
}
else
{
lightpos.set(0.5f,0.25f,0.8f,0.0f);
}
osg::ref_ptr<osgShadow::ShadowedScene> shadowedScene = new osgShadow::ShadowedScene;
@@ -604,99 +612,18 @@ int main(int argc, char** argv)
osg::ref_ptr<osgShadow::ShadowTexture> st = new osgShadow::ShadowTexture;
shadowedScene->setShadowTechnique(st.get());
}
#if 0
else if (arguments.read("--pssm"))
{
int mapcount = 3;
while (arguments.read("--mapcount", mapcount));
osg::ref_ptr<osgShadow::ParallelSplitShadowMap> pssm = new osgShadow::ParallelSplitShadowMap(NULL,mapcount);
int mapres = 1024;
while (arguments.read("--mapres", mapres))
pssm->setTextureResolution(mapres);
while (arguments.read("--debug-color")) { pssm->setDebugColorOn(); }
int minNearSplit=0;
while (arguments.read("--minNearSplit", minNearSplit))
if ( minNearSplit > 0 ) {
pssm->setMinNearDistanceForSplits(minNearSplit);
std::cout << "ParallelSplitShadowMap : setMinNearDistanceForSplits(" << minNearSplit <<")" << std::endl;
}
int maxfardist = 0;
while (arguments.read("--maxFarDist", maxfardist))
if ( maxfardist > 0 ) {
pssm->setMaxFarDistance(maxfardist);
std::cout << "ParallelSplitShadowMap : setMaxFarDistance(" << maxfardist<<")" << std::endl;
}
int moveVCamFactor = 0;
while (arguments.read("--moveVCamFactor", moveVCamFactor))
if ( maxfardist > 0 ) {
pssm->setMoveVCamBehindRCamFactor(moveVCamFactor);
std::cout << "ParallelSplitShadowMap : setMoveVCamBehindRCamFactor(" << moveVCamFactor<<")" << std::endl;
}
double polyoffsetfactor = -0.02;
double polyoffsetunit = 1.0;
while (arguments.read("--PolyOffset-Factor", polyoffsetfactor));
while (arguments.read("--PolyOffset-Unit", polyoffsetunit));
pssm->setPolygonOffset(osg::Vec2(polyoffsetfactor,polyoffsetunit)); //ATI Radeon
if (arguments.read("--NVidea")){
//pssm->setPolygonOffset(osg::Vec2(-0.02,1.0)); //ATI Radeon
pssm->setPolygonOffset(osg::Vec2(10.0f,20.0f)); //NVidea
}
if ( arguments.read("--CullFaceFront") ) {
pssm->forceFrontCullFace();
}
osg::ref_ptr<osgShadow::ParallelSplitShadowMap> pssm = new osgShadow::ParallelSplitShadowMap;
shadowedScene->setShadowTechnique(pssm.get());
}
else if (arguments.read("--ssm"))
{
osg::ref_ptr<osgShadow::SoftShadowMap> sm = new osgShadow::SoftShadowMap;
shadowedScene->setShadowTechnique(sm.get());
}
#endif
else /* if (arguments.read("--sm")) */
{
osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;
shadowedScene->setShadowTechnique(sm.get());
int mapres = 1024;
while (arguments.read("--mapres", mapres))
sm->setTextureSize(osg::Vec2s(mapres,mapres));
}
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
if (model.valid())
{
model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask);
}
else
{
model = createTestModel(arguments);
}
// get the bounds of the model.
osg::ComputeBoundsVisitor cbbv;
model->accept(cbbv);
osg::BoundingBox bb = cbbv.getBoundingBox();
osg::Vec4 lightpos;
if (postionalLight)
{
lightpos.set(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius()*2.0f ,1.0f);
}
else
{
lightpos.set(0.5f,0.25f,0.8f,0.0f);
}
if ( arguments.read("--base"))
{
@@ -719,22 +646,6 @@ int main(int argc, char** argv)
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
ls->getLight()->setPosition(lightpos);
bool spotlight = false;
if (arguments.read("--spotLight"))
{
spotlight = true;
osg::Vec3 center = bb.center();
osg::Vec3 lightdir = center - osg::Vec3(lightpos.x(), lightpos.y(), lightpos.z());
lightdir.normalize();
ls->getLight()->setDirection(lightdir);
ls->getLight()->setSpotCutoff(25.0f);
//set the LightSource, only for checking, there is only 1 light in the scene
dynamic_cast<osgShadow::ShadowMap*>(shadowedScene->getShadowTechnique())->setLight(ls.get());
}
if ( arguments.read("--coloured-light"))
{
ls->getLight()->setAmbient(osg::Vec4(1.0,0.0,0.0,1.0));
@@ -745,34 +656,15 @@ int main(int argc, char** argv)
ls->getLight()->setAmbient(osg::Vec4(0.2,0.2,0.2,1.0));
ls->getLight()->setDiffuse(osg::Vec4(0.8,0.8,0.8,1.0));
}
shadowedScene->addChild(model.get());
shadowedScene->addChild(ls.get());
viewer.setSceneData(shadowedScene.get());
// create the windows and run the threads.
viewer.realize();
// it is done after viewer.realize() so that the windows are already initialized
if ( arguments.read("--debugHUD"))
{
osgViewer::Viewer::Windows windows;
viewer.getWindows(windows);
if (windows.empty()) return 1;
osgShadow::ShadowMap* sm = dynamic_cast<osgShadow::ShadowMap*>(shadowedScene->getShadowTechnique());
osg::ref_ptr<osg::Camera> hudCamera = sm->makeDebugHUD();
// set up cameras to rendering on the first window available.
hudCamera->setGraphicsContext(windows[0]);
hudCamera->setViewport(0,0,windows[0]->getTraits()->width, windows[0]->getTraits()->height);
viewer.addSlave(hudCamera.get(), false);
}
// osgDB::writeNodeFile(*group,"test.osg");
while (!viewer.done())
@@ -782,20 +674,13 @@ int main(int argc, char** argv)
float t = viewer.getFrameStamp()->getSimulationTime();
if (postionalLight)
{
lightpos.set(bb.center().x()+sinf(t)*bb.radius(), bb.center().y() + cosf(t)*bb.radius(), bb.zMax() + bb.radius()*3.0f ,1.0f);
lightpos.set(bb.center().x()+sinf(t)*bb.radius(), bb.center().y() + cosf(t)*bb.radius(), bb.zMax() + bb.radius() ,1.0f);
}
else
{
lightpos.set(sinf(t),cosf(t),1.0f,0.0f);
}
ls->getLight()->setPosition(lightpos);
osg::Vec3f lightDir(-lightpos.x(),-lightpos.y(),-lightpos.z());
if(spotlight)
lightDir = osg::Vec3(bb.center().x()+sinf(t)*bb.radius()/2.0, bb.center().y() + cosf(t)*bb.radius()/2.0, bb.center().z())
- osg::Vec3(lightpos.x(), lightpos.y(), lightpos.z()) ;
lightDir.normalize();
ls->getLight()->setDirection(lightDir);
}
viewer.frame();

View File

@@ -0,0 +1,8 @@
#this file is automatically generated
SET(TARGET_SRC CreateShadowedScene.cpp osgshadowtexture.cpp )
SET(TARGET_H CreateShadowedScene.h )
SET(TARGET_ADDED_LIBRARIES osgShadow )
#### end var setup ###
SETUP_EXAMPLE(osgshadowtexture)

View File

@@ -0,0 +1,224 @@
/* OpenSceneGraph example, osgshadowtexture.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <osg/Texture2D>
#include <osg/Material>
#include <osg/LightSource>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/ShapeDrawable>
#include <osg/Camera>
#include <osg/TexGenNode>
#include <osg/Notify>
#include <osg/io_utils>
#include "CreateShadowedScene.h"
using namespace osg;
class UpdateCameraAndTexGenCallback : public osg::NodeCallback
{
public:
UpdateCameraAndTexGenCallback(const osg::Vec3& position, osg::Camera* Camera, osg::TexGenNode* texgenNode):
_position(position),
_Camera(Camera),
_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<_Camera->getNumChildren(); ++i)
{
bs.expandBy(_Camera->getChild(i)->getBound());
}
if (!bs.valid())
{
osg::notify(osg::WARN) << "bb invalid"<<_Camera.get()<<std::endl;
return;
}
float centerDistance = (_position-bs.center()).length();
float znear = centerDistance-bs.radius();
float zfar = centerDistance+bs.radius();
float zNearRatio = 0.001f;
if (znear<zfar*zNearRatio) znear = zfar*zNearRatio;
float top = (bs.radius()/centerDistance)*znear;
float right = top;
_Camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
_Camera->setProjectionMatrixAsFrustum(-right,right,-top,top,znear,zfar);
_Camera->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 = _Camera->getViewMatrix() *
_Camera->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::Vec3 _position;
osg::ref_ptr<osg::Camera> _Camera;
osg::ref_ptr<osg::TexGenNode> _texgenNode;
};
osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const osg::Vec3& lightPosition,float radius,unsigned int unit)
{
osg::Group* group = new osg::Group;
// add light source
{
osg::LightSource* lightSource = new osg::LightSource;
lightSource->getLight()->setPosition(osg::Vec4(lightPosition,1.0f));
lightSource->getLight()->setLightNum(0);
group->addChild(lightSource);
osg::Geode* lightgeode = new osg::Geode;
lightgeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
lightgeode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(lightPosition,radius)));
group->addChild(lightgeode);
}
osg::Vec4 ambientLightColor(0.2,0.2f,0.2f,1.0f);
// add the shadower and shadowed.
group->addChild(shadower);
group->addChild(shadowed);
unsigned int tex_width = 512;
unsigned int tex_height = 512;
osg::Texture2D* texture = new osg::Texture2D;
texture->setTextureSize(tex_width, tex_height);
texture->setInternalFormat(GL_RGB);
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER);
texture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
// set up the render to texture camera.
{
// create the camera
osg::Camera* camera = new osg::Camera;
camera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
// set viewport
camera->setViewport(0,0,tex_width,tex_height);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::Camera::PRE_RENDER);
// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
// attach the texture and use it as the color buffer.
camera->attach(osg::Camera::COLOR_BUFFER, texture);
// add subgraph to render
camera->addChild(shadower);
osg::StateSet* stateset = camera->getOrCreateStateSet();
// make the material black for a shadow.
osg::Material* material = new osg::Material;
material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,0.0f,1.0f));
material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,0.0f,1.0f));
material->setEmission(osg::Material::FRONT_AND_BACK,ambientLightColor);
material->setShininess(osg::Material::FRONT_AND_BACK,0.0f);
stateset->setAttribute(material,osg::StateAttribute::OVERRIDE);
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(lightPosition, camera, texgenNode));
}
// set the shadowed subgraph so that it uses the texture and tex gen settings.
{
osg::StateSet* stateset = shadowed->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);
}
// set hud to render shadow texture, just for interest
{
osg::Geode* geode = new osg::Geode;
osg::Geometry* geom = osg::createTexturedQuadGeometry(osg::Vec3(0,0,0),osg::Vec3(100.0,0.0,0.0),osg::Vec3(0.0,100.0,0.0));
geom->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
geom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
geode->addDrawable(geom);
osg::Camera* camera = new osg::Camera;
// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,100,0,100));
// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
camera->setViewport(50,50,100,100);
// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);
camera->addChild(geode);
group->addChild(camera);
}
return group;
}

View File

@@ -0,0 +1,32 @@
/* -*-c++-*-
*
* OpenSceneGraph example, osgshadowtexture.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CREATESHADOWEDSCENE_H
#define CREATESHADOWEDSCENE_H
#include <osg/Node>
#include <osg/Vec3>
// function to create a lightsource which contain a shadower and showed subgraph,
// the showadowed subgrph has a cull callback to fire off a pre render to texture
// of the shadowed subgraph.
extern osg::Group* createShadowedScene(osg::Node* shadower,osg::Node* shadowed,const osg::Vec3& lightPosition,float radius,unsigned int textureUnit=1);
#endif

View File

@@ -0,0 +1,274 @@
/* OpenSceneGraph example, osgshadowtexture.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <osg/Notify>
#include <osg/MatrixTransform>
#include <osg/ShapeDrawable>
#include <osg/PositionAttitudeTransform>
#include <osg/Geometry>
#include <osg/Texture2D>
#include <osg/Geode>
#include <osgUtil/Optimizer>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osgShadow/ShadowedScene>
#include <osgShadow/ShadowVolume>
#include <osgShadow/ShadowTexture>
#include <osgShadow/ShadowMap>
// include the call which creates the shadowed subgraph.
#include "CreateShadowedScene.h"
// for the grid data..
#include "../osghangglide/terrain_coords.h"
osg::AnimationPath* createAnimationPath(const osg::Vec3& center,float radius,double looptime)
{
// set up the animation path
osg::AnimationPath* animationPath = new osg::AnimationPath;
animationPath->setLoopMode(osg::AnimationPath::LOOP);
int numSamples = 40;
float yaw = 0.0f;
float yaw_delta = 2.0f*osg::PI/((float)numSamples-1.0f);
float roll = osg::inDegrees(30.0f);
double time=0.0f;
double time_delta = looptime/(double)numSamples;
for(int i=0;i<numSamples;++i)
{
osg::Vec3 position(center+osg::Vec3(sinf(yaw)*radius,cosf(yaw)*radius,0.0f));
osg::Quat rotation(osg::Quat(roll,osg::Vec3(0.0,1.0,0.0))*osg::Quat(-(yaw+osg::inDegrees(90.0f)),osg::Vec3(0.0,0.0,1.0)));
animationPath->insert(time,osg::AnimationPath::ControlPoint(position,rotation));
yaw += yaw_delta;
time += time_delta;
}
return animationPath;
}
osg::Node* createBase(const osg::Vec3& center,float radius)
{
osg::Geode* geode = new osg::Geode;
// set up the texture of the base.
osg::StateSet* stateset = new osg::StateSet();
osg::Image* image = osgDB::readImageFile("Images/lz.rgb");
if (image)
{
osg::Texture2D* texture = new osg::Texture2D;
texture->setImage(image);
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
}
geode->setStateSet( stateset );
osg::HeightField* grid = new osg::HeightField;
grid->allocate(38,39);
grid->setOrigin(center+osg::Vec3(-radius,-radius,0.0f));
grid->setXInterval(radius*2.0f/(float)(38-1));
grid->setYInterval(radius*2.0f/(float)(39-1));
float minHeight = FLT_MAX;
float maxHeight = -FLT_MAX;
unsigned int r;
for(r=0;r<39;++r)
{
for(unsigned int c=0;c<38;++c)
{
float h = vertex[r+c*39][2];
if (h>maxHeight) maxHeight=h;
if (h<minHeight) minHeight=h;
}
}
float hieghtScale = radius*0.5f/(maxHeight-minHeight);
float hieghtOffset = -(minHeight+maxHeight)*0.5f;
for(r=0;r<39;++r)
{
for(unsigned int c=0;c<38;++c)
{
float h = vertex[r+c*39][2];
grid->setHeight(c,r,(h+hieghtOffset)*hieghtScale);
}
}
geode->addDrawable(new osg::ShapeDrawable(grid));
osg::Group* group = new osg::Group;
group->addChild(geode);
return group;
}
osg::Node* createMovingModel(const osg::Vec3& center, float radius)
{
float animationLength = 10.0f;
osg::AnimationPath* animationPath = createAnimationPath(center,radius,animationLength);
osg::Group* model = new osg::Group;
osg::Node* cessna = osgDB::readNodeFile("cessna.osg");
if (cessna)
{
const osg::BoundingSphere& bs = cessna->getBound();
float size = radius/bs.radius()*0.3f;
osg::MatrixTransform* positioned = new osg::MatrixTransform;
positioned->setDataVariance(osg::Object::STATIC);
positioned->setMatrix(osg::Matrix::translate(-bs.center())*
osg::Matrix::scale(size,size,size)*
osg::Matrix::rotate(osg::inDegrees(180.0f),0.0f,0.0f,2.0f));
positioned->addChild(cessna);
osg::MatrixTransform* xform = new osg::MatrixTransform;
xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0));
xform->addChild(positioned);
model->addChild(xform);
}
return model;
}
osg::Node* createModel(osg::ArgumentParser& arguments)
{
osg::Vec3 center(0.0f,0.0f,0.0f);
float radius = 100.0f;
osg::Vec3 lightPosition(center+osg::Vec3(0.0f,0.0f,radius));
// the shadower model
osg::Node* shadower = createMovingModel(center,radius*0.5f);
// the shadowed model
osg::Node* shadowed = createBase(center-osg::Vec3(0.0f,0.0f,radius*0.25),radius);
if (arguments.read("--sv"))
{
// hint to tell viewer to request stencil buffer when setting up windows
osg::DisplaySettings::instance()->setMinimumNumStencilBits(8);
osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene;
osg::ref_ptr<osgShadow::ShadowVolume> shadowVolume = new osgShadow::ShadowVolume;
shadowedScene->setShadowTechnique(shadowVolume.get());
shadowVolume->setDynamicShadowVolumes(true);
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
ls->getLight()->setPosition(osg::Vec4(lightPosition,1.0));
shadowedScene->addChild(shadower);
shadowedScene->addChild(shadowed);
shadowedScene->addChild(ls.get());
return shadowedScene;
}
else if (arguments.read("--st"))
{
osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene;
osg::ref_ptr<osgShadow::ShadowTexture> shadowTexture = new osgShadow::ShadowTexture;
shadowedScene->setShadowTechnique(shadowTexture.get());
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
ls->getLight()->setPosition(osg::Vec4(lightPosition,1.0));
shadowedScene->setReceivesShadowTraversalMask(0x1);
shadowed->setNodeMask(shadowedScene->getReceivesShadowTraversalMask());
shadowedScene->setCastsShadowTraversalMask(0x2);
shadower->setNodeMask(shadowedScene->getCastsShadowTraversalMask());
shadowedScene->addChild(shadower);
shadowedScene->addChild(shadowed);
shadowedScene->addChild(ls.get());
return shadowedScene;
}
else if (arguments.read("--sm"))
{
osgShadow::ShadowedScene* shadowedScene = new osgShadow::ShadowedScene;
osg::ref_ptr<osgShadow::ShadowMap> shadowMap = new osgShadow::ShadowMap;
shadowedScene->setShadowTechnique(shadowMap.get());
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
ls->getLight()->setPosition(osg::Vec4(lightPosition,1.0));
shadowedScene->setReceivesShadowTraversalMask(0x1);
shadowed->setNodeMask(shadowedScene->getReceivesShadowTraversalMask());
shadowedScene->setCastsShadowTraversalMask(0x2);
shadower->setNodeMask(shadowedScene->getCastsShadowTraversalMask());
shadowedScene->addChild(shadower);
shadowedScene->addChild(shadowed);
shadowedScene->addChild(ls.get());
return shadowedScene;
}
else
{
// combine the models together to create one which has the shadower and the shadowed with the required callback.
osg::Group* root = createShadowedScene(shadower,shadowed,lightPosition,radius/100.0f,1);
return root;
}
}
int main(int argc, char ** argv)
{
osg::ArgumentParser arguments(&argc,argv);
// construct the viewer.
osgViewer::Viewer viewer;
// pass the model to the viewer.
viewer.setSceneData( createModel(arguments) );
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
return viewer.run();
}

View File

@@ -658,7 +658,7 @@ int main(int argc, char **argv)
// construct the viewer.
osgViewer::Viewer viewer(arguments);
osgViewer::Viewer viewer;
// if user request help write it out to cout.
unsigned int testCase = 0;

View File

@@ -1,6 +1,6 @@
#this file is automatically generated
SET(TARGET_ADDED_LIBRARIES osgdb_ive osgdb_freetype osgdb_OpenFlight osgdb_osg )
SET(TARGET_ADDED_LIBRARIES osgdb_ive osgdb_freetype )
SET(TARGET_SRC osgstaticviewer.cpp )
#### end var setup ###

View File

@@ -39,8 +39,6 @@
// include the plugins we need
USE_OSGPLUGIN(ive);
USE_OSGPLUGIN(freetype);
USE_OSGPLUGIN(osg);
USE_OSGPLUGIN(OpenFlight);
// include the platform specific GraphicsWindow implementation.
USE_GRAPHICSWINDOW();

View File

@@ -32,123 +32,6 @@
typedef std::vector<std::string> FileList;
osg::Geode* createSectorForImage(osg::Image* image, osg::TexMat* texmat, float s,float t, float radius, float height, float length)
{
int numSegments = 20;
float Theta = length/radius;
float dTheta = Theta/(float)(numSegments-1);
float ThetaZero = height*s/(t*radius);
// set up the texture.
osg::Texture2D* texture = new osg::Texture2D;
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER);
texture->setResizeNonPowerOfTwoHint(false);
texture->setImage(image);
// set up the drawstate.
osg::StateSet* dstate = new osg::StateSet;
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF);
dstate->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
dstate->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
dstate->setTextureAttribute(0, texmat);
// set up the geoset.
osg::Geometry* geom = new osg::Geometry;
geom->setStateSet(dstate);
osg::Vec3Array* coords = new osg::Vec3Array();
osg::Vec2Array* tcoords = new osg::Vec2Array();
int i;
float angle = -Theta/2.0f;
for(i=0;
i<numSegments;
++i, angle+=dTheta)
{
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,height*0.5f)); // top
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,-height*0.5f)); // bottom.
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,1.0f)); // top
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,0.0f)); // bottom.
}
osg::Vec4Array* colors = new osg::Vec4Array();
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
osg::DrawArrays* elements = new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,coords->size());
geom->setVertexArray(coords);
geom->setTexCoordArray(0,tcoords);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(elements);
// set up the geode.
osg::Geode* geode = new osg::Geode;
geode->addDrawable(geom);
return geode;
}
osg::Group * loadImages(std::string image1, std::string image2, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length) {
osg::ref_ptr<osg::Image> imageLeft = osgDB::readImageFile(image1);
osg::ref_ptr<osg::Image> imageRight = osgDB::readImageFile(image2);
if (imageLeft.valid() && imageRight.valid())
{
float average_s = (imageLeft->s()+imageRight->s())*0.5f;
float average_t = (imageLeft->t()+imageRight->t())*0.5f;
osg::Geode* geodeLeft = createSectorForImage(imageLeft.get(),texmatLeft,average_s,average_t, radius, height, length);
geodeLeft->setNodeMask(0x01);
osg::Geode* geodeRight = createSectorForImage(imageRight.get(),texmatRight,average_s,average_t, radius, height, length);
geodeRight->setNodeMask(0x02);
osg::Group * imageGroup = new osg::Group;
imageGroup->addChild(geodeLeft);
imageGroup->addChild(geodeRight);
return imageGroup;
}
else
{
std::cout << "Warning: Unable to load both image files, '"<<image1<<"' & '"<<image2<<"', required for stereo imaging."<<std::endl;
return 0;
}
}
// create a switch containing a set of child each containing a
// stereo image pair.
osg::Switch* createScene(FileList fileList, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length)
{
osg::Switch* sw = new osg::Switch;
// load the images.
for(unsigned int i=0;i+1<fileList.size();i+=2)
{
osg::Group * imageGroup = loadImages(fileList[i],fileList[i+1],texmatLeft,texmatRight, radius, height, length);
if (imageGroup) sw->addChild(imageGroup);
}
if (sw->getNumChildren()>0)
{
// select first child.
sw->setSingleChildOn(0);
}
return sw;
}
class SlideEventHandler : public osgGA::GUIEventHandler
{
public:
@@ -160,9 +43,6 @@ public:
void set(osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float timePerSlide, bool autoSteppingActive);
void set(FileList fileList, osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length, float timePerSlide, bool autoSteppingActive);
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&);
virtual void getUsage(osg::ApplicationUsage& usage) const;
@@ -189,9 +69,6 @@ protected:
osg::ref_ptr<osg::Switch> _switch;
osg::ref_ptr<osg::TexMat> _texmatLeft;
osg::ref_ptr<osg::TexMat> _texmatRight;
float _radius;
float _height;
float _length;
bool _firstTraversal;
unsigned int _activeSlide;
double _previousTime;
@@ -201,7 +78,6 @@ protected:
float _currentSeperationX;
float _initSeperationY;
float _currentSeperationY;
FileList _fileList;
};
@@ -238,35 +114,6 @@ void SlideEventHandler::set(osg::Switch* sw, float offsetX, float offsetY, osg::
}
void SlideEventHandler::set(FileList fileList, osg::Switch* sw, float offsetX, float offsetY, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length, float timePerSlide, bool autoSteppingActive)
{
_switch = sw;
_switch->setUpdateCallback(this);
_fileList=FileList(fileList);
osg::ref_ptr<osg::Group> imageGroup = loadImages(fileList[0],fileList[1],texmatLeft,texmatRight, radius, height, length);
if (imageGroup.get())_switch->addChild(imageGroup.get());
_texmatLeft = texmatLeft;
_texmatRight = texmatRight;
_radius=radius;
_height=height;
_length=length;
_timePerSlide = timePerSlide;
_autoSteppingActive = autoSteppingActive;
_initSeperationX = offsetX;
_currentSeperationX = _initSeperationX;
_initSeperationY = offsetY;
_currentSeperationY = _initSeperationY;
initTexMatrices();
}
bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
switch(ea.getEventType())
@@ -279,22 +126,22 @@ bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction
_previousTime = ea.getTime();
return true;
}
else if ((ea.getKey()=='n') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_Right))
else if (ea.getKey()=='n')
{
nextSlide();
return true;
}
else if ((ea.getKey()=='p') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_Left))
else if (ea.getKey()=='p')
{
previousSlide();
return true;
}
else if ((ea.getKey()=='w') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Add))
else if (ea.getKey()=='w')
{
scaleImage(0.99f);
return true;
}
else if ((ea.getKey()=='s') || (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Subtract))
else if (ea.getKey()=='s')
{
scaleImage(1.01f);
return true;
@@ -387,38 +234,22 @@ void SlideEventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
void SlideEventHandler::nextSlide()
{
if (_switch->getNumChildren()==0) return;
++_activeSlide;
if (_activeSlide>=_switch->getNumChildren()) _activeSlide = 0;
if (_fileList.size()>0) {
if (_activeSlide>= _fileList.size()/2 ) _activeSlide = 0;
osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length);
if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get());
} else {
if (_activeSlide>=_switch->getNumChildren()) _activeSlide = 0;
_switch->setSingleChildOn(_activeSlide);
}
_switch->setSingleChildOn(_activeSlide);
}
void SlideEventHandler::previousSlide()
{
if (_switch->getNumChildren()==0) return;
if (_fileList.size()>0) {
if (_activeSlide==0) _activeSlide = _fileList.size()/2-1;
else --_activeSlide;
osg::ref_ptr<osg::Group> images = loadImages(_fileList[2*_activeSlide],_fileList[2*_activeSlide+1],_texmatLeft.get(),_texmatRight.get(),_radius,_height,_length);
if (images.valid()) _switch->replaceChild(_switch->getChild(0),images.get());
} else {
if (_activeSlide==0) _activeSlide = _switch->getNumChildren()-1;
else --_activeSlide;
if (_activeSlide==0) _activeSlide = _switch->getNumChildren()-1;
else --_activeSlide;
_switch->setSingleChildOn(_activeSlide);
}
_switch->setSingleChildOn(_activeSlide);
}
void SlideEventHandler::scaleImage(float s)
@@ -450,6 +281,115 @@ void SlideEventHandler::initTexMatrices()
}
osg::Geode* createSectorForImage(osg::Image* image, osg::TexMat* texmat, float s,float t, float radius, float height, float length)
{
int numSegments = 20;
float Theta = length/radius;
float dTheta = Theta/(float)(numSegments-1);
float ThetaZero = height*s/(t*radius);
// set up the texture.
osg::Texture2D* texture = new osg::Texture2D;
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
texture->setImage(image);
// set up the drawstate.
osg::StateSet* dstate = new osg::StateSet;
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OFF);
dstate->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
dstate->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
dstate->setTextureAttribute(0, texmat);
// set up the geoset.
osg::Geometry* geom = new osg::Geometry;
geom->setStateSet(dstate);
osg::Vec3Array* coords = new osg::Vec3Array();
osg::Vec2Array* tcoords = new osg::Vec2Array();
int i;
float angle = -Theta/2.0f;
for(i=0;
i<numSegments;
++i, angle+=dTheta)
{
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,height*0.5f)); // top
coords->push_back(osg::Vec3(sinf(angle)*radius,cosf(angle)*radius,-height*0.5f)); // bottom.
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,1.0f)); // top
tcoords->push_back(osg::Vec2(angle/ThetaZero+0.5f,0.0f)); // bottom.
}
osg::Vec4Array* colors = new osg::Vec4Array();
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
osg::DrawArrays* elements = new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,coords->size());
geom->setVertexArray(coords);
geom->setTexCoordArray(0,tcoords);
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
geom->addPrimitiveSet(elements);
// set up the geode.
osg::Geode* geode = new osg::Geode;
geode->addDrawable(geom);
return geode;
}
// create a switch containing a set of child each containing a
// stereo image pair.
osg::Switch* createScene(const FileList& fileList, osg::TexMat* texmatLeft, osg::TexMat* texmatRight, float radius, float height, float length)
{
osg::Switch* sw = new osg::Switch;
// load the images.
for(unsigned int i=0;i+1<fileList.size();i+=2)
{
osg::ref_ptr<osg::Image> imageLeft = osgDB::readImageFile(fileList[i]);
osg::ref_ptr<osg::Image> imageRight = osgDB::readImageFile(fileList[i+1]);
if (imageLeft.valid() && imageRight.valid())
{
float average_s = (imageLeft->s()+imageRight->s())*0.5f;
float average_t = (imageLeft->t()+imageRight->t())*0.5f;
osg::Geode* geodeLeft = createSectorForImage(imageLeft.get(),texmatLeft,average_s,average_t, radius, height, length);
geodeLeft->setNodeMask(0x01);
osg::Geode* geodeRight = createSectorForImage(imageRight.get(),texmatRight,average_s,average_t, radius, height, length);
geodeRight->setNodeMask(0x02);
osg::ref_ptr<osg::Group> imageGroup = new osg::Group;
imageGroup->addChild(geodeLeft);
imageGroup->addChild(geodeRight);
sw->addChild(imageGroup.get());
}
else
{
std::cout << "Warning: Unable to load both image files, '"<<fileList[i]<<"' & '"<<fileList[i+1]<<"', required for stereo imaging."<<std::endl;
}
}
if (sw->getNumChildren()>0)
{
// select first child.
sw->setSingleChildOn(0);
}
return sw;
}
int main( int argc, char **argv )
{
@@ -463,8 +403,6 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->addCommandLineOption("-a","Enter auto advance of image pairs on start up.");
arguments.getApplicationUsage()->addCommandLineOption("-x <float>","Horizontal offset of left and right images.");
arguments.getApplicationUsage()->addCommandLineOption("-y <float>","Vertical offset of left and right images.");
arguments.getApplicationUsage()->addCommandLineOption("--disk","Keep images on disk");
arguments.getApplicationUsage()->addCommandLineOption("-files <filename>","Load filenames from a file");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
@@ -492,22 +430,6 @@ int main( int argc, char **argv )
float offsetY=0.0f;
while (arguments.read("-y",offsetY)) {}
bool onDisk=false;
while (arguments.read("--disk")) { onDisk=true;}
std::string filename="";
FileList fileList;
// extract the filenames from the a file, one filename per line.
while (arguments.read("-files",filename)) {
std::ifstream is(filename.c_str());
if (is) {
std::string line;
while (std::getline(is,line,'\n')) fileList.push_back(line);
is.close();
}
}
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
@@ -534,6 +456,7 @@ int main( int argc, char **argv )
}
// extract the filenames from the arguments list.
FileList fileList;
for(int pos=1;pos<arguments.argc();++pos)
{
if (arguments.isString(pos)) fileList.push_back(arguments[pos]);
@@ -564,9 +487,8 @@ int main( int argc, char **argv )
osg::TexMat* texmatRight = new osg::TexMat;
// creat the scene from the file list.
osg::ref_ptr<osg::Switch> rootNode;
if (!onDisk) rootNode = createScene(fileList,texmatLeft,texmatRight,radius,height,length);
else rootNode=new osg::Switch();
osg::ref_ptr<osg::Switch> rootNode = createScene(fileList,texmatLeft,texmatRight,radius,height,length);
//osgDB::writeNodeFile(*rootNode,"test.osg");
@@ -599,8 +521,7 @@ int main( int argc, char **argv )
viewer.setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,radius);
// set up the SlideEventHandler.
if (onDisk) seh->set(fileList,rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,radius,height,length,timeDelayBetweenSlides,autoSteppingActive);
else seh->set(rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,timeDelayBetweenSlides,autoSteppingActive);
seh->set(rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,timeDelayBetweenSlides,autoSteppingActive);
osg::Matrix homePosition;
homePosition.makeLookAt(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f));

View File

@@ -332,22 +332,6 @@ osg::Geode* createTeapot()
int main(int , char **)
{
#if 1
// create viewer on heap as a test, this looks to be causing problems
// on init on some platforms, and seg fault on exit when multi-threading on linux.
// Normal stack based version below works fine though...
// construct the viewer.
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
// add model to viewer.
viewer->setSceneData( createTeapot() );
return viewer->run();
#else
// construct the viewer.
osgViewer::Viewer viewer;
@@ -356,6 +340,4 @@ int main(int , char **)
// create the windows and run the threads.
return viewer.run();
#endif
}

View File

@@ -1,8 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgterrain.cpp)
SET(TARGET_SRC osgterrain.cpp )
SET(TARGET_ADDED_LIBRARIES osgTerrain )
#### end var setup ###
SETUP_EXAMPLE(osgterrain)

View File

@@ -16,8 +16,6 @@
* THE SOFTWARE.
*/
#include <OpenThreads/Block>
#include <osg/Group>
#include <osg/Geode>
#include <osg/ShapeDrawable>
@@ -28,12 +26,9 @@
#include <osg/ClusterCullingCallback>
#include <osg/ArgumentParser>
#include <osgDB/FileUtils>
#include <osgDB/ReadFile>
#include <osgUtil/GLObjectsVisitor>
#include <osgText/FadeText>
#include <osgViewer/Viewer>
@@ -47,539 +42,22 @@
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>
#include <osgTerrain/Terrain>
#include <osgTerrain/TerrainNode>
#include <osgTerrain/GeometryTechnique>
#include <osgTerrain/Layer>
#include <iostream>
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
class LoadAndCompileOperation : public osg::Operation
{
public:
LoadAndCompileOperation(const std::string& filename, GraphicsThreads& graphicsThreads, osg::RefBlockCount* block):
Operation("Load and compile Operation", false),
_filename(filename),
_graphicsThreads(graphicsThreads),
_block(block) {}
virtual void operator () (osg::Object* object)
{
// osg::notify(osg::NOTICE)<<"LoadAndCompileOperation "<<_filename<<std::endl;
_loadedModel = osgDB::readNodeFile(_filename);
if (_loadedModel.valid() && !_graphicsThreads.empty())
{
osg::ref_ptr<osgUtil::GLObjectsOperation> compileOperation = new osgUtil::GLObjectsOperation(_loadedModel.get());
for(GraphicsThreads::iterator gitr = _graphicsThreads.begin();
gitr != _graphicsThreads.end();
++gitr)
{
(*gitr)->add( compileOperation.get() );
// requiresBarrier = true;
}
}
if (_block.valid()) _block->completed();
// osg::notify(osg::NOTICE)<<"done LoadAndCompileOperation "<<_filename<<std::endl;
}
std::string _filename;
GraphicsThreads _graphicsThreads;
osg::ref_ptr<osg::Node> _loadedModel;
osg::ref_ptr<osg::RefBlockCount> _block;
};
class MasterOperation : public osg::Operation
{
public:
typedef std::set<std::string> Files;
typedef std::map<std::string, osg::ref_ptr<osg::Node> > FilenameNodeMap;
typedef std::vector< osg::ref_ptr<osg::Node> > Nodes;
MasterOperation(const std::string& filename):
Operation("Master reading operation",true),
_filename(filename)
{
}
/** Set the OperationQueue that the MasterOperation can use to place tasks like file loading on for other processes to handle.*/
void setOperationQueue(osg::OperationQueue* oq) { _operationQueue = oq; }
osg::OperationQueue* getOperationQueue() { return _operationQueue.get(); }
bool readMasterFile(Files& files) const
{
std::ifstream fin(_filename.c_str());
if (fin)
{
osgDB::Input fr;
fr.attach(&fin);
bool readFilename;
while(!fr.eof())
{
bool itrAdvanced = false;
if (fr.matchSequence("file %s") || fr.matchSequence("file %w") )
{
files.insert(fr[1].getStr());
fr += 2;
itrAdvanced = true;
readFilename = true;
}
if (!itrAdvanced)
{
++fr;
}
}
return readFilename;
}
return false;
}
bool open(osg::Group* group)
{
Files files;
readMasterFile(files);
for(Files::iterator itr = files.begin();
itr != files.end();
++itr)
{
osg::Node* model = osgDB::readNodeFile(*itr);
if (model)
{
osg::notify(osg::NOTICE)<<"open: Loaded file "<<*itr<<std::endl;
group->addChild(model);
_existingFilenameNodeMap[*itr] = model;
}
}
return true;
}
virtual void operator () (osg::Object* callingObject)
{
// decided which method to call according to whole has called me.
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(callingObject);
if (viewer) update(viewer->getSceneData());
else load();
}
void load()
{
//osg::notify(osg::NOTICE)<<"void load(Object)"<<std::endl;
Files filesA;
Files filesB;
readMasterFile(filesB);
// osg::notify(osg::NOTICE)<<"First read "<<filesA.size()<<std::endl;
// itererate until the master file is stable
do
{
OpenThreads::Thread::microSleep(100000);
filesB.swap(filesA);
filesB.clear();
readMasterFile(filesB);
// osg::notify(osg::NOTICE)<<"second read "<<filesB.size()<<std::endl;
} while (filesA!=filesB);
Files files;
files.swap(filesB);
// osg::notify(osg::NOTICE)<<"Now equal "<<files.size()<<std::endl;
Files newFiles;
Files removedFiles;
// find out which files are new, and which ones have been removed.
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
for(Files::iterator fitr = files.begin();
fitr != files.end();
++fitr)
{
if (_existingFilenameNodeMap.count(*fitr)==0) newFiles.insert(*fitr);
}
for(FilenameNodeMap::iterator litr = _existingFilenameNodeMap.begin();
litr != _existingFilenameNodeMap.end();
++litr)
{
if (files.count(litr->first)==0)
{
removedFiles.insert(litr->first);
}
}
}
#if 0
if (!newFiles.empty() || !removedFiles.empty())
{
osg::notify(osg::NOTICE)<<std::endl<<std::endl<<"void operator () files.size()="<<files.size()<<std::endl;
}
#endif
// first load the new files.
FilenameNodeMap nodesToAdd;
if (!newFiles.empty())
{
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
GraphicsThreads threads;
for(unsigned int i=0; i<= osg::GraphicsContext::getMaxContextID(); ++i)
{
osg::GraphicsContext* gc = osg::GraphicsContext::getCompileContext(i);
osg::GraphicsThread* gt = gc ? gc->getGraphicsThread() : 0;
if (gt) threads.push_back(gt);
}
bool requiresBarrier = false;
if (_operationQueue.valid())
{
// osg::notify(osg::NOTICE)<<"Using OperationQueue"<<std::endl;
_endOfLoadBlock = new osg::RefBlockCount(newFiles.size());
_endOfLoadBlock->reset();
typedef std::list< osg::ref_ptr<LoadAndCompileOperation> > LoadAndCompileList;
LoadAndCompileList loadAndCompileList;
for(Files::iterator nitr = newFiles.begin();
nitr != newFiles.end();
++nitr)
{
// osg::notify(osg::NOTICE)<<"Adding LoadAndCompileOperation "<<*nitr<<std::endl;
osg::ref_ptr<LoadAndCompileOperation> loadAndCompile = new LoadAndCompileOperation( *nitr, threads, _endOfLoadBlock.get() );
loadAndCompileList.push_back(loadAndCompile);
_operationQueue->add( loadAndCompile.get() );
}
#if 1
osg::ref_ptr<osg::Operation> operation;
while ((operation=_operationQueue->getNextOperation()).valid())
{
// osg::notify(osg::NOTICE)<<"Local running of operation"<<std::endl;
(*operation)(0);
}
#endif
// osg::notify(osg::NOTICE)<<"Waiting for completion of LoadAndCompile operations"<<std::endl;
_endOfLoadBlock->block();
// osg::notify(osg::NOTICE)<<"done ... Waiting for completion of LoadAndCompile operations"<<std::endl;
for(LoadAndCompileList::iterator litr = loadAndCompileList.begin();
litr != loadAndCompileList.end();
++litr)
{
if ((*litr)->_loadedModel.valid())
{
nodesToAdd[(*litr)->_filename] = (*litr)->_loadedModel;
requiresBarrier = true;
}
}
}
else
{
for(Files::iterator nitr = newFiles.begin();
nitr != newFiles.end();
++nitr)
{
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(*nitr);
if (loadedModel.get())
{
nodesToAdd[*nitr] = loadedModel;
osg::ref_ptr<osgUtil::GLObjectsOperation> compileOperation = new osgUtil::GLObjectsOperation(loadedModel.get());
for(GraphicsThreads::iterator gitr = threads.begin();
gitr != threads.end();
++gitr)
{
(*gitr)->add( compileOperation.get() );
requiresBarrier = true;
}
}
}
}
if (requiresBarrier)
{
_endOfCompilebarrier = new osg::BarrierOperation(threads.size()+1);
_endOfCompilebarrier->setKeep(false);
for(GraphicsThreads::iterator gitr = threads.begin();
gitr != threads.end();
++gitr)
{
(*gitr)->add(_endOfCompilebarrier.get());
}
// osg::notify(osg::NOTICE)<<"Waiting for Compile to complete"<<std::endl;
// wait for the graphics threads to complete.
_endOfCompilebarrier->block();
// osg::notify(osg::NOTICE)<<"done ... Waiting for Compile to complete"<<std::endl;
}
}
bool requiresBlock = false;
// pass the locally peppared data to MasterOperations shared data
// so that updated thread can merge these changes with the main scene
// graph. This merge is carried out via the update(..) method.
if (!removedFiles.empty() || !nodesToAdd.empty())
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
_nodesToRemove.swap(removedFiles);
_nodesToAdd.swap(nodesToAdd);
requiresBlock = true;
}
// now block so we don't try to load anything till the new data has been merged
// otherwise _existingFilenameNodeMap will get out of sync.
if (requiresBlock)
{
_updatesMergedBlock.block();
}
else
{
OpenThreads::Thread::YieldCurrentThread();
}
}
// merge the changes with the main scene graph.
void update(osg::Node* scene)
{
// osg::notify(osg::NOTICE)<<"void update(Node*)"<<std::endl;
osg::Group* group = dynamic_cast<osg::Group*>(scene);
if (!group)
{
osg::notify(osg::NOTICE)<<"Error, MasterOperation::update(Node*) can only work with a Group as Viewer::getSceneData()."<<std::endl;
return;
}
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (!_nodesToRemove.empty() || !_nodesToAdd.empty())
{
osg::notify(osg::NOTICE)<<"update().................. "<<std::endl;
}
if (!_nodesToRemove.empty())
{
for(Files::iterator itr = _nodesToRemove.begin();
itr != _nodesToRemove.end();
++itr)
{
FilenameNodeMap::iterator fnmItr = _existingFilenameNodeMap.find(*itr);
if (fnmItr != _existingFilenameNodeMap.end())
{
osg::notify(osg::NOTICE)<<" update():removing "<<*itr<<std::endl;
group->removeChild(fnmItr->second.get());
_existingFilenameNodeMap.erase(fnmItr);
}
}
_nodesToRemove.clear();
}
if (!_nodesToAdd.empty())
{
for(FilenameNodeMap::iterator itr = _nodesToAdd.begin();
itr != _nodesToAdd.end();
++itr)
{
osg::notify(osg::NOTICE)<<" update():inserting "<<itr->first<<std::endl;
group->addChild(itr->second.get());
_existingFilenameNodeMap[itr->first] = itr->second;
}
_nodesToAdd.clear();
}
_updatesMergedBlock.release();
}
// add release implementation so that any thread cancellation can
// work even when blocks and barriers are used.
virtual void release()
{
if (_operationQueue.valid()) _operationQueue->removeAllOperations();
_updatesMergedBlock.release();
if (_endOfCompilebarrier.valid()) _endOfCompilebarrier.release();
if (_endOfLoadBlock.valid()) _endOfLoadBlock.release();
}
std::string _filename;
OpenThreads::Mutex _mutex;
FilenameNodeMap _existingFilenameNodeMap;
Files _nodesToRemove;
FilenameNodeMap _nodesToAdd;
OpenThreads::Block _updatesMergedBlock;
osg::ref_ptr<osg::BarrierOperation> _endOfCompilebarrier;
osg::ref_ptr<osg::RefBlockCount> _endOfLoadBlock;
osg::ref_ptr<osg::OperationQueue> _operationQueue;
};
class FilterHandler : public osgGA::GUIEventHandler
{
public:
FilterHandler(osgTerrain::GeometryTechnique* gt):
_gt(gt) {}
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
{
if (!_gt) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey() == 'g')
{
osg::notify(osg::NOTICE)<<"Gaussian"<<std::endl;
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::GAUSSIAN);
return true;
}
else if (ea.getKey() == 's')
{
osg::notify(osg::NOTICE)<<"Smooth"<<std::endl;
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SMOOTH);
return true;
}
else if (ea.getKey() == 'S')
{
osg::notify(osg::NOTICE)<<"Sharpen"<<std::endl;
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SHARPEN);
return true;
}
else if (ea.getKey() == '+')
{
_gt->setFilterWidth(_gt->getFilterWidth()*1.1);
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
return true;
}
else if (ea.getKey() == '-')
{
_gt->setFilterWidth(_gt->getFilterWidth()/1.1);
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
return true;
}
else if (ea.getKey() == '>')
{
_gt->setFilterBias(_gt->getFilterBias()+0.1);
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
return true;
}
else if (ea.getKey() == '<')
{
_gt->setFilterBias(_gt->getFilterBias()-0.1);
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
return true;
}
break;
}
default:
break;
}
return false;
}
protected:
osg::observer_ptr<osgTerrain::GeometryTechnique> _gt;
};
class LayerHandler : public osgGA::GUIEventHandler
{
public:
LayerHandler(osgTerrain::Layer* layer):
_layer(layer) {}
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
{
if (!_layer) return false;
float scale = 1.2;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey() == 'q')
{
_layer->transform(0.0, scale);
return true;
}
else if (ea.getKey() == 'a')
{
_layer->transform(0.0, 1.0f/scale);
return true;
}
break;
}
default:
break;
}
return false;
}
protected:
osg::observer_ptr<osgTerrain::Layer> _layer;
};
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
// construct the viewer.
osgViewer::Viewer viewer(arguments);
osgViewer::Viewer viewer;
// set up the camera manipulators.
{
@@ -614,33 +92,14 @@ int main(int argc, char** argv)
// add the stats handler
viewer.addEventHandler(new osgViewer::StatsHandler);
// add the record camera path handler
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
double x = 0.0;
double y = 0.0;
double w = 1.0;
double h = 1.0;
unsigned int numLoadThreads = 1;
while (arguments.read("--load-threads",numLoadThreads)) { }
osg::ref_ptr<MasterOperation> masterOperation;
std::string masterFilename;
while(arguments.read("-m",masterFilename))
{
masterOperation = new MasterOperation(masterFilename);
}
osg::ref_ptr<osgTerrain::Terrain> terrain = new osgTerrain::Terrain;
osg::ref_ptr<osgTerrain::Locator> locator = new osgTerrain::Locator;
osg::ref_ptr<osgTerrain::TerrainNode> terrain = new osgTerrain::TerrainNode;
osg::ref_ptr<osgTerrain::Locator> locator = new osgTerrain::EllipsoidLocator(-osg::PI, -osg::PI*0.5, 2.0*osg::PI, osg::PI, 0.0);
osg::ref_ptr<osgTerrain::ValidDataOperator> validDataOperator = new osgTerrain::NoDataValue(0.0);
osg::ref_ptr<osgTerrain::Layer> lastAppliedLayer;
locator->setCoordinateSystemType(osgTerrain::Locator::GEOCENTRIC);
locator->setTransformAsExtents(-osg::PI, -osg::PI*0.5, osg::PI, osg::PI*0.5);
unsigned int layerNum = 0;
@@ -671,8 +130,7 @@ int main(int argc, char** argv)
else if (arguments.read(pos, "-e",x,y,w,h))
{
// define the extents.
locator->setCoordinateSystemType(osgTerrain::Locator::GEOCENTRIC);
locator->setTransformAsExtents(x,y,x+w,y+h);
locator = new osgTerrain::EllipsoidLocator(x,y,w,h,0);
readParameter = true;
}
@@ -682,11 +140,11 @@ int main(int argc, char** argv)
readParameter = true;
}
else if (arguments.read(pos, "--cartesian",x,y,w,h))
else if (arguments.read(pos, "--cartizian",x,y,w,h))
{
// define the extents.
locator->setCoordinateSystemType(osgTerrain::Locator::PROJECTED);
locator->setTransformAsExtents(x,y,x+w,y+h);
locator = new osgTerrain::CartizianLocator(x,y,w,h,0);
readParameter = true;
}
else if (arguments.read(pos, "--hf",filename))
@@ -711,8 +169,6 @@ int main(int argc, char** argv)
terrain->setElevationLayer(hfl.get());
lastAppliedLayer = hfl.get();
osg::notify(osg::NOTICE)<<"created osgTerrain::HeightFieldLayer"<<std::endl;
}
else
@@ -745,8 +201,6 @@ int main(int argc, char** argv)
terrain->setElevationLayer(imageLayer.get());
lastAppliedLayer = imageLayer.get();
osg::notify(osg::NOTICE)<<"created Elevation osgTerrain::ImageLayer"<<std::endl;
}
else
@@ -778,9 +232,7 @@ int main(int argc, char** argv)
}
terrain->setColorLayer(layerNum, imageLayer.get());
lastAppliedLayer = imageLayer.get();
osg::notify(osg::NOTICE)<<"created Color osgTerrain::ImageLayer"<<std::endl;
}
else
@@ -800,12 +252,12 @@ int main(int argc, char** argv)
if (filterName=="NEAREST")
{
osg::notify(osg::NOTICE)<<"--filter "<<filterName<<std::endl;
terrain->setColorFilter(layerNum, osgTerrain::Terrain::NEAREST);
terrain->setColorFilter(layerNum, osgTerrain::TerrainNode::NEAREST);
}
else if (filterName=="LINEAR")
else if (filterName=="LINEAER")
{
osg::notify(osg::NOTICE)<<"--filter "<<filterName<<std::endl;
terrain->setColorFilter(layerNum, osgTerrain::Terrain::LINEAR);
terrain->setColorFilter(layerNum, osgTerrain::TerrainNode::LINEAR);
}
else
{
@@ -842,75 +294,16 @@ int main(int argc, char** argv)
}
osg::ref_ptr<osg::Group> scene = new osg::Group;
if (terrain.valid() && (terrain->getElevationLayer() || terrain->getColorLayer(0)))
{
osg::notify(osg::NOTICE)<<"Terrain created"<<std::endl;
osg::ref_ptr<osgTerrain::GeometryTechnique> geometryTechnique = new osgTerrain::GeometryTechnique;
scene->addChild(terrain.get());
osg::ref_ptr<osgTerrain::GeometryTechnique> geometryTechnique = new osgTerrain::GeometryTechnique;
terrain->setTerrainTechnique(geometryTechnique.get());
viewer.addEventHandler(new FilterHandler(geometryTechnique.get()));
viewer.addEventHandler(new LayerHandler(lastAppliedLayer.get()));
}
if (masterOperation.valid())
{
osg::notify(osg::NOTICE)<<"Master operation created"<<std::endl;
masterOperation->open(scene.get());
}
terrain->setTerrainTechnique(geometryTechnique.get());
if (scene->getNumChildren()==0)
{
osg::notify(osg::NOTICE)<<"No model created, please specify terrain or master file on command line."<<std::endl;
return 0;
}
if (!terrain) return 0;
viewer.setSceneData(scene.get());
// return 0;
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData(terrain.get());
// start operation thread if a master file has been used.
osg::ref_ptr<osg::OperationThread> masterOperationThread;
typedef std::list< osg::ref_ptr<osg::OperationThread> > OperationThreadList;
OperationThreadList generalThreadList;
if (masterOperation.valid())
{
masterOperationThread = new osg::OperationThread;
masterOperationThread->startThread();
masterOperationThread->add(masterOperation.get());
// if (numLoadThreads>0)
{
osg::ref_ptr<osg::OperationQueue> operationQueue = new osg::OperationQueue;
masterOperation->setOperationQueue(operationQueue.get());
for(unsigned int i=0; i<numLoadThreads; ++i)
{
osg::ref_ptr<osg::OperationThread> thread = new osg::OperationThread;
thread->setOperationQueue(operationQueue.get());
thread->startThread();
generalThreadList.push_back(thread);
}
}
viewer.addUpdateOperation(masterOperation.get());
}
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
// enable the use of compile contexts and associated threads.
osg::DisplaySettings::instance()->setCompileContextsHint(true);
// realize the graphics windows.
viewer.realize();
// run the viewers main loop
return viewer.run();
}

View File

@@ -23,14 +23,11 @@
#include <osgDB/Registry>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osg/Geode>
#include <osg/Camera>
#include <osg/ShapeDrawable>
#include <osg/Sequence>
#include <osg/PolygonMode>
#include <osg/io_utils>
#include <osgText/Font>
#include <osgText/Text>
@@ -477,182 +474,13 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
return rootNode;
}
class UpdateTextOperation : public osg::Operation
int main(int , char **)
{
public:
UpdateTextOperation(osg::Group* group):
Operation("UpdateTextOperation", true),
_maxNumChildren(200),
_maxNumTextPerGeode(10),
_group(group)
{
}
virtual void operator () (osg::Object* callingObject)
{
// decided which method to call according to whole has called me.
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(callingObject);
if (viewer) update();
else load();
}
void update()
{
// osg::notify(osg::NOTICE)<<"*** Doing update"<<std::endl;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (_mergeSubgraph.valid())
{
_group->addChild(_mergeSubgraph.get());
_mergeSubgraph = 0;
if (_group->getNumChildren()>_maxNumChildren)
{
osg::Geode* geode = dynamic_cast<osg::Geode*>(_group->getChild(0));
if (geode)
{
_availableSubgraph.push_back(geode);
geode->removeDrawables(0,geode->getNumDrawables());
}
_group->removeChild(0,1);
}
_waitOnMergeBlock.release();
}
}
void load()
{
// osg::notify(osg::NOTICE)<<"Doing load"<<std::endl;
osg::ref_ptr<osg::Geode> geode;
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (!_availableSubgraph.empty())
{
geode = _availableSubgraph.front();
_availableSubgraph.pop_front();
}
}
if (!geode) geode = new osg::Geode;
for(unsigned int i=0; i<_maxNumTextPerGeode; ++i)
{
osg::Vec3 position(float(rand()) / float(RAND_MAX), float(rand()) / float(RAND_MAX), float(i)/float(_maxNumTextPerGeode));
std::string str;
unsigned int _numCharacters = 5;
for(unsigned int ni=0; ni<_numCharacters;++ni)
{
str.push_back(char(32.0 + (float(rand())/float(RAND_MAX))*128.0f));
}
osgText::Text* text = new osgText::Text;
text->setDataVariance(osg::Object::DYNAMIC);
text->setPosition(position);
text->setFont("times.ttf");
text->setText(str);
text->setCharacterSize(0.025f);
text->setAxisAlignment(osgText::Text::SCREEN);
geode->addDrawable(text);
}
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
_mergeSubgraph = geode;
}
// osg::notify(osg::NOTICE)<<"Waiting on merge"<<std::endl;
_waitOnMergeBlock.block();
}
virtual void release()
{
_waitOnMergeBlock.release();
}
typedef std::list< osg::ref_ptr<osg::Geode> > AvailableList;
unsigned int _maxNumChildren;
unsigned int _maxNumTextPerGeode;
OpenThreads::Mutex _mutex;
osg::ref_ptr<osg::Group> _group;
osg::ref_ptr<osg::Geode> _mergeSubgraph;
AvailableList _availableSubgraph;
OpenThreads::Block _waitOnMergeBlock;
unsigned int _counter;
};
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
// construct the viewer.
osgViewer::Viewer viewer(arguments);
typedef std::list< osg::ref_ptr<osg::OperationThread> > Threads;
osgViewer::Viewer viewer;
Threads operationThreads;
osg::ref_ptr<UpdateTextOperation> updateOperation;
unsigned int numThreads = 0;
if (arguments.read("--mt", numThreads) || arguments.read("--mt"))
// prepare scene.
{
// construct a multi-threaded text updating test.
if (numThreads==0) numThreads = 1;
// create a group to add everything into.
osg::Group* mainGroup = new osg::Group;
for(unsigned int i=0; i<numThreads; ++i)
{
osg::Group* textGroup = new osg::Group;
mainGroup->addChild(textGroup);
// create the background thread
osg::OperationThread* operationThread = new osg::OperationThread;
operationThreads.push_back(operationThread);
// create the operation that will run in the background and
// sync once per frame with the main viewer loop.
updateOperation = new UpdateTextOperation(textGroup);
// add the operation to the operation thread and start it.
operationThread->add(updateOperation.get());
operationThread->startThread();
// add the operation to the viewer to sync once per frame.
viewer.addUpdateOperation(updateOperation.get());
// add a unit cube for the text to appear within.
osg::Geode* geode = new osg::Geode;
geode->getOrCreateStateSet()->setAttribute(new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE));
geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.5f,0.5f,0.5f),1.0)));
mainGroup->addChild(geode);
}
viewer.setSceneData(mainGroup);
}
else
{
// prepare scene.
osg::Vec3 center(0.0f,0.0f,0.0f);
float radius = 1.0f;
@@ -678,22 +506,8 @@ int main(int argc, char** argv)
viewer.setSceneData(group);
}
#if 0
osgDB::writeNodeFile(*viewer.getSceneData(),"text.osg");
#endif
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.run();
if (!operationThreads.empty())
{
for(Threads::iterator itr = operationThreads.begin();
itr != operationThreads.end();
++itr)
{
(*itr)->cancel();
}
}
return viewer.run();
}

View File

@@ -24,8 +24,6 @@
#include <osg/Timer>
#include <osg/io_utils>
#include <OpenThreads/Thread>
#include "UnitTestFramework.h"
#include "performance.h"
@@ -277,20 +275,14 @@ void testGetQuatFromMatrix(const osg::Vec3d& scale)
osg::Quat out_quat2;
out_quat2 = out_mat.getRotate();
// If the quaternion W is <0, then we should reflect
// to get it into the positive W
if(out_quat1.w()<0) out_quat1 = out_quat1 * -1.0;
if(out_quat2.w()<0) out_quat2 = out_quat2 * -1.0;
// if the output quat length is not one
// or if the components do not match,
// or if the component magnitudes do not match,
// something is amiss
if (fabs(1.0-out_quat2.length()) > eps ||
(fabs(out_quat1.x()-out_quat2.x())) > eps ||
(fabs(out_quat1.y()-out_quat2.y())) > eps ||
(fabs(out_quat1.z()-out_quat2.z())) > eps ||
(fabs(out_quat1.w()-out_quat2.w())) > eps) {
(fabs(out_quat1.x())-fabs(out_quat2.x())) > eps ||
(fabs(out_quat1.y())-fabs(out_quat2.y())) > eps ||
(fabs(out_quat1.z())-fabs(out_quat2.z())) > eps ||
(fabs(out_quat1.w())-fabs(out_quat2.w())) > eps) {
std::cout << __FUNCTION__ << " problem at: \n"
<< " r1=" << rol1
<< " p1=" << pit1
@@ -383,26 +375,6 @@ void testQuat(const osg::Vec3d& quat_scale)
osg::notify(osg::NOTICE)<<"Matrix = "<<matrix<<"rotation = "<<quat<<", expected quat = (0,0,0,1)"<<std::endl;
}
class MyThread : public OpenThreads::Thread {
public:
void run(void) { }
};
void testThreadInitAndExit()
{
std::cout<<"****** Running thread start and delete test ****** "<<std::endl;
{
MyThread thread;
thread.startThread();
}
// add a sleep to allow the thread start to fall over it its going to.
OpenThreads::Thread::microSleep(500000);
std::cout<<"pass thread start and delete test"<<std::endl<<std::endl;
}
int main( int argc, char** argv )
{
@@ -436,10 +408,7 @@ int main( int argc, char** argv )
while (arguments.read("sizeof")) printSizeOfTest = true;
bool printQuatTest = false;
while (arguments.read("quat")) printQuatTest = true;
bool doTestThreadInitAndExit = false;
while (arguments.read("thread")) doTestThreadInitAndExit = true;
while (arguments.read("quat")) printQuatTest = true;
osg::Vec3d quat_scale(1.0,1.0,1.0);
while (arguments.read("quat_scaled", quat_scale.x(), quat_scale.y(), quat_scale.z() )) printQuatTest = true;
@@ -526,11 +495,6 @@ int main( int argc, char** argv )
std::cout<<std::endl;
}
if (doTestThreadInitAndExit)
{
testThreadInitAndExit();
}
std::cout<<"****** Running tests ******"<<std::endl;
// Global Data or Context

View File

@@ -102,7 +102,6 @@ class ViewerFLTK : public osgViewer::Viewer, public AdapterWidget
AdapterWidget(x,y,w,h,label)
{
getCamera()->setViewport(new osg::Viewport(0,0,w,h));
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(w)/static_cast<double>(h), 1.0f, 10000.0f);
getCamera()->setGraphicsContext(getGraphicsWindow());
setThreadingModel(osgViewer::Viewer::SingleThreaded);
}

View File

@@ -1,9 +0,0 @@
SET(TARGET_SRC FOX_OSG.cpp FOX_OSG_MDIView.cpp osgviewerFOX.cpp )
SET(TARGET_H FOX_OSG.h FOX_OSG_MDIView.h osgviewerFOX.h)
INCLUDE_DIRECTORIES( ${FOX_INCLUDE_DIR} )
SET(TARGET_EXTERNAL_LIBRARIES ${FOX_LIBRARY} )
#### end var setup ###
SETUP_EXAMPLE(osgviewerFOX)

View File

@@ -1,193 +0,0 @@
#include <iostream>
#include "FOX_OSG.h"
// Map
FXDEFMAP(GraphicsWindowFOX) GraphicsWindowFOX_Map[] = {
//________Message_Type_________ ___ID___ ________Message_Handler________
FXMAPFUNC(SEL_CONFIGURE, 0, GraphicsWindowFOX::onConfigure),
FXMAPFUNC(SEL_KEYPRESS, 0, GraphicsWindowFOX::onKeyPress),
FXMAPFUNC(SEL_KEYRELEASE, 0, GraphicsWindowFOX::onKeyRelease),
FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, GraphicsWindowFOX::onLeftBtnPress),
FXMAPFUNC(SEL_LEFTBUTTONRELEASE, 0, GraphicsWindowFOX::onLeftBtnRelease),
FXMAPFUNC(SEL_MIDDLEBUTTONPRESS, 0, GraphicsWindowFOX::onMiddleBtnPress),
FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE, 0, GraphicsWindowFOX::onMiddleBtnRelease),
FXMAPFUNC(SEL_RIGHTBUTTONPRESS, 0, GraphicsWindowFOX::onRightBtnPress),
FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, 0, GraphicsWindowFOX::onRightBtnRelease),
FXMAPFUNC(SEL_MOTION, 0, GraphicsWindowFOX::onMotion)
};
FXIMPLEMENT(GraphicsWindowFOX, FXGLCanvas, GraphicsWindowFOX_Map, ARRAYNUMBER(GraphicsWindowFOX_Map))
GraphicsWindowFOX::GraphicsWindowFOX(FXComposite *parent, FXGLVisual *vis,
FXObject *tgt, FXSelector sel,
FXuint opts, FXint x, FXint y,
FXint w, FXint h)
: FXGLCanvas(parent, vis, tgt, sel, opts, x, y, w, h)
{
// default cursor to standard
_oldCursor = new FXCursor(parent->getApp(),CURSOR_CROSS);
_traits = new GraphicsContext::Traits;
_traits->x = x;
_traits->y = y;
_traits->width = w;
_traits->height = h;
_traits->windowDecoration = false;
_traits->doubleBuffer = true;
_traits->sharedContext = 0;
init();
}
void GraphicsWindowFOX::init()
{
if (valid())
{
setState( new osg::State );
getState()->setGraphicsContext(this);
if (_traits.valid() && _traits->sharedContext)
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
}
}
}
GraphicsWindowFOX::~GraphicsWindowFOX()
{
}
void GraphicsWindowFOX::grabFocus()
{
// focus this window
setFocus();
}
void GraphicsWindowFOX::grabFocusIfPointerInWindow()
{
// do nothing
}
void GraphicsWindowFOX::useCursor(bool cursorOn)
{
if (cursorOn) {
// show the old cursor
setDefaultCursor(_oldCursor);
}
else {
setDefaultCursor(NULL);
}
}
bool GraphicsWindowFOX::makeCurrentImplementation()
{
FXGLCanvas::makeCurrent();
return true;
}
bool GraphicsWindowFOX::releaseContext()
{
FXGLCanvas::makeNonCurrent();
return true;
}
void GraphicsWindowFOX::swapBuffersImplementation()
{
FXGLCanvas::swapBuffers();
}
long GraphicsWindowFOX::onConfigure(FXObject *sender, FXSelector sel, void* ptr)
{
// set GL viewport (not called by FXGLCanvas::onConfigure on all platforms...)
// update the window dimensions, in case the window has been resized.
getEventQueue()->windowResize(0, 0, getWidth(), getHeight());
resized(0, 0, getWidth(), getHeight());
return FXGLCanvas::onConfigure(sender, sel, ptr);
}
long GraphicsWindowFOX::onKeyPress(FXObject *sender, FXSelector sel, void* ptr)
{
int key = ((FXEvent*)ptr)->code;
getEventQueue()->keyPress(key);
return FXGLCanvas::onKeyPress(sender, sel, ptr);
}
long GraphicsWindowFOX::onKeyRelease(FXObject *sender, FXSelector sel, void* ptr)
{
int key = ((FXEvent*)ptr)->code;
getEventQueue()->keyRelease(key);
return FXGLCanvas::onKeyRelease(sender, sel, ptr);
}
long GraphicsWindowFOX::onLeftBtnPress(FXObject *sender, FXSelector sel, void* ptr)
{
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
FXEvent* event=(FXEvent*)ptr;
getEventQueue()->mouseButtonPress(event->click_x, event->click_y, 1);
return FXGLCanvas::onLeftBtnPress(sender, sel, ptr);
}
long GraphicsWindowFOX::onLeftBtnRelease(FXObject *sender, FXSelector sel, void* ptr)
{
FXEvent* event=(FXEvent*)ptr;
getEventQueue()->mouseButtonRelease(event->click_x, event->click_y, 1);
return FXGLCanvas::onLeftBtnRelease(sender, sel, ptr);
}
long GraphicsWindowFOX::onMiddleBtnPress(FXObject *sender, FXSelector sel, void* ptr)
{
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
FXEvent* event=(FXEvent*)ptr;
getEventQueue()->mouseButtonPress(event->click_x, event->click_y, 2);
return FXGLCanvas::onMiddleBtnPress(sender, sel, ptr);
}
long GraphicsWindowFOX::onMiddleBtnRelease(FXObject *sender, FXSelector sel, void* ptr)
{
FXEvent* event=(FXEvent*)ptr;
getEventQueue()->mouseButtonRelease(event->click_x, event->click_y, 2);
return FXGLCanvas::onMiddleBtnRelease(sender, sel, ptr);
}
long GraphicsWindowFOX::onRightBtnPress(FXObject *sender, FXSelector sel, void* ptr)
{
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
FXEvent* event=(FXEvent*)ptr;
getEventQueue()->mouseButtonPress(event->click_x, event->click_y, 3);
return FXGLCanvas::onRightBtnPress(sender, sel, ptr);
}
long GraphicsWindowFOX::onRightBtnRelease(FXObject *sender, FXSelector sel, void* ptr)
{
FXEvent* event=(FXEvent*)ptr;
getEventQueue()->mouseButtonRelease(event->click_x, event->click_y, 3);
return FXGLCanvas::onRightBtnRelease(sender, sel, ptr);
}
long GraphicsWindowFOX::onMotion(FXObject *sender, FXSelector sel, void* ptr)
{
FXEvent* event=(FXEvent*)ptr;
getEventQueue()->mouseMotion(event->win_x, event->win_y);
return FXGLCanvas::onMotion(sender, sel, ptr);
}

View File

@@ -1,63 +0,0 @@
#ifndef _FOXOSG_H_
#define _FOXOSG_H_
#include <osgViewer/Viewer>
#include <string>
#include <fx.h>
#include <fx3d.h>
using namespace FX;
class GraphicsWindowFOX: public FXGLCanvas, public osgViewer::GraphicsWindow{
FXDECLARE(GraphicsWindowFOX)
public:
GraphicsWindowFOX(FXComposite *parent, FXGLVisual *vis,
FXObject *tgt=NULL, FXSelector sel=0,
FXuint opts=0, FXint x=0, FXint y=0,
FXint w=0, FXint h=0);
virtual ~GraphicsWindowFOX();
// callback
long onConfigure(FXObject*, FXSelector, void*);
long onKeyPress(FXObject*, FXSelector, void*);
long onKeyRelease(FXObject*, FXSelector, void*);
long onLeftBtnPress(FXObject*, FXSelector, void*);
long onLeftBtnRelease(FXObject*, FXSelector, void*);
long onMiddleBtnPress(FXObject*, FXSelector, void*);
long onMiddleBtnRelease(FXObject*, FXSelector, void*);
long onRightBtnPress(FXObject*, FXSelector, void*);
long onRightBtnRelease(FXObject*, FXSelector, void*);
long onMotion(FXObject*, FXSelector, void*);
void init();
//
// GraphicsWindow interface
//
void grabFocus();
void grabFocusIfPointerInWindow();
void useCursor(bool cursorOn);
bool makeCurrentImplementation();
bool releaseContext();
void swapBuffersImplementation();
// note implemented yet...just use dummy implementation to get working.
virtual bool valid() const { return true; }
virtual bool realizeImplementation() { return true; }
virtual bool isRealizedImplementation() const { return true; }
virtual void closeImplementation() {}
virtual bool releaseContextImplementation() { return true; }
protected:
GraphicsWindowFOX(){};
private:
FXCursor* _oldCursor;
};
#endif // _FOXOSG_H_

View File

@@ -1,77 +0,0 @@
#include "FOX_OSG_MDIView.h"
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
// Map
FXDEFMAP(FOX_OSG_MDIView) FOX_OSG_MDIView_Map[] = {
//________Message_Type_________ ___ID___ ________Message_Handler________
FXMAPFUNC(SEL_CHORE, FOX_OSG_MDIView::ID_CHORE, FOX_OSG_MDIView::OnIdle)
};
FXIMPLEMENT(FOX_OSG_MDIView, FXMDIChild, FOX_OSG_MDIView_Map, ARRAYNUMBER(FOX_OSG_MDIView_Map))
FOX_OSG_MDIView::FOX_OSG_MDIView(FXMDIClient *p, const FXString &name,
FXIcon *ic, FXPopup *pup, FXuint opt,
FXint x, FXint y, FXint w, FXint h)
: FXMDIChild(p, name, ic, pup, opt, x, y, w, h)
{
// A visual to drag OpenGL in double-buffered mode; note the glvisual is
// shared between all windows which need the same depths and numbers of buffers
// Thus, while the first visual may take some time to initialize, each subsequent
// window can be created very quickly; we need to determine grpaphics hardware
// characteristics only once.
FXGLVisual* glVisual=new FXGLVisual(getApp(),VISUAL_DOUBLEBUFFER|VISUAL_STEREO);
m_gwFox = new GraphicsWindowFOX(this, glVisual, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y, x, y, w, h );
osgViewer::Viewer *viewer = new osgViewer::Viewer;
viewer->getCamera()->setGraphicsContext(m_gwFox);
viewer->getCamera()->setViewport(0,0,w,h);
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
// FOX example does not catch the close of the graphics window, so
// don't allow the default escape sets to done to be active.
viewer->setKeyEventSetsDone(0);
// load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
if (!loadedModel)
{
return ;
}
// add the stats handler
viewer->addEventHandler(new osgViewer::StatsHandler);
viewer->setSceneData(loadedModel.get());
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
SetViewer(viewer);
getApp()->addChore(this,ID_CHORE);
}
FOX_OSG_MDIView::~FOX_OSG_MDIView()
{
getApp()->removeChore(this,ID_CHORE);
}
long FOX_OSG_MDIView::OnIdle(FXObject *sender, FXSelector sel, void* ptr)
{
m_osgViewer->frame();
getApp()->addChore(this, ID_CHORE);
return 1;
}
void FOX_OSG_MDIView::SetViewer(osgViewer::Viewer* viewer)
{
m_osgViewer = viewer;
}

View File

@@ -1,41 +0,0 @@
#ifndef _FOXOSGMDIVIEW_H_
#define _FOXOSGMDIVIEW_H_
#include "FOX_OSG.h"
#include <fx.h>
#include <osgViewer/Viewer>
using namespace FX;
class FOX_OSG_MDIView : public FXMDIChild{
FXDECLARE(FOX_OSG_MDIView)
public:
FOX_OSG_MDIView(FXMDIClient *p, const FXString &name,
FXIcon *ic=NULL, FXPopup *pup=NULL, FXuint opts=0,
FXint x=0, FXint y=0, FXint w=0, FXint h=0);
virtual ~FOX_OSG_MDIView();
enum{
ID_CHORE=FXMDIChild::ID_LAST,
ID_LAST
};
// callback
long OnIdle(FXObject* , FXSelector, void*);
void SetViewer(osgViewer::Viewer *viewer);
protected:
FOX_OSG_MDIView(){};
private:
osg::ref_ptr<osgViewer::Viewer> m_osgViewer;
GraphicsWindowFOX* m_gwFox;
};
#endif // _FOXOSGMDIVIEW_H_

View File

@@ -1,75 +0,0 @@
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "osgviewerFOX.h"
#include "FOX_OSG_MDIView.h"
/* My frame constructor */
MainFrame::MainFrame(FXApp *app, const FXString &name, FXIcon *ic, FXIcon *mi, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb, FXint hs, FXint vs) : FXMainWindow(app, name, ic, mi, opts, x, y, w, h, pl, pr, pt, pb, hs, vs)
{
// Site where to dock
FXDockSite* topdock=new FXDockSite(this,DOCKSITE_NO_WRAP|LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
// Menubar 1
m_fxToolbarShell1=new FXToolBarShell(this,FRAME_RAISED);
FXMenuBar* menubar=new FXMenuBar(topdock,m_fxToolbarShell1,LAYOUT_DOCK_SAME|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
new FXToolBarGrip(menubar,menubar,FXMenuBar::ID_TOOLBARGRIP,TOOLBARGRIP_DOUBLE);
// Contents
FXHorizontalFrame *frame=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0, 4,4);
// Nice sunken box around GL viewer
FXVerticalFrame *box=new FXVerticalFrame(frame,FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
// MDI Client
FXMDIClient* mdiclient=new FXMDIClient(box,LAYOUT_FILL_X|LAYOUT_FILL_Y);
// Make MDI Window Menu
FXMDIMenu* mdimenu=new FXMDIMenu(this,mdiclient);
// MDI buttons in menu:- note the message ID's!!!!!
// Normally, MDI commands are simply sensitized or desensitized;
// Under the menubar, however, they're hidden if the MDI Client is
// not maximized. To do this, they must have different ID's.
new FXMDIWindowButton(menubar,mdimenu,mdiclient,FXMDIClient::ID_MDI_MENUWINDOW,LAYOUT_LEFT|LAYOUT_CENTER_Y);
new FXMDIDeleteButton(menubar,mdiclient,FXMDIClient::ID_MDI_MENUCLOSE,FRAME_RAISED|LAYOUT_RIGHT|LAYOUT_CENTER_Y);
new FXMDIRestoreButton(menubar,mdiclient,FXMDIClient::ID_MDI_MENURESTORE,FRAME_RAISED|LAYOUT_RIGHT|LAYOUT_CENTER_Y);
new FXMDIMinimizeButton(menubar,mdiclient,FXMDIClient::ID_MDI_MENUMINIMIZE,FRAME_RAISED|LAYOUT_RIGHT|LAYOUT_CENTER_Y);
// Make an MDI Child
FOX_OSG_MDIView* mdichild=new FOX_OSG_MDIView(mdiclient,"FOX osgViewer", NULL, mdimenu,MDI_TRACKING|MDI_MAXIMIZED,30,30,300,200);
mdichild->setFocus();
// Make it active
mdiclient->setActiveChild(mdichild);
}
// Create and initialize
void MainFrame::create(){
FXMainWindow::create();
m_fxToolbarShell1->create();
show(PLACEMENT_SCREEN);
}
int main(int argc, char** argv){
// Make application
FXApp application("OSGViewer","FoxTest");
// Open the display
application.init(argc,argv);
// Make window
new MainFrame(&application, "Fox Toolkit OSG Sample", NULL, NULL, DECOR_ALL, 100, 100, 800, 600);
// Create the application's windows
application.create();
// Run the application
return application.run();
}

View File

@@ -1,32 +0,0 @@
#ifndef _FOXSIMPLEVIEWERFOX_H_
#define _FOXSIMPLEVIEWERFOX_H_
#include <fx.h>
using namespace FX;
class MainFrame : public FXMainWindow{
public:
MainFrame(FXApp *a, const FXString &name,
FXIcon *ic=NULL, FXIcon *mi=NULL,
FXuint opts=DECOR_ALL,
FXint x=0, FXint y=0,
FXint w=0, FXint h=0,
FXint pl=0, FXint pr=0, FXint pt=0, FXint pb=0,
FXint hs=0, FXint vs=0);
// Initialize
virtual void create();
protected:
MainFrame(){};
private:
// GUI elements
FXToolBarShell* m_fxToolbarShell1;
};
#endif // _FOXSIMPLEVIEWERFOX_H_

View File

@@ -5,17 +5,49 @@
cOSG::cOSG(HWND hWnd) :
m_hWnd(hWnd)
m_hWnd(hWnd), mDone(false)
{
}
//
// We must set the pixelformat before we can create the OSG Rendering Surface
//
PIXELFORMATDESCRIPTOR pixelFormat =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
24,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
cOSG::~cOSG()
{
mViewer->setDone(true);
Sleep(1000);
mViewer->stopThreading();
HDC hdc = ::GetDC(m_hWnd);
if (hdc==0)
{
::DestroyWindow(m_hWnd);
return;
}
delete mViewer;
int pixelFormatIndex = ::ChoosePixelFormat(hdc, &pixelFormat);
if (pixelFormatIndex==0)
{
::ReleaseDC(m_hWnd, hdc);
::DestroyWindow(m_hWnd);
return;
}
if (!::SetPixelFormat(hdc, pixelFormatIndex, &pixelFormat))
{
::ReleaseDC(m_hWnd, hdc);
::DestroyWindow(m_hWnd);
return;
}
}
void cOSG::InitOSG(std::string modelname)
@@ -68,7 +100,7 @@ void cOSG::InitCameraConfig(void)
RECT rect;
// Create the viewer for this window
mViewer = new osgViewer::Viewer();
mViewer = new osgViewer::Viewer;
// Add a Stats Handler to the viewer
mViewer->addEventHandler(new osgViewer::StatsHandler);
@@ -90,7 +122,6 @@ void cOSG::InitCameraConfig(void)
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
traits->setInheritedWindowPixelFormat = true;
traits->inheritedWindowData = windata;
// Create the Graphics Context
@@ -152,5 +183,6 @@ void cOSG::Render(void* ptr)
// and you exit one then all stop rendering
AfxMessageBox("Exit Rendering Thread");
_endthread();
// Set Done to indicate that thread has exited
osg->Done(true);
}

View File

@@ -15,7 +15,7 @@ class cOSG
{
public:
cOSG(HWND hWnd);
~cOSG();
~cOSG(){};
void InitOSG(std::string filename);
void InitManipulators(void);
@@ -29,13 +29,13 @@ public:
bool Done(void) { return mDone; }
static void Render(void* ptr);
osgViewer::Viewer* getViewer() { return mViewer; }
osgViewer::Viewer* getViewer() { return mViewer.get(); }
private:
bool mDone;
std::string m_ModelName;
HWND m_hWnd;
osgViewer::Viewer* mViewer;
osg::ref_ptr<osgViewer::Viewer> mViewer;
osg::ref_ptr<osg::Group> mRoot;
osg::ref_ptr<osg::Node> mModel;
osg::ref_ptr<osgGA::TrackballManipulator> trackball;

View File

@@ -17,7 +17,6 @@ BEGIN_MESSAGE_MAP(CMFC_OSG_MDIView, CView)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_KEYDOWN()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
CMFC_OSG_MDIView::CMFC_OSG_MDIView() :
@@ -75,10 +74,21 @@ int CMFC_OSG_MDIView::OnCreate(LPCREATESTRUCT lpCreateStruct)
void CMFC_OSG_MDIView::OnDestroy()
{
if(mOSG != 0) delete mOSG;
WaitForSingleObject(mThreadHandle, 1000);
// Make sure OSG was created before we try to close it.
if(mOSG)
{
// Wait while the Viewer closes
while(!mOSG->Done())
{
Sleep(10); // Allow others processor time
}
// Remove mOSG
delete mOSG;
}
// Destroy Window
CView::OnDestroy();
}
@@ -93,7 +103,7 @@ void CMFC_OSG_MDIView::OnInitialUpdate()
mOSG->InitOSG(csFileName.GetString());
// Start the thread to do OSG Rendering
mThreadHandle = (HANDLE)_beginthread(&cOSG::Render, 0, mOSG);
_beginthread(&cOSG::Render, 0, mOSG);
}
void CMFC_OSG_MDIView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
@@ -108,9 +118,3 @@ void CMFC_OSG_MDIView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
}
}
BOOL CMFC_OSG_MDIView::OnEraseBkgnd(CDC* pDC)
{
/* Do nothing, to avoid flashing on MSW */
return true;
}

View File

@@ -34,7 +34,6 @@ public:
protected:
cOSG* mOSG;
HANDLE mThreadHandle;
// Generated message map functions
protected:
@@ -43,7 +42,6 @@ protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};
#ifndef _DEBUG // debug version in MFC_OSG_MDIView.cpp

View File

@@ -146,9 +146,7 @@ class ViewerQT : public osgViewer::Viewer, public AdapterWidget
AdapterWidget( parent, name, shareWidget, f )
{
getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
getCamera()->setGraphicsContext(getGraphicsWindow());
setThreadingModel(osgViewer::Viewer::SingleThreaded);
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));

View File

@@ -32,30 +32,23 @@ bool wxOsgApp::OnInit()
int width = 800;
int height = 600;
int *attributes = new int[6];
attributes[0] = int(WX_GL_DOUBLEBUFFER);
attributes[1] = WX_GL_RGBA;
attributes[2] = WX_GL_DEPTH_SIZE;
attributes[3] = 8;
attributes[4] = WX_GL_STENCIL_SIZE;
attributes[5] = 8;
GraphicsWindowWX* gw = new GraphicsWindowWX(frame, wxID_ANY, wxDefaultPosition,
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
wxSize(width, height), wxSUNKEN_BORDER);
osgViewer::Viewer *viewer = new osgViewer::Viewer;
viewer->getCamera()->setGraphicsContext(gw);
viewer->getCamera()->setViewport(0,0,width,height);
viewer->addEventHandler(new osgViewer::StatsHandler);
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
// load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
if (!loadedModel)
{
return false;
}
viewer->setSceneData(loadedModel.get());
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
@@ -88,7 +81,7 @@ void MainFrame::SetViewer(osgViewer::Viewer *viewer)
void MainFrame::OnIdle(wxIdleEvent &event)
{
_viewer->frame();
event.RequestMore();
}
@@ -102,12 +95,12 @@ BEGIN_EVENT_TABLE(GraphicsWindowWX, wxGLCanvas)
END_EVENT_TABLE()
GraphicsWindowWX::GraphicsWindowWX(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attributes)
: wxGLCanvas(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE, name, attributes)
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxGLCanvas(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE, name)
{
// default cursor to standard
_oldCursor = *wxSTANDARD_CURSOR;
_traits = new GraphicsContext::Traits;
_traits->x = pos.x;
_traits->y = pos.y;
@@ -115,7 +108,7 @@ GraphicsWindowWX::GraphicsWindowWX(wxWindow *parent, wxWindowID id,
_traits->height = size.y;
init();
}
void GraphicsWindowWX::init()
@@ -128,7 +121,7 @@ void GraphicsWindowWX::init()
if (_traits.valid() && _traits->sharedContext)
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
@@ -155,7 +148,7 @@ void GraphicsWindowWX::OnSize(wxSizeEvent& event)
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
int width, height;
GetClientSize(&width, &height);
// update the window dimensions, in case the window has been resized.
getEventQueue()->windowResize(0, 0, width, height);
resized(0,0,width,height);
@@ -168,12 +161,12 @@ void GraphicsWindowWX::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
{
#if wxUSE_UNICODE
#if 1
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
getEventQueue()->keyPress(key);
getEventQueue()->keyPress(key);
// propagate event
event.Skip();
@@ -181,12 +174,12 @@ void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
void GraphicsWindowWX::OnKeyUp(wxKeyEvent &event)
{
#if wxUSE_UNICODE
#if 1
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
getEventQueue()->keyRelease(key);
getEventQueue()->keyRelease(key);
// propagate event
event.Skip();

View File

@@ -8,14 +8,13 @@
#include <osgViewer/Viewer>
#include <string>
class GraphicsWindowWX : public wxGLCanvas, public osgViewer::GraphicsWindow
class GraphicsWindowWX: public wxGLCanvas, public osgViewer::GraphicsWindow
{
public:
GraphicsWindowWX(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxT("TestGLCanvas"),
int *attributes = 0);
const wxString& name = wxT("TestGLCanvas"));
~GraphicsWindowWX();
@@ -31,6 +30,7 @@ public:
//
// GraphicsWindow interface
//
void grabFocus();
void grabFocusIfPointerInWindow();
void useCursor(bool cursorOn);

View File

@@ -44,15 +44,12 @@ int main( int argc, char **argv )
// construct the viewer.
osgViewer::Viewer viewer;
int xoffset = 40;
int yoffset = 40;
// left window + left slave camera
{
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = xoffset + 0;
traits->y = yoffset + 0;
traits->width = 600;
traits->x = 0;
traits->y = 0;
traits->width = 640;
traits->height = 480;
traits->windowDecoration = true;
traits->doubleBuffer = true;
@@ -67,16 +64,16 @@ int main( int argc, char **argv )
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
// add this slave camera to the viewer, with a shift left of the projection matrix
// add this slave camra to the viewer, with a shift left of the projection matrix
viewer.addSlave(camera.get(), osg::Matrixd::translate(1.0,0.0,0.0), osg::Matrixd());
}
// right window + right slave camera
// left window + left slave camera
{
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = xoffset + 600;
traits->y = yoffset + 0;
traits->width = 600;
traits->x = 640;
traits->y = 0;
traits->width = 640;
traits->height = 480;
traits->windowDecoration = true;
traits->doubleBuffer = true;
@@ -91,7 +88,7 @@ int main( int argc, char **argv )
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
// add this slave camera to the viewer, with a shift right of the projection matrix
// add this slave camra to the viewer, with a shift right of the projection matrix
viewer.addSlave(camera.get(), osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd());
}

View File

@@ -52,11 +52,6 @@ configure file /osg\/GraphicsContext/
"
end
configure file /osgViewer\/ViewerBase/
emit before "#include <osgViewer/View>
"
end
#############################################################################
# add <io_utils> header to Plane, Quat and Vec* files
@@ -184,22 +179,22 @@ end
configure file "osg/Array"
emit after "
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2b>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3b>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4b>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2s>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3s>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4s>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4ub>)
STD_VECTOR_REFLECTOR(std::vector<GLubyte>)
STD_VECTOR_REFLECTOR(std::vector<GLbyte>)
STD_VECTOR_REFLECTOR(std::vector<GLushort>)
STD_VECTOR_REFLECTOR(std::vector<GLshort>)
STD_VECTOR_REFLECTOR(std::vector<GLuint>)
STD_VECTOR_REFLECTOR(std::vector<GLint>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2b>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3b>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4b>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2s>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3s>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4s>);
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4ub>);
STD_VECTOR_REFLECTOR(std::vector<GLubyte>);
STD_VECTOR_REFLECTOR(std::vector<GLbyte>);
STD_VECTOR_REFLECTOR(std::vector<GLushort>);
STD_VECTOR_REFLECTOR(std::vector<GLshort>);
STD_VECTOR_REFLECTOR(std::vector<GLuint>);
STD_VECTOR_REFLECTOR(std::vector<GLint>);
"
end
@@ -208,7 +203,7 @@ end
# StateSet and related types need some advanced tweaking
configure reflector "std::map< osg::StateAttribute::GLMode, osg::StateAttribute::GLModeValue >"
replace with "STD_MAP_REFLECTOR_WITH_TYPES(std::map< osg::StateAttribute::GLMode COMMA osg::StateAttribute::GLModeValue >, osg::StateAttribute::GLMode, osg::StateAttribute::Values)"
replace with "STD_MAP_REFLECTOR_WITH_TYPES(std::map< osg::StateAttribute::GLMode COMMA osg::StateAttribute::GLModeValue >, osg::StateAttribute::GLMode, osg::StateAttribute::Values);"
end
configure reflector "osg::StateSet"
@@ -291,10 +286,6 @@ configure reflector "OpenThreads::Block"
object-type
end
configure reflector "OpenThreads::BlockCount"
object-type
end
configure reflector "OpenThreads::Barrier"
object-type
end
@@ -330,12 +321,12 @@ end
# Doxygen doesn't parse ReadFunc and WriteFunc correctly...
configure reflector "osgDB::DotOsgWrapper::ReadFunc"
replace with "TYPE_NAME_ALIAS(bool (*)(osg::Object&,osgDB::Input&), osgDB::DotOsgWrapper::ReadFunc)
replace with "TYPE_NAME_ALIAS(bool (*)(osg::Object&,osgDB::Input&), osgDB::DotOsgWrapper::ReadFunc);
"
end
configure reflector "osgDB::DotOsgWrapper::WriteFunc"
replace with "TYPE_NAME_ALIAS(bool (*)(const osg::Object&,osgDB::Output&), osgDB::DotOsgWrapper::WriteFunc)
replace with "TYPE_NAME_ALIAS(bool (*)(const osg::Object&,osgDB::Output&), osgDB::DotOsgWrapper::WriteFunc);
"
end
@@ -368,87 +359,6 @@ configure reflector "osg::Drawable::Extensions"
end
end
configure reflector "osg::BlendColor::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::BlendEquation::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::BlendFunc::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::FragmentProgram::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::Multisample::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::Point::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::ClampColor::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::Texture::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::Texture2DArray::Extensions"
configure method "__typedef__void__APIENTRY_P1"
replace with ""
end
configure method "__typedef__GLboolean__APIENTRY_P1"
replace with ""
end
end
configure reflector "osg::State"
configure method "__typedef__void__APIENTRY_P1"
replace with ""

View File

@@ -33,7 +33,6 @@ class OSG_EXPORT ArgumentParser
public:
enum ParameterType
{
BOOL_PARAMETER,
FLOAT_PARAMETER,
DOUBLE_PARAMETER,
INT_PARAMETER,
@@ -43,7 +42,6 @@ class OSG_EXPORT ArgumentParser
union ValueUnion
{
bool* _bool;
float* _float;
double* _double;
int* _int;
@@ -51,8 +49,6 @@ class OSG_EXPORT ArgumentParser
std::string* _string;
};
Parameter(bool& value) { _type = BOOL_PARAMETER; _value._bool = &value; }
Parameter(float& value) { _type = FLOAT_PARAMETER; _value._float = &value; }
Parameter(double& value) { _type = DOUBLE_PARAMETER; _value._double = &value; }
@@ -87,9 +83,6 @@ class OSG_EXPORT ArgumentParser
/** Return true if specified parameter is a number. */
static bool isNumber(const char* str);
/** Return true if specified parameter is a bool. */
static bool isBool(const char* str);
public:
ArgumentParser(int* argc,char **argv);

View File

@@ -81,21 +81,21 @@ class OSG_EXPORT BlendColor : public StateAttribute
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setupGLExtenions(unsigned int contextID);
void setBlendColorSupported(bool flag) { _isBlendColorSupported=flag; }
bool isBlendColorSupported() const { return _isBlendColorSupported; }
void setBlendColorProc(void* ptr) { _glBlendColor = ptr; }
void glBlendColor(GLclampf red , GLclampf green , GLclampf blue , GLclampf alpha) const;
protected:
~Extensions() {}
bool _isBlendColorSupported;
typedef void (APIENTRY * GLBlendColorProc) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
bool _isBlendColorSupported;
GLBlendColorProc _glBlendColor;
void* _glBlendColor;
};

View File

@@ -103,26 +103,25 @@ class OSG_EXPORT BlendEquation : public StateAttribute
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setupGLExtenions(unsigned int contextID);
void setBlendEquationSupported(bool flag) { _isBlendEquationSupported=flag; }
bool isBlendEquationSupported() const { return _isBlendEquationSupported; }
bool isSGIXMinMaxSupported() const { return _isSGIXMinMaxSupported; }
bool isLogicOpSupported() const { return _isLogicOpSupported; }
void setBlendEquationProc(void* ptr) { _glBlendEquation = ptr; }
void glBlendEquation(GLenum mode) const;
protected:
~Extensions() {}
typedef void (APIENTRY * GLBlendEquationProc) (GLenum mode);
bool _isBlendEquationSupported;
bool _isSGIXMinMaxSupported;
bool _isLogicOpSupported;
bool _isBlendEquationSupported;
bool _isSGIXMinMaxSupported;
bool _isLogicOpSupported;
GLBlendEquationProc _glBlendEquation;
void* _glBlendEquation;
};

View File

@@ -147,6 +147,7 @@ class OSG_EXPORT BlendFunc : public StateAttribute
void setBlendFuncSeparateSupported(bool flag) { _isBlendFuncSeparateSupported=flag; }
bool isBlendFuncSeparateSupported() const { return _isBlendFuncSeparateSupported; }
void setBlendFuncSeparateProc(void* ptr) { _glBlendFuncSeparate = ptr; }
void glBlendFuncSeparate(GLenum sfactorRGB,
GLenum dfactorRGB,
GLenum sfactorAlpha,
@@ -156,13 +157,9 @@ class OSG_EXPORT BlendFunc : public StateAttribute
~Extensions() {}
bool _isBlendFuncSeparateSupported;
typedef void (APIENTRY * GLBlendFuncSeparateProc) (GLenum sfactorRGB,
GLenum dfactorRGB,
GLenum sfactorAlpha,
GLenum dfactorAlpha);
bool _isBlendFuncSeparateSupported;
GLBlendFuncSeparateProc _glBlendFuncSeparate;
void* _glBlendFuncSeparate;
};

View File

@@ -93,16 +93,6 @@ class OSG_EXPORT BufferObject : public Object
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "BufferObject"; }
/** Set what type of usage the buffer object will have. Options are:
* GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY,
* GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY,
* GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY.
*/
void setUsage(GLenum usage) { _usage = usage; }
/** Get the type of usage the buffer object has been set up for.*/
GLenum getUsage() const { return _usage; }
struct BufferEntry
{
BufferEntry(): dataSize(0),offset(0) {}
@@ -169,7 +159,7 @@ class OSG_EXPORT BufferObject : public Object
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setupGLExtenions(unsigned int contextID);
bool isBufferObjectSupported() const { return _glGenBuffers!=0; }
bool isPBOSupported() const { return _isPBOSupported; }
@@ -291,8 +281,8 @@ class OSG_EXPORT ElementBufferObject : public BufferObject
META_Object(osg,ElementBufferObject);
typedef std::pair< BufferEntry, DrawElements* > BufferEntryDrawElementsPair;
typedef std::vector< BufferEntryDrawElementsPair > BufferEntryDrawElementsPairs;
typedef std::pair< BufferEntry, DrawElements* > BufferEntryDrawElementstPair;
typedef std::vector< BufferEntryDrawElementstPair > BufferEntryDrawElementsPairs;
unsigned int addDrawElements(osg::DrawElements* PrimitiveSet);
void removeDrawElements(osg::DrawElements* PrimitiveSet);

View File

@@ -352,13 +352,13 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
void createCameraThread();
/** Assign a operation thread to the camera.*/
void setCameraThread(OperationThread* gt);
void setCameraThread(OperationsThread* gt);
/** Get the operation thread assigned to this camera.*/
OperationThread* getCameraThread() { return _cameraThread.get(); }
OperationsThread* getCameraThread() { return _cameraThread.get(); }
/** Get the const operation thread assigned to this camera.*/
const OperationThread* getCameraThread() const { return _cameraThread.get(); }
const OperationsThread* getCameraThread() const { return _cameraThread.get(); }
@@ -373,23 +373,13 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Set the Rendering object that is used to implement rendering of the subgraph.*/
void setRenderer(osg::GraphicsOperation* rc) { _renderer = rc; }
void setRenderingCache(unsigned int contextID, osg::Object* rc) { _renderingCache[contextID] = rc; }
/** Get the Rendering object that is used to implement rendering of the subgraph.*/
osg::GraphicsOperation* getRenderer() { return _renderer.get(); }
osg::Object* getRenderingCache(unsigned int contextID) { return _renderingCache[contextID].get(); }
/** Get the const Rendering object that is used to implement rendering of the subgraph.*/
const osg::GraphicsOperation* getRenderer() const { return _renderer.get(); }
/** Set the Rendering cache that is used for cached objects associated with rendering of subgraphs.*/
void setRenderingCache(osg::Object* rc) { _renderingCache = rc; }
/** Get the Rendering cache that is used for cached objects associated with rendering of subgraphs.*/
osg::Object* getRenderingCache() { return _renderingCache.get(); }
/** Get the const Rendering cache that is used for cached objects associated with rendering of subgraphs.*/
const osg::Object* getRenderingCache() const { return _renderingCache.get(); }
const osg::Object* getRenderingCache(unsigned int contextID) const { return _renderingCache[contextID].get(); }
/** Draw callback for custom operations.*/
@@ -477,12 +467,11 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
RenderTargetImplementation _renderTargetFallback;
BufferAttachmentMap _bufferAttachmentMap;
ref_ptr<OperationThread> _cameraThread;
ref_ptr<OperationsThread> _cameraThread;
ref_ptr<GraphicsContext> _graphicsContext;
ref_ptr<GraphicsOperation> _renderer;
ref_ptr<Object> _renderingCache;
buffered_object< ref_ptr<Object> > _renderingCache;
ref_ptr<DrawCallback> _preDrawCallback;
ref_ptr<DrawCallback> _postDrawCallback;

View File

@@ -89,20 +89,21 @@ class OSG_EXPORT ClampColor : public StateAttribute
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setupGLExtenions(unsigned int contextID);
void setClampColorSupported(bool flag) { _isClampColorSupported=flag; }
bool isClampColorSupported() const { return _isClampColorSupported; }
void setClampColorProc(void* ptr) { _glClampColor = ptr; }
void glClampColor(GLenum target, GLenum mode) const;
protected:
~Extensions() {}
typedef void (APIENTRY * GLClampColorProc) (GLenum target, GLenum mode);
bool _isClampColorSupported;
GLClampColorProc _glClampColor;
bool _isClampColorSupported;
void* _glClampColor;
};

View File

@@ -62,7 +62,7 @@ class OSG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::
void setCreateDrawablesOnOccludeNodes(bool flag) { _createDrawables=flag; }
bool getCreateDrawablesOnOccludeNodes() const { return _createDrawables; }
void setCollectedOccluderSet(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
void setCollectedOcculderSet(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
ShadowVolumeOccluderSet& getCollectedOccluderSet() { return _occluderSet; }
const ShadowVolumeOccluderSet& getCollectedOccluderSet() const { return _occluderSet; }

View File

@@ -85,7 +85,7 @@ class OSG_EXPORT CullSettings
unsigned int getInheritanceMask() const { return _inheritanceMask; }
/** Set the local cull settings values from specified CullSettings object.*/
void setCullSettings(const CullSettings& settings);
void setCullSettings(const CullSettings& settings) { inheritCullSettings(settings, ALL_VARIABLES); }
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
virtual void inheritCullSettings(const CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }

View File

@@ -31,7 +31,6 @@ class OSG_EXPORT CullStack : public osg::CullSettings
CullStack();
CullStack(const CullStack& cs);
~CullStack();

View File

@@ -37,7 +37,7 @@ class OSG_EXPORT DeleteHandler
DeleteHandler(int numberOfFramesToRetainObjects=0);
virtual ~DeleteHandler();
virtual ~DeleteHandler() { flushAll(); }
/** Set the number of frames to retain objects that are have been requested for deletion.
* When set to zero objects are deleted immediately, by set to 1 there are kept around for an extra frame etc.
@@ -71,9 +71,7 @@ class OSG_EXPORT DeleteHandler
protected:
DeleteHandler(const DeleteHandler&):
_numFramesToRetainObjects(0),
_currentFrameNumber(0) {}
DeleteHandler(const DeleteHandler&) {}
DeleteHandler operator = (const DeleteHandler&) { return *this; }
int _numFramesToRetainObjects;

View File

@@ -36,15 +36,13 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
static DisplaySettings* instance();
DisplaySettings():
Referenced(true)
DisplaySettings()
{
setDefaults();
readEnvironmentalVariables();
}
DisplaySettings(ArgumentParser& arguments):
Referenced(true)
DisplaySettings(ArgumentParser& arguments)
{
setDefaults();
readEnvironmentalVariables();
@@ -94,8 +92,7 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
LEFT_EYE,
RIGHT_EYE,
HORIZONTAL_INTERLACE,
VERTICAL_INTERLACE,
CHECKERBOARD
VERTICAL_INTERLACE
};
void setStereoMode(StereoMode mode) { _stereoMode = mode; }
@@ -128,8 +125,8 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
void setSplitStereoVerticalSeparation(int s) { _splitStereoVerticalSeparation = s; }
int getSplitStereoVerticalSeparation() const { return _splitStereoVerticalSeparation; }
void setSplitStereoAutoAdjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
bool getSplitStereoAutoAdjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
void setSplitStereoAutoAjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
bool getSplitStereoAutoAjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
void setScreenWidth(float width) { _screenWidth = width; }
@@ -177,12 +174,6 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
void setNumMultiSamples(unsigned int samples) { _numMultiSamples = samples; }
unsigned int getNumMultiSamples() const { return _numMultiSamples; }
bool getMultiSamples() const { return _numMultiSamples!=0; }
void setCompileContextsHint(bool useCompileContexts) { _compileContextsHint = useCompileContexts; }
bool getCompileContextsHint() const { return _compileContextsHint; }
void setSerializeDrawDispatch(bool serializeDrawDispatch) { _serializeDrawDispatch = serializeDrawDispatch; }
bool getSerializeDrawDispatch() const { return _serializeDrawDispatch; }
protected:
@@ -216,9 +207,6 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
unsigned int _maxNumOfGraphicsContexts;
unsigned int _numMultiSamples;
bool _compileContextsHint;
bool _serializeDrawDispatch;
};

View File

@@ -575,7 +575,7 @@ class OSG_EXPORT Drawable : public Object
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setupGLExtenions(unsigned int contextID);
void setVertexProgramSupported(bool flag) { _isVertexProgramSupported=flag; }
bool isVertexProgramSupported() const { return _isVertexProgramSupported; }

View File

@@ -240,7 +240,7 @@ class OSG_EXPORT FragmentProgram : public StateAttribute
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtensions(unsigned int contextID);
void setupGLExtenions(unsigned int contextID);
void setFragmentProgramSupported(bool flag) { _isFragmentProgramSupported=flag; }
bool isFragmentProgramSupported() const { return _isFragmentProgramSupported; }
@@ -257,17 +257,11 @@ class OSG_EXPORT FragmentProgram : public StateAttribute
bool _isFragmentProgramSupported;
typedef void (APIENTRY * BindProgramProc) (GLenum target, GLuint id);
typedef void (APIENTRY * GenProgramsProc) (GLsizei n, GLuint *programs);
typedef void (APIENTRY * DeleteProgramsProc) (GLsizei n, GLuint *programs);
typedef void (APIENTRY * ProgramStringProc) (GLenum target, GLenum format, GLsizei len, const void *string);
typedef void (APIENTRY * ProgramLocalParameter4fvProc) (GLenum target, GLuint index, const GLfloat *params);
BindProgramProc _glBindProgram;
GenProgramsProc _glGenPrograms;
DeleteProgramsProc _glDeletePrograms;
ProgramStringProc _glProgramString;
ProgramLocalParameter4fvProc _glProgramLocalParameter4fv;
void* _glBindProgram;
void* _glGenPrograms;
void *_glDeletePrograms;
void* _glProgramString;
void* _glProgramLocalParameter4fv;
};
/** Function to call to get the extension of a specified context.

View File

@@ -44,7 +44,6 @@
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
@@ -106,16 +105,13 @@ namespace osg
typedef void APIENTRY TglFramebufferTexture1DEXT(GLenum, GLenum, GLenum, GLuint, GLint);
typedef void APIENTRY TglFramebufferTexture2DEXT(GLenum, GLenum, GLenum, GLuint, GLint);
typedef void APIENTRY TglFramebufferTexture3DEXT(GLenum, GLenum, GLenum, GLuint, GLint, GLint);
typedef void APIENTRY TglFramebufferTextureLayerEXT(GLenum, GLenum, GLuint, GLint, GLint);
typedef void APIENTRY TglFramebufferRenderbufferEXT(GLenum, GLenum, GLenum, GLuint);
typedef void APIENTRY TglGenerateMipmapEXT(GLenum);
typedef void APIENTRY TglRenderbufferStorageMultisampleCoverageNV(GLenum, GLuint, GLuint, GLenum, GLuint, GLuint);
TglBindRenderbufferEXT* glBindRenderbufferEXT;
TglGenRenderbuffersEXT* glGenRenderbuffersEXT;
TglDeleteRenderbuffersEXT* glDeleteRenderbuffersEXT;
TglRenderbufferStorageEXT* glRenderbufferStorageEXT;
TglRenderbufferStorageMultisampleCoverageNV* glRenderbufferStorageMultisampleCoverageNV;
TglBindFramebufferEXT* glBindFramebufferEXT;
TglDeleteFramebuffersEXT* glDeleteFramebuffersEXT;
TglGenFramebuffersEXT* glGenFramebuffersEXT;
@@ -123,7 +119,6 @@ namespace osg
TglFramebufferTexture1DEXT* glFramebufferTexture1DEXT;
TglFramebufferTexture2DEXT* glFramebufferTexture2DEXT;
TglFramebufferTexture3DEXT* glFramebufferTexture3DEXT;
TglFramebufferTextureLayerEXT* glFramebufferTextureLayerEXT;
TglFramebufferRenderbufferEXT* glFramebufferRenderbufferEXT;
TglGenerateMipmapEXT* glGenerateMipmapEXT;
@@ -251,7 +246,6 @@ namespace osg
class Texture1D;
class Texture2D;
class Texture3D;
class Texture2DArray;
class TextureCubeMap;
class TextureRectangle;
@@ -265,7 +259,6 @@ namespace osg
explicit FrameBufferAttachment(Texture1D* target, int level = 0);
explicit FrameBufferAttachment(Texture2D* target, int level = 0);
explicit FrameBufferAttachment(Texture3D* target, int zoffset, int level = 0);
explicit FrameBufferAttachment(Texture2DArray* target, int layer, int level = 0);
explicit FrameBufferAttachment(TextureCubeMap* target, int face, int level = 0);
explicit FrameBufferAttachment(TextureRectangle* target);
explicit FrameBufferAttachment(Camera::Attachment& attachment);

View File

@@ -1,7 +1,6 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
* Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
* Copyright (C) 2004-2005 Nathan Cournia
* Copyright (C) 2007 Art Tevs
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial
@@ -24,14 +23,6 @@
#include <string>
#ifndef GL_SAMPLER_2D_ARRAY_EXT
#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0
#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1
#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3
#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4
#endif
#ifndef GL_VERSION_2_0 //[
#define GL_VERSION_2_0 1
typedef char GLchar;
@@ -264,11 +255,6 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
bool getProgramInfoLog( GLuint program, std::string& result ) const;
bool getShaderInfoLog( GLuint shader, std::string& result ) const;
bool getAttribLocation( const char* attribName, GLuint& slot ) const;
bool getFragDataLocation( const char* fragDataName, GLuint& slot) const;
//EXT_gpu_shader4 to support frag data binding
void glBindFragDataLocation(GLuint program, GLuint colorNumber, const GLchar *name) const;
GLint glGetFragDataLocation(GLuint program, const GLchar *name) const;
protected:
~GL2Extensions() {}
@@ -379,9 +365,6 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
void* _glGetObjectParameterivARB;
void* _glDeleteObjectARB;
void* _glGetHandleARB;
void* _glBindFragDataLocation;
void* _glGetFragDataLocation;
};
}

Some files were not shown because too many files have changed in this diff Show More