Compare commits
2 Commits
OpenSceneG
...
OpenSceneG
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27c7db56de | ||
|
|
d61306fa72 |
89
AUTHORS.txt
89
AUTHORS.txt
@@ -1,118 +1,113 @@
|
||||
OpenSceneGraph Library 2.6.0
|
||||
OpenSceneGraph Library 2.4.0
|
||||
|
||||
324 Contributors:
|
||||
307 Contributors:
|
||||
|
||||
Firstname Surname
|
||||
-----------------
|
||||
Robert Osfield
|
||||
Don Burns
|
||||
Marco Jez
|
||||
Paul Martz
|
||||
Mike Weiblen
|
||||
Paul Martz
|
||||
Eric Wing
|
||||
Brede Johansen
|
||||
Stephan Huber
|
||||
Geoff Michel
|
||||
Stephan Huber
|
||||
Farshid Lashkari
|
||||
Bob Kuehne
|
||||
Mathias Fr<46>hlich
|
||||
Eric Sokolowsky
|
||||
Ulrich Hertlein
|
||||
Martin Lavery
|
||||
David Callu
|
||||
Eric Sokolowsky
|
||||
Mathias Fr<46>hlich
|
||||
Tree
|
||||
Jean-Sebastien Guay
|
||||
David Callu
|
||||
Luigi Calori
|
||||
Trajce Nikolov
|
||||
Mike Wittman
|
||||
Jean-Sebastien Guay
|
||||
Pavel Moloshtan
|
||||
Colin McDonald
|
||||
Tom Jolley
|
||||
Andy Skinner
|
||||
Roger James
|
||||
Norman Vine
|
||||
Jeremy Moles
|
||||
Colin McDonald
|
||||
Alberto Farre
|
||||
Andr<EFBFBD> Garneau
|
||||
Wojciech Lewandowski
|
||||
Ruben Lopez
|
||||
Randall Hopper
|
||||
Art Tevs
|
||||
Wojciech Lewandowski
|
||||
Olaf Flebbe
|
||||
Gideon May
|
||||
Don Tidrow
|
||||
Romano Jos<6F> Magacho da Silva
|
||||
Philip Lowman
|
||||
Paul Melis
|
||||
Michael Platings
|
||||
Michael Gronager
|
||||
Daniel Sj<53>lie
|
||||
Chris Hanson
|
||||
Adrian Egli
|
||||
Sherman Wilcox
|
||||
Per Fahlberg
|
||||
Jeremy Moles
|
||||
J.P. Delport
|
||||
David Spilling
|
||||
Melchior Franz
|
||||
Art Tevs
|
||||
Sherman Wilcox
|
||||
Joran Jessurun
|
||||
Joakim Simonsson
|
||||
Jason Beverage
|
||||
Paul Melis
|
||||
Jason Daly
|
||||
Frederic Marmond
|
||||
David Fries
|
||||
Boris Bralo
|
||||
Yefei He
|
||||
Terry Welsh
|
||||
Sondra Iverson
|
||||
Serge Lages
|
||||
Rune Schmidt Jensen
|
||||
Rainer Oder
|
||||
Mike Connell
|
||||
Mathieu Marache
|
||||
Glenn Waldron
|
||||
Melchior Franz
|
||||
Joakim Simonsson
|
||||
Carlo Camporesi
|
||||
Ben Discoe
|
||||
Andreas Ekstrand
|
||||
Stephane Lamoliatte
|
||||
Adrian Egli
|
||||
Sasa Bistrovic
|
||||
Martin Naylor
|
||||
Martin Aumueller
|
||||
Markus Trenkwalder
|
||||
Mario Valle
|
||||
Loic Dachary
|
||||
Joseph Steel
|
||||
John Shue
|
||||
Jan Peciva
|
||||
Jan Ciger
|
||||
Gordon Tomlinson
|
||||
Gino van den Bergen
|
||||
Bryan Thrall
|
||||
Brad Colbert
|
||||
Vivek Rajan
|
||||
Thibault Genessay
|
||||
Sean Spicer
|
||||
Ravi Mathur
|
||||
Nikolaus Hanekamp
|
||||
Neil Salter
|
||||
Mihai Radu
|
||||
Michael Platings
|
||||
Michael Hartman
|
||||
Luc Frauciel
|
||||
Laurens Voerman
|
||||
David Guthrie
|
||||
Corbin Holtz
|
||||
Cedric Pinson
|
||||
Brad Christiansen
|
||||
Toshiyuki Takahei
|
||||
Thom DeCarlo
|
||||
Terry Welsh
|
||||
Stephane Lamoliatte
|
||||
Simon Julier
|
||||
Sebastien Grignard
|
||||
Romano Magacho
|
||||
Roland Smeenk
|
||||
Philip Lowman
|
||||
Paul de Repentigny
|
||||
Luc Frauciel
|
||||
Leandro Motta Barros
|
||||
John Kelso
|
||||
Glenn Waldron
|
||||
Daniel Larimer
|
||||
Colin Dunlop
|
||||
Cedric Pinson
|
||||
Bruce Clay
|
||||
Alberto Luaces
|
||||
Alberto Barbati
|
||||
@@ -120,28 +115,28 @@ Vladimir Shabanov
|
||||
Uwe Woessner
|
||||
Tony Horrobin
|
||||
Tim Moore
|
||||
Thibault Genessay
|
||||
Sohey Yamamoto
|
||||
Roland Smeenk
|
||||
Richard Schmidt
|
||||
Rafa Gaitan
|
||||
Phil Atkin
|
||||
Peter Hrenka
|
||||
Neil Groves
|
||||
Neil Hughes
|
||||
Mattias Linde
|
||||
Mattias Helsing
|
||||
Mathieu Marache
|
||||
Maria Ten
|
||||
Ken Sewell
|
||||
Julian Ortiz
|
||||
Jeremy Bell
|
||||
James French
|
||||
Garrett Potts
|
||||
Gabor Dorka
|
||||
Donn Mielcarek
|
||||
Donald Cipperly
|
||||
Domenico Mangieri
|
||||
Charles Cole
|
||||
Blake Williams
|
||||
Antoine Hue
|
||||
Andrew Bettison
|
||||
Anders Backman
|
||||
Ali Botorabi
|
||||
Zach Deedler
|
||||
@@ -154,19 +149,15 @@ Steve Lunsford
|
||||
Stephane Simon
|
||||
Stephan Eilemann
|
||||
Stanislav Blinov
|
||||
Sebastian Messerschmidt
|
||||
Rudolf Wiedemann
|
||||
Riccardo Corsi
|
||||
Ralf Kern
|
||||
Perry Miller
|
||||
Nathan Monteleone
|
||||
Miguel Escriva
|
||||
Michael Henheffer
|
||||
Maya Leonard
|
||||
Max Behensky
|
||||
Mathew May
|
||||
Martijn Kragtwijk
|
||||
Liang Aibin
|
||||
Kevin Moiule
|
||||
Keith Steffen
|
||||
Joseph Winston
|
||||
@@ -174,29 +165,28 @@ John Aughey
|
||||
Johan Nouvel
|
||||
Igor Kravtchenko
|
||||
Gustavo Wagner
|
||||
Gino van den Bergen
|
||||
Gerrick Bivins
|
||||
George Tarantilis
|
||||
Garret Potts
|
||||
Fabio Mierlo
|
||||
Edgar Ellis
|
||||
Doug McCorkle
|
||||
Donald Cipperly
|
||||
David Ergo
|
||||
Daniel Trstenjak
|
||||
Csaba Halasz
|
||||
Brad Anderegg
|
||||
Andrew Sampson
|
||||
Andrew Lorino
|
||||
Andreas Goebel
|
||||
Zbigniew Sroczynski
|
||||
Yuri Vilmanis
|
||||
Warren Macchi
|
||||
Wang Rui
|
||||
Wang Lam
|
||||
Walter J. Altice
|
||||
Volker Walkiewicz
|
||||
Vladimir Vukicevic
|
||||
Vlad Danciu
|
||||
Vincent Vivanloc
|
||||
Vincent Bourdier
|
||||
Vasily Radostev
|
||||
Vaclav Bilek
|
||||
Tyge
|
||||
@@ -207,19 +197,18 @@ Thom Carlo
|
||||
Tery Welsh
|
||||
Tatsuhiro Nishioka
|
||||
Tanguy Fautr<74>
|
||||
Steven Thomas
|
||||
Sid Byce
|
||||
Shuxing Xiao
|
||||
Shane Arnott
|
||||
Sebastien Kuntz
|
||||
Ruth Lang
|
||||
Sebastian Messerschimdt
|
||||
Rudolf Wiedemann
|
||||
Ronny Krueger
|
||||
Robert Swain
|
||||
Rick Pingry
|
||||
Rene Molenaar
|
||||
Reinhard Sainitzer
|
||||
Rein Kadijk
|
||||
Raymond de Vries
|
||||
Qing Shen
|
||||
Philipp Siemoleit
|
||||
Philipp M<>chler
|
||||
@@ -230,9 +219,7 @@ Panagiotis Papadakos
|
||||
Orhun Birsoy
|
||||
Ole-Morten Duesund
|
||||
Nicolas Brodu
|
||||
Neil Hughes
|
||||
Nathan Cournia
|
||||
Morten Haukness
|
||||
Morn<EFBFBD> Pistorius
|
||||
Mirko Viviani
|
||||
Mikkel Gjøl
|
||||
@@ -249,18 +236,15 @@ Mathia Walker
|
||||
Mason Menninger
|
||||
Martin Spott
|
||||
Martin Amueller
|
||||
Mario Valle
|
||||
Mario Guimaraes
|
||||
Marin Lavery
|
||||
Marco Lehmann
|
||||
Louis Hamilton
|
||||
Lilin Xiong
|
||||
Lewis Harmon
|
||||
Lars Nilson
|
||||
Kristopher Bixler
|
||||
Karsten Weiss
|
||||
Karl Heijdenberg
|
||||
Josh Portway
|
||||
John Vidar Larring
|
||||
John Tan
|
||||
John Grant
|
||||
John Donovan
|
||||
@@ -294,23 +278,23 @@ Duvan Cope
|
||||
Duncan Cavens
|
||||
Drew Whitehouse
|
||||
Douglas A. Pouk
|
||||
Doug McCorkle
|
||||
Dean Iverson
|
||||
David Jung
|
||||
David Gurhrie
|
||||
Daniel Stien
|
||||
Daniel Olivier
|
||||
Dan Minor
|
||||
Cyril Brulebois
|
||||
Clay Fowler
|
||||
Chuck Sembroski
|
||||
Chuck Seberion
|
||||
Christophe Loustaunau
|
||||
Christian Kaser
|
||||
Chris McGlone
|
||||
Carlos Garcea
|
||||
Bruno Herbelin
|
||||
Brian Keener
|
||||
Brandon Hamm
|
||||
Brad Anderegg
|
||||
Bora Utka
|
||||
Blasius Czink
|
||||
Benoit Laniel
|
||||
@@ -319,7 +303,6 @@ Bart Gallet
|
||||
Axel Volley
|
||||
Andrew Reyonolds
|
||||
Andreas Jochens
|
||||
Andre Normann
|
||||
Almalric Alexandre
|
||||
Allen Bierbaum
|
||||
Alexandre Amalric
|
||||
|
||||
258
CMakeLists.txt
258
CMakeLists.txt
@@ -2,7 +2,7 @@ IF(WIN32)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
|
||||
ELSE(WIN32)
|
||||
IF(APPLE)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
|
||||
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
MESSAGE("Warning: A critical CMake bug exists in 2.4.6 and below. Trying to build Universal Binaries will result in a compile error that seems unrelated. Either avoid building Universal Binaries by changing the CMAKE_OSX_ARCHITECTURES field to list only your architecture, or upgrade to the current CVS version of CMake or a newer stable version if it exists.")
|
||||
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
|
||||
@@ -11,22 +11,13 @@ ELSE(WIN32)
|
||||
ENDIF(APPLE)
|
||||
ENDIF(WIN32)
|
||||
|
||||
if(COMMAND cmake_policy)
|
||||
# Works around warnings libraries linked against that don't
|
||||
# have absolute paths (e.g. -lpthreads)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
|
||||
# Works around warnings about escaped quotes in ADD_DEFINITIONS
|
||||
# statements.
|
||||
cmake_policy(SET CMP0005 NEW)
|
||||
endif(COMMAND cmake_policy)
|
||||
|
||||
PROJECT(OpenSceneGraph)
|
||||
|
||||
SET(OPENSCENEGRAPH_MAJOR_VERSION 2)
|
||||
SET(OPENSCENEGRAPH_MINOR_VERSION 6)
|
||||
SET(OPENSCENEGRAPH_MINOR_VERSION 4)
|
||||
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
|
||||
SET(OPENSCENEGRAPH_SOVERSION 44)
|
||||
SET(OPENSCENEGRAPH_SOVERSION 35)
|
||||
|
||||
SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION})
|
||||
|
||||
@@ -65,20 +56,20 @@ ENDIF(USING_OSG_OP_OT_TRIPLE_SET)
|
||||
|
||||
|
||||
# Okay, here's the problem: On some platforms, linking against OpenThreads
|
||||
# is not enough and explicit linking to the underlying thread library
|
||||
# is not enough and explicit linking to the underlying thread library
|
||||
# is also required (e.g. FreeBSD). But OpenThreads may be built with different
|
||||
# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
|
||||
# thread library is because some platforms support multiple backends (e.g.
|
||||
# IRIX supports Sproc and Pthreads). Linking all libraries won't work
|
||||
# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
|
||||
# thread library is because some platforms support multiple backends (e.g.
|
||||
# IRIX supports Sproc and Pthreads). Linking all libraries won't work
|
||||
# because the libraries may be incompatible.
|
||||
# So the current solution is to attempt best guess linking and exempt certain
|
||||
# So the current solution is to attempt best guess linking and exempt certain
|
||||
# cases. With IRIX, we're going to hope explicit linking to the underlying
|
||||
# library is not necessary. We currently don't case for pthreads on Windows
|
||||
# which might be an issue on things like Cygwin. This may need to be fixed.
|
||||
FIND_PACKAGE(Threads)
|
||||
IF(CMAKE_SYSTEM MATCHES IRIX)
|
||||
# Erase CMAKE_THREAD_LIBS_INIT and hope it works
|
||||
SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
|
||||
SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
|
||||
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
|
||||
|
||||
# Find OpenGL
|
||||
@@ -96,37 +87,49 @@ IF(UNIX)
|
||||
# Some Unicies need explicit linkage to the Math library or the build fails.
|
||||
FIND_LIBRARY(MATH_LIBRARY m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
|
||||
# Make the headers visible to everything
|
||||
IF(NOT ${PROJECT_BINARY_DIR} EQUAL ${PROJECT_SOURCE_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include)
|
||||
ENDIF(NOT ${PROJECT_BINARY_DIR} EQUAL ${PROJECT_SOURCE_DIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OpenSceneGraph_SOURCE_DIR}/include
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
|
||||
# Common global definitions
|
||||
#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)
|
||||
|
||||
IF(MSVC)
|
||||
# This option is to enable the /MP switch for Visual Studio 2005 and above compilers
|
||||
OPTION(WIN32_USE_MP "Set to ON to build OpenSceneGraph with the /MP option (Visual Studio 2005 and above)." OFF)
|
||||
MARK_AS_ADVANCED(WIN32_USE_MP)
|
||||
IF(WIN32_USE_MP)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
ENDIF(WIN32_USE_MP)
|
||||
|
||||
# More MSVC specific compilation flags
|
||||
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
ENDIF(MSVC)
|
||||
# This option is to enable the /MP switch for Visual Studio 2005 and above compilers
|
||||
OPTION(WIN32_USE_MP "Set to ON to build OpenSceneGraph with the /MP option (Visual Studio 2005 and above)." OFF)
|
||||
MARK_AS_ADVANCED(WIN32_USE_MP)
|
||||
IF(WIN32_USE_MP)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
ENDIF(WIN32_USE_MP)
|
||||
|
||||
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
#needed for net plugin
|
||||
SET (OSG_SOCKET_LIBS wsock32)
|
||||
# Both Cygwin and Msys need -DNOMINMAX ???
|
||||
@@ -135,12 +138,12 @@ IF(WIN32)
|
||||
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
|
||||
# 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
|
||||
# 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
|
||||
##########################################################################################################
|
||||
|
||||
@@ -184,25 +187,27 @@ ENDIF(WIN32)
|
||||
|
||||
OPTION(OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float Matrix instead of double." OFF)
|
||||
MARK_AS_ADVANCED(OSG_USE_FLOAT_MATRIX)
|
||||
IF(OSG_USE_FLOAT_MATRIX)
|
||||
ADD_DEFINITIONS(-DOSG_USE_FLOAT_MATRIX)
|
||||
ENDIF(OSG_USE_FLOAT_MATRIX)
|
||||
|
||||
OPTION(OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float Plane instead of double." OFF)
|
||||
MARK_AS_ADVANCED(OSG_USE_FLOAT_PLANE)
|
||||
IF(OSG_USE_FLOAT_PLANE)
|
||||
ADD_DEFINITIONS(-DOSG_USE_FLOAT_PLANE)
|
||||
ENDIF(OSG_USE_FLOAT_PLANE)
|
||||
|
||||
OPTION(OSG_USE_FLOAT_BOUNDINGSPHERE "Set to ON to build OpenSceneGraph with float BoundingSphere instead of double." ON)
|
||||
MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGSPHERE)
|
||||
IF(NOT OSG_USE_FLOAT_BOUNDINGSPHERE)
|
||||
ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGSPHERE)
|
||||
ENDIF(NOT OSG_USE_FLOAT_BOUNDINGSPHERE)
|
||||
|
||||
OPTION(OSG_USE_FLOAT_BOUNDINGBOX "Set to ON to build OpenSceneGraph with float BoundingBox instead of double." ON)
|
||||
MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Set Config file
|
||||
|
||||
SET(OPENSCENEGRAPH_CONFIG_HEADER "${PROJECT_BINARY_DIR}/include/osg/Config")
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Config.in"
|
||||
"${OPENSCENEGRAPH_CONFIG_HEADER}")
|
||||
# INSTALL_FILES(/include/osg/ FILES "${OPENSCENEGRAPH_CONFIG_HEADER}")
|
||||
|
||||
IF(NOT OSG_USE_FLOAT_BOUNDINGBOX)
|
||||
ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGBOX)
|
||||
ENDIF(NOT OSG_USE_FLOAT_BOUNDINGBOX)
|
||||
|
||||
################################################################################
|
||||
# 3rd Party Dependency Stuff
|
||||
@@ -238,82 +243,26 @@ IF (DESIRED_QT_VERSION)
|
||||
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)
|
||||
|
||||
#use pkg-config to find various modues
|
||||
INCLUDE(FindPkgConfig OPTIONAL)
|
||||
|
||||
IF(PKG_CONFIG_FOUND)
|
||||
|
||||
INCLUDE(FindPkgConfig)
|
||||
|
||||
PKG_CHECK_MODULES(GTK gtk+-2.0)
|
||||
|
||||
IF(WIN32)
|
||||
PKG_CHECK_MODULES(GTKGL gtkglext-win32-1.0)
|
||||
ELSE(WIN32)
|
||||
PKG_CHECK_MODULES(GTKGL gtkglext-x11-1.0)
|
||||
ENDIF(WIN32)
|
||||
|
||||
PKG_CHECK_MODULES(RSVG librsvg-2.0)
|
||||
PKG_CHECK_MODULES(CAIRO cairo)
|
||||
|
||||
ENDIF(PKG_CONFIG_FOUND)
|
||||
|
||||
#
|
||||
# Test to determine if we want the "tripledot" form of the GLU tesselator callback.
|
||||
#
|
||||
IF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
IF(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
||||
# Skip the compile check for platforms that never need the variable
|
||||
# form.
|
||||
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT false)
|
||||
|
||||
ELSE(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
|
||||
# For other platforms perform the check
|
||||
INCLUDE(CheckCXXSourceCompiles)
|
||||
SET(CMAKE_REQUIRED_DEFINITIONS -DGLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include ${GLUT_INCLUDE_DIR} ${GL_INCLUDE_DIR})
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${GLUT_LIBRARY} ${GL_LIBRARY})
|
||||
CHECK_CXX_SOURCE_COMPILES(
|
||||
"#include <osg/GL>
|
||||
#include <osg/GLU>
|
||||
static void testcb(GLvoid *, void*) { }
|
||||
int main() {
|
||||
GLUtesselator *t = gluNewTess();
|
||||
gluTessCallback(t, GLU_TESS_VERTEX_DATA, (GLU_TESS_CALLBACK) testcb);
|
||||
return 0;
|
||||
}"
|
||||
GLU_Tesselator_Needs_Variable_Parameter_Callback_Convention_Failure_Means_No)
|
||||
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT
|
||||
${GLU_Tesselator_Needs_Variable_Parameter_Callback_Convention_Failure_Means_No})
|
||||
|
||||
ENDIF(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
ENDIF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
|
||||
OPTION(OSG_GLU_TESS_CALLBACK_TRIPLEDOT "Set to ON to build build with variable parameter (...) 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)
|
||||
|
||||
# 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
|
||||
# or we can hardcode the cases. The advantage of the former is that
|
||||
# or we can hardcode the cases. The advantage of the former is that
|
||||
# packages that are installed on platforms that don't require them
|
||||
# will still get built (presuming no compatibility issues). But this
|
||||
# also means modules that are redundant may get built. For example,
|
||||
# will still get built (presuming no compatibility issues). But this
|
||||
# also means modules that are redundant may get built. For example,
|
||||
# OS X doesn't need GIF, JPEG, PNG, TIFF, etc because it uses QuickTime.
|
||||
# Also, it will clutter the CMake menu with "NOT_FOUND".
|
||||
# The downside to the latter is that it is harder to build those
|
||||
@@ -331,8 +280,8 @@ IF(NOT APPLE)
|
||||
IF(WIN32)
|
||||
FIND_PACKAGE(QuickTime)
|
||||
ENDIF(WIN32)
|
||||
|
||||
ELSE(NOT APPLE)
|
||||
|
||||
ELSE(NOT APPLE)
|
||||
FIND_PACKAGE(QuickTime)
|
||||
ENDIF(NOT APPLE)
|
||||
|
||||
@@ -347,18 +296,7 @@ ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
################################################################################
|
||||
# Installation stuff
|
||||
|
||||
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
|
||||
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
ADD_DEFINITIONS(-DOSG_DEBUG_POSTFIX="${CMAKE_DEBUG_POSTFIX}")
|
||||
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
ADD_DEFINITIONS(-DOSG_DEBUG_POSTFIX='\"${CMAKE_DEBUG_POSTFIX}\"')
|
||||
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
IF(UNIX AND NOT WIN32 AND NOT APPLE)
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
ADD_DEFINITIONS("-D_DEBUG")
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
ENDIF(UNIX AND NOT WIN32 AND NOT APPLE)
|
||||
|
||||
SET(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
IF(UNIX AND NOT WIN32 AND NOT APPLE)
|
||||
IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
@@ -369,10 +307,7 @@ ENDIF(UNIX AND NOT WIN32 AND NOT APPLE)
|
||||
IF(NOT DEFINED LIB_POSTFIX)
|
||||
SET(LIB_POSTFIX "")
|
||||
ENDIF(NOT DEFINED LIB_POSTFIX)
|
||||
|
||||
# Here we apparantly do some funky stuff with making the bin/ and lib/
|
||||
# folders which is probably needed to work around a very old CMake bug?
|
||||
|
||||
|
||||
#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
|
||||
SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
|
||||
MAKE_DIRECTORY(${OUTPUT_BINDIR})
|
||||
@@ -380,32 +315,17 @@ IF(MSVC AND NOT MSVC_IDE)
|
||||
MAKE_DIRECTORY(${OUTPUT_BINDIR}/${OSG_PLUGINS})
|
||||
ENDIF(MSVC AND NOT MSVC_IDE)
|
||||
|
||||
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)
|
||||
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
|
||||
|
||||
# On CMake 2.4.x use EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH and later
|
||||
# we work around the DLL placement by use of the PREFIX target property hack
|
||||
#
|
||||
# On CMake 2.6.x use the newly minted CMAKE_LIBRARY_OUTPUT_DIRECTORY,
|
||||
# CMAKE_ARCHIVE_OUTPUT_DIRECTORY & CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
||||
|
||||
IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4)
|
||||
# If CMake >= 2.6.0
|
||||
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
|
||||
IF(WIN32)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
|
||||
ELSE(WIN32)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
|
||||
ENDIF(WIN32)
|
||||
ELSE(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4)
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
|
||||
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
|
||||
ENDIF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4)
|
||||
|
||||
#SET(INSTALL_BINDIR OpenSceneGraph/bin)
|
||||
#SET(INSTALL_INCDIR OpenSceneGraph/include)
|
||||
@@ -461,20 +381,20 @@ IF (BUILD_OSG_EXAMPLES)
|
||||
ADD_SUBDIRECTORY(examples)
|
||||
ENDIF(BUILD_OSG_EXAMPLES)
|
||||
|
||||
# This is for an advanced option to give aggressive warnings
|
||||
# This is for an advanced option to give aggressive warnings
|
||||
# under different compilers. If yours is not implemented, this option
|
||||
# will not be made available.
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# To be complete, we might also do GNUCC flags,
|
||||
# To be complete, we might also do GNUCC flags,
|
||||
# but everything here is C++ code.
|
||||
# -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
|
||||
# returns too many hits.
|
||||
# FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
|
||||
# FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
|
||||
# interesting C-specific flag.
|
||||
# Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
|
||||
# errors instead of warnings for certain issues, including superfluous
|
||||
# semicolons and commas, and the use of long long. -fpermissive seems
|
||||
# to be the workaround.
|
||||
# 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")
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
IF(MSVC)
|
||||
@@ -482,11 +402,11 @@ ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# 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
|
||||
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
|
||||
# remain unset.
|
||||
ENDIF(MSVC)
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
@@ -504,7 +424,7 @@ IF(OSG_AGGRESSIVE_WARNING_FLAGS)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OSG_AGGRESSIVE_WARNING_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ENDIF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
|
||||
ELSE(OSG_USE_AGGRESSIVE_WARNINGS)
|
||||
# FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was
|
||||
# FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was
|
||||
# set. The better way would be to parse the string and remove each
|
||||
# option explicitly.
|
||||
IF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
|
||||
@@ -514,28 +434,24 @@ IF(OSG_AGGRESSIVE_WARNING_FLAGS)
|
||||
ENDIF(OSG_USE_AGGRESSIVE_WARNINGS)
|
||||
ENDIF(OSG_AGGRESSIVE_WARNING_FLAGS)
|
||||
|
||||
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
|
||||
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
|
||||
# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
|
||||
IF(APPLE)
|
||||
# These are just defaults/recommendations, but how we want to build
|
||||
# out of the box. But the user needs to be able to change these options.
|
||||
# So we must only set the values the first time CMake is run, or we
|
||||
# So we must only set the values the first time CMake is run, or we
|
||||
# will overwrite any changes the user sets.
|
||||
# FORCE is used because the options are not reflected in the UI otherwise.
|
||||
# Seems like a good place to add version specific compiler flags too.
|
||||
IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||
# This is really fragile, but CMake doesn't provide the OS system
|
||||
# version information we need. (Darwin versions can be changed
|
||||
# This is really fragile, but CMake doesn't provide the OS system
|
||||
# version information we need. (Darwin versions can be changed
|
||||
# independently of OS X versions.)
|
||||
# It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
|
||||
IF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
|
||||
# 64-bit compiles are not supported with Carbon. We should enable
|
||||
# 64-bit compilation by default once osgviewer has been
|
||||
# rewritten with Cocoa.
|
||||
#SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
IF(EXISTS /Developer/SDKs/10.5.sdk)
|
||||
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSE(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
|
||||
ELSE(EXISTS /Developer/SDKs/10.5.sdk)
|
||||
IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
|
||||
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
@@ -544,11 +460,11 @@ IF(APPLE)
|
||||
# Should break down further to set the -mmacosx-version-min,
|
||||
# but the SDK detection is too unreliable here.
|
||||
ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
|
||||
ENDIF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
|
||||
ENDIF(EXISTS /Developer/SDKs/10.5.sdk)
|
||||
ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||
|
||||
|
||||
OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
|
||||
|
||||
|
||||
ENDIF(APPLE)
|
||||
|
||||
OPTION(BUILD_REF_DOCS "Build OpenSceneGraph reference documentation using doxygen (use: make DoxygenDoc)" OFF)
|
||||
@@ -560,7 +476,7 @@ IF(BUILD_REF_DOCS)
|
||||
ENDIF(BUILD_REF_DOCS)
|
||||
|
||||
# For Doxygen
|
||||
#FIXME: I haven't figured out what to do with OSG's multiple doxyfiles
|
||||
#FIXME: I haven't figured out what to do with OSG's multiple doxyfiles
|
||||
# and footer.
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
|
||||
OPTION(BUILD_DOCUMENTATION "Build osg documentation" OFF)
|
||||
@@ -574,13 +490,13 @@ IF(BUILD_DOCUMENTATION)
|
||||
ELSE(BUILD_REF_DOCS_SEARCHENGINE)
|
||||
SET(SEARCHENGINE NO)
|
||||
ENDIF(BUILD_REF_DOCS_SEARCHENGINE)
|
||||
|
||||
|
||||
IF(BUILD_REF_DOCS_TAGFILE)
|
||||
SET(GENERATE_TAGFILE "doc/OpenSceneGraphReferenceDocs/osg.tag")
|
||||
ELSE(BUILD_REF_DOCS_TAGFILE)
|
||||
SET(GENERATE_TAGFILE "")
|
||||
ENDIF(BUILD_REF_DOCS_TAGFILE)
|
||||
|
||||
|
||||
IF(DOT)
|
||||
SET(HAVE_DOT YES)
|
||||
ELSE(DOT)
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
# Check for availability of atomic operations
|
||||
# This module defines
|
||||
# OPENTHREADS_HAVE_ATOMIC_OPS
|
||||
|
||||
INCLUDE(CheckCXXSourceRuns)
|
||||
|
||||
# Do step by step checking,
|
||||
CHECK_CXX_SOURCE_RUNS("
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned value = 0;
|
||||
void* ptr = &value;
|
||||
__sync_add_and_fetch(&value, 1);
|
||||
__sync_synchronize();
|
||||
__sync_sub_and_fetch(&value, 1);
|
||||
if (!__sync_bool_compare_and_swap(&value, 0, 1))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!__sync_bool_compare_and_swap(&ptr, ptr, ptr))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
" _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
|
||||
|
||||
CHECK_CXX_SOURCE_RUNS("
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int, const char**)
|
||||
{
|
||||
unsigned value = 0;
|
||||
void* ptr = &value;
|
||||
__add_and_fetch(&value, 1);
|
||||
__synchronize(value);
|
||||
__sub_and_fetch(&value, 1);
|
||||
if (!__compare_and_swap(&value, 0, 1))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!__compare_and_swap((unsigned long*)&ptr, (unsigned long)ptr, (unsigned long)ptr))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
" _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
|
||||
|
||||
CHECK_CXX_SOURCE_RUNS("
|
||||
#include <atomic.h>
|
||||
#include <cstdlib>
|
||||
|
||||
int main(int, const char**)
|
||||
{
|
||||
uint_t value = 0;
|
||||
void* ptr = &value;
|
||||
atomic_inc_uint_nv(&value);
|
||||
membar_consumer();
|
||||
atomic_dec_uint_nv(&value);
|
||||
if (0 != atomic_cas_uint(&value, 0, 1))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (ptr != atomic_cas_ptr(&ptr, ptr, ptr))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
" _OPENTHREADS_ATOMIC_USE_SUN)
|
||||
|
||||
CHECK_CXX_SOURCE_RUNS("
|
||||
#include <windows.h>
|
||||
#include <cstdlib>
|
||||
|
||||
int main(int, const char**)
|
||||
{
|
||||
volatile long value = 0;
|
||||
long data = 0;
|
||||
long* volatile ptr = &data;
|
||||
|
||||
InterlockedIncrement(&value);
|
||||
MemoryBarrier();
|
||||
InterlockedDecrement(&value);
|
||||
|
||||
if (0 != InterlockedCompareExchange(&value, 1, 0))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (ptr != InterlockedCompareExchangePointer((PVOID volatile*)&ptr, (PVOID)ptr, (PVOID)ptr))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
" _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
|
||||
|
||||
IF(NOT _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_SUN AND NOT _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
|
||||
SET(_OPENTHREADS_ATOMIC_USE_MUTEX 1)
|
||||
ENDIF(NOT _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_SUN AND NOT _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFFIX)
|
||||
|
||||
MESSAGE(STATUS "searching ${DEPNAME} -->${INCLUDEFILE}<-->${LIBRARY_NAMES}<-->${SEARCHPATHLIST}<--")
|
||||
|
||||
MESSAGE(STATUS "searching ${DEPNAME} -->${INCLUDEFILE}<-->${LIBRARY}<-->${SEARCHPATHLIST}<--")
|
||||
|
||||
SET(MY_PATH_INCLUDE )
|
||||
SET(MY_PATH_LIB )
|
||||
|
||||
@@ -14,10 +14,9 @@ MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFF
|
||||
SET(MY_PATH_INCLUDE ${MY_PATH_INCLUDE} ${MYPATH}/include)
|
||||
SET(MY_PATH_LIB ${MY_PATH_LIB} ${MYPATH}/lib)
|
||||
ENDFOREACH( MYPATH ${SEARCHPATHLIST} )
|
||||
|
||||
|
||||
FIND_PATH("${DEPNAME}_INCLUDE_DIR" ${INCLUDEFILE}
|
||||
${MY_PATH_INCLUDE}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
MARK_AS_ADVANCED("${DEPNAME}_INCLUDE_DIR")
|
||||
#MESSAGE( " ${DEPNAME}_INCLUDE_DIR --> ${${DEPNAME}_INCLUDE_DIR}<--")
|
||||
@@ -25,7 +24,6 @@ MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFF
|
||||
FIND_LIBRARY("${DEPNAME}_LIBRARY"
|
||||
NAMES ${LIBRARY_NAMES}
|
||||
PATHS ${MY_PATH_LIB}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
SET(LIBRARY_NAMES_DEBUG "")
|
||||
FOREACH(LIBNAME ${LIBRARY_NAMES})
|
||||
@@ -34,7 +32,6 @@ MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFF
|
||||
FIND_LIBRARY("${DEPNAME}_LIBRARY_DEBUG"
|
||||
NAMES ${LIBRARY_NAMES_DEBUG}
|
||||
PATHS ${MY_PATH_LIB}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
MARK_AS_ADVANCED("${DEPNAME}_LIBRARY")
|
||||
#MESSAGE( " ${DEPNAME}_LIBRARY --> ${${DEPNAME}_LIBRARY}<--")
|
||||
|
||||
@@ -18,9 +18,7 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/local/include/colladadom
|
||||
/usr/include/
|
||||
/usr/include/colladadom
|
||||
/usr/include
|
||||
/sw/include # Fink
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include # Blastwave
|
||||
@@ -30,7 +28,7 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
|
||||
)
|
||||
|
||||
FIND_LIBRARY(COLLADA_LIBRARY
|
||||
NAMES collada_dom collada14dom
|
||||
NAMES collada_dom
|
||||
PATHS
|
||||
$ENV{COLLADA_DIR}/lib
|
||||
$ENV{COLLADA_DIR}/lib-dbg
|
||||
@@ -41,9 +39,7 @@ FIND_LIBRARY(COLLADA_LIBRARY
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
|
||||
@@ -21,26 +21,22 @@ MACRO(LINK_WITH_VARIABLES TRGTNAME)
|
||||
ENDMACRO(LINK_WITH_VARIABLES TRGTNAME)
|
||||
|
||||
MACRO(LINK_INTERNAL TRGTNAME)
|
||||
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN})
|
||||
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
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
|
||||
IF(NOT MSVC_IDE)
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
|
||||
ELSE(NOT MSVC_IDE)
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ENDIF(NOT MSVC_IDE)
|
||||
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)
|
||||
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
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
|
||||
IF(NOT MSVC_IDE)
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
|
||||
ELSE(NOT MSVC_IDE)
|
||||
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
|
||||
ENDIF(NOT MSVC_IDE)
|
||||
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)
|
||||
|
||||
MACRO(LINK_EXTERNAL TRGTNAME)
|
||||
@@ -122,7 +118,7 @@ ENDMACRO(SETUP_LINK_LIBRARIES)
|
||||
|
||||
MACRO(SETUP_PLUGIN PLUGIN_NAME)
|
||||
|
||||
SET(TARGET_NAME ${PLUGIN_NAME} )
|
||||
SET(TARGET_NAME ${PLUGIN_NAME} )
|
||||
|
||||
#MESSAGE("in -->SETUP_PLUGIN<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
|
||||
|
||||
@@ -135,7 +131,7 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
|
||||
SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
|
||||
ENDIF(NOT TARGET_LABEL)
|
||||
|
||||
# here we use the command to generate the library
|
||||
# here we use the command to generate the library
|
||||
|
||||
IF (DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_LIBRARY(${TARGET_TARGETNAME} MODULE ${TARGET_SRC} ${TARGET_H})
|
||||
@@ -145,57 +141,40 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
|
||||
|
||||
#not sure if needed, but for plugins only Msvc need the d suffix
|
||||
IF(NOT MSVC)
|
||||
IF(NOT UNIX)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
|
||||
ENDIF(NOT UNIX)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
|
||||
ELSE(NOT MSVC)
|
||||
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
IF(NOT MSVC_IDE)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
|
||||
ELSE(NOT MSVC_IDE)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../${OSG_PLUGINS}/")
|
||||
ENDIF(NOT MSVC_IDE)
|
||||
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
IF(OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
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}
|
||||
|
||||
|
||||
IF(NOT MSVC_IDE)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/")
|
||||
ELSE(NOT MSVC_IDE)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/" IMPORT_PREFIX "../")
|
||||
ENDIF(NOT MSVC_IDE)
|
||||
|
||||
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(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
|
||||
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}")
|
||||
|
||||
SETUP_LINK_LIBRARIES()
|
||||
|
||||
#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/${OSG_PLUGINS} LIBRARY DESTINATION bin/${OSG_PLUGINS} )
|
||||
ELSE(WIN32)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME}
|
||||
RUNTIME DESTINATION bin
|
||||
ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS}
|
||||
LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} )
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} )
|
||||
ENDIF(WIN32)
|
||||
ENDMACRO(SETUP_PLUGIN)
|
||||
|
||||
@@ -248,15 +227,12 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
|
||||
ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H})
|
||||
|
||||
ENDIF(${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_IDE AND OSG_MSVC_VERSIONED_DLL)
|
||||
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../")
|
||||
ENDIF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
|
||||
|
||||
SETUP_LINK_LIBRARIES()
|
||||
|
||||
ENDMACRO(SETUP_EXE)
|
||||
@@ -274,11 +250,7 @@ MACRO(SETUP_APPLICATION APPLICATION_NAME)
|
||||
|
||||
SETUP_EXE(${IS_COMMANDLINE_APP})
|
||||
|
||||
IF(APPLE)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin)
|
||||
ELSE(APPLE)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin )
|
||||
ENDIF(APPLE)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin )
|
||||
|
||||
ENDMACRO(SETUP_APPLICATION)
|
||||
|
||||
@@ -301,11 +273,7 @@ MACRO(SETUP_EXAMPLE EXAMPLE_NAME)
|
||||
|
||||
SETUP_EXE(${IS_COMMANDLINE_APP})
|
||||
|
||||
IF(APPLE)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )
|
||||
ELSE(APPLE)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin )
|
||||
ENDIF(APPLE)
|
||||
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin )
|
||||
|
||||
ENDMACRO(SETUP_EXAMPLE)
|
||||
|
||||
@@ -318,12 +286,12 @@ 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}-
|
||||
#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)
|
||||
|
||||
69
NEWS.txt
69
NEWS.txt
@@ -1,75 +1,6 @@
|
||||
OSG News
|
||||
========
|
||||
|
||||
= !OpenSceneGraph 2.6 release adds osgWidget library, KdTree intersections, Anti-aliased FBOsand much more. =
|
||||
|
||||
PERTHSHIRE, Scotland - 5th August 2008 - !OpenSceneGraph Professional Services announces the release of !OpenSceneGraph 2.6, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. !OpenSceneGraph 2.6 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.6 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.6 release is the culmination of 9 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: ===
|
||||
|
||||
* New osgWidget library for scene graph based graphics user interface elements (beta release).
|
||||
* KdTree support, with automatic KdTree generation on load and use of KdTree during line intersections which massively improves intersection speeds.
|
||||
* Precision improvements to line intersections, provide accurate whole earth intersection.
|
||||
* OpenGL Multi-sample FrameBufferObject support.
|
||||
* New osg::ImageSequence class for doing texture animation of a series of image files.
|
||||
* New database optimizer that is able to remove static transforms by duplicating shared geometries.
|
||||
* Use glGenerateMipmap to speed up mipmap generation in non power-of-two textures.
|
||||
* New osgViewer::ScreenCaptureHandler for adding screen shot support to osgViewer applications.
|
||||
* New osgscreencapture example that demonstrates use of double buffer PixelBufferObject's for streaming of imagery from the screen.
|
||||
* New utility application osgfilecache which can be used to populate the local cache for given lat/lon ranges and levels.
|
||||
* Rewritten DatabasePager that now supports multiple database reading threads. This includes handling of HTTP requests via a separate reading thread, vastly improving the speed of updates when handling HTTP hosted databases that have already partially been downloaded to local file cache.
|
||||
* Support for a file cache for locally caching paged databases hosted over HTTP.
|
||||
* Support for http authentication in osgDB and the libcurl plugin
|
||||
* New osgconv --format <fmt>, --formats and --plugins command line options for listing available plugins and the file formats/options they support.
|
||||
* Performance improvements in handling TerraPage.
|
||||
* Animated GIF support.
|
||||
* New SVG image loader.
|
||||
* Improvements to the .obj loader to support a wider range of .obj files and material properties.
|
||||
* Support for thread safe Atomic reference counting.
|
||||
* Support for COLLADA DOM 2.x
|
||||
* Support for Philips WOWvx 3D auto-stereoscopic displays
|
||||
* New include/osg/Config and include/OpenThreads/Config configuration files, that are automatically generated by CMake, which make more straight forward to build end users applications against OpenSceneGraph versions built with non default build options.
|
||||
* Support for CMake 2.6
|
||||
* 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.
|
||||
|
||||
!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, and a range of [wiki:Community/Contractors Contractors] from around the world. Services available include:
|
||||
|
||||
* Confidential Professional Support
|
||||
* Bespoke development
|
||||
* Consultancy
|
||||
* Training
|
||||
|
||||
=== Community support and contributions ===
|
||||
The diverse and growing community of over 1900 developers is centred 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/TwoPointSix 324 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.4 release adds geometry shaders, multiple render targets, support for terrabyte scale terrain databases, writing to !OpenFlight and much more. =
|
||||
|
||||
PERTHSHIRE, Scotland - 25th April 2008 - !OpenSceneGraph Professional Services announces the release of !OpenSceneGraph 2.4, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. !OpenSceneGraph 2.4 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.4 runs on all Microsoft Windows platforms, Apple OS/X, GNU/Linux, IRIX, Solaris, HP-UX, AIX and FreeBSD operating systems.
|
||||
|
||||
77
README.txt
77
README.txt
@@ -15,7 +15,7 @@ subscribe to our public mailing list:
|
||||
|
||||
Robert Osfield.
|
||||
Project Lead.
|
||||
5th August 2008.
|
||||
25th April 2008.
|
||||
|
||||
--
|
||||
|
||||
@@ -66,82 +66,9 @@ system should help guide you through the process:
|
||||
|
||||
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. See release notes on OSX CMake build below.
|
||||
directory.
|
||||
|
||||
For further details on compilation, installation and platform-specific
|
||||
information read "Getting Started" guide:
|
||||
|
||||
http://www.openscenegraph.org/projects/osg/wiki/Support/GettingStarted
|
||||
|
||||
|
||||
-- Release notes on OSX build, by Eric Sokolowsky, August 5, 2008
|
||||
|
||||
There are several ways to compile OpenSceneGraph under OSX. The
|
||||
recommended way is to use CMake 2.6 to generate Xcode projects, then use
|
||||
Xcode to build the library. The default project will be able to build
|
||||
Debug or Release libraries, examples, and sample applications. Here are
|
||||
some key settings to consider when using CMake:
|
||||
|
||||
BUILD_OSG_EXAMPLES - By default this is turned off. Turn this setting on
|
||||
to compile many great example programs.
|
||||
|
||||
CMAKE_OSX_ARCHITECTURES - Xcode can create applications, executables,
|
||||
libraries, and frameworks that can be run on more than one architecture.
|
||||
Use this setting to indicate the architectures on which to build OSG.
|
||||
Possibilities include ppc, ppc64, i386, and x86_64. Building OSG using
|
||||
either of the 64-bit options (ppc64 and x86_64) has its own caveats
|
||||
below.
|
||||
|
||||
OSG_BUILD_APPLICATION_BUNDLES - Normally only executable binaries are
|
||||
created for the examples and sample applications. Turn this option on if
|
||||
you want to create real OSX .app bundles. There are caveats to creating
|
||||
.app bundles, see below.
|
||||
|
||||
OSG_WINDOWING_SYSTEM - You have the choice to use Carbon or X11 when
|
||||
building applications on OSX. Under Leopard and later, X11 applications,
|
||||
when started, will automatically launch X11 when needed. However,
|
||||
full-screen X11 applications will still show the menu bar at the top of
|
||||
the screen. Since many parts of the Carbon user interface are not
|
||||
64-bit, X11 is the only supported option for OSX applications compiled
|
||||
for ppc64 or x86_64.
|
||||
|
||||
There is an Xcode directory in the base of the OSG software
|
||||
distribution, but its future is limited, and will be discontinued once
|
||||
the CMake project generator completely implements its functionality.
|
||||
|
||||
|
||||
APPLICATION BUNDLES (.app bundles)
|
||||
|
||||
The example programs when built as application bundles only contain the
|
||||
executable file. They do not contain the dependent libraries as would a
|
||||
normal bundle, so they are not generally portable to other machines.
|
||||
They also do not know where to find plugins. An environmental variable
|
||||
OSG_LIBRARY_PATH may be set to point to the location where the plugin
|
||||
.so files are located. OSG_FILE_PATH may be set to point to the location
|
||||
where data files are located. Setting OSG_FILE_PATH to the
|
||||
OpenSceneGraph-Data directory is very useful when testing OSG by running
|
||||
the example programs.
|
||||
|
||||
Many of the example programs use command-line arguments. When
|
||||
double-clicking on an application (or using the equivalent "open"
|
||||
command on the command line) only those examples and applications that
|
||||
do not require command-line arguments will successfully run. The
|
||||
executable file within the .app bundle can be run from the command-line
|
||||
if command-line arguments are needed.
|
||||
|
||||
|
||||
64-BIT APPLICATION SUPPORT
|
||||
|
||||
OpenSceneGraph will not compile successfully when OSG_WINDOWING_SYSTEM is
|
||||
Carbon and either x86_64 or ppc64 is selected under CMAKE_OSX_ARCHITECTURES,
|
||||
as Carbon is a 32bit only API. A version of the osgviewer library written in
|
||||
Cocoa is needed. However, OSG may be compiled under 64-bits if the X11
|
||||
windowing system is selected. However, Two parts of the OSG default
|
||||
distribution will not work with 64-bit X11: the osgviewerWX example
|
||||
program and the osgdb_qt (Quicktime) plugin. These must be removed from
|
||||
the Xcode project after Cmake generates it in order to compile with
|
||||
64-bit architectures. The lack of the latter means that images such as
|
||||
jpeg, tiff, png, and gif will not work, nor will animations dependent on
|
||||
Quicktime. A new ImageIO-based plugin is being developed to handle the
|
||||
still images, and a QTKit plugin will need to be developed to handle
|
||||
animations.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +0,0 @@
|
||||
#ifndef _OPENTHREADS_CONFIG
|
||||
#define _OPENTHREADS_CONFIG
|
||||
|
||||
/* #undef _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS */
|
||||
/* #undef _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS */
|
||||
/* #undef _OPENTHREADS_ATOMIC_USE_SUN */
|
||||
/* #undef _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED */
|
||||
/* #undef _OPENTHREADS_ATOMIC_USE_MUTEX */
|
||||
|
||||
#endif
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef OSG_CONFIG
|
||||
#define OSG_CONFIG 1
|
||||
|
||||
/* #undef OSG_USE_FLOAT_MATRIX */
|
||||
/* #undef OSG_USE_FLOAT_PLANE */
|
||||
#define OSG_USE_FLOAT_BOUNDINGSPHERE
|
||||
#define OSG_USE_FLOAT_BOUNDINGBOX
|
||||
/* #undef OSG_ENFORCE_THREADSAFE */
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>osgWidget</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.OpenSceneGraph.osgWidget</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string></string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.2.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>osgimagesequence</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.OpenSceneGraph.osgimagesequence</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>osgwidgetmenu</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.OpenSceneGraph.osgwidgetmenu</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -30,7 +30,6 @@ ADD_SUBDIRECTORY(osgviewer)
|
||||
ADD_SUBDIRECTORY(osgarchive)
|
||||
ADD_SUBDIRECTORY(osgconv)
|
||||
ADD_SUBDIRECTORY(osgversion)
|
||||
ADD_SUBDIRECTORY(osgfilecache)
|
||||
|
||||
#REWRITE_CMAKELIST(ADD_OSG_EXAMPLE)
|
||||
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC
|
||||
OrientationConverter.cpp
|
||||
osgconv.cpp
|
||||
)
|
||||
SET(TARGET_H
|
||||
OrientationConverter.h
|
||||
)
|
||||
|
||||
SET(TARGET_SRC OrientationConverter.cpp osgconv.cpp )
|
||||
SET(TARGET_H OrientationConverter.h )
|
||||
#### end var setup ###
|
||||
SETUP_APPLICATION(osgconv)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/ReaderWriter>
|
||||
#include <osgDB/PluginQuery>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgUtil/Simplifier>
|
||||
@@ -507,8 +506,6 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--formats","List supported file formats");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--plugins","List database olugins");
|
||||
|
||||
|
||||
// if user request help write it out to cout.
|
||||
@@ -525,45 +522,6 @@ int main( int argc, char **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arguments.read("--plugins"))
|
||||
{
|
||||
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
|
||||
for(osgDB::FileNameList::iterator itr = plugins.begin();
|
||||
itr != plugins.end();
|
||||
++itr)
|
||||
{
|
||||
std::cout<<"Plugin "<<*itr<<std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string plugin;
|
||||
if (arguments.read("--plugin", plugin))
|
||||
{
|
||||
osgDB::outputPluginDetails(std::cout, plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string ext;
|
||||
if (arguments.read("--format", ext))
|
||||
{
|
||||
plugin = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
|
||||
osgDB::outputPluginDetails(std::cout, plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.read("--formats"))
|
||||
{
|
||||
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
|
||||
for(osgDB::FileNameList::iterator itr = plugins.begin();
|
||||
itr != plugins.end();
|
||||
++itr)
|
||||
{
|
||||
osgDB::outputPluginDetails(std::cout,*itr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arguments.argc()<=1)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||
@@ -582,6 +540,7 @@ int main( int argc, char **argv )
|
||||
osgDB::Registry::instance()->setOptions(options);
|
||||
}
|
||||
|
||||
std::string ext;
|
||||
while (arguments.read("-e",ext))
|
||||
{
|
||||
std::string libName = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
SET(TARGET_SRC osgfilecache.cpp )
|
||||
|
||||
SET(TARGET_ADDED_LIBRARIES osgTerrain )
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_APPLICATION(osgfilecache)
|
||||
@@ -1,427 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This application is open source and may be redistributed and/or modified
|
||||
* freely and without restriction, both in commericial and non commericial applications,
|
||||
* as long as this copyright notice is maintained.
|
||||
*
|
||||
* This application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <osg/Timer>
|
||||
#include <osg/ArgumentParser>
|
||||
#include <osg/ApplicationUsage>
|
||||
#include <osg/CoordinateSystemNode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgTerrain/TerrainTile>
|
||||
|
||||
#include <osgDB/Archive>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
static bool s_ExitApplication = false;
|
||||
|
||||
struct Extents
|
||||
{
|
||||
|
||||
Extents():
|
||||
_maxLevel(0),
|
||||
_min(DBL_MAX,DBL_MAX),
|
||||
_max(-DBL_MAX,-DBL_MAX) {}
|
||||
|
||||
Extents(unsigned int maxLevel, double minX, double minY, double maxX, double maxY):
|
||||
_maxLevel(maxLevel),
|
||||
_min(minX, minY),
|
||||
_max(maxX, maxY) {}
|
||||
|
||||
Extents(const Extents& extents):
|
||||
_maxLevel(extents._maxLevel),
|
||||
_min(extents._min),
|
||||
_max(extents._max) {}
|
||||
|
||||
Extents& operator = (const Extents& rhs)
|
||||
{
|
||||
if (&rhs == this) return *this;
|
||||
|
||||
_maxLevel = rhs._maxLevel;
|
||||
_min = rhs._min;
|
||||
_max = rhs._max;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool intersects(unsigned level, osg::Vec2d& in_min, osg::Vec2d& in_max)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"intersects("<<level<<", min="<<in_min<<" max="<<in_max<<")"<<std::endl;
|
||||
osg::notify(osg::INFO)<<" _maxLevel="<<_maxLevel<<", _min="<<_min<<" _max="<<_max<<std::endl;
|
||||
|
||||
if (level>_maxLevel) return false;
|
||||
|
||||
osg::Vec2d union_min, union_max;
|
||||
|
||||
// handle mins
|
||||
if (_min.x()!=DBL_MAX && in_min.x()!=DBL_MAX)
|
||||
{
|
||||
// both _min.x() and in_min.x() are defined so use max of two
|
||||
union_min.x() = _min.x()>in_min.x() ? _min.x() : in_min.x();
|
||||
}
|
||||
else
|
||||
{
|
||||
// one or both _min.x() and in_min.x() aren't defined so use min of two
|
||||
union_min.x() = _min.x()<in_min.x() ? _min.x() : in_min.x();
|
||||
}
|
||||
|
||||
if (_min.y()!=DBL_MAX && in_min.y()!=DBL_MAX)
|
||||
{
|
||||
// both _min.y() and in_min.y() are defined so use max of two
|
||||
union_min.y() = _min.y()>in_min.y() ? _min.y() : in_min.y();
|
||||
}
|
||||
else
|
||||
{
|
||||
// one or both _min.y() and in_min.y() aren't defined so use min of two
|
||||
union_min.y() = _min.y()<in_min.y() ? _min.y() : in_min.y();
|
||||
}
|
||||
|
||||
// handle maxs
|
||||
if (_max.x()!=-DBL_MAX && in_max.x()!=-DBL_MAX)
|
||||
{
|
||||
// both _max.x() and in_max.x() are defined so use max of two
|
||||
union_max.x() = _max.x()<in_max.x() ? _max.x() : in_max.x();
|
||||
}
|
||||
else
|
||||
{
|
||||
// one or both _max.x() and in_max.x() aren't defined so use max of two
|
||||
union_max.x() = _max.x()>in_max.x() ? _max.x() : in_max.x();
|
||||
}
|
||||
|
||||
if (_max.y()!=-DBL_MAX && in_max.y()!=-DBL_MAX)
|
||||
{
|
||||
// both _max.y() and in_max.y() are defined so use max of two
|
||||
union_max.y() = _max.y()<in_max.y() ? _max.y() : in_max.y();
|
||||
}
|
||||
else
|
||||
{
|
||||
// one or both _max.y() and in_max.y() aren't defined so use max of two
|
||||
union_max.y() = _max.y()>in_max.y() ? _max.y() : in_max.y();
|
||||
}
|
||||
|
||||
bool result = union_min.x()<union_max.x() && union_min.y()<union_max.y() ;
|
||||
|
||||
osg::notify(osg::INFO)<<" union_min="<<union_min<<" union_max="<<union_max<<" result = "<<result<<std::endl;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int _maxLevel;
|
||||
osg::Vec2d _min;
|
||||
osg::Vec2d _max;
|
||||
};
|
||||
|
||||
class LoadDataVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
LoadDataVisitor():
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_currentLevel(0) {}
|
||||
|
||||
void addExtents(unsigned int maxLevel, double minX, double minY, double maxX, double maxY)
|
||||
{
|
||||
_extentsList.push_back(Extents(maxLevel, minX, minY, maxX, maxY));
|
||||
}
|
||||
|
||||
void addExtents(unsigned int maxLevel)
|
||||
{
|
||||
_extentsList.push_back(Extents(maxLevel, DBL_MAX, DBL_MAX, -DBL_MAX, -DBL_MAX));
|
||||
}
|
||||
|
||||
void apply(osg::CoordinateSystemNode& cs)
|
||||
{
|
||||
_csnStack.push_back(&cs);
|
||||
|
||||
if (!s_ExitApplication) traverse(cs);
|
||||
|
||||
_csnStack.pop_back();
|
||||
}
|
||||
|
||||
void apply(osg::Group& group)
|
||||
{
|
||||
if (s_ExitApplication) return;
|
||||
|
||||
osgTerrain::TerrainTile* terrainTile = dynamic_cast<osgTerrain::TerrainTile*>(&group);
|
||||
osgTerrain::Locator* locator = terrainTile ? terrainTile->getLocator() : 0;
|
||||
if (locator)
|
||||
{
|
||||
osg::Vec3d l00(0.0,0.0,0.0);
|
||||
osg::Vec3d l10(1.0,0.0,0.0);
|
||||
osg::Vec3d l11(1.0,1.0,0.0);
|
||||
osg::Vec3d l01(0.0,1.0,0.0);
|
||||
|
||||
osg::Vec3d w00, w10, w11, w01;
|
||||
|
||||
locator->convertLocalToModel(l00, w00);
|
||||
locator->convertLocalToModel(l10, w10);
|
||||
locator->convertLocalToModel(l11, w11);
|
||||
locator->convertLocalToModel(l01, w01);
|
||||
|
||||
if (locator->getEllipsoidModel() &&
|
||||
locator->getCoordinateSystemType()==osgTerrain::Locator::GEOCENTRIC)
|
||||
{
|
||||
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w00);
|
||||
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w10);
|
||||
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w11);
|
||||
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w01);
|
||||
}
|
||||
|
||||
updateBound(w00);
|
||||
updateBound(w10);
|
||||
updateBound(w11);
|
||||
updateBound(w01);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
traverse(group);
|
||||
}
|
||||
|
||||
void apply(osg::Transform& transform)
|
||||
{
|
||||
osg::Matrix matrix;
|
||||
if (!_matrixStack.empty()) matrix = _matrixStack.back();
|
||||
|
||||
transform.computeLocalToWorldMatrix(matrix,this);
|
||||
|
||||
pushMatrix(matrix);
|
||||
|
||||
traverse(transform);
|
||||
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
void apply(osg::PagedLOD& plod)
|
||||
{
|
||||
if (s_ExitApplication) return;
|
||||
|
||||
++_currentLevel;
|
||||
|
||||
initBound();
|
||||
|
||||
// first compute the bounds of this subgraph
|
||||
for(unsigned int i=0; i<plod.getNumFileNames(); ++i)
|
||||
{
|
||||
if (plod.getFileName(i).empty())
|
||||
{
|
||||
traverse(plod);
|
||||
}
|
||||
}
|
||||
|
||||
if (intersects())
|
||||
{
|
||||
for(unsigned int i=0; i<plod.getNumFileNames(); ++i)
|
||||
{
|
||||
osg::notify(osg::INFO)<<" filename["<<i<<"] "<<plod.getFileName(i)<<std::endl;
|
||||
if (!plod.getFileName(i).empty())
|
||||
{
|
||||
std::string filename;
|
||||
if (!plod.getDatabasePath().empty())
|
||||
{
|
||||
filename = plod.getDatabasePath() + plod.getFileName(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = plod.getFileName(i);
|
||||
}
|
||||
|
||||
osg::notify(osg::NOTICE)<<"reading "<<filename<<std::endl;
|
||||
|
||||
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filename);
|
||||
|
||||
if (!s_ExitApplication && node.valid()) node->accept(*this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--_currentLevel;
|
||||
}
|
||||
|
||||
void apply(osg::Geode& geode)
|
||||
{
|
||||
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
|
||||
{
|
||||
osg::Geometry* geom = geode.getDrawable(i)->asGeometry();
|
||||
if (geom)
|
||||
{
|
||||
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
|
||||
if (vertices) updateBound(*vertices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
inline void pushMatrix(osg::Matrix& matrix) { _matrixStack.push_back(matrix); }
|
||||
|
||||
inline void popMatrix() { _matrixStack.pop_back(); }
|
||||
|
||||
void convertXYZToLatLongHeight(osg::EllipsoidModel* em, osg::Vec3d& v)
|
||||
{
|
||||
em->convertXYZToLatLongHeight(v.x(), v.y(), v.z(),
|
||||
v.y(), v.x(), v.z());
|
||||
|
||||
v.x() = osg::RadiansToDegrees(v.x());
|
||||
v.y() = osg::RadiansToDegrees(v.y());
|
||||
}
|
||||
|
||||
void initBound()
|
||||
{
|
||||
_min.set(DBL_MAX, DBL_MAX);
|
||||
_max.set(-DBL_MAX, -DBL_MAX);
|
||||
}
|
||||
|
||||
void updateBound(osg::Vec3d& v)
|
||||
{
|
||||
if (v.x() < _min.x()) _min.x() = v.x();
|
||||
if (v.y() < _min.y()) _min.y() = v.y();
|
||||
if (v.x() > _max.x()) _max.x() = v.x();
|
||||
if (v.y() > _max.y()) _max.y() = v.y();
|
||||
}
|
||||
|
||||
void updateBound(osg::Vec3Array& vertices)
|
||||
{
|
||||
// set up matrix
|
||||
osg::Matrix matrix;
|
||||
if (!_matrixStack.empty()) matrix = _matrixStack.back();
|
||||
|
||||
// set up ellipsoid model
|
||||
osg::EllipsoidModel* em = !_csnStack.empty() ? _csnStack.back()->getEllipsoidModel() : 0;
|
||||
|
||||
for(osg::Vec3Array::iterator itr = vertices.begin();
|
||||
itr != vertices.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Vec3d v = osg::Vec3d(*itr) * matrix;
|
||||
if (em) convertXYZToLatLongHeight(em, v);
|
||||
|
||||
updateBound(v);
|
||||
}
|
||||
}
|
||||
|
||||
bool intersects()
|
||||
{
|
||||
osg::notify(osg::INFO)<<"intersects() _min = "<<_min<<" _max = "<<_max<<std::endl;
|
||||
for(ExtentsList::iterator itr = _extentsList.begin();
|
||||
itr != _extentsList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->intersects(_currentLevel, _min, _max)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef std::vector<Extents> ExtentsList;
|
||||
typedef std::vector<osg::Matrix> MatrixStack;
|
||||
typedef std::vector<osg::CoordinateSystemNode*> CSNStack;
|
||||
|
||||
|
||||
ExtentsList _extentsList;
|
||||
unsigned int _currentLevel;
|
||||
MatrixStack _matrixStack;
|
||||
CSNStack _csnStack;
|
||||
|
||||
osg::Vec2d _min;
|
||||
osg::Vec2d _max;
|
||||
};
|
||||
|
||||
static void signalHandler(int sig)
|
||||
{
|
||||
printf("\nCaught signal %d, requesting exit...\n\n",sig);
|
||||
s_ExitApplication = true;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
#ifndef _WIN32
|
||||
signal(SIGHUP, signalHandler);
|
||||
signal(SIGQUIT, signalHandler);
|
||||
signal(SIGKILL, signalHandler);
|
||||
signal(SIGUSR1, signalHandler);
|
||||
signal(SIGUSR2, signalHandler);
|
||||
#endif
|
||||
signal(SIGABRT, signalHandler);
|
||||
signal(SIGINT, signalHandler);
|
||||
signal(SIGTERM, signalHandler);
|
||||
|
||||
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of seperate files into a single archive file that can be later read in OSG applications..");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-l level","Read down to level across the whole database.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-e level minX minY maxX maxY","Read down to <level> across the extents minX, minY to maxY, maxY. Note, for geocentric datase X and Y are longitude and latitude respectively.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-c directory","Shorthand for --file-cache directory.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--file-cache directory","Set directory as to place cache download files.");
|
||||
|
||||
// if user request help write it out to cout.
|
||||
if (arguments.read("-h") || arguments.read("--help"))
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LoadDataVisitor ldv;
|
||||
|
||||
unsigned int maxLevels = 0;
|
||||
while(arguments.read("-l",maxLevels))
|
||||
{
|
||||
ldv.addExtents(maxLevels);
|
||||
}
|
||||
|
||||
double minX, maxX, minY, maxY;
|
||||
while(arguments.read("-e",maxLevels, minX, minY, maxX, maxY))
|
||||
{
|
||||
ldv.addExtents(maxLevels, minX, minY, maxX, maxY);
|
||||
}
|
||||
|
||||
std::string fileCache;
|
||||
while(arguments.read("--file-cache",fileCache) || arguments.read("-c",fileCache)) {}
|
||||
|
||||
if (!fileCache.empty())
|
||||
{
|
||||
std::string str("OSG_FILE_CACHE=");
|
||||
str += fileCache;
|
||||
|
||||
putenv(strdup((char*)str.c_str()));
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||
if (!loadedModel)
|
||||
{
|
||||
std::cout<<"No data loaded, please specify a database to load"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
loadedModel->accept(ldv);
|
||||
|
||||
if (s_ExitApplication)
|
||||
{
|
||||
std::cout<<"osgfilecache cleanly exited in response to signal."<<std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -219,8 +219,6 @@ bool validName(const std::string& first)
|
||||
if (first=="LightPointNode") return false;
|
||||
if (first=="GeometryTechnique") return false;
|
||||
if (first=="GeoemtryTechnique") return false;
|
||||
if (first=="KdTree") return false;
|
||||
if (first=="LineSegment") return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -232,7 +230,6 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="") return "";
|
||||
if (name=="") return "";
|
||||
#endif
|
||||
if (name=="Weidemann") return "Wiedemann";
|
||||
if (name=="Martsz") return "Martz";
|
||||
if (name=="Matz") return "Martz";
|
||||
if (name=="Froenlich") return "Fr<EFBFBD>hlich";
|
||||
@@ -241,7 +238,6 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="Fruciel") return "Frauciel";
|
||||
if (name=="Hebelin") return "Herbelin";
|
||||
if (name=="Jea-Sebastien") return "Jean-Sebastien";
|
||||
if (name=="Jean-Sebastian") return "Jean-Sebastien";
|
||||
if (name=="Robet") return "Robert";
|
||||
if (name=="Morné") return "Morn<EFBFBD>";
|
||||
if (name=="Adndre") return "Andre";
|
||||
@@ -260,7 +256,7 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="Drederic") return "Frederic";
|
||||
if (name=="Fredrick") return "Frederic";
|
||||
if (name=="Fredric") return "Frederic";
|
||||
if (name=="Garrat") return "Garrett";
|
||||
if (name=="Garrat") return "Garret";
|
||||
if (name=="Geof") return "Geoff";
|
||||
if (name=="Gronenger") return "Gronager";
|
||||
if (name=="Gronger") return "Gronager";
|
||||
@@ -346,33 +342,16 @@ std::string typoCorrection(const std::string& name)
|
||||
if (name=="Giatan") return "Gaitan";
|
||||
if (name=="Melchoir") return "Melchior";
|
||||
if (name=="Simmonsson") return "Simonsson";
|
||||
if (name=="Simmonson") return "Simonsson";
|
||||
if (name=="Sokolwsky") return "Sokolowsky";
|
||||
if (name=="Cullu") return "Callu";
|
||||
if (name=="Comporesi") return "Camporesi";
|
||||
if (name=="Machler") return "M<EFBFBD>chler";
|
||||
if (name=="Maechler") return "M<EFBFBD>chler";
|
||||
if (name=="Messerschimdt") return "Messerschmidt";
|
||||
if (name=="Garret") return "Garrett";
|
||||
if (name=="Adrain") return "Adrian";
|
||||
if (name=="Elgi") return "Egli";
|
||||
return name;
|
||||
}
|
||||
|
||||
void nameCorrection(NamePair& name)
|
||||
{
|
||||
if (name.first=="John" && name.second=="Vidar")
|
||||
{
|
||||
name.first = "John";
|
||||
name.second = "Vidar Larring";
|
||||
}
|
||||
|
||||
if (name.first=="Sebastien" && name.second=="Messerschmidt")
|
||||
{
|
||||
name.first = "Sebastian";
|
||||
name.second = "Messerschmidt";
|
||||
}
|
||||
|
||||
if ((name.first=="Jose" || name.first=="Jos<EFBFBD>") && name.second=="Delport")
|
||||
{
|
||||
name.first = "J.P.";
|
||||
@@ -433,11 +412,6 @@ void nameCorrection(NamePair& name)
|
||||
name.first = "Paul";
|
||||
name.second = "de Repentigny";
|
||||
}
|
||||
if (name.first=="Raymond" && name.second=="de")
|
||||
{
|
||||
name.first = "Raymond";
|
||||
name.second = "de Vries";
|
||||
}
|
||||
if (name.first=="Nick" && name.second=="")
|
||||
{
|
||||
name.first = "Trajce";
|
||||
|
||||
@@ -39,16 +39,27 @@ int main(int argc, char** argv)
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer.");
|
||||
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
unsigned int helpType = 0;
|
||||
if ((helpType = arguments.readHelpType()))
|
||||
// if user request help write it out to cout.
|
||||
bool helpAll = arguments.read("--help-all");
|
||||
unsigned int helpType = ((helpAll || arguments.read("-h") || arguments.read("--help"))? osg::ApplicationUsage::COMMAND_LINE_OPTION : 0 ) |
|
||||
((helpAll || arguments.read("--help-env"))? osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE : 0 ) |
|
||||
((helpAll || arguments.read("--help-keys"))? osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING : 0 );
|
||||
if (helpType)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout, helpType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
// report any errors if they have occurred when parsing the program arguments.
|
||||
if (arguments.errors())
|
||||
@@ -63,19 +74,6 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string url, username, password;
|
||||
while(arguments.read("--login",url, username, password))
|
||||
{
|
||||
if (!osgDB::Registry::instance()->getAuthenticationMap())
|
||||
{
|
||||
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
|
||||
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
|
||||
url,
|
||||
new osgDB::AuthenticationDetails(username, password)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// set up the camera manipulators.
|
||||
{
|
||||
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
|
||||
@@ -123,9 +121,6 @@ int main(int argc, char** argv)
|
||||
// add the LOD Scale handler
|
||||
viewer.addEventHandler(new osgViewer::LODScaleHandler);
|
||||
|
||||
// add the screen capture handler
|
||||
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
||||
|
||||
// load the data
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||
if (!loadedModel)
|
||||
|
||||
@@ -323,7 +323,6 @@ INPUT = $(OSGHOME)/include/osg \
|
||||
$(OSGHOME)/include/osgIntrospection \
|
||||
$(OSGHOME)/include/osgParticle \
|
||||
$(OSGHOME)/include/osgViewer \
|
||||
$(OSGHOME)/include/osgWidget \
|
||||
$(OSGHOME)/include/osgShadow \
|
||||
$(OSGHOME)/include/osgManipulator \
|
||||
$(OSGHOME)/include/osgSim \
|
||||
|
||||
@@ -398,7 +398,6 @@ INPUT = $(OSGHOME)/include/osg \
|
||||
$(OSGHOME)/include/osgIntrospection \
|
||||
$(OSGHOME)/include/osgParticle \
|
||||
$(OSGHOME)/include/osgViewer \
|
||||
$(OSGHOME)/include/osgWidget \
|
||||
$(OSGHOME)/include/osgManipulator \
|
||||
$(OSGHOME)/include/osgShadow \
|
||||
$(OSGHOME)/include/osgSim \
|
||||
|
||||
@@ -398,7 +398,6 @@ INPUT = ${OpenSceneGraph_SOURCE_DIR}/include/osg \
|
||||
${OpenSceneGraph_SOURCE_DIR}/include/osgIntrospection \
|
||||
${OpenSceneGraph_SOURCE_DIR}/include/osgParticle \
|
||||
${OpenSceneGraph_SOURCE_DIR}/include/osgViewer \
|
||||
${OpenSceneGraph_SOURCE_DIR}/include/osgWidget \
|
||||
${OpenSceneGraph_SOURCE_DIR}/include/osgManipulator \
|
||||
${OpenSceneGraph_SOURCE_DIR}/include/osgShadow \
|
||||
${OpenSceneGraph_SOURCE_DIR}/include/osgSim \
|
||||
|
||||
@@ -5,13 +5,13 @@ SET(TARGET_DEFAULT_PREFIX "example_")
|
||||
SET(TARGET_DEFAULT_LABEL_PREFIX "Examples")
|
||||
|
||||
SET(TARGET_COMMON_LIBRARIES
|
||||
OpenThreads
|
||||
osg
|
||||
osgDB
|
||||
osgUtil
|
||||
osgGA
|
||||
osgViewer
|
||||
osgText
|
||||
OpenThreads
|
||||
osg
|
||||
osgDB
|
||||
osgUtil
|
||||
osgGA
|
||||
osgViewer
|
||||
osgText
|
||||
)
|
||||
|
||||
IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
@@ -32,7 +32,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgdepthpeeling)
|
||||
ADD_SUBDIRECTORY(osgdistortion)
|
||||
ADD_SUBDIRECTORY(osgfadetext)
|
||||
ADD_SUBDIRECTORY(osgfont)
|
||||
ADD_SUBDIRECTORY(osgforest)
|
||||
ADD_SUBDIRECTORY(osgfxbrowser)
|
||||
ADD_SUBDIRECTORY(osggeodemo)
|
||||
@@ -40,10 +39,9 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osggeometryshaders)
|
||||
ADD_SUBDIRECTORY(osghangglide)
|
||||
ADD_SUBDIRECTORY(osghud)
|
||||
ADD_SUBDIRECTORY(osgimagesequence)
|
||||
ADD_SUBDIRECTORY(osgimpostor)
|
||||
ADD_SUBDIRECTORY(osgintersection)
|
||||
ADD_SUBDIRECTORY(osgkdtree)
|
||||
ADD_SUBDIRECTORY(osgmultiplerendertargets)
|
||||
ADD_SUBDIRECTORY(osgkeyboard)
|
||||
ADD_SUBDIRECTORY(osgkeyboardmouse)
|
||||
ADD_SUBDIRECTORY(osglauncher)
|
||||
@@ -54,7 +52,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgmanipulator)
|
||||
ADD_SUBDIRECTORY(osgmotionblur)
|
||||
ADD_SUBDIRECTORY(osgmovie)
|
||||
ADD_SUBDIRECTORY(osgmultiplerendertargets)
|
||||
ADD_SUBDIRECTORY(osgmultitexture)
|
||||
ADD_SUBDIRECTORY(osgmultitexturecontrol)
|
||||
ADD_SUBDIRECTORY(osgoccluder)
|
||||
@@ -73,7 +70,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgprerendercubemap)
|
||||
ADD_SUBDIRECTORY(osgreflect)
|
||||
ADD_SUBDIRECTORY(osgscalarbar)
|
||||
ADD_SUBDIRECTORY(osgscreencapture)
|
||||
ADD_SUBDIRECTORY(osgscribe)
|
||||
ADD_SUBDIRECTORY(osgsequence)
|
||||
ADD_SUBDIRECTORY(osgshaders)
|
||||
@@ -91,7 +87,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgstereomatch)
|
||||
ADD_SUBDIRECTORY(osgteapot)
|
||||
ADD_SUBDIRECTORY(osgterrain)
|
||||
ADD_SUBDIRECTORY(osgtessellate)
|
||||
ADD_SUBDIRECTORY(osgtessellate)#)
|
||||
ADD_SUBDIRECTORY(osgtext)
|
||||
ADD_SUBDIRECTORY(osgtext3D)
|
||||
ADD_SUBDIRECTORY(osgtexture1D)
|
||||
@@ -116,10 +112,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgviewerSDL)
|
||||
ENDIF(SDL_FOUND)
|
||||
|
||||
IF (GTKGL_FOUND)
|
||||
ADD_SUBDIRECTORY(osgviewerGTK)
|
||||
ENDIF(GTKGL_FOUND)
|
||||
|
||||
IF (FOX_FOUND)
|
||||
ADD_SUBDIRECTORY(osgviewerFOX)
|
||||
ENDIF(FOX_FOUND)
|
||||
@@ -146,27 +138,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF (APPLE)
|
||||
ADD_SUBDIRECTORY(osgviewerCocoa)
|
||||
ENDIF(APPLE)
|
||||
|
||||
IF (BUILD_OSGWIDGET)
|
||||
ADD_SUBDIRECTORY(osgwidgetaddremove)
|
||||
ADD_SUBDIRECTORY(osgwidgetbox)
|
||||
ADD_SUBDIRECTORY(osgwidgetcanvas)
|
||||
ADD_SUBDIRECTORY(osgwidgetframe)
|
||||
ADD_SUBDIRECTORY(osgwidgetinput)
|
||||
ADD_SUBDIRECTORY(osgwidgetlabel)
|
||||
ADD_SUBDIRECTORY(osgwidgetmenu)
|
||||
ADD_SUBDIRECTORY(osgwidgetnotebook)
|
||||
ADD_SUBDIRECTORY(osgwidgetscrolled)
|
||||
ADD_SUBDIRECTORY(osgwidgetshader)
|
||||
ADD_SUBDIRECTORY(osgwidgetstyled)
|
||||
ADD_SUBDIRECTORY(osgwidgettable)
|
||||
ADD_SUBDIRECTORY(osgwidgetwindow)
|
||||
ENDIF(BUILD_OSGWIDGET)
|
||||
|
||||
|
||||
#ADD_SUBDIRECTORY(osgcegui)
|
||||
#to add subject to find socket#ADD_SUBDIRECTORY(osgcluster)
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
SET(TARGET_SRC osgfont.cpp)
|
||||
SET(TARGET_ADDED_LIBRARIES osgText)
|
||||
|
||||
SETUP_EXAMPLE(osgfont)
|
||||
@@ -1,140 +0,0 @@
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <osg/io_utils>
|
||||
#include <osg/ArgumentParser>
|
||||
#include <osg/Geode>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
void textInfo(osgText::Text* text)
|
||||
{
|
||||
const osgText::Text::TextureGlyphQuadMap& tgqm = text->getTextureGlyphQuadMap();
|
||||
|
||||
const osgText::Text::TextureGlyphQuadMap::const_iterator tgqmi = tgqm.begin();
|
||||
|
||||
const osgText::Text::GlyphQuads& gq = tgqmi->second;
|
||||
|
||||
osgText::String& s = text->getText();
|
||||
|
||||
for(unsigned int i = 0; i < s.size(); i++)
|
||||
{
|
||||
osg::Vec2 ul = gq.getCoords()[0 + (i * 4)]; // upperLeft
|
||||
osg::Vec2 ll = gq.getCoords()[1 + (i * 4)]; // lowerLeft
|
||||
osg::Vec2 lr = gq.getCoords()[2 + (i * 4)]; // lowerRight
|
||||
osg::Vec2 ur = gq.getCoords()[3 + (i * 4)]; // upperRight
|
||||
|
||||
/*
|
||||
osg::Vec3 ul = gq.getTransformedCoords(0)[0 + (i * 4)];
|
||||
osg::Vec3 ll = gq.getTransformedCoords(0)[1 + (i * 4)];
|
||||
osg::Vec3 lr = gq.getTransformedCoords(0)[2 + (i * 4)];
|
||||
osg::Vec3 ur = gq.getTransformedCoords(0)[3 + (i * 4)];
|
||||
*/
|
||||
|
||||
osg::notify(osg::NOTICE)
|
||||
<< "'" << static_cast<char>(s[i]) << "':"
|
||||
<< " width(" << lr.x() - ll.x() << ")"
|
||||
<< " height(" << ul.y() - ll.y() << ")" << std::endl << "\t"
|
||||
<< "ul(" << ul << "), "
|
||||
<< "ll(" << ll << "), "
|
||||
<< "lr(" << lr << "), "
|
||||
<< "ur(" << ur << ")"
|
||||
<< std::endl
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
osg::Camera* createOrthoCamera(double width, double height)
|
||||
{
|
||||
osg::Camera* camera = new osg::Camera();
|
||||
|
||||
camera->getOrCreateStateSet()->setMode(
|
||||
GL_LIGHTING,
|
||||
osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF
|
||||
);
|
||||
|
||||
osg::Matrix m = osg::Matrix::ortho2D(0.0f, width, 0.0f, height);
|
||||
|
||||
camera->setProjectionMatrix(m);
|
||||
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
||||
camera->setViewMatrix(osg::Matrix::identity());
|
||||
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
|
||||
camera->setRenderOrder(osg::Camera::POST_RENDER);
|
||||
|
||||
return camera;
|
||||
}
|
||||
|
||||
osgText::Text* createLabel(const std::string& l, const char* f, unsigned int size)
|
||||
{
|
||||
static osg::Vec3 pos(10.0f, 10.0f, 0.0f);
|
||||
|
||||
osgText::Text* label = new osgText::Text();
|
||||
osgText::Font* font = osgText::readFontFile(f);
|
||||
|
||||
label->setFont(font);
|
||||
label->setCharacterSize(size);
|
||||
label->setFontResolution(size, size);
|
||||
label->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
label->setPosition(pos);
|
||||
label->setAlignment(osgText::Text::LEFT_BOTTOM);
|
||||
|
||||
// It seems to be important we do this last to get best results?
|
||||
label->setText(l);
|
||||
|
||||
textInfo(label);
|
||||
|
||||
pos.y() += size + 10.0f;
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
typedef std::list<unsigned int> Sizes;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
osgViewer::Viewer viewer;
|
||||
osg::ArgumentParser args(&argc, argv);
|
||||
|
||||
// Make sure we have the minimum args...
|
||||
if(argc <= 2)
|
||||
{
|
||||
osg::notify(osg::FATAL) << "usage: " << args[0] << " FONTFILE [sizes...]" << std::endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler());
|
||||
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
|
||||
|
||||
osg::Group* group = new osg::Group();
|
||||
osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f);
|
||||
|
||||
// Create the list of desired sizes.
|
||||
Sizes sizes;
|
||||
|
||||
for(int i = 2; i < argc; i++)
|
||||
{
|
||||
if(!args.isNumber(i)) continue;
|
||||
|
||||
sizes.push_back(std::atoi(args[i]));
|
||||
}
|
||||
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
|
||||
// Add all of our osgText drawables.
|
||||
for(Sizes::const_iterator i = sizes.begin(); i != sizes.end(); i++)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << *i << " 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
geode->addDrawable(createLabel(ss.str(), args[1], *i));
|
||||
}
|
||||
|
||||
camera->addChild(geode);
|
||||
|
||||
group->addChild(camera);
|
||||
|
||||
viewer.setSceneData(group);
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
SET(TARGET_SRC osgimagesequence.cpp )
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgimagesequence)
|
||||
@@ -1,114 +0,0 @@
|
||||
/* OpenSceneGraph example, osgtexture3D.
|
||||
*
|
||||
* 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/Node>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Texture1D>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Texture3D>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/ImageSequence>
|
||||
#include <osg/Geode>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
//
|
||||
// A simple demo demonstrating how to set on an animated texture using an osg::ImageSequence
|
||||
//
|
||||
|
||||
osg::StateSet* createState()
|
||||
{
|
||||
osg::ref_ptr<osg::ImageSequence> imageSequence = new osg::ImageSequence;
|
||||
|
||||
imageSequence->setDuration(2.0);
|
||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posx.png"));
|
||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negx.png"));
|
||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posy.png"));
|
||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negy.png"));
|
||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posz.png"));
|
||||
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negz.png"));
|
||||
|
||||
#if 1
|
||||
osg::Texture2D* texture = new osg::Texture2D;
|
||||
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
||||
texture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT);
|
||||
texture->setResizeNonPowerOfTwoHint(false);
|
||||
texture->setImage(imageSequence.get());
|
||||
//texture->setTextureSize(512,512);
|
||||
|
||||
//texture->setUpdateCallback(new osg::ImageSequence::UpdateCallback);
|
||||
#else
|
||||
osg::TextureRectangle* texture = new osg::TextureRectangle;
|
||||
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
||||
texture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT);
|
||||
// texture->setResizeNonPowerOfTwoHint(false);
|
||||
texture->setImage(imageSequence.get());
|
||||
//texture->setTextureSize(512,512);
|
||||
|
||||
//texture->setUpdateCallback(new osg::ImageSequence::UpdateCallback);
|
||||
#endif
|
||||
|
||||
// create the StateSet to store the texture data
|
||||
osg::StateSet* stateset = new osg::StateSet;
|
||||
|
||||
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
|
||||
return stateset;
|
||||
}
|
||||
|
||||
osg::Node* createModel()
|
||||
{
|
||||
|
||||
// create the geometry of the model, just a simple 2d quad right now.
|
||||
osg::Geode* geode = new osg::Geode;
|
||||
geode->addDrawable(osg::createTexturedQuadGeometry(osg::Vec3(0.0f,0.0f,0.0), osg::Vec3(1.0f,0.0f,0.0), osg::Vec3(0.0f,0.0f,1.0f)));
|
||||
|
||||
geode->setStateSet(createState());
|
||||
|
||||
return geode;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
// create a model from the images and pass it to the viewer.
|
||||
viewer.setSceneData(createModel());
|
||||
|
||||
std::string filename;
|
||||
if (arguments.read("-o",filename))
|
||||
{
|
||||
osgDB::writeNodeFile(*viewer.getSceneData(),filename);
|
||||
}
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
SET(TARGET_SRC
|
||||
osgkdtree.cpp
|
||||
)
|
||||
|
||||
|
||||
SET(TARGET_ADDED_LIBRARIES osgSim )
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgkdtree)
|
||||
@@ -1,70 +0,0 @@
|
||||
/* OpenSceneGraph example, osgintersection.
|
||||
*
|
||||
* 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 <osgDB/ReadFile>
|
||||
|
||||
#include <osg/ArgumentParser>
|
||||
#include <osg/ApplicationUsage>
|
||||
#include <osg/Timer>
|
||||
#include <osg/CoordinateSystemNode>
|
||||
#include <osg/Notify>
|
||||
#include <osg/io_utils>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/TriangleIndexFunctor>
|
||||
|
||||
|
||||
#include <osgUtil/IntersectionVisitor>
|
||||
#include <osgUtil/LineSegmentIntersector>
|
||||
#include <osgUtil/UpdateVisitor>
|
||||
|
||||
#include <osgSim/LineOfSight>
|
||||
#include <osgSim/HeightAboveTerrain>
|
||||
#include <osgSim/ElevationSlice>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <osg/KdTree>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
int maxNumLevels = 16;
|
||||
int targetNumIndicesPerLeaf = 16;
|
||||
|
||||
while (arguments.read("--max", maxNumLevels)) {}
|
||||
while (arguments.read("--leaf", targetNumIndicesPerLeaf)) {}
|
||||
|
||||
osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
|
||||
|
||||
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
|
||||
|
||||
if (!scene)
|
||||
{
|
||||
std::cout<<"No model loaded, please specify a valid model on the command line."<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
osgViewer::Viewer viewer;
|
||||
viewer.setSceneData(scene.get());
|
||||
return viewer.run();
|
||||
}
|
||||
@@ -31,11 +31,6 @@
|
||||
#include <osgManipulator/Translate2DDragger>
|
||||
#include <osgManipulator/TranslateAxisDragger>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Material>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
osgManipulator::Dragger* createDragger(const std::string& name)
|
||||
@@ -83,13 +78,10 @@ osgManipulator::Dragger* createDragger(const std::string& name)
|
||||
d->setupDefaultGeometry();
|
||||
dragger = d;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return dragger;
|
||||
}
|
||||
|
||||
|
||||
osg::Node* createHUD()
|
||||
{
|
||||
osg::Geode* geode = new osg::Geode();
|
||||
@@ -149,104 +141,6 @@ osg::Node* addDraggerToScene(osg::Node* scene, osgManipulator::CommandManager* c
|
||||
return root;
|
||||
}
|
||||
|
||||
osg::Node* createDemoScene(osgManipulator::CommandManager* cmdMgr) {
|
||||
|
||||
osg::Group* root = new osg::Group;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode_1 = new osg::Geode;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform_1 = new osg::MatrixTransform;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode_2 = new osg::Geode;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform_2 = new osg::MatrixTransform;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode_3 = new osg::Geode;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform_3 = new osg::MatrixTransform;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode_4 = new osg::Geode;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform_4 = new osg::MatrixTransform;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode_5 = new osg::Geode;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform_5 = new osg::MatrixTransform;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode_6 = new osg::Geode;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform_6 = new osg::MatrixTransform;
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode_7 = new osg::Geode;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform_7 = new osg::MatrixTransform;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const float radius = 0.8f;
|
||||
const float height = 1.0f;
|
||||
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
|
||||
hints->setDetailRatio(2.0f);
|
||||
osg::ref_ptr<osg::ShapeDrawable> shape;
|
||||
|
||||
shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f, 0.0f, -2.0f), 10, 10.0f, 0.1f), hints.get());
|
||||
shape->setColor(osg::Vec4(0.5f, 0.5f, 0.7f, 1.0f));
|
||||
geode_1->addDrawable(shape.get());
|
||||
|
||||
shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, 0.0f), radius * 2,radius), hints.get());
|
||||
shape->setColor(osg::Vec4(0.8f, 0.8f, 0.8f, 1.0f));
|
||||
geode_2->addDrawable(shape.get());
|
||||
|
||||
shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(-3.0f, 0.0f, 0.0f), radius,radius), hints.get());
|
||||
shape->setColor(osg::Vec4(0.6f, 0.8f, 0.8f, 1.0f));
|
||||
geode_3->addDrawable(shape.get());
|
||||
|
||||
shape = new osg::ShapeDrawable(new osg::Cone(osg::Vec3(3.0f, 0.0f, 0.0f), 2 * radius,radius), hints.get());
|
||||
shape->setColor(osg::Vec4(0.4f, 0.9f, 0.3f, 1.0f));
|
||||
geode_4->addDrawable(shape.get());
|
||||
|
||||
shape = new osg::ShapeDrawable(new osg::Cone(osg::Vec3(0.0f, -3.0f, 0.0f), radius, height), hints.get());
|
||||
shape->setColor(osg::Vec4(0.2f, 0.5f, 0.7f, 1.0f));
|
||||
geode_5->addDrawable(shape.get());
|
||||
|
||||
shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 3.0f, 0.0f), radius, height), hints.get());
|
||||
shape->setColor(osg::Vec4(1.0f, 0.3f, 0.3f, 1.0f));
|
||||
geode_6->addDrawable(shape.get());
|
||||
|
||||
shape = new osg::ShapeDrawable(new osg::Cone(osg::Vec3(0.0f, 0.0f, 3.0f), 2.0f, 2.0f), hints.get());
|
||||
shape->setColor(osg::Vec4(0.8f, 0.8f, 0.4f, 1.0f));
|
||||
geode_7->addDrawable(shape.get());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// material
|
||||
osg::ref_ptr<osg::Material> matirial = new osg::Material;
|
||||
matirial->setColorMode(osg::Material::DIFFUSE);
|
||||
matirial->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
|
||||
matirial->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
|
||||
matirial->setShininess(osg::Material::FRONT_AND_BACK, 64.0f);
|
||||
root->getOrCreateStateSet()->setAttributeAndModes(matirial.get(), osg::StateAttribute::ON);
|
||||
|
||||
transform_1.get()->addChild(addDraggerToScene(geode_1.get(),cmdMgr,"TabBoxDragger"));
|
||||
transform_2.get()->addChild(addDraggerToScene(geode_2.get(),cmdMgr,"TabPlaneDragger"));
|
||||
transform_3.get()->addChild(addDraggerToScene(geode_3.get(),cmdMgr,"TabPlaneTrackballDragger"));
|
||||
transform_4.get()->addChild(addDraggerToScene(geode_4.get(),cmdMgr,"TrackballDragger"));
|
||||
transform_5.get()->addChild(addDraggerToScene(geode_5.get(),cmdMgr,"Translate1DDragger"));
|
||||
transform_6.get()->addChild(addDraggerToScene(geode_6.get(),cmdMgr,"Translate2DDragger"));
|
||||
transform_7.get()->addChild(addDraggerToScene(geode_7.get(),cmdMgr,"TranslateAxisDragger"));
|
||||
|
||||
root->addChild(transform_1.get());
|
||||
root->addChild(transform_2.get());
|
||||
root->addChild(transform_3.get());
|
||||
root->addChild(transform_4.get());
|
||||
root->addChild(transform_5.get());
|
||||
root->addChild(transform_6.get());
|
||||
root->addChild(transform_7.get());
|
||||
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
class PickModeHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
@@ -360,7 +254,7 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings.");
|
||||
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation [TabPlaneDragger,TabPlaneTrackballDragger,TrackballDragger,Translate1DDragger,Translate2DDragger,TranslateAxisDragger,TabBoxDragger]");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation");
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
@@ -386,6 +280,12 @@ int main( int argc, char **argv )
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arguments.argc()<=1)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string dragger_name = "TabBoxDragger";
|
||||
arguments.read("--dragger", dragger_name);
|
||||
@@ -395,17 +295,11 @@ int main( int argc, char **argv )
|
||||
// read the scene from the list of file specified command line args.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||
|
||||
// create a command manager
|
||||
osg::ref_ptr<osgManipulator::CommandManager> cmdMgr = new osgManipulator::CommandManager;
|
||||
|
||||
// if no model has been successfully loaded report failure.
|
||||
bool tragger2Scene(true);
|
||||
if (!loadedModel)
|
||||
{
|
||||
//std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||
//return 1;
|
||||
loadedModel = createDemoScene(cmdMgr.get());
|
||||
tragger2Scene=false;
|
||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// any option left unread are converted into errors to write out later.
|
||||
@@ -426,13 +320,11 @@ int main( int argc, char **argv )
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get());
|
||||
|
||||
osg::ref_ptr<osgManipulator::CommandManager> cmdMgr = new osgManipulator::CommandManager;
|
||||
|
||||
// pass the loaded scene graph to the viewer.
|
||||
if ( tragger2Scene ) {
|
||||
viewer.setSceneData(addDraggerToScene(loadedModel.get(), cmdMgr.get(), dragger_name));
|
||||
} else {
|
||||
viewer.setSceneData(loadedModel.get());
|
||||
}
|
||||
viewer.setSceneData(addDraggerToScene(loadedModel.get(), cmdMgr.get(), dragger_name));
|
||||
|
||||
viewer.addEventHandler(new PickModeHandler());
|
||||
|
||||
return viewer.run();
|
||||
|
||||
@@ -428,14 +428,11 @@ int main(int argc, char** argv)
|
||||
|
||||
if (image)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" image-t()="<<image->t()<<std::endl;
|
||||
|
||||
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);
|
||||
|
||||
if (xyPlane) pos.y() += image->t()*1.05f;
|
||||
else pos.z() += image->t()*1.05f;
|
||||
pos.y() += image->t()*1.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -92,175 +92,103 @@ class ElevationLayerBlendingCallback : public osg::NodeCallback
|
||||
ElevationLayerBlendingCallback(osgFX::MultiTextureControl* mtc, const Elevations& elevations, float animationTime=4.0f):
|
||||
_previousFrame(-1),
|
||||
_previousTime(0.0),
|
||||
_currentElevation(0.0),
|
||||
_mtc(mtc),
|
||||
_elevations(elevations),
|
||||
_animationTime(animationTime) {}
|
||||
|
||||
/** Callback method called by the NodeVisitor when visiting a node.*/
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
if (nv->getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR)
|
||||
{
|
||||
if (!nv->getFrameStamp() || _previousFrame==nv->getFrameStamp()->getFrameNumber())
|
||||
{
|
||||
// we've already updated for this frame so no need to do it again, just traverse children.
|
||||
traverse(node,nv);
|
||||
return;
|
||||
}
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
|
||||
float deltaTime = 0.01f;
|
||||
if (_previousFrame!=-1)
|
||||
{
|
||||
deltaTime = float(nv->getFrameStamp()->getReferenceTime() - _previousTime);
|
||||
}
|
||||
|
||||
_previousTime = nv->getFrameStamp()->getReferenceTime();
|
||||
_previousFrame = nv->getFrameStamp()->getFrameNumber();
|
||||
|
||||
float deltaTime = 0.01f;
|
||||
if (_previousFrame!=-1)
|
||||
double elevation = nv->getViewPoint().z();
|
||||
|
||||
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(node);
|
||||
if (csn)
|
||||
{
|
||||
osg::EllipsoidModel* em = csn->getEllipsoidModel();
|
||||
if (em)
|
||||
{
|
||||
deltaTime = float(nv->getFrameStamp()->getReferenceTime() - _previousTime);
|
||||
}
|
||||
|
||||
_previousTime = nv->getFrameStamp()->getReferenceTime();
|
||||
_previousFrame = nv->getFrameStamp()->getFrameNumber();
|
||||
|
||||
if (_mtc.valid() && !_elevations.empty())
|
||||
{
|
||||
unsigned int index = _mtc->getNumTextureWeights()-1;
|
||||
for(unsigned int i=0; i<_elevations.size(); ++i)
|
||||
{
|
||||
if (_currentElevation>_elevations[i])
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float delta = std::min(deltaTime/_animationTime, 1.0f);
|
||||
|
||||
for(unsigned int i=0; i<_mtc->getNumTextureWeights(); ++i)
|
||||
{
|
||||
float currentValue = _mtc->getTextureWeight(i);
|
||||
float desiredValue = (i==index) ? 1.0f : 0.0f;
|
||||
if (desiredValue != currentValue)
|
||||
{
|
||||
if (currentValue<desiredValue)
|
||||
{
|
||||
desiredValue = std::min(currentValue + delta, desiredValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
desiredValue = std::max(currentValue - delta, desiredValue);
|
||||
}
|
||||
|
||||
_mtc->setTextureWeight(i, desiredValue);
|
||||
}
|
||||
}
|
||||
|
||||
double X = nv->getViewPoint().x();
|
||||
double Y = nv->getViewPoint().y();
|
||||
double Z = nv->getViewPoint().z();
|
||||
double latitude, longitude;
|
||||
em->convertXYZToLatLongHeight(X,Y,Z,latitude, longitude, elevation);
|
||||
}
|
||||
}
|
||||
else if (nv->getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
|
||||
if (_mtc.valid() && !_elevations.empty())
|
||||
{
|
||||
_currentElevation = nv->getViewPoint().z();
|
||||
|
||||
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(node);
|
||||
if (csn)
|
||||
unsigned int index = _mtc->getNumTextureWeights()-1;
|
||||
for(unsigned int i=0; i<_elevations.size(); ++i)
|
||||
{
|
||||
osg::EllipsoidModel* em = csn->getEllipsoidModel();
|
||||
if (em)
|
||||
if (elevation>_elevations[i])
|
||||
{
|
||||
double X = nv->getViewPoint().x();
|
||||
double Y = nv->getViewPoint().y();
|
||||
double Z = nv->getViewPoint().z();
|
||||
double latitude, longitude;
|
||||
em->convertXYZToLatLongHeight(X,Y,Z,latitude, longitude, _currentElevation);
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float delta = std::min(deltaTime/_animationTime, 1.0f);
|
||||
|
||||
for(unsigned int i=0; i<_mtc->getNumTextureWeights(); ++i)
|
||||
{
|
||||
float currentValue = _mtc->getTextureWeight(i);
|
||||
float desiredValue = (i==index) ? 1.0f : 0.0f;
|
||||
if (desiredValue != currentValue)
|
||||
{
|
||||
if (currentValue<desiredValue)
|
||||
{
|
||||
desiredValue = std::min(currentValue + delta, desiredValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
desiredValue = std::max(currentValue - delta, desiredValue);
|
||||
}
|
||||
|
||||
_mtc->setTextureWeight(i, desiredValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
traverse(node,nv);
|
||||
}
|
||||
|
||||
int _previousFrame;
|
||||
double _previousTime;
|
||||
float _animationTime;
|
||||
double _currentElevation;
|
||||
|
||||
osg::observer_ptr<osgFX::MultiTextureControl> _mtc;
|
||||
Elevations _elevations;
|
||||
|
||||
OpenThreads::Mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
// class to handle events with a pick
|
||||
class TerrainHandler : public osgGA::GUIEventHandler {
|
||||
public:
|
||||
|
||||
TerrainHandler(osgTerrain::Terrain* terrain):
|
||||
_terrain(terrain) {}
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
|
||||
{
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey()=='r')
|
||||
{
|
||||
_terrain->setSampleRatio(_terrain->getSampleRatio()*0.5);
|
||||
osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='R')
|
||||
{
|
||||
_terrain->setSampleRatio(_terrain->getSampleRatio()/0.5);
|
||||
osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='v')
|
||||
{
|
||||
_terrain->setVerticalScale(_terrain->getVerticalScale()*1.25);
|
||||
osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='V')
|
||||
{
|
||||
_terrain->setVerticalScale(_terrain->getVerticalScale()/1.25);
|
||||
osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~TerrainHandler() {}
|
||||
|
||||
osg::ref_ptr<osgTerrain::Terrain> _terrain;
|
||||
};
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-v","Set the terrain vertical scale.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-r","Set the terrain sample ratio.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
float verticalScale = 1.0f;
|
||||
while(arguments.read("-v",verticalScale)) {}
|
||||
|
||||
float sampleRatio = 1.0f;
|
||||
while(arguments.read("-r",sampleRatio)) {}
|
||||
|
||||
std::string url, username, password;
|
||||
while(arguments.read("--login",url, username, password))
|
||||
{
|
||||
if (!osgDB::Registry::instance()->getAuthenticationMap())
|
||||
{
|
||||
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
|
||||
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
|
||||
url,
|
||||
new osgDB::AuthenticationDetails(username, password)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// add all the event handlers to the viewer
|
||||
{
|
||||
@@ -331,16 +259,11 @@ int main( int argc, char **argv )
|
||||
{
|
||||
terrain = new osgTerrain::Terrain;
|
||||
terrain->addChild(rootnode);
|
||||
terrain->setSampleRatio(0.25f);
|
||||
|
||||
rootnode = terrain;
|
||||
}
|
||||
|
||||
terrain->setSampleRatio(sampleRatio);
|
||||
terrain->setVerticalScale(verticalScale);
|
||||
|
||||
// register our custom handler for adjust Terrain settings
|
||||
viewer.addEventHandler(new TerrainHandler(terrain));
|
||||
|
||||
osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(rootnode);
|
||||
|
||||
unsigned int numLayers = 1;
|
||||
@@ -367,19 +290,14 @@ int main( int argc, char **argv )
|
||||
ElevationLayerBlendingCallback* elbc = new ElevationLayerBlendingCallback(mtc, elevations);
|
||||
|
||||
// assign to the most appropriate node (the CoordinateSystemNode is best as it provides the elevation on the globe.)
|
||||
// note we must assign callback as both an update and cull callback, as update callback to do the update of
|
||||
// the the osgFX::MultiTextureControl node a thread safe way, and as a cull callback to gather the camera
|
||||
// position information.
|
||||
osg::Node* nodeToAssignCallbackTo = csn ? csn : (mtc ? mtc : rootnode);
|
||||
nodeToAssignCallbackTo->setUpdateCallback(elbc);
|
||||
nodeToAssignCallbackTo->setCullCallback(elbc);
|
||||
if (csn) csn->setCullCallback(elbc);
|
||||
else if (mtc) mtc->setCullCallback(elbc);
|
||||
else rootnode->setCullCallback(elbc);
|
||||
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer.setSceneData( rootnode );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
|
||||
@@ -26,17 +26,6 @@
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/CompositeViewer>
|
||||
|
||||
#include <osgGA/TerrainManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
#include <osgGA/KeySwitchMatrixManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
#include <osgGA/TerrainManipulator>
|
||||
|
||||
#include <osg/Material>
|
||||
#include <osg/Geode>
|
||||
#include <osg/BlendFunc>
|
||||
@@ -83,18 +72,6 @@ bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapte
|
||||
if (view) pick(view,ea);
|
||||
return false;
|
||||
}
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey()=='c')
|
||||
{
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter(ea);
|
||||
event->setX((ea.getXmin()+ea.getXmax())*0.5);
|
||||
event->setY((ea.getYmin()+ea.getYmax())*0.5);
|
||||
if (view) pick(view,*event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -278,36 +255,6 @@ int main( int argc, char **argv )
|
||||
{
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
|
||||
// add all the camera manipulators
|
||||
{
|
||||
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
|
||||
|
||||
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
|
||||
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
|
||||
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
|
||||
|
||||
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
|
||||
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
|
||||
|
||||
std::string pathfile;
|
||||
char keyForAnimationPath = '5';
|
||||
while (arguments.read("-p",pathfile))
|
||||
{
|
||||
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
|
||||
if (apm || !apm->valid())
|
||||
{
|
||||
num = keyswitchManipulator->getNumMatrixManipulators();
|
||||
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
|
||||
++keyForAnimationPath;
|
||||
}
|
||||
}
|
||||
|
||||
keyswitchManipulator->selectMatrixManipulator(num);
|
||||
|
||||
viewer.setCameraManipulator( keyswitchManipulator.get() );
|
||||
}
|
||||
|
||||
// add the handler for doing the picking
|
||||
viewer.addEventHandler(new PickHandler(updateText.get()));
|
||||
|
||||
|
||||
@@ -200,11 +200,7 @@ struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback
|
||||
};
|
||||
|
||||
|
||||
osg::Node* createPreRenderSubGraph(osg::Node* subgraph,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
osg::Camera::RenderTargetImplementation renderImplementation,
|
||||
bool useImage, bool useTextureRectangle, bool useHDR,
|
||||
unsigned int samples, unsigned int colorSamples)
|
||||
osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsigned tex_height, osg::Camera::RenderTargetImplementation renderImplementation, bool useImage, bool useTextureRectangle, bool useHDR)
|
||||
{
|
||||
if (!subgraph) return 0;
|
||||
|
||||
@@ -363,8 +359,7 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph,
|
||||
image->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_FLOAT);
|
||||
|
||||
// attach the image so its copied on each frame.
|
||||
camera->attach(osg::Camera::COLOR_BUFFER, image,
|
||||
samples, colorSamples);
|
||||
camera->attach(osg::Camera::COLOR_BUFFER, image);
|
||||
|
||||
camera->setPostDrawCallback(new MyCameraPostDrawCallback(image));
|
||||
|
||||
@@ -381,9 +376,7 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph,
|
||||
else
|
||||
{
|
||||
// attach the texture and use it as the color buffer.
|
||||
camera->attach(osg::Camera::COLOR_BUFFER, texture,
|
||||
0, 0, false,
|
||||
samples, colorSamples);
|
||||
camera->attach(osg::Camera::COLOR_BUFFER, texture);
|
||||
}
|
||||
|
||||
|
||||
@@ -434,11 +427,8 @@ int main( int argc, char **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int tex_width = 1024;
|
||||
unsigned int tex_height = 512;
|
||||
unsigned int samples = 0;
|
||||
unsigned int colorSamples = 0;
|
||||
|
||||
unsigned tex_width = 1024;
|
||||
unsigned tex_height = 512;
|
||||
while (arguments.read("--width", tex_width)) {}
|
||||
while (arguments.read("--height", tex_height)) {}
|
||||
|
||||
@@ -449,8 +439,6 @@ int main( int argc, char **argv )
|
||||
while (arguments.read("--pbuffer-rtt")) { renderImplementation = osg::Camera::PIXEL_BUFFER_RTT; }
|
||||
while (arguments.read("--fb")) { renderImplementation = osg::Camera::FRAME_BUFFER; }
|
||||
while (arguments.read("--window")) { renderImplementation = osg::Camera::SEPERATE_WINDOW; }
|
||||
while (arguments.read("--fbo-samples", samples)) {}
|
||||
while (arguments.read("--color-samples", colorSamples)) {}
|
||||
|
||||
bool useImage = false;
|
||||
while (arguments.read("--image")) { useImage = true; }
|
||||
@@ -481,7 +469,7 @@ int main( int argc, char **argv )
|
||||
loadedModelTransform->setUpdateCallback(nc);
|
||||
|
||||
osg::Group* rootNode = new osg::Group();
|
||||
rootNode->addChild(createPreRenderSubGraph(loadedModelTransform,tex_width,tex_height, renderImplementation, useImage, useTextureRectangle, useHDR, samples, colorSamples));
|
||||
rootNode->addChild(createPreRenderSubGraph(loadedModelTransform,tex_width,tex_height, renderImplementation, useImage, useTextureRectangle, useHDR));
|
||||
|
||||
// add model to the viewer.
|
||||
viewer.setSceneData( rootNode );
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
SET(TARGET_SRC osgscreencapture.cpp )
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgscreencapture)
|
||||
@@ -1,791 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This application is open source and may be redistributed and/or modified
|
||||
* freely and without restriction, both in commericial and non commericial applications,
|
||||
* as long as this copyright notice is maintained.
|
||||
*
|
||||
* This application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osg/CoordinateSystemNode>
|
||||
|
||||
#include <osg/Switch>
|
||||
#include <osgText/Text>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
#include <osgGA/KeySwitchMatrixManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgGA/AnimationPathManipulator>
|
||||
#include <osgGA/TerrainManipulator>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
class WindowCaptureCallback : public osg::Camera::DrawCallback
|
||||
{
|
||||
public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
READ_PIXELS,
|
||||
SINGLE_PBO,
|
||||
DOUBLE_PBO,
|
||||
TRIPLE_PBO
|
||||
};
|
||||
|
||||
enum FramePosition
|
||||
{
|
||||
START_FRAME,
|
||||
END_FRAME
|
||||
};
|
||||
|
||||
struct ContextData : public osg::Referenced
|
||||
{
|
||||
|
||||
ContextData(osg::GraphicsContext* gc, Mode mode, GLenum readBuffer, const std::string& name):
|
||||
_gc(gc),
|
||||
_mode(mode),
|
||||
_readBuffer(readBuffer),
|
||||
_fileName(name),
|
||||
_pixelFormat(GL_BGRA),
|
||||
_type(GL_UNSIGNED_BYTE),
|
||||
_width(0),
|
||||
_height(0),
|
||||
_currentImageIndex(0),
|
||||
_currentPboIndex(0),
|
||||
_reportTimingFrequency(100),
|
||||
_numTimeValuesRecorded(0),
|
||||
_timeForReadPixels(0.0),
|
||||
_timeForFullCopy(0.0),
|
||||
_timeForMemCpy(0.0)
|
||||
|
||||
{
|
||||
_previousFrameTick = osg::Timer::instance()->tick();
|
||||
|
||||
if (gc->getTraits())
|
||||
{
|
||||
if (gc->getTraits()->alpha)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Select GL_BGRA read back format"<<std::endl;
|
||||
_pixelFormat = GL_BGRA;
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Select GL_BGR read back format"<<std::endl;
|
||||
_pixelFormat = GL_BGR;
|
||||
}
|
||||
}
|
||||
|
||||
getSize(gc, _width, _height);
|
||||
|
||||
std::cout<<"Window size "<<_width<<", "<<_height<<std::endl;
|
||||
|
||||
// single buffered image
|
||||
_imageBuffer.push_back(new osg::Image);
|
||||
|
||||
// double buffer PBO.
|
||||
switch(_mode)
|
||||
{
|
||||
case(READ_PIXELS):
|
||||
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with out PixelBufferObject."<<std::endl;
|
||||
break;
|
||||
case(SINGLE_PBO):
|
||||
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with a single PixelBufferObject."<<std::endl;
|
||||
_pboBuffer.push_back(0);
|
||||
break;
|
||||
case(DOUBLE_PBO):
|
||||
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with a double buffer PixelBufferObject."<<std::endl;
|
||||
_pboBuffer.push_back(0);
|
||||
_pboBuffer.push_back(0);
|
||||
break;
|
||||
case(TRIPLE_PBO):
|
||||
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with a triple buffer PixelBufferObject."<<std::endl;
|
||||
_pboBuffer.push_back(0);
|
||||
_pboBuffer.push_back(0);
|
||||
_pboBuffer.push_back(0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void getSize(osg::GraphicsContext* gc, int& width, int& height)
|
||||
{
|
||||
if (gc->getTraits())
|
||||
{
|
||||
width = gc->getTraits()->width;
|
||||
height = gc->getTraits()->height;
|
||||
}
|
||||
}
|
||||
|
||||
void updateTimings(osg::Timer_t tick_start,
|
||||
osg::Timer_t tick_afterReadPixels,
|
||||
osg::Timer_t tick_afterMemCpy,
|
||||
unsigned int dataSize);
|
||||
|
||||
void read()
|
||||
{
|
||||
osg::BufferObject::Extensions* ext = osg::BufferObject::getExtensions(_gc->getState()->getContextID(),true);
|
||||
|
||||
if (ext->isPBOSupported() && !_pboBuffer.empty())
|
||||
{
|
||||
if (_pboBuffer.size()==1)
|
||||
{
|
||||
singlePBO(ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
multiPBO(ext);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
readPixels();
|
||||
}
|
||||
}
|
||||
|
||||
void readPixels();
|
||||
|
||||
void singlePBO(osg::BufferObject::Extensions* ext);
|
||||
|
||||
void multiPBO(osg::BufferObject::Extensions* ext);
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
|
||||
typedef std::vector< GLuint > PBOBuffer;
|
||||
|
||||
osg::GraphicsContext* _gc;
|
||||
Mode _mode;
|
||||
GLenum _readBuffer;
|
||||
std::string _fileName;
|
||||
|
||||
GLenum _pixelFormat;
|
||||
GLenum _type;
|
||||
int _width;
|
||||
int _height;
|
||||
|
||||
unsigned int _currentImageIndex;
|
||||
ImageBuffer _imageBuffer;
|
||||
|
||||
unsigned int _currentPboIndex;
|
||||
PBOBuffer _pboBuffer;
|
||||
|
||||
unsigned int _reportTimingFrequency;
|
||||
unsigned int _numTimeValuesRecorded;
|
||||
double _timeForReadPixels;
|
||||
double _timeForFullCopy;
|
||||
double _timeForMemCpy;
|
||||
osg::Timer_t _previousFrameTick;
|
||||
};
|
||||
|
||||
WindowCaptureCallback(Mode mode, FramePosition position, GLenum readBuffer):
|
||||
_mode(mode),
|
||||
_position(position),
|
||||
_readBuffer(readBuffer)
|
||||
{
|
||||
}
|
||||
|
||||
FramePosition getFramePosition() const { return _position; }
|
||||
|
||||
ContextData* createContextData(osg::GraphicsContext* gc) const
|
||||
{
|
||||
std::stringstream filename;
|
||||
filename << "test_"<<_contextDataMap.size()<<".jpg";
|
||||
return new ContextData(gc, _mode, _readBuffer, filename.str());
|
||||
}
|
||||
|
||||
ContextData* getContextData(osg::GraphicsContext* gc) const
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
osg::ref_ptr<ContextData>& data = _contextDataMap[gc];
|
||||
if (!data) data = createContextData(gc);
|
||||
|
||||
return data.get();
|
||||
}
|
||||
|
||||
virtual void operator () (osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
glReadBuffer(_readBuffer);
|
||||
|
||||
osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext();
|
||||
osg::ref_ptr<ContextData> cd = getContextData(gc);
|
||||
cd->read();
|
||||
}
|
||||
|
||||
typedef std::map<osg::GraphicsContext*, osg::ref_ptr<ContextData> > ContextDataMap;
|
||||
|
||||
Mode _mode;
|
||||
FramePosition _position;
|
||||
GLenum _readBuffer;
|
||||
mutable OpenThreads::Mutex _mutex;
|
||||
mutable ContextDataMap _contextDataMap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
void WindowCaptureCallback::ContextData::updateTimings(osg::Timer_t tick_start,
|
||||
osg::Timer_t tick_afterReadPixels,
|
||||
osg::Timer_t tick_afterMemCpy,
|
||||
unsigned int dataSize)
|
||||
{
|
||||
if (!_reportTimingFrequency) return;
|
||||
|
||||
double timeForReadPixels = osg::Timer::instance()->delta_s(tick_start, tick_afterReadPixels);
|
||||
double timeForFullCopy = osg::Timer::instance()->delta_s(tick_start, tick_afterMemCpy);
|
||||
double timeForMemCpy = osg::Timer::instance()->delta_s(tick_afterReadPixels, tick_afterMemCpy);
|
||||
|
||||
_timeForReadPixels += timeForReadPixels;
|
||||
_timeForFullCopy += timeForFullCopy;
|
||||
_timeForMemCpy += timeForMemCpy;
|
||||
|
||||
++_numTimeValuesRecorded;
|
||||
|
||||
if (_numTimeValuesRecorded==_reportTimingFrequency)
|
||||
{
|
||||
timeForReadPixels = _timeForReadPixels/double(_numTimeValuesRecorded);
|
||||
timeForFullCopy = _timeForFullCopy/double(_numTimeValuesRecorded);
|
||||
timeForMemCpy = _timeForMemCpy/double(_numTimeValuesRecorded);
|
||||
|
||||
double averageFrameTime = osg::Timer::instance()->delta_s(_previousFrameTick, tick_afterMemCpy)/double(_numTimeValuesRecorded);
|
||||
double fps = 1.0/averageFrameTime;
|
||||
_previousFrameTick = tick_afterMemCpy;
|
||||
|
||||
_timeForReadPixels = 0.0;
|
||||
_timeForFullCopy = 0.0;
|
||||
_timeForMemCpy = 0.0;
|
||||
|
||||
_numTimeValuesRecorded = 0;
|
||||
|
||||
double numMPixels = double(_width * _height) / 1000000.0;
|
||||
double numMb = double(dataSize) / (1024*1024);
|
||||
|
||||
int prec = osg::notify(osg::NOTICE).precision(5);
|
||||
|
||||
if (timeForMemCpy==0.0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"fps = "<<fps<<", full frame copy = "<<timeForFullCopy*1000.0f<<"ms rate = "<<numMPixels / timeForFullCopy<<" Mpixel/sec, copy speed = "<<numMb / timeForFullCopy<<" Mb/sec"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"fps = "<<fps<<", full frame copy = "<<timeForFullCopy*1000.0f<<"ms rate = "<<numMPixels / timeForFullCopy<<" Mpixel/sec, "<<numMb / timeForFullCopy<< " Mb/sec "<<
|
||||
"time for memcpy = "<<timeForMemCpy*1000.0<<"ms memcpy speed = "<<numMb / timeForMemCpy<<" Mb/sec"<<std::endl;
|
||||
}
|
||||
osg::notify(osg::NOTICE).precision(prec);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WindowCaptureCallback::ContextData::readPixels()
|
||||
{
|
||||
// std::cout<<"readPixels("<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
||||
|
||||
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
||||
unsigned int nextPboIndex = _pboBuffer.empty() ? 0 : (_currentPboIndex+1)%_pboBuffer.size();
|
||||
|
||||
int width=0, height=0;
|
||||
getSize(_gc, width, height);
|
||||
if (width!=_width || _height!=height)
|
||||
{
|
||||
std::cout<<" Window resized "<<width<<", "<<height<<std::endl;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
osg::Image* image = _imageBuffer[_currentImageIndex].get();
|
||||
|
||||
osg::Timer_t tick_start = osg::Timer::instance()->tick();
|
||||
|
||||
#if 1
|
||||
image->readPixels(0,0,_width,_height,
|
||||
_pixelFormat,_type);
|
||||
#endif
|
||||
|
||||
osg::Timer_t tick_afterReadPixels = osg::Timer::instance()->tick();
|
||||
|
||||
updateTimings(tick_start, tick_afterReadPixels, tick_afterReadPixels, image->getTotalSizeInBytes());
|
||||
|
||||
if (!_fileName.empty())
|
||||
{
|
||||
// osgDB::writeImageFile(*image, _fileName);
|
||||
}
|
||||
|
||||
_currentImageIndex = nextImageIndex;
|
||||
_currentPboIndex = nextPboIndex;
|
||||
}
|
||||
|
||||
void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions* ext)
|
||||
{
|
||||
// std::cout<<"singelPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
||||
|
||||
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
||||
|
||||
int width=0, height=0;
|
||||
getSize(_gc, width, height);
|
||||
if (width!=_width || _height!=height)
|
||||
{
|
||||
std::cout<<" Window resized "<<width<<", "<<height<<std::endl;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
GLuint& pbo = _pboBuffer[0];
|
||||
|
||||
osg::Image* image = _imageBuffer[_currentImageIndex].get();
|
||||
if (image->s() != _width ||
|
||||
image->t() != _height)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Allocating image "<<std::endl;
|
||||
image->allocateImage(_width, _height, 1, _pixelFormat, _type);
|
||||
|
||||
if (pbo!=0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"deleting pbo "<<pbo<<std::endl;
|
||||
ext->glDeleteBuffers (1, &pbo);
|
||||
pbo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pbo==0)
|
||||
{
|
||||
ext->glGenBuffers(1, &pbo);
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
|
||||
ext->glBufferData(GL_PIXEL_PACK_BUFFER_ARB, image->getTotalSizeInBytes(), 0, GL_STREAM_READ);
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Generating pbo "<<pbo<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
|
||||
}
|
||||
|
||||
osg::Timer_t tick_start = osg::Timer::instance()->tick();
|
||||
|
||||
#if 1
|
||||
glReadPixels(0, 0, _width, _height, _pixelFormat, _type, 0);
|
||||
#endif
|
||||
|
||||
osg::Timer_t tick_afterReadPixels = osg::Timer::instance()->tick();
|
||||
|
||||
GLubyte* src = (GLubyte*)ext->glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB,
|
||||
GL_READ_ONLY_ARB);
|
||||
if(src)
|
||||
{
|
||||
memcpy(image->data(), src, image->getTotalSizeInBytes());
|
||||
ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
|
||||
}
|
||||
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
|
||||
|
||||
osg::Timer_t tick_afterMemCpy = osg::Timer::instance()->tick();
|
||||
|
||||
updateTimings(tick_start, tick_afterReadPixels, tick_afterMemCpy, image->getTotalSizeInBytes());
|
||||
|
||||
if (!_fileName.empty())
|
||||
{
|
||||
// osgDB::writeImageFile(*image, _fileName);
|
||||
}
|
||||
|
||||
|
||||
_currentImageIndex = nextImageIndex;
|
||||
}
|
||||
|
||||
void WindowCaptureCallback::ContextData::multiPBO(osg::BufferObject::Extensions* ext)
|
||||
{
|
||||
// std::cout<<"multiPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
|
||||
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
|
||||
unsigned int nextPboIndex = (_currentPboIndex+1)%_pboBuffer.size();
|
||||
|
||||
int width=0, height=0;
|
||||
getSize(_gc, width, height);
|
||||
if (width!=_width || _height!=height)
|
||||
{
|
||||
std::cout<<" Window resized "<<width<<", "<<height<<std::endl;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
GLuint& copy_pbo = _pboBuffer[_currentPboIndex];
|
||||
GLuint& read_pbo = _pboBuffer[nextPboIndex];
|
||||
|
||||
osg::Image* image = _imageBuffer[_currentImageIndex].get();
|
||||
if (image->s() != _width ||
|
||||
image->t() != _height)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Allocating image "<<std::endl;
|
||||
image->allocateImage(_width, _height, 1, _pixelFormat, _type);
|
||||
|
||||
if (read_pbo!=0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"deleting pbo "<<read_pbo<<std::endl;
|
||||
ext->glDeleteBuffers (1, &read_pbo);
|
||||
read_pbo = 0;
|
||||
}
|
||||
|
||||
if (copy_pbo!=0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"deleting pbo "<<copy_pbo<<std::endl;
|
||||
ext->glDeleteBuffers (1, ©_pbo);
|
||||
copy_pbo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool doCopy = copy_pbo!=0;
|
||||
if (copy_pbo==0)
|
||||
{
|
||||
ext->glGenBuffers(1, ©_pbo);
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, copy_pbo);
|
||||
ext->glBufferData(GL_PIXEL_PACK_BUFFER_ARB, image->getTotalSizeInBytes(), 0, GL_STREAM_READ);
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Generating pbo "<<read_pbo<<std::endl;
|
||||
}
|
||||
|
||||
if (read_pbo==0)
|
||||
{
|
||||
ext->glGenBuffers(1, &read_pbo);
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, read_pbo);
|
||||
ext->glBufferData(GL_PIXEL_PACK_BUFFER_ARB, image->getTotalSizeInBytes(), 0, GL_STREAM_READ);
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Generating pbo "<<read_pbo<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, read_pbo);
|
||||
}
|
||||
|
||||
osg::Timer_t tick_start = osg::Timer::instance()->tick();
|
||||
|
||||
#if 1
|
||||
glReadPixels(0, 0, _width, _height, _pixelFormat, _type, 0);
|
||||
#endif
|
||||
|
||||
osg::Timer_t tick_afterReadPixels = osg::Timer::instance()->tick();
|
||||
|
||||
if (doCopy)
|
||||
{
|
||||
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, copy_pbo);
|
||||
|
||||
GLubyte* src = (GLubyte*)ext->glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB,
|
||||
GL_READ_ONLY_ARB);
|
||||
if(src)
|
||||
{
|
||||
memcpy(image->data(), src, image->getTotalSizeInBytes());
|
||||
ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
|
||||
}
|
||||
|
||||
if (!_fileName.empty())
|
||||
{
|
||||
// osgDB::writeImageFile(*image, _fileName);
|
||||
}
|
||||
}
|
||||
|
||||
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
|
||||
|
||||
osg::Timer_t tick_afterMemCpy = osg::Timer::instance()->tick();
|
||||
|
||||
updateTimings(tick_start, tick_afterReadPixels, tick_afterMemCpy, image->getTotalSizeInBytes());
|
||||
|
||||
_currentImageIndex = nextImageIndex;
|
||||
_currentPboIndex = nextPboIndex;
|
||||
}
|
||||
|
||||
void addCallbackToViewer(osgViewer::ViewerBase& viewer, WindowCaptureCallback* callback)
|
||||
{
|
||||
|
||||
if (callback->getFramePosition()==WindowCaptureCallback::START_FRAME)
|
||||
{
|
||||
osgViewer::ViewerBase::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
for(osgViewer::ViewerBase::Windows::iterator itr = windows.begin();
|
||||
itr != windows.end();
|
||||
++itr)
|
||||
{
|
||||
osgViewer::GraphicsWindow* window = *itr;
|
||||
osg::GraphicsContext::Cameras& cameras = window->getCameras();
|
||||
osg::Camera* firstCamera = 0;
|
||||
for(osg::GraphicsContext::Cameras::iterator cam_itr = cameras.begin();
|
||||
cam_itr != cameras.end();
|
||||
++cam_itr)
|
||||
{
|
||||
if (firstCamera)
|
||||
{
|
||||
if ((*cam_itr)->getRenderOrder() < firstCamera->getRenderOrder())
|
||||
{
|
||||
firstCamera = (*cam_itr);
|
||||
}
|
||||
if ((*cam_itr)->getRenderOrder() == firstCamera->getRenderOrder() &&
|
||||
(*cam_itr)->getRenderOrderNum() < firstCamera->getRenderOrderNum())
|
||||
{
|
||||
firstCamera = (*cam_itr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
firstCamera = *cam_itr;
|
||||
}
|
||||
}
|
||||
|
||||
if (firstCamera)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"First camera "<<firstCamera<<std::endl;
|
||||
|
||||
firstCamera->setInitialDrawCallback(callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"No camera found"<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
osgViewer::ViewerBase::Windows windows;
|
||||
viewer.getWindows(windows);
|
||||
for(osgViewer::ViewerBase::Windows::iterator itr = windows.begin();
|
||||
itr != windows.end();
|
||||
++itr)
|
||||
{
|
||||
osgViewer::GraphicsWindow* window = *itr;
|
||||
osg::GraphicsContext::Cameras& cameras = window->getCameras();
|
||||
osg::Camera* lastCamera = 0;
|
||||
for(osg::GraphicsContext::Cameras::iterator cam_itr = cameras.begin();
|
||||
cam_itr != cameras.end();
|
||||
++cam_itr)
|
||||
{
|
||||
if (lastCamera)
|
||||
{
|
||||
if ((*cam_itr)->getRenderOrder() > lastCamera->getRenderOrder())
|
||||
{
|
||||
lastCamera = (*cam_itr);
|
||||
}
|
||||
if ((*cam_itr)->getRenderOrder() == lastCamera->getRenderOrder() &&
|
||||
(*cam_itr)->getRenderOrderNum() >= lastCamera->getRenderOrderNum())
|
||||
{
|
||||
lastCamera = (*cam_itr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastCamera = *cam_itr;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastCamera)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Last camera "<<lastCamera<<std::endl;
|
||||
|
||||
lastCamera->setFinalDrawCallback(callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"No camera found"<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models.");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
|
||||
osgViewer::Viewer viewer(arguments);
|
||||
|
||||
unsigned int helpType = 0;
|
||||
if ((helpType = arguments.readHelpType()))
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout, helpType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// report any errors if they have occurred when parsing the program arguments.
|
||||
if (arguments.errors())
|
||||
{
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (arguments.argc()<=1)
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// set up the camera manipulators.
|
||||
{
|
||||
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
|
||||
|
||||
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
|
||||
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
|
||||
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
|
||||
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
|
||||
|
||||
std::string pathfile;
|
||||
char keyForAnimationPath = '5';
|
||||
while (arguments.read("-p",pathfile))
|
||||
{
|
||||
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
|
||||
if (apm || !apm->valid())
|
||||
{
|
||||
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
|
||||
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
|
||||
keyswitchManipulator->selectMatrixManipulator(num);
|
||||
++keyForAnimationPath;
|
||||
}
|
||||
}
|
||||
|
||||
viewer.setCameraManipulator( keyswitchManipulator.get() );
|
||||
}
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
|
||||
// add the thread model handler
|
||||
viewer.addEventHandler(new osgViewer::ThreadingHandler);
|
||||
|
||||
// add the window size toggle handler
|
||||
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
|
||||
|
||||
// add the stats handler
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
// add the help handler
|
||||
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
|
||||
|
||||
// add the record camera path handler
|
||||
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
|
||||
|
||||
// add the LOD Scale handler
|
||||
viewer.addEventHandler(new osgViewer::LODScaleHandler);
|
||||
|
||||
GLenum readBuffer = GL_BACK;
|
||||
WindowCaptureCallback::FramePosition position = WindowCaptureCallback::END_FRAME;
|
||||
WindowCaptureCallback::Mode mode = WindowCaptureCallback::DOUBLE_PBO;
|
||||
|
||||
while (arguments.read("--start-frame")) { position = WindowCaptureCallback::START_FRAME; readBuffer = GL_FRONT; }
|
||||
while (arguments.read("--end-frame")) position = WindowCaptureCallback::END_FRAME;
|
||||
|
||||
while (arguments.read("--front")) readBuffer = GL_FRONT;
|
||||
while (arguments.read("--back")) readBuffer = GL_BACK;
|
||||
|
||||
while (arguments.read("--no-pbo")) mode = WindowCaptureCallback::READ_PIXELS;
|
||||
while (arguments.read("--single-pbo")) mode = WindowCaptureCallback::SINGLE_PBO;
|
||||
while (arguments.read("--double-pbo")) mode = WindowCaptureCallback::DOUBLE_PBO;
|
||||
while (arguments.read("--triple-pbo")) mode = WindowCaptureCallback::TRIPLE_PBO;
|
||||
|
||||
|
||||
unsigned int width=1280;
|
||||
unsigned int height=1024;
|
||||
bool pbufferOnly = false;
|
||||
osg::ref_ptr<osg::GraphicsContext> pbuffer;
|
||||
if (arguments.read("--pbuffer",width,height) ||
|
||||
(pbufferOnly = arguments.read("--pbuffer-only",width,height)))
|
||||
{
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->red = 8;
|
||||
traits->green = 8;
|
||||
traits->blue = 8;
|
||||
traits->alpha = 8;
|
||||
traits->windowDecoration = false;
|
||||
traits->pbuffer = true;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
|
||||
pbuffer = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
if (pbuffer.valid())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Pixel buffer has been created successfully."<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Pixel buffer has not been created successfully."<<std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// load the data
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||
if (!loadedModel)
|
||||
{
|
||||
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// any option left unread are converted into errors to write out later.
|
||||
arguments.reportRemainingOptionsAsUnrecognized();
|
||||
|
||||
// report any errors if they have occurred when parsing the program arguments.
|
||||
if (arguments.errors())
|
||||
{
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// optimize the scene graph, remove redundant nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get());
|
||||
|
||||
viewer.setSceneData( loadedModel.get() );
|
||||
|
||||
|
||||
if (pbuffer.valid())
|
||||
{
|
||||
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
|
||||
camera->setGraphicsContext(pbuffer.get());
|
||||
camera->setViewport(new osg::Viewport(0,0,width,height));
|
||||
GLenum buffer = pbuffer->getTraits()->doubleBuffer ? GL_BACK : GL_FRONT;
|
||||
camera->setDrawBuffer(buffer);
|
||||
camera->setReadBuffer(buffer);
|
||||
camera->setFinalDrawCallback(new WindowCaptureCallback(mode, position, readBuffer));
|
||||
|
||||
if (pbufferOnly)
|
||||
{
|
||||
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
|
||||
|
||||
viewer.realize();
|
||||
}
|
||||
else
|
||||
{
|
||||
viewer.realize();
|
||||
|
||||
viewer.stopThreading();
|
||||
|
||||
pbuffer->realize();
|
||||
|
||||
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
|
||||
|
||||
viewer.startThreading();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
viewer.realize();
|
||||
|
||||
addCallbackToViewer(viewer, new WindowCaptureCallback(mode, position, readBuffer));
|
||||
}
|
||||
|
||||
return viewer.run();
|
||||
|
||||
}
|
||||
@@ -502,8 +502,10 @@ int main(int argc, char** argv)
|
||||
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("--NVidia", "ParallelSplitShadowMap set default PolygonOffset for NVidia.");//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.");
|
||||
@@ -624,12 +626,20 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
|
||||
|
||||
double polyoffsetfactor = pssm->getPolygonOffset().x();
|
||||
double polyoffsetunit = pssm->getPolygonOffset().y();
|
||||
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));
|
||||
pssm->setPolygonOffset(osg::Vec2(polyoffsetfactor,polyoffsetunit)); //ATI Radeon
|
||||
|
||||
if (arguments.read("--NVidia")){
|
||||
//pssm->setPolygonOffset(osg::Vec2(-0.02,1.0)); //ATI Radeon
|
||||
pssm->setPolygonOffset(osg::Vec2(10.0f,20.0f)); //NVidia
|
||||
}
|
||||
|
||||
if ( arguments.read("--CullFaceFront") ) {
|
||||
pssm->forceFrontCullFace();
|
||||
}
|
||||
|
||||
shadowedScene->setShadowTechnique(pssm.get());
|
||||
}
|
||||
@@ -751,7 +761,7 @@ int main(int argc, char** argv)
|
||||
|
||||
|
||||
// osgDB::writeNodeFile(*group,"test.osg");
|
||||
|
||||
|
||||
while (!viewer.done())
|
||||
{
|
||||
if (updateLightPosition)
|
||||
|
||||
@@ -412,49 +412,7 @@ void testQuat(const osg::Vec3d& quat_scale)
|
||||
|
||||
class MyThread : public OpenThreads::Thread {
|
||||
public:
|
||||
void run(void) { }
|
||||
};
|
||||
|
||||
class NotifyThread : public OpenThreads::Thread {
|
||||
public:
|
||||
|
||||
NotifyThread(osg::NotifySeverity level, const std::string& message):
|
||||
_done(false),
|
||||
_level(level),
|
||||
_message(message) {}
|
||||
|
||||
~NotifyThread()
|
||||
{
|
||||
_done = true;
|
||||
while(isRunning())
|
||||
{
|
||||
OpenThreads::Thread::YieldCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
void run(void)
|
||||
{
|
||||
std::cout << "Entering thread ..." <<_message<< std::endl;
|
||||
|
||||
unsigned int count=0;
|
||||
|
||||
while(!_done)
|
||||
{
|
||||
++count;
|
||||
#if 1
|
||||
osg::notify(_level)<<_message<<this<<"\n";
|
||||
#else
|
||||
osg::notify(_level)<<_message<<this<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::cout << "Leaving thread ..." <<_message<< " count="<<count<<std::endl;
|
||||
}
|
||||
|
||||
bool _done;
|
||||
osg::NotifySeverity _level;
|
||||
std::string _message;
|
||||
|
||||
void run(void) { }
|
||||
};
|
||||
|
||||
void testThreadInitAndExit()
|
||||
@@ -470,25 +428,6 @@ void testThreadInitAndExit()
|
||||
OpenThreads::Thread::microSleep(500000);
|
||||
|
||||
std::cout<<"pass thread start and delete test"<<std::endl<<std::endl;
|
||||
|
||||
|
||||
std::cout<<"****** Running notify thread test ****** "<<std::endl;
|
||||
|
||||
{
|
||||
NotifyThread thread1(osg::INFO,"thread one:");
|
||||
NotifyThread thread2(osg::INFO,"thread two:");
|
||||
NotifyThread thread3(osg::INFO,"thread three:");
|
||||
NotifyThread thread4(osg::INFO,"thread four:");
|
||||
thread1.startThread();
|
||||
thread2.startThread();
|
||||
thread3.startThread();
|
||||
thread4.startThread();
|
||||
|
||||
// add a sleep to allow the thread start to fall over it its going to.
|
||||
OpenThreads::Thread::microSleep(5000000);
|
||||
}
|
||||
|
||||
std::cout<<"pass noitfy thread test."<<std::endl<<std::endl;
|
||||
}
|
||||
|
||||
void testPolytope()
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
FILE(GLOB ui_files_1 "English.lproj/*.strings")
|
||||
FILE(GLOB ui_files_2 "English.lproj/MainMenu.nib/*.nib")
|
||||
SET(TARGET_SRC ViewerCocoa.mm main.m Info.plist ${ui_files_1} ${ui_files_2})
|
||||
|
||||
SET(TARGET_EXTERNAL_LIBRARIES osg ${COCOA_LIBRARY})
|
||||
SET_SOURCE_FILES_PROPERTIES(Info.plist PROPERTIES MACOSX_PACKAGE_LOCATION .)
|
||||
SET_SOURCE_FILES_PROPERTIES(${ui_files_1} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/English.lproj)
|
||||
SET_SOURCE_FILES_PROPERTIES(${ui_files_2} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/English.lproj/MainMenu.nib)
|
||||
|
||||
SETUP_EXAMPLE(osgviewerCocoa)
|
||||
@@ -2,27 +2,27 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>osgviewerCocoa</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.openscenegraph.osgviewerCocoa</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>osgviewerCocoa</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.openscenegraph.osgsimpleviewerCocoa</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -53,37 +53,37 @@
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
// Just a forward declaration so I don't need the #include in the header.
|
||||
class Viewer;
|
||||
class GraphicsWindowEmbedded;
|
||||
// Just a forward declaration so I don't need the #include in the header.
|
||||
class Viewer;
|
||||
class GraphicsWindowEmbedded;
|
||||
}
|
||||
|
||||
// Subclass NSOpenGLView. We could subclass NSView instead, but NSOpenGLView is easy.
|
||||
@interface ViewerCocoa : NSOpenGLView
|
||||
{
|
||||
// Note: In Objective-C++, if you use objects instead of pointers as
|
||||
// member instance variables, you MUST turn on "Call C++ Default Ctors/Dtors in Objective-C".
|
||||
// -fobjc-call-cxx-cdtors
|
||||
// This option makes sure constructors and destructors are run.
|
||||
// This option is only available for gcc 4.0+ (Mac OS X 10.4+)
|
||||
// Note: In Objective-C++, if you use objects instead of pointers as
|
||||
// member instance variables, you MUST turn on "Call C++ Default Ctors/Dtors in Objective-C".
|
||||
// -fobjc-call-cxx-cdtors
|
||||
// This option makes sure constructors and destructors are run.
|
||||
// This option is only available for gcc 4.0+ (Mac OS X 10.4+)
|
||||
|
||||
// Is SimpleViewer supposed use ref_ptr? (Doesn't look like it to me.)
|
||||
// If so, remember ref_ptr is an object on the stack and the cdtors option must be activated.
|
||||
// We could also make simpleViewer an object instead of a pointer, but again, turn on the option.
|
||||
osgViewer::Viewer* theViewer;
|
||||
osgViewer::GraphicsWindowEmbedded* graphicsWindow;
|
||||
|
||||
// Is SimpleViewer supposed use ref_ptr? (Doesn't look like it to me.)
|
||||
// If so, remember ref_ptr is an object on the stack and the cdtors option must be activated.
|
||||
// We could also make simpleViewer an object instead of a pointer, but again, turn on the option.
|
||||
osgViewer::Viewer* theViewer;
|
||||
osgViewer::GraphicsWindowEmbedded* graphicsWindow;
|
||||
|
||||
|
||||
// This timer is used to trigger animation callbacks since everything is event driven.
|
||||
NSTimer* animationTimer;
|
||||
// This timer is used to trigger animation callbacks since everything is event driven.
|
||||
NSTimer* animationTimer;
|
||||
|
||||
// Flags to help track whether ctrl-clicking or option-clicking is being used
|
||||
BOOL isUsingCtrlClick;
|
||||
BOOL isUsingOptionClick;
|
||||
|
||||
// Flag to track whether the OpenGL multithreading engine is enabled or not
|
||||
BOOL isUsingMultithreadedOpenGLEngine;
|
||||
|
||||
// Flags to help track whether ctrl-clicking or option-clicking is being used
|
||||
BOOL isUsingCtrlClick;
|
||||
BOOL isUsingOptionClick;
|
||||
|
||||
// Flag to track whether the OpenGL multithreading engine is enabled or not
|
||||
BOOL isUsingMultithreadedOpenGLEngine;
|
||||
|
||||
}
|
||||
|
||||
// My custom static method to create a basic pixel format
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
SET(TARGET_SRC osggtkdrawingarea.cpp osgviewerGTK.cpp)
|
||||
SET(TARGET_H osggtkdrawingarea.h)
|
||||
|
||||
INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS} ${GTKGL_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${GTK_LIBRARY_DIRS} ${GTKGL_LIBRARY_DIRS})
|
||||
LINK_LIBRARIES(osgViewer ${GTK_LIBRARIES} ${GTKGL_LIBRARIES})
|
||||
|
||||
SETUP_EXAMPLE(osgviewerGTK)
|
||||
@@ -1,148 +0,0 @@
|
||||
#include "osggtkdrawingarea.h"
|
||||
|
||||
OSGGTKDrawingArea::OSGGTKDrawingArea():
|
||||
_widget (gtk_drawing_area_new()),
|
||||
_glconfig (0),
|
||||
_context (0),
|
||||
_drawable (0),
|
||||
_state (0),
|
||||
_queue (*getEventQueue()) {
|
||||
setCameraManipulator(new osgGA::TrackballManipulator());
|
||||
}
|
||||
|
||||
OSGGTKDrawingArea::~OSGGTKDrawingArea() {
|
||||
}
|
||||
|
||||
bool OSGGTKDrawingArea::createWidget(int width, int height) {
|
||||
_glconfig = gdk_gl_config_new_by_mode(static_cast<GdkGLConfigMode>(
|
||||
GDK_GL_MODE_RGBA |
|
||||
GDK_GL_MODE_DEPTH |
|
||||
GDK_GL_MODE_DOUBLE
|
||||
));
|
||||
|
||||
if(not _glconfig) {
|
||||
osg::notify(osg::FATAL) << "Fail!" << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
gtk_widget_set_size_request(_widget, width, height);
|
||||
|
||||
gtk_widget_set_gl_capability(
|
||||
_widget,
|
||||
_glconfig,
|
||||
0,
|
||||
true,
|
||||
GDK_GL_RGBA_TYPE
|
||||
);
|
||||
|
||||
gtk_widget_add_events(
|
||||
_widget,
|
||||
GDK_BUTTON1_MOTION_MASK |
|
||||
GDK_BUTTON2_MOTION_MASK |
|
||||
GDK_BUTTON3_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_KEY_PRESS_MASK |
|
||||
GDK_KEY_RELEASE_MASK |
|
||||
GDK_VISIBILITY_NOTIFY_MASK
|
||||
);
|
||||
|
||||
// We do this so that we don't have to suck up ALL the input to the
|
||||
// window, but instead just when the drawing area is focused.
|
||||
g_object_set(_widget, "can-focus", true, NULL);
|
||||
|
||||
_connect("realize", G_CALLBACK(&OSGGTKDrawingArea::_srealize));
|
||||
_connect("unrealize", G_CALLBACK(&OSGGTKDrawingArea::_sunrealize));
|
||||
_connect("expose_event", G_CALLBACK(&OSGGTKDrawingArea::_sexpose_event));
|
||||
_connect("configure_event", G_CALLBACK(&OSGGTKDrawingArea::_sconfigure_event));
|
||||
_connect("motion_notify_event", G_CALLBACK(&OSGGTKDrawingArea::_smotion_notify_event));
|
||||
_connect("button_press_event", G_CALLBACK(&OSGGTKDrawingArea::_sbutton_press_event));
|
||||
_connect("button_release_event", G_CALLBACK(&OSGGTKDrawingArea::_sbutton_press_event));
|
||||
_connect("key_press_event", G_CALLBACK(&OSGGTKDrawingArea::_skey_press_event));
|
||||
|
||||
_gw = setUpViewerAsEmbeddedInWindow(0, 0, width, height);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OSGGTKDrawingArea::_realize(GtkWidget* widget) {
|
||||
_context = gtk_widget_get_gl_context(widget);
|
||||
_drawable = gtk_widget_get_gl_drawable(widget);
|
||||
|
||||
gtkRealize();
|
||||
}
|
||||
|
||||
void OSGGTKDrawingArea::_unrealize(GtkWidget* widget) {
|
||||
gtkUnrealize();
|
||||
}
|
||||
|
||||
bool OSGGTKDrawingArea::_expose_event(GtkWidget* widget, GdkEventExpose* event) {
|
||||
if(not gtkGLBegin()) return false;
|
||||
|
||||
frame();
|
||||
|
||||
gtkGLSwap();
|
||||
gtkGLEnd();
|
||||
|
||||
return gtkExpose();
|
||||
}
|
||||
|
||||
bool OSGGTKDrawingArea::_configure_event(GtkWidget* widget, GdkEventConfigure* event) {
|
||||
gtkGLBegin();
|
||||
|
||||
_queue.windowResize(0, 0, event->width, event->height);
|
||||
|
||||
_gw->resized(0, 0, event->width, event->height);
|
||||
|
||||
gtkGLEnd();
|
||||
|
||||
return gtkConfigure(event->width, event->height);
|
||||
}
|
||||
|
||||
bool OSGGTKDrawingArea::_motion_notify_event(GtkWidget* widget, GdkEventMotion* event) {
|
||||
_state = event->state;
|
||||
|
||||
_queue.mouseMotion(event->x, event->y);
|
||||
|
||||
return gtkMotionNotify(event->x, event->y);
|
||||
}
|
||||
|
||||
bool OSGGTKDrawingArea::_button_press_event(GtkWidget* widget, GdkEventButton* event) {
|
||||
_state = event->state;
|
||||
|
||||
if(event->type == GDK_BUTTON_PRESS) {
|
||||
if(event->button == 1) gtk_widget_grab_focus(_widget);
|
||||
|
||||
_queue.mouseButtonPress(event->x, event->y, event->button);
|
||||
|
||||
return gtkButtonPress(event->x, event->y, event->button);
|
||||
}
|
||||
|
||||
else if(event->type == GDK_BUTTON_RELEASE) {
|
||||
_queue.mouseButtonRelease(event->x, event->y, event->button);
|
||||
|
||||
return gtkButtonRelease(event->x, event->y, event->button);
|
||||
}
|
||||
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool OSGGTKDrawingArea::_key_press_event(GtkWidget* widget, GdkEventKey* event) {
|
||||
_state = event->state;
|
||||
|
||||
if(event->type == GDK_KEY_PRESS) {
|
||||
_queue.keyPress(event->keyval);
|
||||
|
||||
return gtkKeyPress(event->keyval);
|
||||
}
|
||||
|
||||
else if(event->type == GDK_KEY_RELEASE) {
|
||||
_queue.keyRelease(event->keyval);
|
||||
|
||||
return gtkKeyRelease(event->keyval);
|
||||
}
|
||||
|
||||
else return false;
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkgl.h>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgGA/TrackballManipulator>
|
||||
|
||||
// This is an implementation of SimpleViewer that is designed to be subclassed
|
||||
// and used as a GtkDrawingArea in a GTK application. Because of the implemention
|
||||
// of GTK, I was unable to derive from GtkWidget and instead had to "wrap" it.
|
||||
// Conceptually, however, you can think of an OSGGTKDrawingArea as both an OSG
|
||||
// Viewer AND GtkDrawingArea.
|
||||
//
|
||||
// While it is possible to use this class directly, it won't end up doing anything
|
||||
// interesting without calls to queueDraw, which ideally are done in the user's
|
||||
// subclass implementation (see: osgviewerGTK).
|
||||
class OSGGTKDrawingArea : public osgViewer::Viewer {
|
||||
GtkWidget* _widget;
|
||||
GdkGLConfig* _glconfig;
|
||||
GdkGLContext* _context;
|
||||
GdkGLDrawable* _drawable;
|
||||
|
||||
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
|
||||
|
||||
unsigned int _state;
|
||||
|
||||
osgGA::EventQueue& _queue;
|
||||
|
||||
static OSGGTKDrawingArea* _self(gpointer self) {
|
||||
return static_cast<OSGGTKDrawingArea*>(self);
|
||||
}
|
||||
|
||||
// A simple helper function to connect us to the various GTK signals.
|
||||
void _connect(const char* name, GCallback callback) {
|
||||
g_signal_connect(G_OBJECT(_widget), name, callback, this);
|
||||
}
|
||||
|
||||
void _realize (GtkWidget*);
|
||||
void _unrealize (GtkWidget*);
|
||||
bool _expose_event (GtkWidget*, GdkEventExpose*);
|
||||
bool _configure_event (GtkWidget*, GdkEventConfigure*);
|
||||
bool _motion_notify_event (GtkWidget*, GdkEventMotion*);
|
||||
bool _button_press_event (GtkWidget*, GdkEventButton*);
|
||||
bool _key_press_event (GtkWidget*, GdkEventKey*);
|
||||
|
||||
// The following functions are static "wrappers" so that we can invoke the
|
||||
// bound methods of a class instance by passing the "this" pointer as the
|
||||
// self argument and invoking it explicitly.
|
||||
static void _srealize(GtkWidget* widget, gpointer self) {
|
||||
_self(self)->_realize(widget);
|
||||
}
|
||||
|
||||
static void _sunrealize(GtkWidget* widget, gpointer self) {
|
||||
_self(self)->_unrealize(widget);
|
||||
}
|
||||
|
||||
static bool _sexpose_event(GtkWidget* widget, GdkEventExpose* expose, gpointer self) {
|
||||
return _self(self)->_expose_event(widget, expose);
|
||||
}
|
||||
|
||||
static bool _sconfigure_event(
|
||||
GtkWidget* widget,
|
||||
GdkEventConfigure* event,
|
||||
gpointer self
|
||||
) {
|
||||
return _self(self)->_configure_event(widget, event);
|
||||
}
|
||||
|
||||
static bool _smotion_notify_event(
|
||||
GtkWidget* widget,
|
||||
GdkEventMotion* event,
|
||||
gpointer self
|
||||
) {
|
||||
return _self(self)->_motion_notify_event(widget, event);
|
||||
}
|
||||
|
||||
static bool _sbutton_press_event(
|
||||
GtkWidget* widget,
|
||||
GdkEventButton* event,
|
||||
gpointer self
|
||||
) {
|
||||
return _self(self)->_button_press_event(widget, event);
|
||||
}
|
||||
|
||||
static bool _skey_press_event(
|
||||
GtkWidget* widget,
|
||||
GdkEventKey* event,
|
||||
gpointer self
|
||||
) {
|
||||
return _self(self)->_key_press_event(widget, event);
|
||||
}
|
||||
|
||||
protected:
|
||||
// You can override these in your subclass if you'd like. :)
|
||||
// Right now they're fairly uninformative, but they could be easily extended.
|
||||
// Note that the "state" information isn't passed around to each function
|
||||
// but is instead stored and abstracted internally. See below.
|
||||
|
||||
virtual void gtkRealize () {};
|
||||
virtual void gtkUnrealize () {};
|
||||
virtual bool gtkExpose () {
|
||||
return true;
|
||||
};
|
||||
|
||||
// The new width and height.
|
||||
virtual bool gtkConfigure(int, int) {
|
||||
return true;
|
||||
};
|
||||
|
||||
// The "normalized" coordinates of the mouse.
|
||||
virtual bool gtkMotionNotify(double, double) {
|
||||
return true;
|
||||
};
|
||||
|
||||
// The "normalized" coordinates of the mouse and the mouse button code on down.
|
||||
virtual bool gtkButtonPress(double, double, unsigned int) {
|
||||
return true;
|
||||
};
|
||||
|
||||
// The "normalized" coordinates of the mouse and mouse button code on release.
|
||||
virtual bool gtkButtonRelease(double, double, unsigned int) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// The X key value on down.
|
||||
virtual bool gtkKeyPress(unsigned int) {
|
||||
return true;
|
||||
};
|
||||
|
||||
// The X key value on release.
|
||||
virtual bool gtkKeyRelease(unsigned int) {
|
||||
return true;
|
||||
};
|
||||
|
||||
// These functions wrap state tests of the most recent state in the
|
||||
// GtkDrawingArea.
|
||||
|
||||
inline bool stateShift() {
|
||||
return _state & GDK_SHIFT_MASK;
|
||||
}
|
||||
|
||||
inline bool stateLock() {
|
||||
return _state & GDK_LOCK_MASK;
|
||||
}
|
||||
|
||||
inline bool stateControl() {
|
||||
return _state & GDK_CONTROL_MASK;
|
||||
}
|
||||
|
||||
inline bool stateMod() {
|
||||
return _state & (
|
||||
GDK_MOD1_MASK |
|
||||
GDK_MOD2_MASK |
|
||||
GDK_MOD3_MASK |
|
||||
GDK_MOD4_MASK |
|
||||
GDK_MOD5_MASK
|
||||
);
|
||||
}
|
||||
|
||||
inline bool stateButton() {
|
||||
return _state & (
|
||||
GDK_BUTTON1_MASK |
|
||||
GDK_BUTTON2_MASK |
|
||||
GDK_BUTTON3_MASK |
|
||||
GDK_BUTTON4_MASK |
|
||||
GDK_BUTTON5_MASK
|
||||
);
|
||||
}
|
||||
|
||||
public:
|
||||
OSGGTKDrawingArea ();
|
||||
~OSGGTKDrawingArea ();
|
||||
|
||||
bool createWidget(int, int);
|
||||
|
||||
GtkWidget* getWidget() {
|
||||
return _widget;
|
||||
}
|
||||
|
||||
bool gtkGLBegin() {
|
||||
if(_drawable and _context) return gdk_gl_drawable_gl_begin(_drawable, _context);
|
||||
|
||||
else return false;
|
||||
}
|
||||
|
||||
void gtkGLEnd() {
|
||||
if(_drawable) gdk_gl_drawable_gl_end(_drawable);
|
||||
}
|
||||
|
||||
// Because of GTK's internal double buffering, I'm not sure if we're really
|
||||
// taking advantage of OpenGL's internal swapping.
|
||||
bool gtkGLSwap() {
|
||||
if(_drawable and gdk_gl_drawable_is_double_buffered(_drawable)) {
|
||||
gdk_gl_drawable_swap_buffers(_drawable);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else {
|
||||
glFlush();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void queueDraw() {
|
||||
gtk_widget_queue_draw(_widget);
|
||||
}
|
||||
};
|
||||
@@ -1,232 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <osg/Stats>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include "osggtkdrawingarea.h"
|
||||
|
||||
const char* HELP_TEXT =
|
||||
"Use CTRL or SHIFT plus right-click to pull up a fake menu.\n"
|
||||
"Use the standard TrackballManipulator keys to rotate the loaded\n"
|
||||
"model (with caveats; the model won't keep rotating).\n"
|
||||
"\n"
|
||||
"<b>OpenSceneGraph Project, 2008</b>"
|
||||
;
|
||||
|
||||
// If you want to see how to connect class method to callbacks, take a look at the
|
||||
// implementation of OSGGTKDrawingArea. It's dirty, but it's the only way I could
|
||||
// come up with.
|
||||
bool activate(GtkWidget* widget, gpointer) {
|
||||
GtkWidget* label = gtk_bin_get_child(GTK_BIN(widget));
|
||||
|
||||
std::cout << "MENU: " << gtk_label_get_label(GTK_LABEL(label)) << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Our derived OSGGTKDrawingArea "widget." Redraws occur while the mouse buttons
|
||||
// are held down and mouse motion is detected.
|
||||
//
|
||||
// This is the easiest way to demonstrate the use of OSGGTKDrawingArea. We override
|
||||
// a few of the event methods to setup our menu and to issue redraws. Note that an
|
||||
// unmodified OSGGTKDrawingArea never calls queueDraw, so OSG is never asked to render
|
||||
// itself.
|
||||
class ExampleOSGGTKDrawingArea : public OSGGTKDrawingArea {
|
||||
GtkWidget* _menu;
|
||||
|
||||
unsigned int _tid;
|
||||
|
||||
// A helper function to easily setup our menu entries.
|
||||
void _menuAdd(const std::string& title) {
|
||||
GtkWidget* item = gtk_menu_item_new_with_label(title.c_str());
|
||||
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(_menu), item);
|
||||
|
||||
g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(activate), 0);
|
||||
}
|
||||
|
||||
bool _clicked(GtkWidget* widget) {
|
||||
const char* text = gtk_label_get_label(
|
||||
GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)))
|
||||
);
|
||||
|
||||
if(not std::strncmp(text, "Close", 5)) gtk_main_quit();
|
||||
|
||||
else if(not std::strncmp(text, "Open File", 9)) {
|
||||
GtkWidget* of = gtk_file_chooser_dialog_new(
|
||||
"Please select an OSG file...",
|
||||
GTK_WINDOW(gtk_widget_get_toplevel(getWidget())),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN,
|
||||
GTK_RESPONSE_ACCEPT,
|
||||
NULL
|
||||
);
|
||||
|
||||
if(gtk_dialog_run(GTK_DIALOG(of)) == GTK_RESPONSE_ACCEPT) {
|
||||
char* file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(of));
|
||||
|
||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(file);
|
||||
|
||||
if(model.valid()) {
|
||||
setSceneData(model.get());
|
||||
|
||||
queueDraw();
|
||||
}
|
||||
|
||||
g_free(file);
|
||||
}
|
||||
|
||||
gtk_widget_destroy(of);
|
||||
}
|
||||
|
||||
// Assume we're wanting FPS toggling.
|
||||
else {
|
||||
if(not _tid) {
|
||||
_tid = g_timeout_add(
|
||||
15,
|
||||
(GSourceFunc)(ExampleOSGGTKDrawingArea::timeout),
|
||||
this
|
||||
);
|
||||
|
||||
gtk_button_set_label(GTK_BUTTON(widget), "Toggle 60 FPS (off)");
|
||||
}
|
||||
|
||||
else {
|
||||
g_source_remove(_tid);
|
||||
gtk_button_set_label(GTK_BUTTON(widget), "Toggle 60 FPS (on)");
|
||||
|
||||
_tid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Check right-click release to see if we need to popup our menu.
|
||||
bool gtkButtonRelease(double, double, unsigned int button) {
|
||||
if(button == 3 and (stateControl() or stateShift())) gtk_menu_popup(
|
||||
GTK_MENU(_menu),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
button,
|
||||
0
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Our "main" drawing pump. Since our app is just a model viewer, we use
|
||||
// click+motion as our criteria for issuing OpenGL refreshes.
|
||||
bool gtkMotionNotify(double, double) {
|
||||
if(stateButton()) queueDraw();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
ExampleOSGGTKDrawingArea():
|
||||
OSGGTKDrawingArea (),
|
||||
_menu (gtk_menu_new()),
|
||||
_tid (0) {
|
||||
_menuAdd("Option");
|
||||
_menuAdd("Another Option");
|
||||
_menuAdd("Still More Options");
|
||||
|
||||
gtk_widget_show_all(_menu);
|
||||
|
||||
getCamera()->setStats(new osg::Stats("omg"));
|
||||
}
|
||||
|
||||
~ExampleOSGGTKDrawingArea() {}
|
||||
|
||||
// Public so that we can use this as a callback in main().
|
||||
static bool clicked(GtkWidget* widget, gpointer self) {
|
||||
return static_cast<ExampleOSGGTKDrawingArea*>(self)->_clicked(widget);
|
||||
}
|
||||
|
||||
//static gboolean timeout(GtkWidget* widget) {
|
||||
static bool timeout(void* self) {
|
||||
static_cast<ExampleOSGGTKDrawingArea*>(self)->queueDraw();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Our main() function! FINALLY! Most of this code is GTK stuff, so it's mostly boilerplate.
|
||||
// If we wanted to get real jiggy with it we could use Glade and cut down about 20 lines of
|
||||
// code or so.
|
||||
int main(int argc, char** argv) {
|
||||
gtk_init(&argc, &argv);
|
||||
gtk_gl_init(&argc, &argv);
|
||||
|
||||
ExampleOSGGTKDrawingArea da;
|
||||
|
||||
if(da.createWidget(640, 480)) {
|
||||
if(argc >= 2) {
|
||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(argv[1]);
|
||||
|
||||
if(model.valid()) da.setSceneData(model.get());
|
||||
}
|
||||
|
||||
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
GtkWidget* vbox1 = gtk_vbox_new(false, 3);
|
||||
GtkWidget* vbox2 = gtk_vbox_new(false, 3);
|
||||
GtkWidget* hbox = gtk_hbox_new(false, 3);
|
||||
GtkWidget* label = gtk_label_new("");
|
||||
GtkWidget* buttons[] = {
|
||||
gtk_button_new_with_label("Open File"),
|
||||
gtk_button_new_with_label("Toggle 60 FPS (on)"),
|
||||
gtk_button_new_with_label("Close")
|
||||
};
|
||||
|
||||
gtk_label_set_use_markup(GTK_LABEL(label), true);
|
||||
gtk_label_set_label(GTK_LABEL(label), HELP_TEXT);
|
||||
|
||||
for(unsigned int i = 0; i < sizeof(buttons) / sizeof(GtkWidget*); i++) {
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(vbox2),
|
||||
buttons[i],
|
||||
false,
|
||||
false,
|
||||
0
|
||||
);
|
||||
|
||||
g_signal_connect(
|
||||
G_OBJECT(buttons[i]),
|
||||
"clicked",
|
||||
G_CALLBACK(ExampleOSGGTKDrawingArea::clicked),
|
||||
&da
|
||||
);
|
||||
}
|
||||
|
||||
gtk_window_set_title(GTK_WINDOW(window), "osgviewerGTK");
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox), vbox2, true, true, 2);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), label, true, true, 2);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), da.getWidget(), true, true, 2);
|
||||
gtk_box_pack_start(GTK_BOX(vbox1), hbox, false, false, 2);
|
||||
|
||||
gtk_container_set_reallocate_redraws(GTK_CONTAINER(window), true);
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox1);
|
||||
|
||||
g_signal_connect(
|
||||
G_OBJECT(window),
|
||||
"delete_event",
|
||||
G_CALLBACK(gtk_main_quit),
|
||||
0
|
||||
);
|
||||
|
||||
gtk_widget_show_all(window);
|
||||
gtk_main();
|
||||
}
|
||||
|
||||
else return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -9,11 +9,6 @@
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
// For wxCURSOR_BLANK below, but isn't used a.t.m.
|
||||
//#ifdef WIN32
|
||||
//#include "wx/msw/wx.rc"
|
||||
//#endif
|
||||
|
||||
#include "osgviewerWX.h"
|
||||
|
||||
|
||||
@@ -45,21 +40,16 @@ bool wxOsgApp::OnInit()
|
||||
// create osg canvas
|
||||
// - initialize
|
||||
|
||||
int *attributes = new int[7];
|
||||
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;
|
||||
attributes[6] = 0;
|
||||
|
||||
OSGCanvas *canvas = new OSGCanvas(frame, wxID_ANY, wxDefaultPosition,
|
||||
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
|
||||
|
||||
GraphicsWindowWX* gw = new GraphicsWindowWX(canvas);
|
||||
|
||||
canvas->SetGraphicsWindow(gw);
|
||||
GraphicsWindowWX* gw = new GraphicsWindowWX(frame, wxID_ANY, wxDefaultPosition,
|
||||
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
|
||||
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer;
|
||||
viewer->getCamera()->setGraphicsContext(gw);
|
||||
@@ -78,6 +68,7 @@ bool wxOsgApp::OnInit()
|
||||
|
||||
viewer->setSceneData(loadedModel.get());
|
||||
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
frame->SetViewer(viewer);
|
||||
|
||||
/* Show the frame */
|
||||
@@ -111,169 +102,30 @@ void MainFrame::OnIdle(wxIdleEvent &event)
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(OSGCanvas, wxGLCanvas)
|
||||
EVT_SIZE (OSGCanvas::OnSize)
|
||||
EVT_PAINT (OSGCanvas::OnPaint)
|
||||
EVT_ERASE_BACKGROUND (OSGCanvas::OnEraseBackground)
|
||||
|
||||
EVT_CHAR (OSGCanvas::OnChar)
|
||||
EVT_KEY_UP (OSGCanvas::OnKeyUp)
|
||||
|
||||
EVT_ENTER_WINDOW (OSGCanvas::OnMouseEnter)
|
||||
EVT_LEFT_DOWN (OSGCanvas::OnMouseDown)
|
||||
EVT_MIDDLE_DOWN (OSGCanvas::OnMouseDown)
|
||||
EVT_RIGHT_DOWN (OSGCanvas::OnMouseDown)
|
||||
EVT_LEFT_UP (OSGCanvas::OnMouseUp)
|
||||
EVT_MIDDLE_UP (OSGCanvas::OnMouseUp)
|
||||
EVT_RIGHT_UP (OSGCanvas::OnMouseUp)
|
||||
EVT_MOTION (OSGCanvas::OnMouseMotion)
|
||||
BEGIN_EVENT_TABLE(GraphicsWindowWX, wxGLCanvas)
|
||||
EVT_SIZE (GraphicsWindowWX::OnSize )
|
||||
EVT_PAINT (GraphicsWindowWX::OnPaint )
|
||||
EVT_ERASE_BACKGROUND(GraphicsWindowWX::OnEraseBackground)
|
||||
EVT_KEY_DOWN (GraphicsWindowWX::OnKeyDown )
|
||||
EVT_KEY_UP (GraphicsWindowWX::OnKeyUp )
|
||||
EVT_MOUSE_EVENTS (GraphicsWindowWX::OnMouse )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
OSGCanvas::OSGCanvas(wxWindow *parent, wxWindowID id,
|
||||
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)
|
||||
{
|
||||
// default cursor to standard
|
||||
_oldCursor = *wxSTANDARD_CURSOR;
|
||||
}
|
||||
|
||||
OSGCanvas::~OSGCanvas()
|
||||
{
|
||||
}
|
||||
|
||||
void OSGCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
{
|
||||
/* must always be here */
|
||||
wxPaintDC dc(this);
|
||||
}
|
||||
|
||||
void OSGCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
// this is also necessary to update the context on some platforms
|
||||
wxGLCanvas::OnSize(event);
|
||||
|
||||
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
|
||||
int width, height;
|
||||
GetClientSize(&width, &height);
|
||||
|
||||
if (_graphics_window.valid())
|
||||
{
|
||||
// update the window dimensions, in case the window has been resized.
|
||||
_graphics_window->getEventQueue()->windowResize(0, 0, width, height);
|
||||
_graphics_window->resized(0,0,width,height);
|
||||
}
|
||||
}
|
||||
|
||||
void OSGCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
|
||||
{
|
||||
/* Do nothing, to avoid flashing on MSW */
|
||||
}
|
||||
|
||||
void OSGCanvas::OnChar(wxKeyEvent &event)
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
|
||||
if (_graphics_window.valid())
|
||||
_graphics_window->getEventQueue()->keyPress(key);
|
||||
|
||||
// If this key event is not processed here, we should call
|
||||
// event.Skip() to allow processing to continue.
|
||||
}
|
||||
|
||||
void OSGCanvas::OnKeyUp(wxKeyEvent &event)
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
|
||||
if (_graphics_window.valid())
|
||||
_graphics_window->getEventQueue()->keyRelease(key);
|
||||
|
||||
// If this key event is not processed here, we should call
|
||||
// event.Skip() to allow processing to continue.
|
||||
}
|
||||
|
||||
void OSGCanvas::OnMouseEnter(wxMouseEvent &event)
|
||||
{
|
||||
// Set focus to ourselves, so keyboard events get directed to us
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void OSGCanvas::OnMouseDown(wxMouseEvent &event)
|
||||
{
|
||||
if (_graphics_window.valid())
|
||||
{
|
||||
_graphics_window->getEventQueue()->mouseButtonPress(event.GetX(), event.GetY(),
|
||||
event.GetButton());
|
||||
}
|
||||
}
|
||||
|
||||
void OSGCanvas::OnMouseUp(wxMouseEvent &event)
|
||||
{
|
||||
if (_graphics_window.valid())
|
||||
{
|
||||
_graphics_window->getEventQueue()->mouseButtonRelease(event.GetX(), event.GetY(),
|
||||
event.GetButton());
|
||||
}
|
||||
}
|
||||
|
||||
void OSGCanvas::OnMouseMotion(wxMouseEvent &event)
|
||||
{
|
||||
if (_graphics_window.valid())
|
||||
_graphics_window->getEventQueue()->mouseMotion(event.GetX(), event.GetY());
|
||||
}
|
||||
|
||||
void OSGCanvas::UseCursor(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// show the old cursor
|
||||
SetCursor(_oldCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// remember the old cursor
|
||||
_oldCursor = GetCursor();
|
||||
|
||||
// hide the cursor
|
||||
// - can't find a way to do this neatly, so create a 1x1, transparent image
|
||||
wxImage image(1,1);
|
||||
image.SetMask(true);
|
||||
image.SetMaskColour(0, 0, 0);
|
||||
wxCursor cursor(image);
|
||||
SetCursor(cursor);
|
||||
|
||||
// On wxGTK, only works as of version 2.7.0
|
||||
// (http://trac.wxwidgets.org/ticket/2946)
|
||||
// SetCursor( wxStockCursor( wxCURSOR_BLANK ) );
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsWindowWX::GraphicsWindowWX(OSGCanvas *canvas)
|
||||
{
|
||||
_canvas = canvas;
|
||||
|
||||
_traits = new GraphicsContext::Traits;
|
||||
|
||||
wxPoint pos = _canvas->GetPosition();
|
||||
wxSize size = _canvas->GetSize();
|
||||
|
||||
_traits->x = pos.x;
|
||||
_traits->y = pos.y;
|
||||
_traits->width = size.x;
|
||||
_traits->height = size.y;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
GraphicsWindowWX::~GraphicsWindowWX()
|
||||
{
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::init()
|
||||
@@ -295,32 +147,120 @@ void GraphicsWindowWX::init()
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsWindowWX::~GraphicsWindowWX()
|
||||
{
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
{
|
||||
/* must always be here */
|
||||
wxPaintDC dc(this);
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
// this is also necessary to update the context on some platforms
|
||||
wxGLCanvas::OnSize(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);
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
|
||||
{
|
||||
/* Do nothing, to avoid flashing on MSW */
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
getEventQueue()->keyPress(key);
|
||||
|
||||
// propagate event
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::OnKeyUp(wxKeyEvent &event)
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
getEventQueue()->keyRelease(key);
|
||||
|
||||
// propagate event
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::OnMouse(wxMouseEvent& event)
|
||||
{
|
||||
if (event.ButtonDown()) {
|
||||
int button = event.GetButton();
|
||||
getEventQueue()->mouseButtonPress(event.GetX(), event.GetY(), button);
|
||||
}
|
||||
else if (event.ButtonUp()) {
|
||||
int button = event.GetButton();
|
||||
getEventQueue()->mouseButtonRelease(event.GetX(), event.GetY(), button);
|
||||
}
|
||||
else if (event.Dragging()) {
|
||||
getEventQueue()->mouseMotion(event.GetX(), event.GetY());
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::grabFocus()
|
||||
{
|
||||
// focus the canvas
|
||||
_canvas->SetFocus();
|
||||
// focus this window
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::grabFocusIfPointerInWindow()
|
||||
{
|
||||
// focus this window, if the pointer is in the window
|
||||
wxPoint pos = wxGetMousePosition();
|
||||
if (wxFindWindowAtPoint(pos) == _canvas)
|
||||
_canvas->SetFocus();
|
||||
if (this == wxFindWindowAtPoint(pos)) {
|
||||
SetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::useCursor(bool cursorOn)
|
||||
{
|
||||
_canvas->UseCursor(cursorOn);
|
||||
if (cursorOn) {
|
||||
|
||||
// show the old cursor
|
||||
SetCursor(_oldCursor);
|
||||
}
|
||||
else {
|
||||
|
||||
// remember the old cursor
|
||||
_oldCursor = GetCursor();
|
||||
|
||||
// hide the cursor
|
||||
// - can't find a way to do this neatly, so create a 1x1, transparent image
|
||||
wxImage image(1,1);
|
||||
image.SetMask(true);
|
||||
image.SetMaskColour(0, 0, 0);
|
||||
wxCursor cursor(image);
|
||||
SetCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
bool GraphicsWindowWX::makeCurrentImplementation()
|
||||
{
|
||||
_canvas->SetCurrent();
|
||||
SetCurrent();
|
||||
return true;
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::swapBuffersImplementation()
|
||||
{
|
||||
_canvas->SwapBuffers();
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
@@ -8,50 +8,25 @@
|
||||
#include <osgViewer/Viewer>
|
||||
#include <string>
|
||||
|
||||
class GraphicsWindowWX;
|
||||
|
||||
class OSGCanvas : public wxGLCanvas
|
||||
class GraphicsWindowWX : public wxGLCanvas, public osgViewer::GraphicsWindow
|
||||
{
|
||||
public:
|
||||
OSGCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
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);
|
||||
|
||||
virtual ~OSGCanvas();
|
||||
|
||||
void SetGraphicsWindow(osgViewer::GraphicsWindow *gw) { _graphics_window = gw; }
|
||||
~GraphicsWindowWX();
|
||||
|
||||
void init();
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
|
||||
void OnChar(wxKeyEvent &event);
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
void OnKeyUp(wxKeyEvent &event);
|
||||
|
||||
void OnMouseEnter(wxMouseEvent &event);
|
||||
void OnMouseDown(wxMouseEvent &event);
|
||||
void OnMouseUp(wxMouseEvent &event);
|
||||
void OnMouseMotion(wxMouseEvent &event);
|
||||
|
||||
void UseCursor(bool value);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
osg::ref_ptr<osgViewer::GraphicsWindow> _graphics_window;
|
||||
|
||||
wxCursor _oldCursor;
|
||||
};
|
||||
|
||||
class GraphicsWindowWX : public osgViewer::GraphicsWindow
|
||||
{
|
||||
public:
|
||||
GraphicsWindowWX(OSGCanvas *canvas);
|
||||
~GraphicsWindowWX();
|
||||
|
||||
void init();
|
||||
void OnMouse(wxMouseEvent &event);
|
||||
|
||||
//
|
||||
// GraphicsWindow interface
|
||||
@@ -63,7 +38,7 @@ public:
|
||||
bool makeCurrentImplementation();
|
||||
void swapBuffersImplementation();
|
||||
|
||||
// not implemented yet...just use dummy implementation to get working.
|
||||
// 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; }
|
||||
@@ -71,15 +46,15 @@ public:
|
||||
virtual bool releaseContextImplementation() { return true; }
|
||||
|
||||
private:
|
||||
// XXX need to set _canvas to NULL when the canvas is deleted by
|
||||
// its parent. for this, need to add event handler in OSGCanvas
|
||||
OSGCanvas* _canvas;
|
||||
wxCursor _oldCursor;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MainFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
MainFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
|
||||
MainFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
void SetViewer(osgViewer::Viewer *viewer);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetaddremove.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetaddremove)
|
||||
@@ -1,134 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetaddremove.cpp 45 2008-04-23 16:46:11Z cubicool $
|
||||
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Table>
|
||||
#include <osgWidget/Box>
|
||||
#include <osgWidget/Label>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
class ABCWidget: public osgWidget::Label {
|
||||
public:
|
||||
ABCWidget(const std::string& label):
|
||||
osgWidget::Label("", label) {
|
||||
setFont("fonts/Vera.ttf");
|
||||
setFontSize(20);
|
||||
setCanFill(true);
|
||||
setShadow(0.08f);
|
||||
addSize(10.0f, 10.0f);
|
||||
}
|
||||
};
|
||||
|
||||
class Button: public osgWidget::Label {
|
||||
public:
|
||||
Button(const std::string& label):
|
||||
osgWidget::Label("", label) {
|
||||
setFont("fonts/Vera.ttf");
|
||||
setFontSize(30);
|
||||
setColor(0.8f, 0.2f, 0.2f, 0.8f);
|
||||
setCanFill(true);
|
||||
setShadow(0.1f);
|
||||
setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK);
|
||||
addSize(20.0f, 20.0f);
|
||||
}
|
||||
|
||||
// NOTE! I need to make it clearer than Push/Release can happen so fast that
|
||||
// the changes you make aren't visible with your refresh rate. Throttling state
|
||||
// changes and what-have-you on mousePush/mouseRelease/etc. is going to be
|
||||
// annoying...
|
||||
|
||||
virtual bool mousePush(double, double, osgWidget::WindowManager*) {
|
||||
addColor(0.2f, 0.2f, 0.2f, 0.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool mouseRelease(double, double, osgWidget::WindowManager*) {
|
||||
addColor(-0.2f, -0.2f, -0.2f, 0.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class AddRemove: public osgWidget::Box {
|
||||
osg::ref_ptr<osgWidget::Window> _win1;
|
||||
|
||||
public:
|
||||
AddRemove():
|
||||
osgWidget::Box ("buttons", osgWidget::Box::VERTICAL),
|
||||
_win1 (new osgWidget::Box("win1", osgWidget::Box::VERTICAL)) {
|
||||
addWidget(new Button("Add Widget"));
|
||||
addWidget(new Button("Remove Widget"));
|
||||
|
||||
// Take special note here! Not only do the Button objects have their
|
||||
// own overridden methods for changing the color, but they have attached
|
||||
// callbacks for doing the work with local data.
|
||||
getByName("Widget_1")->addCallback(osgWidget::Callback(
|
||||
&AddRemove::handlePressAdd,
|
||||
this,
|
||||
osgWidget::EVENT_MOUSE_PUSH
|
||||
));
|
||||
|
||||
getByName("Widget_2")->addCallback(osgWidget::Callback(
|
||||
&AddRemove::handlePressRemove,
|
||||
this,
|
||||
osgWidget::EVENT_MOUSE_PUSH
|
||||
));
|
||||
}
|
||||
|
||||
virtual void managed(osgWidget::WindowManager* wm) {
|
||||
osgWidget::Box::managed(wm);
|
||||
|
||||
_win1->setOrigin(250.0f, 0.0f);
|
||||
|
||||
wm->addChild(_win1.get());
|
||||
}
|
||||
|
||||
bool handlePressAdd(osgWidget::Event& ev) {
|
||||
static unsigned int num = 0;
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "a random widget " << num;
|
||||
|
||||
_win1->addWidget(new ABCWidget(ss.str()));
|
||||
_win1->resize();
|
||||
|
||||
num++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool handlePressRemove(osgWidget::Event& ev) {
|
||||
// TODO: Temporary hack!
|
||||
const osgWidget::Box::Vector& v = _win1->getObjects();
|
||||
|
||||
if(!v.size()) return false;
|
||||
|
||||
osgWidget::Widget* w = _win1->getObjects()[v.size() - 1].get();
|
||||
|
||||
_win1->removeWidget(w);
|
||||
_win1->resize();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D
|
||||
);
|
||||
|
||||
osgWidget::Box* buttons = new AddRemove();
|
||||
|
||||
wm->addChild(buttons);
|
||||
|
||||
return createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetbox.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetbox)
|
||||
@@ -1,122 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetbox.cpp 59 2008-05-15 20:55:31Z cubicool $
|
||||
|
||||
// NOTE: You'll find this example very similar to osgwidgetwindow. However, here we
|
||||
// demonstrate a bit of subclassing of Widget so that we can respond to events
|
||||
// such as mouseEnter and mouseLeave. We also demonstrate the use of padding, though
|
||||
// fill and alignment should be working too.
|
||||
|
||||
#include <osg/io_utils>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Box>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
const unsigned int MASK_3D = 0x0F000000;
|
||||
|
||||
struct ColorWidget: public osgWidget::Widget {
|
||||
ColorWidget():
|
||||
osgWidget::Widget("", 256.0f, 256.0f) {
|
||||
}
|
||||
|
||||
bool mouseEnter(double, double, osgWidget::WindowManager*) {
|
||||
addColor(-osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "enter: " << getColor() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseLeave(double, double, osgWidget::WindowManager*) {
|
||||
addColor(osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
|
||||
|
||||
// osgWidget::warn() << "leave: " << getColor() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseOver(double x, double y, osgWidget::WindowManager*) {
|
||||
osgWidget::Color c = getImageColorAtPointerXY(x, y);
|
||||
|
||||
if(c.a() < 0.001f) {
|
||||
// osgWidget::warn() << "Transparent Pixel: " << x << " " << y << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool keyUp(int key, int keyMask, osgWidget::WindowManager*) {
|
||||
// osgWidget::warn() << "..." << key << " - " << keyMask << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
osgWidget::Box* createBox(const std::string& name, osgWidget::Box::BOX_TYPE bt) {
|
||||
osgWidget::Box* box = new osgWidget::Box(name, bt, true);
|
||||
osgWidget::Widget* widget1 = new osgWidget::Widget(name + "_widget1", 100.0f, 100.0f);
|
||||
osgWidget::Widget* widget2 = new osgWidget::Widget(name + "_widget2", 100.0f, 100.0f);
|
||||
osgWidget::Widget* widget3 = new ColorWidget();
|
||||
|
||||
widget1->setColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
widget2->setColor(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
|
||||
widget3->setImage("osgWidget/natascha.png");
|
||||
widget3->setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT);
|
||||
widget3->setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT);
|
||||
widget3->setTexCoord(1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
|
||||
widget3->setTexCoord(0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
|
||||
|
||||
box->addWidget(widget1);
|
||||
box->addWidget(widget2);
|
||||
box->addWidget(widget3);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::CompositeViewer viewer;
|
||||
|
||||
osgViewer::View* view = new osgViewer::View();
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
view,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG |
|
||||
osgWidget::WindowManager::WM_NO_INVERT_Y
|
||||
);
|
||||
|
||||
wm->setPointerFocusMode(osgWidget::WindowManager::PFM_SLOPPY);
|
||||
|
||||
osgWidget::Window* box1 = createBox("HBOX", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Window* box2 = createBox("VBOX", osgWidget::Box::VERTICAL);
|
||||
osgWidget::Window* box3 = createBox("HBOX2", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Window* box4 = createBox("VBOX2", osgWidget::Box::VERTICAL);
|
||||
|
||||
box1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 0.8f);
|
||||
box1->attachMoveCallback();
|
||||
|
||||
box2->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.8f);
|
||||
box2->attachMoveCallback();
|
||||
|
||||
box3->getBackground()->setColor(0.0f, 0.0f, 1.0f, 0.8f);
|
||||
box3->attachMoveCallback();
|
||||
|
||||
wm->addChild(box1);
|
||||
wm->addChild(box2);
|
||||
wm->addChild(box3);
|
||||
wm->addChild(box4);
|
||||
|
||||
box4->hide();
|
||||
|
||||
osg::Node* model = osgDB::readNodeFile("spaceship.osg");
|
||||
|
||||
model->setNodeMask(MASK_3D);
|
||||
|
||||
return osgWidget::createCompositeExample(viewer, view, wm, model);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetcanvas.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetcanvas)
|
||||
@@ -1,118 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetcanvas.cpp 33 2008-04-04 19:03:12Z cubicool $
|
||||
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Canvas>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
bool colorWidgetEnter(osgWidget::Event& event) {
|
||||
event.getWidget()->addColor(0.5f, 0.2f, 0.3f, 0.0f);
|
||||
|
||||
// osgWidget::warn() << "WIDGET mouseEnter " << event.getWidget()->getName() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool colorWidgetLeave(osgWidget::Event& event) {
|
||||
event.getWidget()->addColor(-0.5f, -0.2f, -0.3f, 0.0f);
|
||||
|
||||
// osgWidget::warn() << "WIDGET mouseLeave" << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool windowMouseOver(osgWidget::Event& event) {
|
||||
osgWidget::XYCoord xy = event.getWindow()->localXY(event.x, event.y);
|
||||
|
||||
// osgWidget::warn() << "WINDOW " << xy.x() << " - " << xy.y() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool widgetMouseOver(osgWidget::Event& event) {
|
||||
osgWidget::XYCoord xy = event.getWidget()->localXY(event.x, event.y);
|
||||
|
||||
// osgWidget::warn() << "WIDGET mouseOver " << xy.x() << " - " << xy.y() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
osgWidget::Widget* createWidget(
|
||||
const std::string& name,
|
||||
osgWidget::color_type col,
|
||||
osgWidget::Widget::Layer layer
|
||||
) {
|
||||
osgWidget::Widget* widget = new osgWidget::Widget(name, 200.0f, 200.0f);
|
||||
|
||||
widget->setEventMask(osgWidget::EVENT_ALL);
|
||||
widget->addCallback(osgWidget::Callback(&colorWidgetEnter, osgWidget::EVENT_MOUSE_PUSH));
|
||||
widget->addCallback(osgWidget::Callback(&colorWidgetLeave, osgWidget::EVENT_MOUSE_RELEASE));
|
||||
widget->addCallback(osgWidget::Callback(&colorWidgetEnter, osgWidget::EVENT_MOUSE_ENTER));
|
||||
widget->addCallback(osgWidget::Callback(&colorWidgetLeave, osgWidget::EVENT_MOUSE_LEAVE));
|
||||
widget->addCallback(osgWidget::Callback(&widgetMouseOver, osgWidget::EVENT_MOUSE_OVER));
|
||||
widget->setColor(col, col, col, 0.5f);
|
||||
widget->setLayer(layer);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||
);
|
||||
|
||||
osgWidget::Canvas* canvas = new osgWidget::Canvas("canvas");
|
||||
|
||||
canvas->addCallback(osgWidget::Callback(&windowMouseOver, osgWidget::EVENT_MOUSE_OVER));
|
||||
canvas->attachMoveCallback();
|
||||
canvas->attachRotateCallback();
|
||||
canvas->attachScaleCallback();
|
||||
|
||||
canvas->addWidget(
|
||||
createWidget("w1", 0.2f, osgWidget::Widget::LAYER_LOW),
|
||||
0.0f,
|
||||
0.0f
|
||||
);
|
||||
|
||||
canvas->addWidget(
|
||||
createWidget("w2", 0.4f, osgWidget::Widget::LAYER_MIDDLE),
|
||||
200.0f,
|
||||
0.0f
|
||||
);
|
||||
|
||||
canvas->addWidget(
|
||||
createWidget("w3", 0.6f, osgWidget::Widget::LAYER_HIGH),
|
||||
400.0f,
|
||||
0.0f
|
||||
);
|
||||
|
||||
// Add a child and then resize it relatively to the size of the parent Window.
|
||||
osgWidget::Widget* relWidget = new osgWidget::Widget("relative");
|
||||
|
||||
relWidget->setLayer(osgWidget::Widget::LAYER_LOW, 1);
|
||||
relWidget->setCoordinateMode(osgWidget::Widget::CM_RELATIVE);
|
||||
relWidget->setSize(0.2f, 0.2f);
|
||||
relWidget->setColor(0.5f, 0.5f, 0.1f, 0.9f);
|
||||
|
||||
osgWidget::warn() << canvas->getWidth() << std::endl;
|
||||
|
||||
canvas->addWidget(relWidget, 0.4f, 0.4f);
|
||||
|
||||
relWidget->addOrigin(0.1f, 0.1f);
|
||||
relWidget->addSize(0.2f, 0.2f);
|
||||
|
||||
canvas->resize();
|
||||
|
||||
// Finally, add the whole thing to the WindowManager.
|
||||
wm->addChild(canvas);
|
||||
|
||||
return osgWidget::createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetframe.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetframe)
|
||||
@@ -1,89 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetframe.cpp 40 2008-04-11 14:05:11Z cubicool $
|
||||
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Frame>
|
||||
#include <osgWidget/Box>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||
);
|
||||
|
||||
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrame(
|
||||
"frame",
|
||||
32.0f,
|
||||
32.0f,
|
||||
300.0f,
|
||||
300.0f
|
||||
);
|
||||
|
||||
osgWidget::Table* table = new osgWidget::Table("table", 2, 2);
|
||||
osgWidget::Box* bottom = new osgWidget::Box("panel", osgWidget::Box::HORIZONTAL);
|
||||
|
||||
table->addWidget(new osgWidget::Widget("red", 300.0f, 300.0f), 0, 0);
|
||||
table->addWidget(new osgWidget::Widget("white", 300.0f, 300.0f), 0, 1);
|
||||
table->addWidget(new osgWidget::Widget("yellow", 300.0f, 300.0f), 1, 0);
|
||||
table->addWidget(new osgWidget::Widget("purple", 300.0f, 300.0f), 1, 1);
|
||||
table->getByRowCol(0, 0)->setColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
table->getByRowCol(0, 1)->setColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
table->getByRowCol(1, 0)->setColor(1.0f, 1.0f, 0.0f, 1.0f);
|
||||
table->getByRowCol(1, 1)->setColor(1.0f, 0.0f, 1.0f, 1.0f);
|
||||
table->getByRowCol(0, 0)->setMinimumSize(100.0f, 100.0f);
|
||||
table->getByRowCol(0, 1)->setMinimumSize(100.0f, 100.0f);
|
||||
table->getByRowCol(1, 0)->setMinimumSize(100.0f, 100.0f);
|
||||
table->getByRowCol(1, 1)->setMinimumSize(100.0f, 100.0f);
|
||||
|
||||
frame->setWindow(table);
|
||||
|
||||
// Give frame some nice textures.
|
||||
// TODO: This has to be done after setWindow(); wtf?
|
||||
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
osgWidget::Widget* l = frame->getBorder(osgWidget::Frame::BORDER_LEFT);
|
||||
osgWidget::Widget* r = frame->getBorder(osgWidget::Frame::BORDER_RIGHT);
|
||||
osgWidget::Widget* t = frame->getBorder(osgWidget::Frame::BORDER_TOP);
|
||||
osgWidget::Widget* b = frame->getBorder(osgWidget::Frame::BORDER_BOTTOM);
|
||||
|
||||
l->setImage("osgWidget/border-left.tga", true);
|
||||
r->setImage("osgWidget/border-right.tga", true);
|
||||
t->setImage("osgWidget/border-top.tga", true);
|
||||
b->setImage("osgWidget/border-bottom.tga", true);
|
||||
|
||||
l->setTexCoordWrapVertical();
|
||||
r->setTexCoordWrapVertical();
|
||||
t->setTexCoordWrapHorizontal();
|
||||
b->setTexCoordWrapHorizontal();
|
||||
|
||||
// Create the bottom, XArt panel.
|
||||
osgWidget::Widget* left = new osgWidget::Widget("left", 512.0f, 256.0f);
|
||||
osgWidget::Widget* center = new osgWidget::Widget("center", 256.0f, 256.0f);
|
||||
osgWidget::Widget* right = new osgWidget::Widget("right", 512.0f, 256.0f);
|
||||
|
||||
left->setImage ("osgWidget/panel-left.tga", true);
|
||||
center->setImage("osgWidget/panel-center.tga", true);
|
||||
right->setImage ("osgWidget/panel-right.tga", true);
|
||||
|
||||
center->setTexCoordWrapHorizontal();
|
||||
|
||||
bottom->addWidget(left);
|
||||
bottom->addWidget(center);
|
||||
bottom->addWidget(right);
|
||||
bottom->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
bottom->setOrigin(0.0f, 1024.0f - 256.0f);
|
||||
|
||||
// Add everything to the WindowManager.
|
||||
wm->addChild(frame);
|
||||
wm->addChild(bottom);
|
||||
|
||||
return osgWidget::createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetinput.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetinput)
|
||||
@@ -1,185 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetinput.cpp 50 2008-05-06 05:06:36Z cubicool $
|
||||
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Box>
|
||||
#include <osgWidget/Table>
|
||||
#include <osgWidget/Frame>
|
||||
#include <osgWidget/Label>
|
||||
#include <osgWidget/Input>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
const char* INFO =
|
||||
"Use the Input Wigets below to enter the X, Y, and Z position of a\n"
|
||||
"sphere to be inserted into the scene. Once you've done this, use\n"
|
||||
"the button below to add it!"
|
||||
;
|
||||
|
||||
void setupLabel(osgWidget::Label* label) {
|
||||
label->setFontSize(16);
|
||||
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
label->setFont("fonts/Vera.ttf");
|
||||
label->setPadding(2.0f);
|
||||
label->setHeight(18.0f);
|
||||
label->setCanFill(true);
|
||||
}
|
||||
|
||||
osgWidget::Input* createTableRow(
|
||||
osgWidget::Table* table,
|
||||
unsigned int rowNum,
|
||||
const std::string& valName
|
||||
) {
|
||||
std::stringstream ssLabel;
|
||||
std::stringstream ssInput;
|
||||
|
||||
ssLabel << "Label_Row" << rowNum;
|
||||
ssInput << "Input_Row" << rowNum;
|
||||
|
||||
osgWidget::Label* label = new osgWidget::Label(ssLabel.str(), valName);
|
||||
osgWidget::Input* input = new osgWidget::Input(ssInput.str(), "", 20);
|
||||
|
||||
setupLabel(label);
|
||||
setupLabel(input);
|
||||
|
||||
label->setWidth(50.0f);
|
||||
label->setColor(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
|
||||
input->setWidth(150.0f);
|
||||
input->setColor(0.4f, 0.4f, 0.4f, 1.0f);
|
||||
|
||||
table->addWidget(label, rowNum, 0);
|
||||
table->addWidget(input, rowNum, 1);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
osgWidget::Label* createLabel(const std::string& text) {
|
||||
osgWidget::Label* label = new osgWidget::Label("", text);
|
||||
|
||||
setupLabel(label);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
class Button: public osgWidget::Label {
|
||||
public:
|
||||
typedef std::vector<osgWidget::Input*> Inputs;
|
||||
|
||||
private:
|
||||
Inputs _xyz;
|
||||
|
||||
public:
|
||||
Button(const std::string& text, const Inputs& inputs):
|
||||
osgWidget::Label("", text),
|
||||
_xyz(inputs) {
|
||||
setupLabel(this);
|
||||
|
||||
setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK);
|
||||
setShadow(0.1f);
|
||||
addHeight(4.0f);
|
||||
}
|
||||
|
||||
bool mousePush(double, double, osgWidget::WindowManager*) {
|
||||
osgWidget::warn()
|
||||
<< "x: " << _xyz[0]->getLabel() << std::endl
|
||||
<< "y: " << _xyz[1]->getLabel() << std::endl
|
||||
<< "z: " << _xyz[2]->getLabel() << std::endl
|
||||
;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Testing our _parent/EmbeddedWindow stuff.
|
||||
bool info(osgWidget::Event& ev) {
|
||||
osgWidget::warn() << "MousePush @ Window: " << ev.getWindow()->getName() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||
);
|
||||
|
||||
osgWidget::Box* box = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
|
||||
osgWidget::Table* table = new osgWidget::Table("table", 3, 2);
|
||||
osgWidget::Box* lbox1 = new osgWidget::Box("lbox1", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Box* lbox2 = new osgWidget::Box("lbox2", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture(
|
||||
"frame",
|
||||
"osgWidget/theme.png",
|
||||
64.0f,
|
||||
64.0f,
|
||||
16.0f,
|
||||
16.0f,
|
||||
100.0f,
|
||||
100.0f
|
||||
);
|
||||
|
||||
osgWidget::Input* x = createTableRow(table, 0, "X Position");
|
||||
osgWidget::Input* y = createTableRow(table, 1, "Y Position");
|
||||
osgWidget::Input* z = createTableRow(table, 2, "Z Position");
|
||||
|
||||
Button::Inputs inputs;
|
||||
|
||||
inputs.push_back(x);
|
||||
inputs.push_back(y);
|
||||
inputs.push_back(z);
|
||||
|
||||
table->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
|
||||
|
||||
lbox1->addWidget(createLabel(INFO));
|
||||
lbox2->addWidget(new Button("Add To Scene...", inputs));
|
||||
|
||||
box->addWidget(lbox1->embed());
|
||||
box->addWidget(table->embed());
|
||||
box->addWidget(lbox2->embed());
|
||||
box->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
|
||||
|
||||
frame->setWindow(box);
|
||||
frame->getEmbeddedWindow()->setSize(box->getWidth(), box->getHeight());
|
||||
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
frame->attachTabFocusCallback();
|
||||
|
||||
for(osgWidget::Frame::Iterator i = frame->begin(); i != frame->end(); i++) {
|
||||
if(i->valid()) i->get()->setColor(0.5f, 0.7f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
wm->addChild(frame);
|
||||
|
||||
/*
|
||||
// Print out our focus list, it should just have 3 widgets.
|
||||
osgWidget::WidgetList wl;
|
||||
|
||||
box->getFocusList(wl);
|
||||
|
||||
for(osgWidget::WidgetList::iterator i = wl.begin(); i != wl.end(); i++) {
|
||||
osgWidget::warn() << i->get()->getName() << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
lbox1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
|
||||
lbox1->getBackground()->setColor(0.0f, 1.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT);
|
||||
lbox1->getBackground()->setColor(0.0f, 0.0f, 1.0f, 1.0f, osgWidget::Widget::LOWER_RIGHT);
|
||||
lbox1->getBackground()->setColor(1.0f, 1.0f, 1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
|
||||
lbox1->setVisibilityMode(osgWidget::Window::VM_ENTIRE);
|
||||
lbox1->update();
|
||||
|
||||
int r = osgWidget::createExample(viewer, wm);
|
||||
|
||||
// osgWidget::writeWindowManagerNode(wm);
|
||||
// osgDB::writeNodeFile(*box, "osgWidget.osg");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetlabel.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetlabel)
|
||||
@@ -1,120 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetlabel.cpp 66 2008-07-14 21:54:09Z cubicool $
|
||||
|
||||
#include <osg/io_utils>
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Box>
|
||||
#include <osgWidget/Label>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
const char* LABEL1 =
|
||||
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed\n"
|
||||
"do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"
|
||||
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n"
|
||||
"nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in..."
|
||||
;
|
||||
|
||||
const char* LABEL2 =
|
||||
"...reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n"
|
||||
"pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \n"
|
||||
"culpa qui officia deserunt mollit anim id est laborum. BBBBB"
|
||||
;
|
||||
|
||||
osgWidget::Label* createLabel(const std::string& l, unsigned int size=13) {
|
||||
osgWidget::Label* label = new osgWidget::Label("", "");
|
||||
|
||||
label->setFont("fonts/Vera.ttf");
|
||||
label->setFontSize(size);
|
||||
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
label->setLabel(l);
|
||||
|
||||
/*
|
||||
text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT);
|
||||
text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER);
|
||||
text->setBackdropOffset(0.2f);
|
||||
*/
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG |
|
||||
osgWidget::WindowManager::WM_NO_INVERT_Y
|
||||
);
|
||||
|
||||
osgWidget::Box* box = new osgWidget::Box("HBOX", osgWidget::Box::HORIZONTAL);
|
||||
osgWidget::Box* vbox = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
|
||||
osgWidget::Label* label1 = createLabel(LABEL1);
|
||||
osgWidget::Label* label2 = createLabel(LABEL2);
|
||||
|
||||
// Setup the labels for horizontal box.
|
||||
label1->setPadding(10.0f);
|
||||
label2->setPadding(10.0f);
|
||||
|
||||
label1->addSize(21.0f, 22.0f);
|
||||
label2->addSize(21.0f, 22.0f);
|
||||
|
||||
label1->setColor(1.0f, 0.5f, 0.0f, 0.0f);
|
||||
label2->setColor(1.0f, 0.5f, 0.0f, 0.0f);
|
||||
|
||||
box->addWidget(label1);
|
||||
box->addWidget(label2);
|
||||
box->attachMoveCallback();
|
||||
box->attachScaleCallback();
|
||||
box->attachRotateCallback();
|
||||
|
||||
// Setup the labels for the vertical box.
|
||||
osgWidget::Label* label3 = createLabel("Label 3", 80);
|
||||
osgWidget::Label* label4 = createLabel("Label 4", 60);
|
||||
osgWidget::Label* label5 = createLabel("ABCDEFGHIJK", 93);
|
||||
|
||||
label3->setPadding(3.0f);
|
||||
label4->setPadding(3.0f);
|
||||
label5->setPadding(3.0f);
|
||||
|
||||
label3->setColor(0.0f, 0.0f, 0.5f, 0.5f);
|
||||
label4->setColor(0.0f, 0.0f, 0.5f, 0.5f);
|
||||
label5->setColor(0.0f, 0.0f, 0.5f, 0.5f);
|
||||
|
||||
label5->setAlignHorizontal(osgWidget::Widget::HA_LEFT);
|
||||
label5->setAlignVertical(osgWidget::Widget::VA_BOTTOM);
|
||||
|
||||
// Test our label copy construction...
|
||||
osgWidget::Label* label6 = label5->cloneAs("label6");
|
||||
|
||||
label6->setLabel("abcdefghijklmnopqrs");
|
||||
|
||||
vbox->addWidget(label3);
|
||||
vbox->addWidget(label4);
|
||||
vbox->addWidget(label5);
|
||||
vbox->addWidget(label6);
|
||||
vbox->attachMoveCallback();
|
||||
vbox->attachScaleCallback();
|
||||
|
||||
vbox->resize();
|
||||
|
||||
// vbox->setVisibilityMode(osgWidget::Window::VM_ENTIRE);
|
||||
// vbox->setVisibleArea(50, 50, 500, 200);
|
||||
// vbox->setAnchorVertical(osgWidget::Window::VA_TOP);
|
||||
// vbox->setAnchorHorizontal(osgWidget::Window::HA_RIGHT);
|
||||
|
||||
// Test our label-in-window copy construction...
|
||||
osgWidget::Box* clonedBox = box->cloneAs("HBOX-new");
|
||||
|
||||
clonedBox->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.5f);
|
||||
|
||||
wm->addChild(box);
|
||||
wm->addChild(vbox);
|
||||
wm->addChild(clonedBox);
|
||||
|
||||
return osgWidget::createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetmenu.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetmenu)
|
||||
@@ -1,129 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetmenu.cpp 66 2008-07-14 21:54:09Z cubicool $
|
||||
|
||||
#include <iostream>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Box>
|
||||
#include <osgWidget/Label>
|
||||
|
||||
// For now this is just an example, but osgWidget::Menu will later be it's own Window.
|
||||
// I just wanted to get this out there so that people could see it was possible.
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
const unsigned int MASK_3D = 0x0F000000;
|
||||
|
||||
struct ColorLabel: public osgWidget::Label {
|
||||
ColorLabel(const char* label):
|
||||
osgWidget::Label("", "") {
|
||||
setFont("fonts/Vera.ttf");
|
||||
setFontSize(14);
|
||||
setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
setColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
addHeight(18.0f);
|
||||
setCanFill(true);
|
||||
setLabel(label);
|
||||
setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE);
|
||||
}
|
||||
|
||||
bool mousePush(double, double, osgWidget::WindowManager*) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseEnter(double, double, osgWidget::WindowManager*) {
|
||||
setColor(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseLeave(double, double, osgWidget::WindowManager*) {
|
||||
setColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class ColorLabelMenu: public ColorLabel {
|
||||
osg::ref_ptr<osgWidget::Window> _window;
|
||||
|
||||
public:
|
||||
ColorLabelMenu(const char* label):
|
||||
ColorLabel(label) {
|
||||
_window = new osgWidget::Box(
|
||||
std::string("Menu_") + label,
|
||||
osgWidget::Box::VERTICAL,
|
||||
true
|
||||
);
|
||||
|
||||
_window->addWidget(new ColorLabel("Open Some Stuff"));
|
||||
_window->addWidget(new ColorLabel("Do It Now"));
|
||||
_window->addWidget(new ColorLabel("Hello, How Are U?"));
|
||||
_window->addWidget(new ColorLabel("Hmmm..."));
|
||||
_window->addWidget(new ColorLabel("Option 5"));
|
||||
|
||||
_window->resize();
|
||||
|
||||
setColor(0.8f, 0.8f, 0.8f, 0.8f);
|
||||
}
|
||||
|
||||
void managed(osgWidget::WindowManager* wm) {
|
||||
osgWidget::Label::managed(wm);
|
||||
|
||||
wm->addChild(_window.get());
|
||||
|
||||
_window->hide();
|
||||
}
|
||||
|
||||
void positioned() {
|
||||
osgWidget::Label::positioned();
|
||||
|
||||
_window->setOrigin(getX(), getHeight());
|
||||
_window->resize(getWidth());
|
||||
}
|
||||
|
||||
bool mousePush(double, double, osgWidget::WindowManager*) {
|
||||
if(!_window->isVisible()) _window->show();
|
||||
|
||||
else _window->hide();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mouseLeave(double, double, osgWidget::WindowManager*) {
|
||||
if(!_window->isVisible()) setColor(0.8f, 0.8f, 0.8f, 0.8f);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG |
|
||||
osgWidget::WindowManager::WM_NO_BETA_WARN
|
||||
);
|
||||
|
||||
osgWidget::Window* menu = new osgWidget::Box("menu", osgWidget::Box::HORIZONTAL);
|
||||
|
||||
menu->addWidget(new ColorLabelMenu("Pick me!"));
|
||||
menu->addWidget(new ColorLabelMenu("No, wait, pick me!"));
|
||||
menu->addWidget(new ColorLabelMenu("Dont pick them..."));
|
||||
menu->addWidget(new ColorLabelMenu("Grarar!?!"));
|
||||
|
||||
wm->addChild(menu);
|
||||
|
||||
menu->getBackground()->setColor(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
menu->resizePercent(100.0f);
|
||||
|
||||
osg::Node* model = osgDB::readNodeFile("osgcool.osg");
|
||||
|
||||
model->setNodeMask(MASK_3D);
|
||||
|
||||
return osgWidget::createExample(viewer, wm, model);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetnotebook.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetnotebook)
|
||||
@@ -1,134 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetnotebook.cpp 45 2008-04-23 16:46:11Z cubicool $
|
||||
|
||||
#include <osg/io_utils>
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Box>
|
||||
#include <osgWidget/Canvas>
|
||||
#include <osgWidget/Label>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
const unsigned int MASK_3D = 0x0F000000;
|
||||
|
||||
class Notebook: public osgWidget::Box {
|
||||
osg::ref_ptr<osgWidget::Box> _tabs;
|
||||
osg::ref_ptr<osgWidget::Canvas> _windows;
|
||||
|
||||
public:
|
||||
// NOTE: This whole thing is just a hack to demonstrate a concept. The real
|
||||
// implementation would need to be much cleaner.
|
||||
bool callbackTabPressed(osgWidget::Event& ev) {
|
||||
osgWidget::Canvas::Vector& objs = _windows->getObjects();
|
||||
|
||||
for(unsigned int i = 0; i < objs.size(); i++) objs[i]->setLayer(
|
||||
osgWidget::Widget::LAYER_MIDDLE,
|
||||
i
|
||||
);
|
||||
|
||||
_windows->getByName(ev.getWidget()->getName())->setLayer(
|
||||
osgWidget::Widget::LAYER_MIDDLE,
|
||||
objs.size()
|
||||
);
|
||||
|
||||
_windows->resize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Notebook(const std::string& name):
|
||||
osgWidget::Box(name, osgWidget::Box::VERTICAL) {
|
||||
_tabs = new osgWidget::Box("tabs", osgWidget::Box::HORIZONTAL);
|
||||
_windows = new osgWidget::Canvas("canvas");
|
||||
|
||||
for(unsigned int i = 0; i < 4; i++) {
|
||||
std::stringstream ss;
|
||||
|
||||
// Setup everything for our Tab...
|
||||
ss << "Tab_" << i;
|
||||
|
||||
osgWidget::Label* label1 = new osgWidget::Label(ss.str());
|
||||
|
||||
label1->setFont("fonts/VeraMono.ttf");
|
||||
label1->setFontSize(20);
|
||||
label1->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
label1->setColor(0.0f, i / 4.0f, 0.3f, 1.0f);
|
||||
label1->setLabel(ss.str());
|
||||
label1->addSize(20.0f, 20.0f);
|
||||
label1->setShadow(0.1f);
|
||||
label1->setCanFill(true);
|
||||
|
||||
_tabs->addWidget(label1);
|
||||
|
||||
// Setup everything for the Window corresponding to the Tab
|
||||
// in the Canvas down below.
|
||||
std::stringstream descr;
|
||||
|
||||
descr
|
||||
<< "This is some text" << std::endl
|
||||
<< "for the Tab_" << i << " tab." << std::endl
|
||||
<< "Press the button up top" << std::endl
|
||||
<< "And this should go to the next Window!" << std::endl
|
||||
;
|
||||
|
||||
osgWidget::Label* label2 = new osgWidget::Label(ss.str());
|
||||
|
||||
label2->setFont("fonts/Vera.ttf");
|
||||
label2->setFontSize(15);
|
||||
label2->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
label2->setColor(0.0f, i / 4.0f, 0.3f, 1.0f);
|
||||
label2->setLabel(descr.str());
|
||||
label2->setLayer(osgWidget::Widget::LAYER_MIDDLE, i);
|
||||
label2->addSize(50.0f, 50.0f);
|
||||
|
||||
_windows->addWidget(label2, 0.0f, 0.0f);
|
||||
|
||||
label1->setEventMask(osgWidget::EVENT_MOUSE_PUSH);
|
||||
label1->addCallback(osgWidget::Callback(
|
||||
&Notebook::callbackTabPressed,
|
||||
this,
|
||||
osgWidget::EVENT_MOUSE_PUSH
|
||||
));
|
||||
}
|
||||
|
||||
osgWidget::Label* label = new osgWidget::Label("label");
|
||||
|
||||
label->setFont("fonts/arial.ttf");
|
||||
label->setFontSize(15);
|
||||
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
label->setLabel("Drag the window here...");
|
||||
label->addSize(20.0f, 20.0f);
|
||||
label->setShadow(0.08f);
|
||||
label->setCanFill(true);
|
||||
|
||||
addWidget(label);
|
||||
addWidget(_tabs->embed());
|
||||
addWidget(_windows->embed());
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
720.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||
);
|
||||
|
||||
Notebook* notebook = new Notebook("notebook");
|
||||
|
||||
osgWidget::warn()
|
||||
<< "Sizes are..." << std::endl
|
||||
<< "Cur: " << notebook->getSize() << std::endl
|
||||
<< "Min: " << notebook->getMinSize() << std::endl
|
||||
;
|
||||
|
||||
notebook->attachMoveCallback();
|
||||
|
||||
wm->addChild(notebook);
|
||||
|
||||
return osgWidget::createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetscrolled.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetscrolled)
|
||||
@@ -1,134 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetframe.cpp 34 2008-04-07 03:12:41Z cubicool $
|
||||
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Frame>
|
||||
#include <osgWidget/Box>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
// NOTE: THIS IS JUST A TEMPORARY HACK! :) This functionality will all eventually be
|
||||
// encapsulate into another class in osgWidget proper.
|
||||
bool scrollWindow(osgWidget::Event& ev) {
|
||||
// The first thing we need to do is make sure we have a Frame object...
|
||||
osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());
|
||||
|
||||
if(!frame) return false;
|
||||
|
||||
// And now we need to make sure our Frame has a valid internal EmbeddedWindow widget.
|
||||
osgWidget::Window::EmbeddedWindow* ew =
|
||||
dynamic_cast<osgWidget::Window::EmbeddedWindow*>(frame->getEmbeddedWindow())
|
||||
;
|
||||
|
||||
if(!ew) return false;
|
||||
|
||||
// Lets get the visible area so that we can use it to make sure our scrolling action
|
||||
// is necessary in the first place.
|
||||
const osgWidget::Quad& va = ew->getWindow()->getVisibleArea();
|
||||
|
||||
// The user wants to scroll up; make sure that the visible area's Y origin isn't already
|
||||
// at 0.0f, 0.0f.
|
||||
if(ev.getWindowManager()->isMouseScrollingUp() && va[1] != 0.0f)
|
||||
ew->getWindow()->addVisibleArea(0, -20)
|
||||
;
|
||||
|
||||
else if(va[1] <= (ew->getWindow()->getHeight() - ew->getHeight()))
|
||||
ew->getWindow()->addVisibleArea(0, 20)
|
||||
;
|
||||
|
||||
// We need to manually call update to make sure the visible area scissoring is done
|
||||
// properly.
|
||||
frame->update();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool changeTheme(osgWidget::Event& ev) {
|
||||
std::string theme;
|
||||
|
||||
if(ev.key == osgGA::GUIEventAdapter::KEY_Right)
|
||||
theme = "osgWidget/theme-1.png"
|
||||
;
|
||||
|
||||
else if(ev.key == osgGA::GUIEventAdapter::KEY_Left)
|
||||
theme = "osgWidget/theme-2.png"
|
||||
;
|
||||
|
||||
else return false;
|
||||
|
||||
osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());
|
||||
|
||||
if(!frame) return false;
|
||||
|
||||
// This is just one way to access all our Widgets; we could just as well have used:
|
||||
//
|
||||
// for(osgWidget::Frame::Iterator i = frame.begin(); i != frame.end() i++) {}
|
||||
//
|
||||
// ...and it have worked, too.
|
||||
for(unsigned int row = 0; row < 3; row++) {
|
||||
for(unsigned int col = 0; col < 3; col++) {
|
||||
frame->getByRowCol(row, col)->setImage(theme);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||
);
|
||||
|
||||
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture(
|
||||
"frame",
|
||||
"osgWidget/theme-2.png",
|
||||
64.0f,
|
||||
64.0f,
|
||||
16.0f,
|
||||
16.0f,
|
||||
100.0f,
|
||||
100.0f
|
||||
);
|
||||
|
||||
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// This is our Transformers box. :)
|
||||
osgWidget::Box* box = new osgWidget::Box("images", osgWidget::Box::VERTICAL);
|
||||
osgWidget::Widget* img1 = new osgWidget::Widget("im1", 512.0f, 512.0f);
|
||||
osgWidget::Widget* img2 = new osgWidget::Widget("im2", 512.0f, 512.0f);
|
||||
osgWidget::Widget* img3 = new osgWidget::Widget("im3", 512.0f, 512.0f);
|
||||
osgWidget::Widget* img4 = new osgWidget::Widget("im4", 512.0f, 512.0f);
|
||||
|
||||
img1->setImage("osgWidget/scrolled1.jpg", true);
|
||||
img2->setImage("osgWidget/scrolled2.jpg", true);
|
||||
img3->setImage("osgWidget/scrolled3.jpg", true);
|
||||
img4->setImage("osgWidget/scrolled4.jpg", true);
|
||||
|
||||
img1->setMinimumSize(10.0f, 10.0f);
|
||||
img2->setMinimumSize(10.0f, 10.0f);
|
||||
img3->setMinimumSize(10.0f, 10.0f);
|
||||
img4->setMinimumSize(10.0f, 10.0f);
|
||||
|
||||
box->addWidget(img1);
|
||||
box->addWidget(img2);
|
||||
box->addWidget(img3);
|
||||
box->addWidget(img4);
|
||||
box->setEventMask(osgWidget::EVENT_NONE);
|
||||
|
||||
frame->getEmbeddedWindow()->setWindow(box);
|
||||
frame->getEmbeddedWindow()->setColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
frame->resize(300.0f, 300.0f);
|
||||
frame->addCallback(osgWidget::Callback(&scrollWindow, osgWidget::EVENT_MOUSE_SCROLL));
|
||||
frame->addCallback(osgWidget::Callback(&changeTheme, osgWidget::EVENT_KEY_DOWN));
|
||||
|
||||
wm->addChild(frame);
|
||||
|
||||
return osgWidget::createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetshader.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetshader)
|
||||
@@ -1,75 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetshader.cpp 28 2008-03-26 15:26:48Z cubicool $
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Canvas>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
osgWidget::Widget* createWidget(
|
||||
const std::string& name,
|
||||
osgWidget::color_type col,
|
||||
osgWidget::Widget::Layer layer
|
||||
) {
|
||||
osgWidget::Widget* widget = new osgWidget::Widget(name, 200.0f, 200.0f);
|
||||
|
||||
widget->setColor(col, col, col, 0.2f);
|
||||
widget->setLayer(layer);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D
|
||||
);
|
||||
|
||||
osgWidget::Canvas* canvas = new osgWidget::Canvas("canvas");
|
||||
|
||||
canvas->attachMoveCallback();
|
||||
canvas->attachScaleCallback();
|
||||
|
||||
canvas->addWidget(
|
||||
createWidget("w1", 0.2f, osgWidget::Widget::LAYER_LOW),
|
||||
0.0f,
|
||||
0.0f
|
||||
);
|
||||
|
||||
canvas->addWidget(
|
||||
createWidget("w2", 0.4f, osgWidget::Widget::LAYER_MIDDLE),
|
||||
200.0f,
|
||||
0.0f
|
||||
);
|
||||
|
||||
canvas->addWidget(
|
||||
createWidget("w3", 0.6f, osgWidget::Widget::LAYER_HIGH),
|
||||
400.0f,
|
||||
0.0f
|
||||
);
|
||||
|
||||
|
||||
wm->addChild(canvas);
|
||||
|
||||
osg::Program* program = new osg::Program();
|
||||
|
||||
program->addShader(osg::Shader::readShaderFile(
|
||||
osg::Shader::VERTEX,
|
||||
osgDB::findDataFile("osgWidget/osgwidgetshader-vert.glsl")
|
||||
));
|
||||
|
||||
program->addShader(osg::Shader::readShaderFile(
|
||||
osg::Shader::FRAGMENT,
|
||||
osgDB::findDataFile("osgWidget/osgwidgetshader-frag.glsl")
|
||||
));
|
||||
|
||||
canvas->getGeode()->getOrCreateStateSet()->setAttribute(program);
|
||||
|
||||
return osgWidget::createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetstyled.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetstyled)
|
||||
@@ -1,83 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetshader.cpp 28 2008-03-26 15:26:48Z cubicool $
|
||||
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/StyleManager>
|
||||
#include <osgWidget/Box>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
const std::string& STYLE1 =
|
||||
"color 0 0 0 128\n"
|
||||
"padding 5\n"
|
||||
;
|
||||
|
||||
const std::string& STYLE2 =
|
||||
"color 1.0 0.5 0.0\n"
|
||||
;
|
||||
|
||||
const std::string& STYLE3 =
|
||||
"fill true\n"
|
||||
;
|
||||
|
||||
const std::string& STYLE4 =
|
||||
"pos 100.0 100.0\n"
|
||||
"size 600 600\n"
|
||||
;
|
||||
|
||||
class CustomStyled: public osgWidget::Widget {
|
||||
};
|
||||
|
||||
class CustomStyle: public osgWidget::Style {
|
||||
virtual bool applyStyle(osgWidget::Widget* w, osgWidget::Reader r) {
|
||||
CustomStyled* cs = dynamic_cast<CustomStyled*>(w);
|
||||
|
||||
if(!cs) return false;
|
||||
|
||||
osgWidget::warn() << "Here, okay." << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D
|
||||
);
|
||||
|
||||
osgWidget::Box* box = new osgWidget::Box("box", osgWidget::Box::VERTICAL);
|
||||
|
||||
osgWidget::Widget* widget1 = new osgWidget::Widget("w1", 200.0f, 200.0f);
|
||||
osgWidget::Widget* widget2 = new osgWidget::Widget("w2", 100.0f, 100.0f);
|
||||
osgWidget::Widget* widget3 = new osgWidget::Widget("w3", 0.0f, 0.0f);
|
||||
CustomStyled* cs = new CustomStyled();
|
||||
|
||||
// Yep.
|
||||
wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style1", STYLE1));
|
||||
wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style2", STYLE2));
|
||||
wm->getStyleManager()->addStyle(new osgWidget::Style("spacer", STYLE3));
|
||||
wm->getStyleManager()->addStyle(new osgWidget::Style("window", STYLE4));
|
||||
// wm->getStyleManager()->addStyle(new CustomStyle("widget", ""));
|
||||
|
||||
widget1->setStyle("widget.style1");
|
||||
widget2->setStyle("widget.style2");
|
||||
widget3->setStyle("spacer");
|
||||
|
||||
box->setStyle("window");
|
||||
|
||||
box->addWidget(widget1);
|
||||
box->addWidget(widget2);
|
||||
box->addWidget(widget3);
|
||||
|
||||
wm->addChild(box);
|
||||
|
||||
// box->resizePercent(0.0f, 100.0f);
|
||||
|
||||
return osgWidget::createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgettable.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgettable)
|
||||
@@ -1,69 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgettable.cpp 43 2008-04-17 03:40:05Z cubicool $
|
||||
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Table>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
|
||||
// This examples demonstrates the use of an osgWidget::Table, which differs from a Box in
|
||||
// many ways. First and foremost, a Table's size is intially known, whereas a Box can be
|
||||
// dynamically added to. Secondly, a table is matrix Layout, with both vertical and
|
||||
// horizontal placement cells. A Box, on the other hand, can only be vertical or horizontal.
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||
);
|
||||
|
||||
osgWidget::Table* table = new osgWidget::Table("table", 3, 3);
|
||||
|
||||
// Here we create our "cells" manually, though it will often be convenient to
|
||||
// do so algorithmically. Also, notice how we set the text name of each widget to
|
||||
// correspond with it's "index" in the table. This is merely a convenience, which
|
||||
// we use later...
|
||||
table->addWidget(new osgWidget::Widget("0, 0", 100.0f, 25.0f), 0, 0);
|
||||
table->addWidget(new osgWidget::Widget("0, 1", 100.0f, 25.0f), 0, 1);
|
||||
table->addWidget(new osgWidget::Widget("0, 2", 100.0f, 75.0f), 0, 2);
|
||||
|
||||
table->addWidget(new osgWidget::Widget("1, 0", 200.0f, 45.0f), 1, 0);
|
||||
table->addWidget(new osgWidget::Widget("1, 1", 200.0f, 45.0f), 1, 1);
|
||||
table->addWidget(new osgWidget::Widget("1, 2", 200.0f, 45.0f), 1, 2);
|
||||
|
||||
table->addWidget(new osgWidget::Widget("2, 0", 300.0f, 65.0f), 2, 0);
|
||||
table->addWidget(new osgWidget::Widget("2, 1", 300.0f, 65.0f), 2, 1);
|
||||
table->addWidget(new osgWidget::Widget("2, 2", 300.0f, 65.0f), 2, 2);
|
||||
|
||||
table->getBackground()->setColor(0.0f, 0.0f, 0.5f, 1.0f);
|
||||
table->attachMoveCallback();
|
||||
|
||||
// Use a hackish method of setting the spacing for all Widgets.
|
||||
for(osgWidget::Table::Iterator i = table->begin(); i != table->end(); i++)
|
||||
i->get()->setPadding(1.0f)
|
||||
;
|
||||
|
||||
// Now we fetch the very first 0, 0 Widget in the table using an awkward method.
|
||||
// This is merely one way to fetch a Widget from a Window, there are many others.
|
||||
// The osgWidget::Window::getByName interface will be very handy in scripting languages
|
||||
// where users will want to retrieve handles to existing Windows using a useful
|
||||
// textual name, such as "MainGUIParent" or something.
|
||||
table->getByName("0, 0")->setAlignHorizontal(osgWidget::Widget::HA_LEFT);
|
||||
table->getByName("0, 0")->setAlignVertical(osgWidget::Widget::VA_BOTTOM);
|
||||
table->getByName("0, 0")->setPadding(10.0f);
|
||||
|
||||
// Change the colors a bit to differentiate this row from the others.
|
||||
table->getByName("2, 0")->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT);
|
||||
table->getByName("2, 1")->setColor(1.0f, 0.0f, 0.0f, 0.5f);
|
||||
table->getByName("2, 2")->setColor(1.0f, 0.0f, 0.0f, 0.5f);
|
||||
|
||||
wm->addChild(table);
|
||||
|
||||
return createExample(viewer, wm);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#this file is automatically generated
|
||||
|
||||
|
||||
SET(TARGET_SRC osgwidgetwindow.cpp )
|
||||
SET(TARGET_ADDED_LIBRARIES osgWidget )
|
||||
#### end var setup ###
|
||||
SETUP_EXAMPLE(osgwidgetwindow)
|
||||
@@ -1,204 +0,0 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetwindow.cpp 66 2008-07-14 21:54:09Z cubicool $
|
||||
|
||||
#include <iostream>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/ViewerEventHandlers>
|
||||
#include <osgWidget/Box>
|
||||
|
||||
const unsigned int MASK_2D = 0xF0000000;
|
||||
const unsigned int MASK_3D = 0x0F000000;
|
||||
|
||||
// Here we create (and later demonstrate) the use of a simple function callback.
|
||||
bool windowClicked(osgWidget::Event& ev) {
|
||||
std::cout << "windowClicked: " << ev.getWindow()->getName() << std::endl;
|
||||
|
||||
if(ev.getData()) {
|
||||
std::string* s = static_cast<std::string*>(ev.getData());
|
||||
|
||||
std::cout << "This is data attached to the event: " << *s << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool windowScrolled(osgWidget::Event& ev) {
|
||||
osgWidget::warn()
|
||||
<< "scrolling up? " << ev.getWindowManager()->isMouseScrollingUp()
|
||||
<< std::endl
|
||||
;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Here we dcreate a new class and show how to use a method callback (which differs from
|
||||
// a function callback in that we are required to also pass the "this" argument).
|
||||
struct Object {
|
||||
bool windowClicked(osgWidget::Event& ev) {
|
||||
std::cout << "Object::windowClicked " << ev.getWindow()->getName() << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
// Let's get busy! The WindowManager class is actually an osg::Switch,
|
||||
// so you can add it to (ideally) an orthographic camera and have it behave as
|
||||
// expected. Note that you create a WindowManager with a NodeMask--it is very important
|
||||
// that this be unique for picking to work properly. This also makes it possible to have
|
||||
// multiple WindowManagers each operating on their own, unique set of Window objects.
|
||||
// The final bool argument is a group of flags that introduce optional functionality
|
||||
// for the WindowManager. In our case we include the flags USE_PYTHON and USE_LUA,
|
||||
// to demonstrate (and test) their usage. Finally, we pass the temporary WM_NO_BETA_WARN
|
||||
// argument, which prevents creating the orange warning window. :) It will be shown
|
||||
// in other examples...
|
||||
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||
&viewer,
|
||||
1280.0f,
|
||||
1024.0f,
|
||||
MASK_2D,
|
||||
osgWidget::WindowManager::WM_USE_LUA |
|
||||
osgWidget::WindowManager::WM_USE_PYTHON |
|
||||
osgWidget::WindowManager::WM_PICK_DEBUG |
|
||||
osgWidget::WindowManager::WM_NO_BETA_WARN
|
||||
);
|
||||
|
||||
// An actual osgWidget::Window is pure virtual, so we've got to use the osgWidget::Box
|
||||
// implementation for now. At a later time, support for Tables and other kinds of
|
||||
// advanced layout Window types will be added.
|
||||
osgWidget::Window* box = new osgWidget::Box("box", osgWidget::Box::HORIZONTAL);
|
||||
|
||||
// Now we actually attach our two types of callbacks to the box instance. The first
|
||||
// uses the simple function signature, the second uses a bound method, passing "this"
|
||||
// as the second argument to the Callback constructor.
|
||||
Object obj;
|
||||
|
||||
static std::string data = "lol ur face!";
|
||||
|
||||
box->addCallback(osgWidget::Callback(&windowClicked, osgWidget::EVENT_MOUSE_PUSH, &data));
|
||||
box->addCallback(osgWidget::Callback(&windowScrolled, osgWidget::EVENT_MOUSE_SCROLL));
|
||||
box->addCallback(osgWidget::Callback(
|
||||
&Object::windowClicked,
|
||||
&obj,
|
||||
osgWidget::EVENT_MOUSE_PUSH
|
||||
));
|
||||
|
||||
// Create some of our "testing" Widgets; included are two Widget subclasses I made
|
||||
// during testing which I've kept around for testing purposes. You'll notice
|
||||
// that you cannot move the box using the NullWidget, and that the NotifyWidget
|
||||
// is a bit verbose. :)
|
||||
osgWidget::Widget* widget1 = new osgWidget::NotifyWidget("widget1", 300.0f, 100.0f);
|
||||
osgWidget::Widget* widget2 = new osgWidget::NullWidget("widget2", 400.0f, 75.0f);
|
||||
osgWidget::Widget* widget3 = new osgWidget::Widget("widget3", 100.0f, 100.0f);
|
||||
// Set the colors of widget1 and widget3 to green.
|
||||
widget1->setColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
widget1->setCanFill(true);
|
||||
widget3->setColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
widget1->setImage(osgDB::readImageFile("Images/Saturn.TGA"), true);
|
||||
|
||||
// Set the color of widget2, to differentiate it and make it sassy. This is
|
||||
// like a poor man's gradient!
|
||||
widget2->setColor(0.9f, 0.0f, 0.0f, 0.9f, osgWidget::Widget::LOWER_LEFT);
|
||||
widget2->setColor(0.9f, 0.0f, 0.0f, 0.9f, osgWidget::Widget::LOWER_RIGHT);
|
||||
widget2->setColor(0.0f, 0.0f, 0.9f, 0.9f, osgWidget::Widget::UPPER_RIGHT);
|
||||
widget2->setColor(0.0f, 0.0f, 0.9f, 0.9f, osgWidget::Widget::UPPER_LEFT);
|
||||
|
||||
// Now add our newly created widgets to our box.
|
||||
box->addWidget(widget1);
|
||||
box->addWidget(widget2);
|
||||
box->addWidget(widget3);
|
||||
|
||||
// For maximum efficiency, Windows don't automatically reallocate their geometry
|
||||
// and internal positioning every time a widget is added. Thus, we either have to
|
||||
// call the WindowManger::resizeAllWindows method or manually call
|
||||
// Window::resize when we're ready.
|
||||
box->resize();
|
||||
|
||||
// Now, lets clone our existing box and create a new copy of of it, also adding that
|
||||
// to the WindowManager. This demonstrates the usages of OSG's ->clone() support,
|
||||
// though that is abstracted by our META_UIObject macro.
|
||||
osgWidget::Window* boxCopy = box->cloneAs("newBox");
|
||||
|
||||
// Move our copy to make it visible.
|
||||
boxCopy->setOrigin(0.0f, 125.0f);
|
||||
|
||||
boxCopy->getByName("widget1")->setColor(0.5f, 0.0f, 1.0f, 1.0f);
|
||||
boxCopy->getByName("widget3")->setColor(0.5f, 0.0f, 1.0f, 1.0f);
|
||||
|
||||
// Add the successfully created Box (if we get this far) into the WindowManager, so
|
||||
// that they can receive events.
|
||||
wm->addChild(box);
|
||||
wm->addChild(boxCopy);
|
||||
|
||||
// Now, ask our new box to be 100% the width of the WindowManager.
|
||||
boxCopy->resizePercent(100.0f, 0.0f);
|
||||
|
||||
// Here we demonstrate the use of osgWidget/io_utils. This is really only useful for
|
||||
// debugging at the moment, but later I'll make it more generic for .osg and .ive
|
||||
// creation.
|
||||
// std::cout << *box << std::endl << *boxCopy << std::endl;
|
||||
|
||||
// Add our event handler; is this better as a MatrixManipulator? Add a few other
|
||||
// helpful ViewerEventHandlers.
|
||||
viewer.addEventHandler(new osgWidget::MouseHandler(wm));
|
||||
viewer.addEventHandler(new osgWidget::KeyboardHandler(wm));
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler());
|
||||
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
|
||||
viewer.addEventHandler(new osgGA::StateSetManipulator(
|
||||
viewer.getCamera()->getOrCreateStateSet()
|
||||
));
|
||||
|
||||
// Setup our OSG objects for our scene; note the use of the utility function
|
||||
// createOrthoCamera, which is just a helper for setting up a proper viewing area.
|
||||
// An alternative (and a MUCH easier alternative at that!) is to
|
||||
// simply use the createParentOrthoCamera method of the WindowManager class,
|
||||
// which will wrap the calls to createOrthoCamera and addChild for us! Check out
|
||||
// some of the other examples to see this in action...
|
||||
osg::Group* group = new osg::Group();
|
||||
osg::Camera* camera = osgWidget::createInvertedYOrthoCamera(1280.0f, 1024.0f);
|
||||
osg::Node* model = osgDB::readNodeFile("cow.osg");
|
||||
|
||||
// Set our first non-UI node to be something other than the mask we created our
|
||||
// WindowManager with to avoid picking.
|
||||
// TODO: Do I need to create a mechanism for doing this automatically, or should
|
||||
// that be the responsibility of the users of osgWidget?
|
||||
model->setNodeMask(MASK_3D);
|
||||
|
||||
// Add the WindowManager instance to the 2D camera. This isn't strictly necessary,
|
||||
// and you can get some cool results putting the WindowManager directly into a
|
||||
// 3D scene. This is not necessary if you use WindowManager::createParentOrthoCamera.
|
||||
camera->addChild(wm);
|
||||
|
||||
// Add our camera and a testing 3D model to the scene.
|
||||
group->addChild(camera);
|
||||
group->addChild(model);
|
||||
|
||||
// Here we show how to both run simple strings of code AND run entire files. These
|
||||
// assume that you're running the osgwidgetwindow example from the build directory,
|
||||
// otherwise you'll need to adjust the file path below in the call to runFile().
|
||||
wm->getLuaEngine()->eval("window = osgwidget.newWindow()");
|
||||
wm->getLuaEngine()->runFile("osgWidget/osgwidgetwindow.lua");
|
||||
|
||||
wm->getPythonEngine()->eval("import osgwidget");
|
||||
wm->getPythonEngine()->runFile("osgWidget/osgwidgetwindow.py");
|
||||
|
||||
viewer.setUpViewInWindow(0, 0, 1280, 1024);
|
||||
viewer.setSceneData(group);
|
||||
|
||||
/*
|
||||
osgViewer::Viewer::Cameras cameras;
|
||||
viewer.getCameras(cameras);
|
||||
osg::Camera* c = cameras[0];
|
||||
osg::Matrix s = osg::Matrix::scale(1.0f, -1.0f, 1.0f);
|
||||
c->setProjectionMatrix(s * c->getProjectionMatrix());
|
||||
*/
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
144
genwrapper.conf
144
genwrapper.conf
@@ -90,6 +90,22 @@ end
|
||||
# Doxygen fails to detect that std::vector<T> is a base class for
|
||||
# osg::Vector*, so we need to specify that manually
|
||||
|
||||
configure reflector "osg::VectorGLsizei"
|
||||
add base "std::vector<GLsizei>"
|
||||
end
|
||||
|
||||
configure reflector "osg::VectorGLubyte"
|
||||
add base "std::vector<GLubyte>"
|
||||
end
|
||||
|
||||
configure reflector "osg::VectorGLushort"
|
||||
add base "std::vector<GLushort>"
|
||||
end
|
||||
|
||||
configure reflector "osg::VectorGLuint"
|
||||
add base "std::vector<GLuint>"
|
||||
end
|
||||
|
||||
configure reflector "osgText::VectorUInt"
|
||||
add base "std::vector<unsigned int>"
|
||||
end
|
||||
@@ -97,49 +113,99 @@ end
|
||||
|
||||
#############################################################################
|
||||
|
||||
# Doxygen/genwrapper is not coping with the new MixinVector so disable associated wrappers
|
||||
# Doxygen fails to detect that std::vector<T> is a base class for
|
||||
# TemplateArray<> and TemplateIndexArray<> templates, so we need
|
||||
# to specify that manually
|
||||
|
||||
suppress reflector /osg::TemplateIndexArray< GLbyte.*/
|
||||
suppress reflector /osg::TemplateIndexArray< GLubyte.*/
|
||||
suppress reflector /osg::TemplateIndexArray< GLshort.*/
|
||||
suppress reflector /osg::TemplateIndexArray< GLushort.*/
|
||||
suppress reflector /osg::TemplateIndexArray< GLint.*/
|
||||
suppress reflector /osg::TemplateIndexArray< GLuint.*/
|
||||
suppress reflector /osg::TemplateArray< GLfloat.*/
|
||||
suppress reflector /osg::TemplateArray< GLdouble.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec2\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec3\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec4\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec2d\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec3d\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec4d\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec2b\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec3b\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec4b\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec2s\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec3s\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec4s\s*\,.*/
|
||||
suppress reflector /osg::TemplateArray< osg::Vec4ub\s*\,.*/
|
||||
configure reflector /osg::TemplateIndexArray< GLbyte.*/
|
||||
add base "std::vector<GLbyte>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateIndexArray< GLubyte.*/
|
||||
add base "std::vector<GLubyte>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateIndexArray< GLshort.*/
|
||||
add base "std::vector<GLshort>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateIndexArray< GLushort.*/
|
||||
add base "std::vector<GLushort>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateIndexArray< GLint.*/
|
||||
add base "std::vector<GLint>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateIndexArray< GLuint.*/
|
||||
add base "std::vector<GLuint>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateArray< GLfloat.*/
|
||||
add base "std::vector<GLfloat>"
|
||||
end
|
||||
|
||||
|
||||
suppress reflector "osg::DrawArrayLengths"
|
||||
suppress reflector "osg::DrawElementsUByte"
|
||||
suppress reflector "osg::DrawElementsUShort"
|
||||
suppress reflector "osg::DrawElementsUInt"
|
||||
configure reflector /osg::TemplateArray< osg::Vec2\s*\,.*/
|
||||
add base "std::vector<osg::Vec2>"
|
||||
end
|
||||
|
||||
suppress reflector "osg::VectorGLsizei"
|
||||
suppress reflector "osg::VectorGLubyte"
|
||||
suppress reflector "osg::VectorGLushort"
|
||||
suppress reflector "osg::VectorGLuint"
|
||||
configure reflector /osg::TemplateArray< osg::Vec3\s*\,.*/
|
||||
add base "std::vector<osg::Vec3>"
|
||||
end
|
||||
|
||||
suppress reflector "osg::MixinVector< GLsizei >"
|
||||
suppress reflector "osg::MixinVector< GLubyte >"
|
||||
suppress reflector "osg::MixinVector< GLushort >"
|
||||
suppress reflector "osg::MixinVector< GLuint >"
|
||||
configure reflector /osg::TemplateArray< osg::Vec4\s*\,.*/
|
||||
add base "std::vector<osg::Vec4>"
|
||||
end
|
||||
|
||||
suppress reflector "OpenThreads::Atomic"
|
||||
suppress reflector "OpenThreads::AtomicPtr"
|
||||
configure reflector /osg::TemplateArray< osg::Vec2b\s*\,.*/
|
||||
add base "std::vector<osg::Vec2b>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateArray< osg::Vec3b\s*\,.*/
|
||||
add base "std::vector<osg::Vec3b>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateArray< osg::Vec4b\s*\,.*/
|
||||
add base "std::vector<osg::Vec4b>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateArray< osg::Vec2s\s*\,.*/
|
||||
add base "std::vector<osg::Vec2s>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateArray< osg::Vec3s\s*\,.*/
|
||||
add base "std::vector<osg::Vec3s>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateArray< osg::Vec4s\s*\,.*/
|
||||
add base "std::vector<osg::Vec4s>"
|
||||
end
|
||||
|
||||
configure reflector /osg::TemplateArray< osg::Vec4ub\s*\,.*/
|
||||
add base "std::vector<osg::Vec4ub>"
|
||||
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>)
|
||||
"
|
||||
end
|
||||
|
||||
#############################################################################
|
||||
|
||||
@@ -398,12 +464,6 @@ end
|
||||
# avoid functions that use protected types, since those are not handled
|
||||
# currently
|
||||
|
||||
configure reflector "osgSim::OverlayNode"
|
||||
configure method /.*getOverlayData.*/
|
||||
replace with ""
|
||||
end
|
||||
end
|
||||
|
||||
configure reflector "osg::Shader"
|
||||
configure method /.*_PerContextShader_.*/
|
||||
replace with ""
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
/* -*-c++-*- OpenThreads library, Copyright (C) 2008 The Open Thread Group
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _OPENTHREADS_ATOMIC_
|
||||
#define _OPENTHREADS_ATOMIC_
|
||||
|
||||
#include <OpenThreads/Config>
|
||||
#include <OpenThreads/Exports>
|
||||
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS) && defined(__i386__)
|
||||
#define _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
|
||||
#define _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
|
||||
# include <atomic.h>
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
# include "Mutex"
|
||||
# include "ScopedLock"
|
||||
#endif
|
||||
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
|
||||
#define _OPENTHREADS_ATOMIC_INLINE
|
||||
#else
|
||||
#define _OPENTHREADS_ATOMIC_INLINE inline
|
||||
#endif
|
||||
|
||||
namespace OpenThreads {
|
||||
|
||||
/**
|
||||
* @class Atomic
|
||||
* @brief This class provides an atomic increment and decrement operation.
|
||||
*/
|
||||
class OPENTHREAD_EXPORT_DIRECTIVE Atomic {
|
||||
public:
|
||||
Atomic(unsigned value = 0) : _value(value)
|
||||
{ }
|
||||
_OPENTHREADS_ATOMIC_INLINE unsigned operator++();
|
||||
_OPENTHREADS_ATOMIC_INLINE unsigned operator--();
|
||||
_OPENTHREADS_ATOMIC_INLINE operator unsigned() const;
|
||||
private:
|
||||
|
||||
Atomic(const Atomic&);
|
||||
Atomic& operator=(const Atomic&);
|
||||
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
mutable Mutex _mutex;
|
||||
#endif
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
|
||||
volatile long _value;
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
|
||||
volatile uint_t _value;
|
||||
#else
|
||||
volatile unsigned _value;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @class AtomicPtr
|
||||
* @brief This class provides an atomic pointer assignment using cas operations.
|
||||
*/
|
||||
class OPENTHREAD_EXPORT_DIRECTIVE AtomicPtr {
|
||||
public:
|
||||
AtomicPtr(void* ptr = 0) : _ptr(ptr)
|
||||
{ }
|
||||
~AtomicPtr()
|
||||
{ _ptr = 0; }
|
||||
|
||||
// assigns a new pointer
|
||||
_OPENTHREADS_ATOMIC_INLINE bool assign(void* ptrNew, const void* const ptrOld);
|
||||
_OPENTHREADS_ATOMIC_INLINE void* get() const;
|
||||
|
||||
private:
|
||||
AtomicPtr(const AtomicPtr&);
|
||||
AtomicPtr& operator=(const AtomicPtr&);
|
||||
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
mutable Mutex _mutex;
|
||||
#endif
|
||||
void* volatile _ptr;
|
||||
};
|
||||
|
||||
#if !defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
|
||||
|
||||
_OPENTHREADS_ATOMIC_INLINE unsigned
|
||||
Atomic::operator++()
|
||||
{
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
|
||||
return __sync_add_and_fetch(&_value, 1);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
|
||||
return __add_and_fetch(&_value, 1);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
|
||||
return atomic_inc_uint_nv(&_value);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
ScopedLock<Mutex> lock(_mutex);
|
||||
return ++_value;
|
||||
#else
|
||||
return ++_value;
|
||||
#endif
|
||||
}
|
||||
|
||||
_OPENTHREADS_ATOMIC_INLINE unsigned
|
||||
Atomic::operator--()
|
||||
{
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
|
||||
return __sync_sub_and_fetch(&_value, 1);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
|
||||
return __sub_and_fetch(&_value, 1);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
|
||||
return atomic_dec_uint_nv(&_value);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
ScopedLock<Mutex> lock(_mutex);
|
||||
return --_value;
|
||||
#else
|
||||
return --_value;
|
||||
#endif
|
||||
}
|
||||
|
||||
_OPENTHREADS_ATOMIC_INLINE
|
||||
Atomic::operator unsigned() const
|
||||
{
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
|
||||
__sync_synchronize();
|
||||
return _value;
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
|
||||
__synchronize();
|
||||
return _value;
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
|
||||
membar_consumer(); // Hmm, do we need???
|
||||
return _value;
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
ScopedLock<Mutex> lock(_mutex);
|
||||
return _value;
|
||||
#else
|
||||
return _value;
|
||||
#endif
|
||||
}
|
||||
|
||||
_OPENTHREADS_ATOMIC_INLINE bool
|
||||
AtomicPtr::assign(void* ptrNew, const void* const ptrOld)
|
||||
{
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
|
||||
return __sync_bool_compare_and_swap(&_ptr, ptrOld, ptrNew);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
|
||||
return __compare_and_swap((unsigned long*)&_ptr, (unsigned long)ptrOld, (unsigned long)ptrNew);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
|
||||
return ptrOld == atomic_cas_ptr(&_ptr, ptrOld, ptrNew);
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
ScopedLock<Mutex> lock(_mutex);
|
||||
if (_ptr != ptrOld)
|
||||
return false;
|
||||
_ptr = ptrNew;
|
||||
return true;
|
||||
#else
|
||||
if (_ptr != ptrOld)
|
||||
return false;
|
||||
_ptr = ptrNew;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
_OPENTHREADS_ATOMIC_INLINE void*
|
||||
AtomicPtr::get() const
|
||||
{
|
||||
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
|
||||
__sync_synchronize();
|
||||
return _ptr;
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
|
||||
__synchronize();
|
||||
return _ptr;
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
|
||||
membar_consumer(); // Hmm, do we need???
|
||||
return _ptr;
|
||||
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
|
||||
ScopedLock<Mutex> lock(_mutex);
|
||||
return _ptr;
|
||||
#else
|
||||
return _ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // !defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
|
||||
|
||||
}
|
||||
|
||||
#endif // _OPENTHREADS_ATOMIC_
|
||||
@@ -19,9 +19,9 @@
|
||||
extern "C" {
|
||||
|
||||
#define OPENTHREADS_MAJOR_VERSION 2
|
||||
#define OPENTHREADS_MINOR_VERSION 3
|
||||
#define OPENTHREADS_PATCH_VERSION 0
|
||||
#define OPENTHREADS_SOVERSION 11
|
||||
#define OPENTHREADS_MINOR_VERSION 2
|
||||
#define OPENTHREADS_PATCH_VERSION 1
|
||||
#define OPENTHREADS_SOVERSION 10
|
||||
|
||||
/** OpenThreadsGetVersion() returns the library version number.
|
||||
* Numbering convention : OpenThreads-1.0 will return 1.0 from OpenThreadsGetVersion. */
|
||||
|
||||
@@ -116,7 +116,7 @@ class OSG_EXPORT AnimationPath : public virtual osg::Object
|
||||
matrix.preMult(osg::Matrixd::rotate(_rotation.inverse()));
|
||||
matrix.preMult(osg::Matrixd::translate(-_position));
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
osg::Vec3d _position;
|
||||
@@ -164,7 +164,6 @@ class OSG_EXPORT AnimationPath : public virtual osg::Object
|
||||
/** Given a specific time, return the local ControlPoint frame for a point. */
|
||||
virtual bool getInterpolatedControlPoint(double time,ControlPoint& controlPoint) const;
|
||||
|
||||
/** Insert a control point into the AnimationPath.*/
|
||||
void insert(double time,const ControlPoint& controlPoint);
|
||||
|
||||
double getFirstTime() const { if (!_timeControlPointMap.empty()) return _timeControlPointMap.begin()->first; else return 0.0;}
|
||||
@@ -201,9 +200,6 @@ class OSG_EXPORT AnimationPath : public virtual osg::Object
|
||||
/** Write the animation path to a flat ASCII file stream. */
|
||||
void write(std::ostream& out) const;
|
||||
|
||||
/** Write the control point to a flat ASCII file stream. */
|
||||
void write(TimeControlPointMap::const_iterator itr, std::ostream& out) const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~AnimationPath() {}
|
||||
|
||||
@@ -43,11 +43,9 @@ class OSG_EXPORT ApplicationUsage : public osg::Referenced
|
||||
|
||||
enum Type
|
||||
{
|
||||
NO_HELP = 0x0,
|
||||
COMMAND_LINE_OPTION = 0x1,
|
||||
ENVIRONMENTAL_VARIABLE = 0x2,
|
||||
KEYBOARD_MOUSE_BINDING = 0x4,
|
||||
HELP_ALL = KEYBOARD_MOUSE_BINDING|ENVIRONMENTAL_VARIABLE|COMMAND_LINE_OPTION
|
||||
KEYBOARD_MOUSE_BINDING = 0x4
|
||||
};
|
||||
|
||||
void addUsageExplanation(Type type,const std::string& option,const std::string& explanation);
|
||||
|
||||
@@ -190,14 +190,6 @@ class OSG_EXPORT ArgumentParser
|
||||
/** Write error messages to the given ostream, if at or above the given severity. */
|
||||
void writeErrorMessages(std::ostream& output,ErrorSeverity sevrity=BENIGN);
|
||||
|
||||
|
||||
/** This convinience method handles help requests on the command line.
|
||||
* Return the type(s) of help requested. The return value of this
|
||||
* function is suitable for passing into getApplicationUsage()->write().
|
||||
* If ApplicationUsage::NO_HELP is returned then no help commandline option
|
||||
* was found on the command line. */
|
||||
ApplicationUsage::Type readHelpType();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#ifndef OSG_ARRAY
|
||||
#define OSG_ARRAY 1
|
||||
|
||||
#include <osg/MixinVector>
|
||||
#include <vector>
|
||||
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
@@ -171,7 +171,7 @@ class OSG_EXPORT Array : public Object
|
||||
};
|
||||
|
||||
template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>
|
||||
class TemplateArray : public Array, public MixinVector<T>
|
||||
class TemplateArray : public Array, public std::vector<T>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -179,20 +179,20 @@ class TemplateArray : public Array, public MixinVector<T>
|
||||
|
||||
TemplateArray(const TemplateArray& ta,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Array(ta,copyop),
|
||||
MixinVector<T>(ta) {}
|
||||
std::vector<T>(ta) {}
|
||||
|
||||
TemplateArray(unsigned int no) :
|
||||
Array(ARRAYTYPE,DataSize,DataType),
|
||||
MixinVector<T>(no) {}
|
||||
std::vector<T>(no) {}
|
||||
|
||||
TemplateArray(unsigned int no,T* ptr) :
|
||||
Array(ARRAYTYPE,DataSize,DataType),
|
||||
MixinVector<T>(ptr,ptr+no) {}
|
||||
std::vector<T>(ptr,ptr+no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
TemplateArray(InputIterator first,InputIterator last) :
|
||||
Array(ARRAYTYPE,DataSize,DataType),
|
||||
MixinVector<T>(first,last) {}
|
||||
std::vector<T>(first,last) {}
|
||||
|
||||
TemplateArray& operator = (const TemplateArray& array)
|
||||
{
|
||||
@@ -222,7 +222,7 @@ class TemplateArray : public Array, public MixinVector<T>
|
||||
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
|
||||
virtual void trim()
|
||||
{
|
||||
MixinVector<T>( *this ).swap( *this );
|
||||
std::vector<T>( *this ).swap( *this );
|
||||
}
|
||||
|
||||
virtual const GLvoid* getDataPointer() const { if (!this->empty()) return &this->front(); else return 0; }
|
||||
@@ -257,7 +257,7 @@ class OSG_EXPORT IndexArray : public Array
|
||||
};
|
||||
|
||||
template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>
|
||||
class TemplateIndexArray : public IndexArray, public MixinVector<T>
|
||||
class TemplateIndexArray : public IndexArray, public std::vector<T>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -265,20 +265,20 @@ class TemplateIndexArray : public IndexArray, public MixinVector<T>
|
||||
|
||||
TemplateIndexArray(const TemplateIndexArray& ta,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
IndexArray(ta,copyop),
|
||||
MixinVector<T>(ta) {}
|
||||
std::vector<T>(ta) {}
|
||||
|
||||
TemplateIndexArray(unsigned int no) :
|
||||
IndexArray(ARRAYTYPE,DataSize,DataType),
|
||||
MixinVector<T>(no) {}
|
||||
std::vector<T>(no) {}
|
||||
|
||||
TemplateIndexArray(unsigned int no,T* ptr) :
|
||||
IndexArray(ARRAYTYPE,DataSize,DataType),
|
||||
MixinVector<T>(ptr,ptr+no) {}
|
||||
std::vector<T>(ptr,ptr+no) {}
|
||||
|
||||
template <class InputIterator>
|
||||
TemplateIndexArray(InputIterator first,InputIterator last) :
|
||||
IndexArray(ARRAYTYPE,DataSize,DataType),
|
||||
MixinVector<T>(first,last) {}
|
||||
std::vector<T>(first,last) {}
|
||||
|
||||
TemplateIndexArray& operator = (const TemplateIndexArray& array)
|
||||
{
|
||||
@@ -308,7 +308,7 @@ class TemplateIndexArray : public IndexArray, public MixinVector<T>
|
||||
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
|
||||
virtual void trim()
|
||||
{
|
||||
MixinVector<T>( *this ).swap( *this );
|
||||
std::vector<T>( *this ).swap( *this );
|
||||
}
|
||||
|
||||
virtual const GLvoid* getDataPointer() const { if (!this->empty()) return &this->front(); else return 0; }
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
public :
|
||||
AutoTransform();
|
||||
|
||||
AutoTransform(const AutoTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
AutoTransform(const AutoTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual osg::Object* cloneType() const { return new AutoTransform (); }
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AutoTransform (*this,copyop); }
|
||||
@@ -48,12 +48,12 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
|
||||
inline void setRotation(const Quat& quat) { _rotation = quat; _matrixDirty=true; dirtyBound(); }
|
||||
inline const Quat& getRotation() const { return _rotation; }
|
||||
|
||||
|
||||
inline void setScale(float scale) { setScale(osg::Vec3(scale,scale,scale)); }
|
||||
|
||||
void setScale(const Vec3& scale);
|
||||
inline const Vec3& getScale() const { return _scale; }
|
||||
|
||||
|
||||
void setMinimumScale(float minimumScale) { _minimumScale = minimumScale; }
|
||||
float getMinimumScale() const { return _minimumScale; }
|
||||
|
||||
@@ -62,7 +62,7 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
|
||||
inline void setPivotPoint(const Vec3& pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); }
|
||||
inline const Vec3& getPivotPoint() const { return _pivotPoint; }
|
||||
|
||||
|
||||
|
||||
void setAutoUpdateEyeMovementTolerance(float tolerance) { _autoUpdateEyeMovementTolerance = tolerance; }
|
||||
float getAutoUpdateEyeMovementTolerance() const { return _autoUpdateEyeMovementTolerance; }
|
||||
@@ -74,7 +74,7 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
ROTATE_TO_SCREEN,
|
||||
ROTATE_TO_CAMERA
|
||||
};
|
||||
|
||||
|
||||
void setAutoRotateMode(AutoRotateMode mode) { _autoRotateMode = mode; _firstTimeToInitEyePoint = true; }
|
||||
|
||||
AutoRotateMode getAutoRotateMode() const { return _autoRotateMode; }
|
||||
@@ -83,8 +83,8 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
|
||||
bool getAutoScaleToScreen() const { return _autoScaleToScreen; }
|
||||
|
||||
void setAutoScaleTransitionWidthRatio(float ratio) { _autoScaleTransitionWidthRatio = ratio; }
|
||||
float getAutoScaleTransitionWidthRatio() const { return _autoScaleTransitionWidthRatio; }
|
||||
void setAutoScaleTransistionWidthRatio(float ratio) { _autoScaleTransitionWidthRatio = ratio; }
|
||||
float getAutoScaleTransistionWidthRatio() const { return _autoScaleTransitionWidthRatio; }
|
||||
|
||||
|
||||
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
|
||||
@@ -95,7 +95,7 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
|
||||
virtual ~AutoTransform() {}
|
||||
|
||||
Vec3 _position;
|
||||
@@ -105,17 +105,17 @@ class OSG_EXPORT AutoTransform : public Transform
|
||||
AutoRotateMode _autoRotateMode;
|
||||
|
||||
bool _autoScaleToScreen;
|
||||
|
||||
|
||||
mutable Quat _rotation;
|
||||
mutable Vec3 _scale;
|
||||
mutable bool _firstTimeToInitEyePoint;
|
||||
mutable osg::Vec3 _previousEyePoint;
|
||||
mutable osg::Vec3 _previousLocalUp;
|
||||
mutable Viewport::value_type _previousWidth;
|
||||
mutable Viewport::value_type _previousHeight;
|
||||
mutable Viewport::value_type _previousHeight;
|
||||
mutable osg::Matrix _previousProjection;
|
||||
mutable osg::Vec3 _previousPosition;
|
||||
|
||||
|
||||
float _minimumScale;
|
||||
float _maximumScale;
|
||||
float _autoScaleTransitionWidthRatio;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#ifndef OSG_BOUNDINGBOX
|
||||
#define OSG_BOUNDINGBOX 1
|
||||
|
||||
#include <osg/Config>
|
||||
#include <osg/Export>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec3d>
|
||||
@@ -32,12 +31,12 @@ class OSG_EXPORT BoundingBox
|
||||
{
|
||||
public:
|
||||
|
||||
#ifdef OSG_USE_FLOAT_BOUNDINGBOX
|
||||
typedef Vec3f vec_type;
|
||||
typedef float value_type;
|
||||
#else
|
||||
#ifdef OSG_USE_DOUBLE_BOUNDINGBOX
|
||||
typedef Vec3d vec_type;
|
||||
typedef double value_type;
|
||||
#else
|
||||
typedef Vec3f vec_type;
|
||||
typedef float value_type;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#ifndef OSG_BOUNDINGSPHERE
|
||||
#define OSG_BOUNDINGSPHERE 1
|
||||
|
||||
#include <osg/Config>
|
||||
#include <osg/Export>
|
||||
#include <osg/Vec3f>
|
||||
#include <osg/Vec3d>
|
||||
@@ -33,12 +32,12 @@ class OSG_EXPORT BoundingSphere
|
||||
{
|
||||
public:
|
||||
|
||||
#ifdef OSG_USE_FLOAT_BOUNDINGSPHERE
|
||||
typedef Vec3f vec_type;
|
||||
typedef float value_type;
|
||||
#else
|
||||
#ifdef OSG_USE_DOUBLE_BOUNDINGSPHERE
|
||||
typedef Vec3d vec_type;
|
||||
typedef double value_type;
|
||||
#else
|
||||
typedef Vec3f vec_type;
|
||||
typedef float value_type;
|
||||
#endif
|
||||
|
||||
vec_type _center;
|
||||
|
||||
@@ -68,29 +68,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_1_5
|
||||
#define GL_STREAM_DRAW 0x88E0
|
||||
#define GL_STREAM_READ 0x88E1
|
||||
#define GL_STREAM_COPY 0x88E2
|
||||
#define GL_STATIC_DRAW 0x88E4
|
||||
#define GL_STATIC_READ 0x88E5
|
||||
#define GL_STATIC_COPY 0x88E6
|
||||
#define GL_DYNAMIC_DRAW 0x88E8
|
||||
#define GL_DYNAMIC_READ 0x88E9
|
||||
#define GL_DYNAMIC_COPY 0x88EA
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_2_1
|
||||
#define GL_PIXEL_PACK_BUFFER 0x88EB
|
||||
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
|
||||
#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
|
||||
#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef GL_ARB_pixel_buffer_object
|
||||
#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
|
||||
#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
|
||||
#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
|
||||
#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
|
||||
#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
|
||||
#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
|
||||
#endif
|
||||
|
||||
@@ -91,7 +91,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
|
||||
/** Set the clear color used in glClearColor(..).
|
||||
* glClearColor is only called if mask & GL_COLOR_BUFFER_BIT is true*/
|
||||
void setClearColor(const osg::Vec4& color) { _clearColor=color; applyMaskAction(CLEAR_COLOR); }
|
||||
void setClearColor(const osg::Vec4& color) { _clearColor=color; }
|
||||
|
||||
/** Get the clear color.*/
|
||||
const osg::Vec4& getClearColor() const { return _clearColor; }
|
||||
@@ -329,23 +329,12 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
COLOR_BUFFER15 = COLOR_BUFFER0+15
|
||||
};
|
||||
|
||||
/** Attach a buffer with specified OpenGL internal format.*/
|
||||
void attach(BufferComponent buffer, GLenum internalFormat);
|
||||
|
||||
/** Attach a Texture to specified buffer component.
|
||||
* The level parameter controls the mip map level of the texture that is attached.
|
||||
* The face parameter controls the face of texture cube map or z level of 3d texture.
|
||||
* The mipMapGeneration flag controls whether mipmap generation should be done for texture.*/
|
||||
void attach(BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face=0, bool mipMapGeneration=false,
|
||||
unsigned int multisampleSamples = 0,
|
||||
unsigned int multisampleColorSamples = 0);
|
||||
void attach(BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face=0, bool mipMapGeneration=false);
|
||||
|
||||
/** Attach a Image to specified buffer component.*/
|
||||
void attach(BufferComponent buffer, osg::Image* image,
|
||||
unsigned int multisampleSamples = 0,
|
||||
unsigned int multisampleColorSamples = 0);
|
||||
void attach(BufferComponent buffer, osg::Image* image);
|
||||
|
||||
/** Detach specified buffer component.*/
|
||||
void detach(BufferComponent buffer);
|
||||
|
||||
struct Attachment
|
||||
@@ -354,9 +343,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
_internalFormat(GL_NONE),
|
||||
_level(0),
|
||||
_face(0),
|
||||
_mipMapGeneration(false),
|
||||
_multisampleSamples(0),
|
||||
_multisampleColorSamples(0) {}
|
||||
_mipMapGeneration(false) {}
|
||||
|
||||
int width() const
|
||||
{
|
||||
@@ -385,8 +372,6 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
unsigned int _level;
|
||||
unsigned int _face;
|
||||
bool _mipMapGeneration;
|
||||
unsigned int _multisampleSamples;
|
||||
unsigned int _multisampleColorSamples;
|
||||
};
|
||||
|
||||
typedef std::map< BufferComponent, Attachment> BufferAttachmentMap;
|
||||
@@ -396,8 +381,8 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
|
||||
/** Get the const BufferAttachmentMap, used to configure frame buffer objects, pbuffers and texture reads.*/
|
||||
const BufferAttachmentMap& getBufferAttachmentMap() const { return _bufferAttachmentMap; }
|
||||
|
||||
|
||||
|
||||
|
||||
/** Create a operation thread for this camera.*/
|
||||
void createCameraThread();
|
||||
|
||||
@@ -450,16 +435,14 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
DrawCallback(const DrawCallback&,const CopyOp&) {}
|
||||
|
||||
META_Object(osg,DrawCallback)
|
||||
|
||||
/** Functor method called by rendering thread. Users will typically override this method to carry tasks such as screen capture.*/
|
||||
|
||||
virtual void operator () (osg::RenderInfo& renderInfo) const;
|
||||
|
||||
/** Functor method, provided for backwards compatibility, called by operator() (osg::RenderInfo& renderInfo) method.*/
|
||||
virtual void operator () (const osg::Camera& /*camera*/) const {}
|
||||
};
|
||||
|
||||
/** Set the initial draw callback for custom operations to be done before the drawing of the camera's subgraph and pre render stages.*/
|
||||
void setInitialDrawCallback(DrawCallback* cb) { _initialDrawCallback = cb; }
|
||||
void setIntialDrawCallback(DrawCallback* cb) { _preDrawCallback = cb; }
|
||||
|
||||
/** Get the initial draw callback.*/
|
||||
DrawCallback* getInitialDrawCallback() { return _initialDrawCallback.get(); }
|
||||
@@ -516,9 +499,6 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
|
||||
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const;
|
||||
|
||||
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
|
||||
virtual void inheritCullSettings(const CullSettings& settings, unsigned int inheritanceMask);
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~Camera();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
/* -*-c++-*- OpenSceneGraph - setCullSettingsright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
@@ -14,7 +14,6 @@
|
||||
#ifndef OSG_CULLSETTINGS
|
||||
#define OSG_CULLSETTINGS 1
|
||||
|
||||
#include <iosfwd>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/ClearNode>
|
||||
|
||||
|
||||
@@ -79,35 +79,6 @@
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_framebuffer_blit
|
||||
#define GL_EXT_framebuffer_blit 1
|
||||
#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
|
||||
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
|
||||
#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_framebuffer_multisample
|
||||
#define GL_EXT_framebuffer_multisample 1
|
||||
#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
|
||||
#define GL_MAX_SAMPLES_EXT 0x8D57
|
||||
#endif
|
||||
|
||||
#ifndef GL_MAX_SAMPLES_EXT
|
||||
// Workaround for Centos 5 and other distros that define
|
||||
// GL_EXT_framebuffer_multisample but not GL_MAX_SAMPLES_EXT
|
||||
#define GL_MAX_SAMPLES_EXT 0x8D57
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_framebuffer_multisample_coverage
|
||||
#define GL_NV_framebuffer_multisample_coverage 1
|
||||
#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB
|
||||
#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10
|
||||
#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
|
||||
#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_1_4
|
||||
#define GL_DEPTH_COMPONENT16 0x81A5
|
||||
#define GL_DEPTH_COMPONENT24 0x81A6
|
||||
@@ -128,8 +99,6 @@ namespace osg
|
||||
typedef void APIENTRY TglDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
|
||||
typedef void APIENTRY TglGenRenderbuffersEXT(GLsizei, GLuint *);
|
||||
typedef void APIENTRY TglRenderbufferStorageEXT(GLenum, GLenum, GLsizei, GLsizei);
|
||||
typedef void APIENTRY TglRenderbufferStorageMultisampleEXT(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
|
||||
typedef void APIENTRY TglRenderbufferStorageMultisampleCoverageNV(GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei);
|
||||
typedef void APIENTRY TglBindFramebufferEXT(GLenum, GLuint);
|
||||
typedef void APIENTRY TglDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
|
||||
typedef void APIENTRY TglGenFramebuffersEXT(GLsizei, GLuint *);
|
||||
@@ -140,13 +109,12 @@ namespace osg
|
||||
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 TglBlitFramebufferEXT(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
|
||||
|
||||
typedef void APIENTRY TglRenderbufferStorageMultisampleCoverageNV(GLenum, GLuint, GLuint, GLenum, GLuint, GLuint);
|
||||
|
||||
TglBindRenderbufferEXT* glBindRenderbufferEXT;
|
||||
TglGenRenderbuffersEXT* glGenRenderbuffersEXT;
|
||||
TglDeleteRenderbuffersEXT* glDeleteRenderbuffersEXT;
|
||||
TglRenderbufferStorageEXT* glRenderbufferStorageEXT;
|
||||
TglRenderbufferStorageMultisampleEXT* glRenderbufferStorageMultisampleEXT;
|
||||
TglRenderbufferStorageMultisampleCoverageNV* glRenderbufferStorageMultisampleCoverageNV;
|
||||
TglBindFramebufferEXT* glBindFramebufferEXT;
|
||||
TglDeleteFramebuffersEXT* glDeleteFramebuffersEXT;
|
||||
@@ -158,13 +126,10 @@ namespace osg
|
||||
TglFramebufferTextureLayerEXT* glFramebufferTextureLayerEXT;
|
||||
TglFramebufferRenderbufferEXT* glFramebufferRenderbufferEXT;
|
||||
TglGenerateMipmapEXT* glGenerateMipmapEXT;
|
||||
TglBlitFramebufferEXT* glBlitFramebufferEXT;
|
||||
|
||||
static FBOExtensions* instance(unsigned contextID, bool createIfNotInitalized);
|
||||
|
||||
bool isSupported() const { return _supported; }
|
||||
bool isMultisampleSupported() const { return glRenderbufferStorageMultisampleEXT != 0; }
|
||||
bool isMultisampleCoverageSupported() const { return glRenderbufferStorageMultisampleCoverageNV != 0; }
|
||||
|
||||
protected:
|
||||
FBOExtensions(unsigned int contextID);
|
||||
@@ -181,7 +146,7 @@ namespace osg
|
||||
{
|
||||
public:
|
||||
RenderBuffer();
|
||||
RenderBuffer(int width, int height, GLenum internalFormat, int samples=0, int colorSamples=0);
|
||||
RenderBuffer(int width, int height, GLenum internalFormat);
|
||||
RenderBuffer(const RenderBuffer& copy, const CopyOp& copyop = CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osg, RenderBuffer);
|
||||
@@ -193,10 +158,6 @@ namespace osg
|
||||
inline void setSize(int w, int h);
|
||||
inline GLenum getInternalFormat() const;
|
||||
inline void setInternalFormat(GLenum format);
|
||||
inline int getSamples() const;
|
||||
inline int getColorSamples() const;
|
||||
inline void setSamples(int samples);
|
||||
inline void setColorSamples(int colorSamples);
|
||||
|
||||
GLuint getObjectID(unsigned int contextID, const FBOExtensions *ext) const;
|
||||
inline int compare(const RenderBuffer &rb) const;
|
||||
@@ -215,8 +176,6 @@ namespace osg
|
||||
* this call is useful for when an OpenGL context has been destroyed. */
|
||||
static void discardDeletedRenderBuffers(unsigned int contextID);
|
||||
|
||||
static int getMaxSamples(unsigned int contextID, const FBOExtensions *ext);
|
||||
|
||||
protected:
|
||||
virtual ~RenderBuffer();
|
||||
RenderBuffer &operator=(const RenderBuffer &) { return *this; }
|
||||
@@ -226,14 +185,9 @@ namespace osg
|
||||
private:
|
||||
mutable buffered_value<GLuint> _objectID;
|
||||
mutable buffered_value<int> _dirty;
|
||||
|
||||
GLenum _internalFormat;
|
||||
int _width;
|
||||
int _height;
|
||||
// "samples" in the framebuffer_multisample extension is equivalent to
|
||||
// "coverageSamples" in the framebuffer_multisample_coverage extension.
|
||||
int _samples;
|
||||
int _colorSamples;
|
||||
};
|
||||
|
||||
// INLINE METHODS
|
||||
@@ -278,28 +232,6 @@ namespace osg
|
||||
dirtyAll();
|
||||
}
|
||||
|
||||
inline int RenderBuffer::getSamples() const
|
||||
{
|
||||
return _samples;
|
||||
}
|
||||
|
||||
inline int RenderBuffer::getColorSamples() const
|
||||
{
|
||||
return _colorSamples;
|
||||
}
|
||||
|
||||
inline void RenderBuffer::setSamples(int samples)
|
||||
{
|
||||
_samples = samples;
|
||||
dirtyAll();
|
||||
}
|
||||
|
||||
inline void RenderBuffer::setColorSamples(int colorSamples)
|
||||
{
|
||||
_colorSamples = colorSamples;
|
||||
dirtyAll();
|
||||
}
|
||||
|
||||
inline void RenderBuffer::dirtyAll() const
|
||||
{
|
||||
_dirty.setAllElementsTo(1);
|
||||
@@ -346,9 +278,8 @@ namespace osg
|
||||
|
||||
FrameBufferAttachment&operator = (const FrameBufferAttachment& copy);
|
||||
|
||||
bool isMultisample() const;
|
||||
void createRequiredTexturesAndApplyGenerateMipMap(State& state, const FBOExtensions* ext) const;
|
||||
void attach(State &state, GLenum target, GLenum attachment_point, const FBOExtensions* ext) const;
|
||||
void attach(State &state, GLenum attachment_point, const FBOExtensions* ext) const;
|
||||
int compare(const FrameBufferAttachment &fa) const;
|
||||
|
||||
private:
|
||||
@@ -377,29 +308,25 @@ namespace osg
|
||||
inline const AttachmentMap& getAttachmentMap() const;
|
||||
|
||||
|
||||
void setAttachment(GLenum attachment_point, const FrameBufferAttachment &attachment);
|
||||
inline const FrameBufferAttachment& getAttachment(GLenum attachment_point) const;
|
||||
inline bool hasAttachment(GLenum attachment_point) const;
|
||||
|
||||
void setAttachment(BufferComponent attachment_point, const FrameBufferAttachment &attachment);
|
||||
inline const FrameBufferAttachment& getAttachment(BufferComponent attachment_point) const;
|
||||
inline bool hasAttachment(BufferComponent attachment_point) const;
|
||||
|
||||
GLenum convertBufferComponentToGLenum(BufferComponent attachment_point) const;
|
||||
BufferComponent convertGLenumToBufferComponent(GLenum attachment_point) const;
|
||||
|
||||
|
||||
inline bool hasMultipleRenderingTargets() const { return !_drawBuffers.empty(); }
|
||||
inline const MultipleRenderingTargets& getMultipleRenderingTargets() const { return _drawBuffers; }
|
||||
|
||||
bool isMultisample() const;
|
||||
|
||||
int compare(const StateAttribute &sa) const;
|
||||
|
||||
void apply(State &state) const;
|
||||
|
||||
enum BindTarget
|
||||
{
|
||||
READ_FRAMEBUFFER = GL_READ_FRAMEBUFFER_EXT,
|
||||
DRAW_FRAMEBUFFER = GL_DRAW_FRAMEBUFFER_EXT,
|
||||
READ_DRAW_FRAMEBUFFER = GL_FRAMEBUFFER_EXT
|
||||
};
|
||||
|
||||
/** Bind the FBO as either the read or draw target, or both. */
|
||||
void apply(State &state, BindTarget target) const;
|
||||
|
||||
/** Mark internal FBO for deletion.
|
||||
* Deletion requests are queued until they can be executed
|
||||
* in the proper GL context. */
|
||||
@@ -421,8 +348,6 @@ namespace osg
|
||||
|
||||
inline void dirtyAll();
|
||||
|
||||
GLenum convertBufferComponentToGLenum(BufferComponent attachment_point) const;
|
||||
|
||||
private:
|
||||
AttachmentMap _attachments;
|
||||
|
||||
@@ -442,11 +367,21 @@ namespace osg
|
||||
return _attachments;
|
||||
}
|
||||
|
||||
inline bool FrameBufferObject::hasAttachment(GLenum attachment_point) const
|
||||
{
|
||||
return hasAttachment(convertGLenumToBufferComponent(attachment_point));
|
||||
}
|
||||
|
||||
inline bool FrameBufferObject::hasAttachment(FrameBufferObject::BufferComponent attachment_point) const
|
||||
{
|
||||
return _attachments.find(attachment_point) != _attachments.end();
|
||||
}
|
||||
|
||||
inline const FrameBufferAttachment &FrameBufferObject::getAttachment(GLenum attachment_point) const
|
||||
{
|
||||
return getAttachment(convertGLenumToBufferComponent(attachment_point));
|
||||
}
|
||||
|
||||
inline const FrameBufferAttachment &FrameBufferObject::getAttachment(FrameBufferObject::BufferComponent attachment_point) const
|
||||
{
|
||||
return _attachments.find(attachment_point)->second;
|
||||
|
||||
@@ -80,7 +80,7 @@ bool setGLExtensionFuncPtr(T& t, const char* str1)
|
||||
if (data)
|
||||
{
|
||||
memcpy(&t, &data, sizeof(T));
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -96,7 +96,7 @@ bool setGLExtensionFuncPtr(T& t, const char* str1, const char* str2)
|
||||
if (data)
|
||||
{
|
||||
memcpy(&t, &data, sizeof(T));
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -139,6 +139,10 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
Array* getVertexArray() { return _vertexData.array.get(); }
|
||||
const Array* getVertexArray() const { return _vertexData.array.get(); }
|
||||
|
||||
void setVertexIndices(IndexArray* array);
|
||||
IndexArray* getVertexIndices() { return _vertexData.indices.get(); }
|
||||
const IndexArray* getVertexIndices() const { return _vertexData.indices.get(); }
|
||||
|
||||
void setVertexData(const ArrayData& arrayData);
|
||||
ArrayData& getVertexData() { return _vertexData; }
|
||||
const ArrayData& getVertexData() const { return _vertexData; }
|
||||
@@ -150,6 +154,10 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
void setNormalArray(Array* array);
|
||||
Array* getNormalArray() { return _normalData.array.get(); }
|
||||
const Array* getNormalArray() const { return _normalData.array.get(); }
|
||||
|
||||
void setNormalIndices(IndexArray* array);
|
||||
IndexArray* getNormalIndices() { return _normalData.indices.get(); }
|
||||
const IndexArray* getNormalIndices() const { return _normalData.indices.get(); }
|
||||
|
||||
void setNormalData(const ArrayData& arrayData);
|
||||
ArrayData& getNormalData() { return _normalData; }
|
||||
@@ -162,6 +170,10 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
Array* getColorArray() { return _colorData.array.get(); }
|
||||
const Array* getColorArray() const { return _colorData.array.get(); }
|
||||
|
||||
void setColorIndices(IndexArray* array);
|
||||
IndexArray* getColorIndices() { return _colorData.indices.get(); }
|
||||
const IndexArray* getColorIndices() const { return _colorData.indices.get(); }
|
||||
|
||||
void setColorData(const ArrayData& arrayData);
|
||||
ArrayData& getColorData() { return _colorData; }
|
||||
const ArrayData& getColorData() const { return _colorData; }
|
||||
@@ -174,6 +186,10 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
Array* getSecondaryColorArray() { return _secondaryColorData.array.get(); }
|
||||
const Array* getSecondaryColorArray() const { return _secondaryColorData.array.get(); }
|
||||
|
||||
void setSecondaryColorIndices(IndexArray* array);
|
||||
IndexArray* getSecondaryColorIndices() { return _secondaryColorData.indices.get(); }
|
||||
const IndexArray* getSecondaryColorIndices() const { return _secondaryColorData.indices.get(); }
|
||||
|
||||
void setSecondaryColorData(const ArrayData& arrayData);
|
||||
ArrayData& getSecondaryColorData() { return _secondaryColorData; }
|
||||
const ArrayData& getSecondaryColorData() const { return _secondaryColorData; }
|
||||
@@ -186,6 +202,10 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
Array* getFogCoordArray() { return _fogCoordData.array.get(); }
|
||||
const Array* getFogCoordArray() const { return _fogCoordData.array.get(); }
|
||||
|
||||
void setFogCoordIndices(IndexArray* array);
|
||||
IndexArray* getFogCoordIndices() { return _fogCoordData.indices.get(); }
|
||||
const IndexArray* getFogCoordIndices() const { return _fogCoordData.indices.get(); }
|
||||
|
||||
void setFogCoordData(const ArrayData& arrayData);
|
||||
ArrayData& getFogCoordData() { return _fogCoordData; }
|
||||
const ArrayData& getFogCoordData() const { return _fogCoordData; }
|
||||
@@ -194,6 +214,10 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
void setTexCoordArray(unsigned int unit,Array*);
|
||||
Array* getTexCoordArray(unsigned int unit);
|
||||
const Array* getTexCoordArray(unsigned int unit) const;
|
||||
|
||||
void setTexCoordIndices(unsigned int unit,IndexArray*);
|
||||
IndexArray* getTexCoordIndices(unsigned int unit);
|
||||
const IndexArray* getTexCoordIndices(unsigned int unit) const;
|
||||
|
||||
void setTexCoordData(unsigned int index,const ArrayData& arrayData);
|
||||
ArrayData& getTexCoordData(unsigned int index);
|
||||
@@ -209,6 +233,10 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
Array *getVertexAttribArray(unsigned int index);
|
||||
const Array *getVertexAttribArray(unsigned int index) const;
|
||||
|
||||
void setVertexAttribIndices(unsigned int index,IndexArray* array);
|
||||
IndexArray* getVertexAttribIndices(unsigned int index);
|
||||
const IndexArray* getVertexAttribIndices(unsigned int index) const;
|
||||
|
||||
void setVertexAttribBinding(unsigned int index,AttributeBinding ab);
|
||||
AttributeBinding getVertexAttribBinding(unsigned int index) const;
|
||||
|
||||
@@ -254,45 +282,6 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
unsigned int getPrimitiveSetIndex(const PrimitiveSet* primitiveset) const;
|
||||
|
||||
|
||||
|
||||
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
|
||||
void setVertexIndices(IndexArray* array);
|
||||
IndexArray* getVertexIndices() { return _vertexData.indices.get(); }
|
||||
const IndexArray* getVertexIndices() const { return _vertexData.indices.get(); }
|
||||
|
||||
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
|
||||
void setNormalIndices(IndexArray* array);
|
||||
IndexArray* getNormalIndices() { return _normalData.indices.get(); }
|
||||
const IndexArray* getNormalIndices() const { return _normalData.indices.get(); }
|
||||
|
||||
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
|
||||
void setColorIndices(IndexArray* array);
|
||||
IndexArray* getColorIndices() { return _colorData.indices.get(); }
|
||||
const IndexArray* getColorIndices() const { return _colorData.indices.get(); }
|
||||
|
||||
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
|
||||
void setSecondaryColorIndices(IndexArray* array);
|
||||
IndexArray* getSecondaryColorIndices() { return _secondaryColorData.indices.get(); }
|
||||
const IndexArray* getSecondaryColorIndices() const { return _secondaryColorData.indices.get(); }
|
||||
|
||||
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
|
||||
void setFogCoordIndices(IndexArray* array);
|
||||
IndexArray* getFogCoordIndices() { return _fogCoordData.indices.get(); }
|
||||
const IndexArray* getFogCoordIndices() const { return _fogCoordData.indices.get(); }
|
||||
|
||||
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
|
||||
void setTexCoordIndices(unsigned int unit,IndexArray*);
|
||||
IndexArray* getTexCoordIndices(unsigned int unit);
|
||||
const IndexArray* getTexCoordIndices(unsigned int unit) const;
|
||||
|
||||
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
|
||||
void setVertexAttribIndices(unsigned int index,IndexArray* array);
|
||||
IndexArray* getVertexAttribIndices(unsigned int index);
|
||||
const IndexArray* getVertexAttribIndices(unsigned int index) const;
|
||||
|
||||
|
||||
|
||||
|
||||
/** When set to true, ignore the setUseDisplayList() settings, and hints to the drawImplementation
|
||||
method to use OpenGL vertex buffer objects for rendering.*/
|
||||
virtual void setUseVertexBufferObjects(bool flag);
|
||||
|
||||
@@ -92,8 +92,7 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
useMultiThreadedOpenGLEngine(false),
|
||||
useCursor(true),
|
||||
sharedContext(0),
|
||||
setInheritedWindowPixelFormat(false),
|
||||
overrideRedirect(false) {}
|
||||
setInheritedWindowPixelFormat(false) {}
|
||||
|
||||
// graphics context original and size
|
||||
int x;
|
||||
@@ -146,9 +145,6 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
|
||||
// ask the GraphicsWindow implementation to set the pixel format of an inherited window
|
||||
bool setInheritedWindowPixelFormat;
|
||||
|
||||
// X11 hint whether to override the window managers window size/position redirection
|
||||
bool overrideRedirect;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new Hint(*this,copyop); }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Hint *>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "Hint"; }
|
||||
virtual const char* className() const { return "Light"; }
|
||||
virtual Type getType() const { return HINT; }
|
||||
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <osg/Vec2>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/FrameStamp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -53,9 +52,6 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
// forward declare
|
||||
class NodeVisitor;
|
||||
|
||||
/** Image class for encapsulating the storage texture image data. */
|
||||
class OSG_EXPORT Image : public Object
|
||||
{
|
||||
@@ -297,8 +293,6 @@ class OSG_EXPORT Image : public Object
|
||||
|
||||
/** Get the const PixelBufferObject.*/
|
||||
const PixelBufferObject* getPixelBufferObject() const { return _bufferObject.get(); }
|
||||
|
||||
virtual void update(NodeVisitor* nv) {}
|
||||
|
||||
protected :
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSG_IMAGESEQUENCE
|
||||
#define OSG_IMAGESEQUENCE 1
|
||||
|
||||
#include <OpenThreads/Mutex>
|
||||
#include <osg/ImageStream>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/**
|
||||
* Image Buffer class.
|
||||
*/
|
||||
class OSG_EXPORT ImageSequence : public ImageStream
|
||||
{
|
||||
public:
|
||||
ImageSequence();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
ImageSequence(const ImageSequence& ImageSequence, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual Object* cloneType() const { return new ImageSequence(); }
|
||||
virtual Object* clone(const CopyOp& copyop) const { return new ImageSequence(*this,copyop); }
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImageSequence*>(obj)!=0; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "ImageSequence"; }
|
||||
|
||||
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
|
||||
virtual int compare(const Image& rhs) const;
|
||||
|
||||
virtual void setReferenceTime(double t) { _referenceTime = t; }
|
||||
virtual double getReferenceTime() const { return _referenceTime; }
|
||||
|
||||
virtual void setTimeMultiplier(double tm) { _timeMultiplier = tm; }
|
||||
virtual double getTimeMultiplier() const { return _timeMultiplier; }
|
||||
|
||||
typedef std::list< osg::ref_ptr<osg::Image> > Images;
|
||||
typedef std::list< std::string > FileNames;
|
||||
|
||||
enum Mode
|
||||
{
|
||||
PRE_LOAD_ALL_IMAGES,
|
||||
PAGE_AND_RETAIN_IMAGES,
|
||||
PAGE_AND_DISCARD_USED_IMAGES
|
||||
};
|
||||
|
||||
void setMode(Mode mode);
|
||||
Mode getMode() const { return _mode; }
|
||||
|
||||
void setDuration(double duration);
|
||||
double getDuration() const { return _duration; }
|
||||
|
||||
void addImageFile(const std::string& fileName);
|
||||
|
||||
FileNames& getFileNames() { return _fileNames; }
|
||||
const FileNames& getFileNames() const { return _fileNames; }
|
||||
|
||||
void addImage(osg::Image* image);
|
||||
|
||||
Images& getImages() { return _images; }
|
||||
const Images& getImages() const { return _images; }
|
||||
|
||||
|
||||
virtual void update(NodeVisitor* nv);
|
||||
|
||||
struct OSG_EXPORT UpdateCallback : public osg::StateAttribute::Callback
|
||||
{
|
||||
virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~ImageSequence() {}
|
||||
|
||||
void setImageToChild(const osg::Image* image);
|
||||
|
||||
void computeTimePerImage();
|
||||
|
||||
double _referenceTime;
|
||||
double _timeMultiplier;
|
||||
|
||||
Mode _mode;
|
||||
double _duration;
|
||||
|
||||
double _timePerImage;
|
||||
|
||||
OpenThreads::Mutex _mutex;
|
||||
FileNames _fileNames;
|
||||
FileNames::iterator _fileNamesIterator;
|
||||
double _fileNamesIteratorTime;
|
||||
|
||||
double _imageHeadTime;
|
||||
Images _images;
|
||||
Images::iterator _imageIterator;
|
||||
double _imageIteratorTime;
|
||||
|
||||
typedef std::pair< std::string, osg::ref_ptr<osg::Image> > FileNameImagePair;
|
||||
typedef std::list< FileNameImagePair > FileNameImageList;
|
||||
|
||||
FileNameImageList _filesRequested;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
@@ -78,6 +78,7 @@ class OSG_EXPORT ImageStream : public Image
|
||||
virtual void setVolume(float) {}
|
||||
virtual float getVolume() const { return 0.0f; }
|
||||
|
||||
virtual void update() {}
|
||||
|
||||
protected:
|
||||
virtual void applyLoopingMode() {}
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSG_KDTREE
|
||||
#define OSG_KDTREE 1
|
||||
|
||||
#include <osg/Shape>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
|
||||
/** Implementation of a kdtree for Geometry leaves, to enable fast intersection tests.*/
|
||||
class OSG_EXPORT KdTree : public osg::Shape
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
KdTree();
|
||||
|
||||
KdTree(const KdTree& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Shape(osg, KdTree)
|
||||
|
||||
struct OSG_EXPORT BuildOptions
|
||||
{
|
||||
BuildOptions();
|
||||
|
||||
unsigned int _numVerticesProcessed;
|
||||
unsigned int _targetNumTrianglesPerLeaf;
|
||||
unsigned int _maxNumLevels;
|
||||
};
|
||||
|
||||
|
||||
/** Build the kdtree from the specified source geometry object.
|
||||
* retun true on success. */
|
||||
virtual bool build(BuildOptions& buildOptions, osg::Geometry* geometry);
|
||||
|
||||
struct LineSegmentIntersection
|
||||
{
|
||||
LineSegmentIntersection():
|
||||
ratio(-1.0),
|
||||
p0(0),
|
||||
p1(0),
|
||||
p2(0),
|
||||
r0(0.0f),
|
||||
r1(0.0f),
|
||||
r2(0.0f),
|
||||
primitiveIndex(0) {}
|
||||
|
||||
bool operator < (const LineSegmentIntersection& rhs) const { return ratio < rhs.ratio; }
|
||||
|
||||
typedef std::vector<unsigned int> IndexList;
|
||||
typedef std::vector<double> RatioList;
|
||||
|
||||
double ratio;
|
||||
osg::Vec3d intersectionPoint;
|
||||
osg::Vec3 intersectionNormal;
|
||||
|
||||
unsigned int p0;
|
||||
unsigned int p1;
|
||||
unsigned int p2;
|
||||
float r0;
|
||||
float r1;
|
||||
float r2;
|
||||
|
||||
unsigned int primitiveIndex;
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<LineSegmentIntersection> LineSegmentIntersections;
|
||||
|
||||
/** compute the intersection of a line segment and the kdtree, return true if an intersection has been found.*/
|
||||
virtual bool intersect(const osg::Vec3& start, const osg::Vec3& end, LineSegmentIntersections& intersections) const;
|
||||
|
||||
|
||||
typedef int value_type;
|
||||
|
||||
struct KdNode
|
||||
{
|
||||
KdNode():
|
||||
first(0),
|
||||
second(0) {}
|
||||
|
||||
KdNode(value_type f, value_type s):
|
||||
first(f),
|
||||
second(s) {}
|
||||
|
||||
osg::BoundingBox bb;
|
||||
|
||||
value_type first;
|
||||
value_type second;
|
||||
};
|
||||
|
||||
struct Triangle
|
||||
{
|
||||
Triangle():
|
||||
p0(0),p1(0),p2(0) {}
|
||||
|
||||
Triangle(unsigned int ip0, unsigned int ip1, unsigned int ip2):
|
||||
p0(ip0), p1(ip1), p2(ip2) {}
|
||||
|
||||
bool operator < (const Triangle& rhs) const
|
||||
{
|
||||
if (p0<rhs.p0) return true;
|
||||
if (p0>rhs.p0) return false;
|
||||
if (p1<rhs.p1) return true;
|
||||
if (p1>rhs.p1) return false;
|
||||
return p2<rhs.p2;
|
||||
}
|
||||
|
||||
unsigned int p0;
|
||||
unsigned int p1;
|
||||
unsigned int p2;
|
||||
};
|
||||
|
||||
typedef std::vector< KdNode > KdNodeList;
|
||||
typedef std::vector< Triangle > TriangleList;
|
||||
|
||||
int addNode(const KdNode& node)
|
||||
{
|
||||
int num = _kdNodes.size();
|
||||
_kdNodes.push_back(node);
|
||||
return num;
|
||||
}
|
||||
|
||||
KdNode& getNode(int nodeNum) { return _kdNodes[nodeNum]; }
|
||||
const KdNode& getNode(int nodeNum) const { return _kdNodes[nodeNum]; }
|
||||
|
||||
KdNodeList& getNodes() { return _kdNodes; }
|
||||
const KdNodeList& getNodes() const { return _kdNodes; }
|
||||
|
||||
void setVertices(osg::Vec3Array* vertices) { _vertices = vertices; }
|
||||
const osg::Vec3Array* getVertices() const { return _vertices.get(); }
|
||||
|
||||
unsigned int addTriangle(const Triangle& tri)
|
||||
{
|
||||
unsigned int num = _triangles.size();
|
||||
_triangles.push_back(tri);
|
||||
return num;
|
||||
}
|
||||
|
||||
Triangle& getTriangle(unsigned int i) { return _triangles[i]; }
|
||||
const Triangle& getTriangle(unsigned int i) const { return _triangles[i]; }
|
||||
|
||||
TriangleList& getTriangles() { return _triangles; }
|
||||
const TriangleList& getTriangles() const { return _triangles; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
osg::ref_ptr<osg::Vec3Array> _vertices;
|
||||
KdNodeList _kdNodes;
|
||||
TriangleList _triangles;
|
||||
|
||||
};
|
||||
|
||||
class OSG_EXPORT KdTreeBuilder : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
KdTreeBuilder();
|
||||
|
||||
KdTreeBuilder(const KdTreeBuilder& rhs);
|
||||
|
||||
virtual KdTreeBuilder* clone() { return new KdTreeBuilder(*this); }
|
||||
|
||||
void apply(osg::Geode& geode);
|
||||
|
||||
KdTree::BuildOptions _buildOptions;
|
||||
|
||||
osg::ref_ptr<osg::KdTree> _kdTreePrototype;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~KdTreeBuilder() {}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -14,7 +14,6 @@
|
||||
#ifndef OSG_MATRIX
|
||||
#define OSG_MATRIX 1
|
||||
|
||||
#include <osg/Config>
|
||||
#include <osg/Matrixd>
|
||||
#include <osg/Matrixf>
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user