Moved SimpleViewer and GraphicsWindow into their own osgViewer library, updated simpleviewer examples to reflect this change

This commit is contained in:
Robert Osfield 2006-11-02 12:27:15 +00:00
parent f9fb99dc43
commit e0f395fd07
35 changed files with 470 additions and 117 deletions

View File

@ -183,6 +183,30 @@ Package=<4>
###############################################################################
Project: "Core osgViewer"=.\osgViewer\osgViewer.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name Core osg
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgUtil
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgDB
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
}}}
###############################################################################
Project: "Core osgProducer"=.\osgProducer\osgProducer.dsp - Package Owner=<4>
Package=<5>
@ -2042,6 +2066,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgViewer
End Project Dependency
}}}
###############################################################################
@ -2066,6 +2093,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgViewer
End Project Dependency
}}}
###############################################################################
@ -2090,6 +2120,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgViewer
End Project Dependency
}}}
###############################################################################
@ -2114,6 +2147,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgViewer
End Project Dependency
}}}
###############################################################################
@ -2138,6 +2174,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgViewer
End Project Dependency
}}}
###############################################################################
@ -2162,6 +2201,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgViewer
End Project Dependency
}}}
###############################################################################
@ -2186,6 +2228,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name Core osgGA
End Project Dependency
Begin Project Dependency
Project_Dep_Name Core osgViewer
End Project Dependency
}}}
###############################################################################

View File

@ -191,10 +191,6 @@ SOURCE=..\..\src\osgGA\MatrixManipulator.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osgGA\SimpleViewer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osgGA\StateSetManipulator.cpp
# End Source File
# Begin Source File
@ -267,10 +263,6 @@ SOURCE=..\..\Include\osgGA\MatrixManipulator
# End Source File
# Begin Source File
SOURCE=..\..\Include\osgGA\SimpleViewer
# End Source File
# Begin Source File
SOURCE=..\..\Include\osgGA\StateSetManipulator
# End Source File
# Begin Source File

View File

@ -0,0 +1,191 @@
# Microsoft Developer Studio Project File - Name="Core osgViewer" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=Core osgViewer - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "osgViewer.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "osgViewer.mak" CFG="Core osgViewer - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Core osgViewer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Core osgViewer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Core osgViewer - Win32 Release Static" (based on "Win32 (x86) Static Library")
!MESSAGE "Core osgViewer - Win32 Debug Static" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Core osgViewer - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "../../lib"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../bin/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "OSGVIEWER_LIBRARY" /D "WIN32" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 OpenThreadsWin32.lib opengl32.lib glu32.lib /nologo /dll /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgViewer.dll" /implib:"../../lib/$(PlatformName)/osgViewer.lib" /libpath:"../../lib/$(PlatformName)" /libpath:"../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../Producer/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib"
!ELSEIF "$(CFG)" == "Core osgViewer - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../bin/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /vmg /GR /GX /Zi /Od /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "OSGVIEWER_LIBRARY" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /Zm200 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 OpenThreadsWin32d.lib opengl32.lib glu32.lib /nologo /dll /debug /machine:I386 /out:"$(OutDir)/osgViewerd.dll" /pdbtype:sept /implib:"../../lib/$(PlatformName)/osgViewerd.lib" /libpath:"../../lib/$(PlatformName)" /libpath:"../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../Producer/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "Core osgViewer - Win32 Release Static"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "../../lib"
# PROP BASE Intermediate_Dir "Release_Static"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../lib/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "NDEBUG" /D "_MBCS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "WIN32" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgViewer_s.lib"
!ELSEIF "$(CFG)" == "Core osgViewer - Win32 Debug Static"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "../../lib"
# PROP BASE Intermediate_Dir "Debug_Static"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../lib/$(PlatformName)"
# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /vmg /GR /GX /Z7 /Od /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /Zm200 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgViewerd_s.lib"
# SUBTRACT LIB32 /pdb:none
!ENDIF
# Begin Target
# Name "Core osgViewer - Win32 Release"
# Name "Core osgViewer - Win32 Debug"
# Name "Core osgViewer - Win32 Release Static"
# Name "Core osgViewer - Win32 Debug Static"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\src\osgViewer\SimpleViewer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osgViewer\Version.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter ";h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\Include\osgViewer\Export
# End Source File
# Begin Source File
SOURCE=..\..\Include\osgViewer\GraphicsWindow
# End Source File
# Begin Source File
SOURCE=..\..\Include\osgViewer\SimpleViewer
# End Source File
# Begin Source File
SOURCE=..\..\Include\osgViewer\Version
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgkeyboardmouse.cpp\
LIBS += -lProducer -losgFX -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads
LIBS += -lProducer -losgFX -losgViewer -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgkeyboardmouse.cpp\
LIBS += -lProducer -losgFX -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -lProducer -losgFX -losgViewer -losgGA -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgkeyboardmouse

View File

@ -1,6 +1,6 @@
// C++ source file - (C) 2003 Robert Osfield, released under the OSGPL.
//
// Simple example of use of Producer::RenderSurface + KeyboardMouseCallback + SceneView
// Simple example of use of Producer::RenderSurface + KeyboardMouseCallback + SimpleViewer
// example that provides the user with control over view position with basic picking.
#include <Producer/RenderSurface>
@ -11,17 +11,16 @@
#include <osg/io_utils>
#include <osg/observer_ptr>
#include <osgUtil/SceneView>
#include <osgUtil/IntersectVisitor>
#include <osgUtil/IntersectionVisitor>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgGA/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgGA/StateSetManipulator>
#include <osgViewer/SimpleViewer>
#include <osgFX/Scribe>
// ----------- Begining of glue classes to adapter Producer's keyboard mouse events to osgGA's abstraction events.
@ -138,21 +137,22 @@ public:
class PickHandler : public osgGA::GUIEventHandler {
public:
PickHandler(osgUtil::SceneView* sceneView):
_sceneView(sceneView),
PickHandler():
_mx(0.0),_my(0.0) {}
~PickHandler() {}
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
osgViewer::SimpleViewer* viewer = dynamic_cast<osgViewer::SimpleViewer*>(&aa);
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
{
if (ea.getKey()=='s')
if (ea.getKey()=='s' && viewer)
{
saveSelectedModel();
saveSelectedModel(viewer->getSceneData());
}
return false;
}
@ -168,7 +168,7 @@ public:
if (_mx == ea.getX() && _my == ea.getY())
{
// only do a pick if the mouse hasn't moved
pick(ea);
pick(ea,viewer);
}
return true;
}
@ -178,39 +178,39 @@ public:
}
}
void pick(const osgGA::GUIEventAdapter& ea)
void pick(const osgGA::GUIEventAdapter& ea, osgViewer::SimpleViewer* viewer)
{
osg::Node* scene = _sceneView.valid() ? _sceneView->getSceneData() : 0;
osg::Node* scene = viewer->getSceneData();
if (!scene) return;
// remap the mouse x,y into viewport coordinates.
osg::notify(osg::NOTICE)<<std::endl;
#if 0
// use non dimension coordinates - in projection/clip space
osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, osg::Vec3d(ea.getXnormalized(),ea.getYnormalized(),0.0), osg::Vec3d(ea.getXnormalized(),ea.getYnormalized(),1.0) );
osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, osg::Vec3d(ea.getXnormalized(),ea.getYnormalized(),-1.0), osg::Vec3d(ea.getXnormalized(),ea.getYnormalized(),1.0) );
#else
// use window coordinates
float mx = _sceneView->getViewport()->x() + (int)((float)_sceneView->getViewport()->width()*(ea.getXnormalized()*0.5f+0.5f));
float my = _sceneView->getViewport()->y() + (int)((float)_sceneView->getViewport()->height()*(ea.getYnormalized()*0.5f+0.5f));
// remap the mouse x,y into viewport coordinates.
osg::Viewport* viewport = viewer->getCamera()->getViewport();
float mx = viewport->x() + (int)((float)viewport->width()*(ea.getXnormalized()*0.5f+0.5f));
float my = viewport->y() + (int)((float)viewport->height()*(ea.getYnormalized()*0.5f+0.5f));
osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, osg::Vec3d(mx,my,0.0), osg::Vec3d(mx,my,1.0) );
#endif
osgUtil::IntersectionVisitor iv(picker);
_sceneView->getCamera()->accept(iv);
osg::notify(osg::NOTICE)<<"Done pick, "<<picker->containsIntersections()<<std::endl;
viewer->getCamera()->accept(iv);
if (picker->containsIntersections())
{
osgUtil::LineSegmentIntersector::Intersection intersection = picker->getFirstIntersection();
osg::notify(osg::NOTICE)<<"Picking "<<intersection.localIntersectionPoint<<std::endl;
osg::notify(osg::NOTICE)<<"Picked "<<intersection.localIntersectionPoint<<std::endl;
#if 0
#if 1
osg::NodePath& nodePath = intersection.nodePath;
osg::Node* node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
osg::Group* parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;
@ -247,37 +247,14 @@ public:
}
{
float mx = _sceneView->getViewport()->x() + (int)((float)_sceneView->getViewport()->width()*(ea.getXnormalized()*0.5f+0.5f));
float my = _sceneView->getViewport()->y() + (int)((float)_sceneView->getViewport()->height()*(ea.getYnormalized()*0.5f+0.5f));
// do the pick traversal use the other PickVisitor to double check results.
osgUtil::PickVisitor pick(_sceneView->getViewport(),
_sceneView->getProjectionMatrix(),
_sceneView->getViewMatrix(), mx, my);
scene->accept(pick);
osgUtil::PickVisitor::LineSegmentHitListMap& segHitList = pick.getSegHitList();
if (!segHitList.empty() && !segHitList.begin()->second.empty())
{
// get the hits for the first segment
osgUtil::PickVisitor::HitList& hits = segHitList.begin()->second;
// just take the first hit - nearest the eye point.
osgUtil::Hit& hit = hits.front();
std::cout<<"Got hits"<<hit.getLocalIntersectPoint()<<std::endl;
}
}
}
void saveSelectedModel()
void saveSelectedModel(osg::Node* scene)
{
if (!scene) return;
CreateModelToSaveVisitor cmtsv;
_sceneView->getSceneData()->accept(cmtsv);
scene->accept(cmtsv);
if (cmtsv._group->getNumChildren()>0)
{
@ -288,7 +265,6 @@ public:
protected:
osg::observer_ptr<osgUtil::SceneView> _sceneView;
float _mx,_my;
};
@ -317,7 +293,7 @@ int main( int argc, char **argv )
// create the view of the scene.
osgGA::SimpleViewer viewer;
osgViewer::SimpleViewer viewer;
viewer.setSceneData(loadedModel.get());
// set up a KeyboardMouse to manage the events comming in from the RenderSurface
@ -334,7 +310,7 @@ int main( int argc, char **argv )
viewer.addEventHandler(statesetManipulator.get());
// add the pick handler
viewer.addEventHandler(new PickHandler(viewer.getSceneView()));
viewer.addEventHandler(new PickHandler());
// set the window dimensions
viewer.getEventQueue()->getCurrentEventState()->setWindowRectangle(100,100,800,600);

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimple.cpp\
LIBS += -lProducer -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) -lOpenThreads
LIBS += -lProducer -losgViewer -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) -lOpenThreads
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimple.cpp\
LIBS += -lProducer -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -lProducer -losgViewer -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgsimple

View File

@ -7,7 +7,7 @@
#include <osgUtil/SceneView>
#include <osgDB/ReadFile>
#include <osgGA/SimpleViewer>
#include <osgViewer/SimpleViewer>
int main( int argc, char **argv )
@ -34,7 +34,7 @@ int main( int argc, char **argv )
renderSurface->realize();
osgGA::SimpleViewer viewer;
osgViewer::SimpleViewer viewer;
viewer.setSceneData(loadedModel.get());
// initialize the view to look at the center of the scene graph

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerFLTK.cpp\
LIBS += -losgGA -losgDB -losgUtil -losg -lfltk -lfltk_gl $(GL_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lfltk -lfltk_gl $(GL_LIBS) $(OTHER_LIBS)
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerQT3.cpp\
LIBS += -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgsimpleviewerQT3

View File

@ -3,7 +3,7 @@
// Simple example using GLUT to create an OpenGL window and OSG for rendering.
// Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp
#include <osgGA/SimpleViewer>
#include <osgViewer/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
@ -12,7 +12,7 @@
#include <iostream>
class GraphicsWindowFLTK : public Fl_Gl_Window, virtual osgGA::GraphicsWindow
class GraphicsWindowFLTK : public Fl_Gl_Window, virtual osgViewer::GraphicsWindow
{
public:
@ -70,7 +70,7 @@ void idle_cb()
}
class SimpleViewerFLTK : public osgGA::SimpleViewer, public GraphicsWindowFLTK
class SimpleViewerFLTK : public osgViewer::SimpleViewer, public GraphicsWindowFLTK
{
public:
SimpleViewerFLTK(int x, int y, int w, int h, const char *label=0):

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerGLUT.cpp\
LIBS += -losgGA -losgDB -losgUtil -losg $(GLUT_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg $(GLUT_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerGLUT.cpp\
LIBS += -losgGA -losgDB -losgUtil -losg -lglut $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lglut $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgsimpleviewerGLUT

View File

@ -13,11 +13,11 @@
# include <GL/glut.h>
#endif
#include <osgGA/SimpleViewer>
#include <osgViewer/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
osg::ref_ptr<osgGA::SimpleViewer> viewer;
osg::ref_ptr<osgViewer::SimpleViewer> viewer;
void display(void)
{
@ -89,7 +89,7 @@ int main( int argc, char **argv )
glutKeyboardFunc( keyboard );
// create the view of the scene.
viewer = new osgGA::SimpleViewer;
viewer = new osgViewer::SimpleViewer;
viewer->setSceneData(loadedModel.get());
viewer->setCameraManipulator(new osgGA::TrackballManipulator);

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerProducer.cpp\
LIBS += -lProducer -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads
LIBS += -lProducer -losgViewer -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerProducer.cpp\
LIBS += -lProducer -losgGA -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -lProducer -losgViewer -losgGA -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgsimpleviewerProducer

View File

@ -8,7 +8,7 @@
#include <osgDB/ReadFile>
#include <osgGA/SimpleViewer>
#include <osgViewer/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgGA/StateSetManipulator>
@ -81,7 +81,7 @@ private:
// first approach uses a custom GraphicsWindow
// then uses multiple inheritance to create a SimpleViewerWindowProducer
class GraphicsWindowProducer : public virtual osgGA::GraphicsWindow, public Producer::RenderSurface
class GraphicsWindowProducer : public virtual osgViewer::GraphicsWindow, public Producer::RenderSurface
{
public:
@ -120,7 +120,7 @@ class GraphicsWindowProducer : public virtual osgGA::GraphicsWindow, public Prod
osg::ref_ptr<MyKeyboardMouseCallback> _kbmcb;
};
class SimplerViewerProducer : public osgGA::SimpleViewer, public GraphicsWindowProducer
class SimplerViewerProducer : public osgViewer::SimpleViewer, public GraphicsWindowProducer
{
public:
SimplerViewerProducer() {}
@ -198,7 +198,7 @@ int main( int argc, char **argv )
// create the view of the scene.
osgGA::SimpleViewer viewer;
osgViewer::SimpleViewer viewer;
viewer.setSceneData(loadedModel.get());
// set up a KeyboardMouse to manage the events comming in from the RenderSurface

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerQT3.cpp\
LIBS += -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(OTHER_LIBS)
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerQT3.cpp\
LIBS += -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgsimpleviewerQT3

View File

@ -3,7 +3,7 @@
// Simple example using GLUT to create an OpenGL window and OSG for rendering.
// Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp
#include <osgGA/SimpleViewer>
#include <osgViewer/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
@ -14,7 +14,7 @@ class QWidget;
#include <iostream>
class GraphicsWindowQT : public QGLWidget, virtual public osgGA::GraphicsWindow
class GraphicsWindowQT : public QGLWidget, virtual public osgViewer::GraphicsWindow
{
public:
@ -89,7 +89,7 @@ void GraphicsWindowQT::mouseMoveEvent( QMouseEvent* event )
}
class SimpleViewerQT : public osgGA::SimpleViewer, public GraphicsWindowQT
class SimpleViewerQT : public osgViewer::SimpleViewer, public GraphicsWindowQT
{
public:
SimpleViewerQT() {}

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerQT4.cpp\
LIBS += -losgGA -losgDB -losgUtil -losg -lQtOpenGL -lQtGui -lQtCore $(GL_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lQtOpenGL -lQtGui -lQtCore $(GL_LIBS) $(OTHER_LIBS)
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerQT4.cpp\
LIBS += -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgsimpleviewerQT4

View File

@ -3,7 +3,7 @@
// Simple example using GLUT to create an OpenGL window and OSG for rendering.
// Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp
#include <osgGA/SimpleViewer>
#include <osgViewer/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
@ -14,7 +14,7 @@
#include <iostream>
class GraphicsWindowQT : public QGLWidget, virtual osgGA::GraphicsWindow
class GraphicsWindowQT : public QGLWidget, virtual osgViewer::GraphicsWindow
{
public:
@ -89,7 +89,7 @@ void GraphicsWindowQT::mouseMoveEvent( QMouseEvent* event )
}
class SimpleViewerQT : public osgGA::SimpleViewer, public GraphicsWindowQT
class SimpleViewerQT : public osgViewer::SimpleViewer, public GraphicsWindowQT
{
public:
SimpleViewerQT() {}

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerSDL.cpp\
LIBS += -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
INSTFILES = \
$(CXXFILES)\

View File

@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgsimpleviewerSDL.cpp\
LIBS += -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgsimpleviewerSDL

View File

@ -3,7 +3,7 @@
// Simple example using GLUT to create an OpenGL window and OSG for rendering.
// Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp
#include <osgGA/SimpleViewer>
#include <osgViewer/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
@ -90,7 +90,7 @@ int main( int argc, char **argv )
SDL_EnableUNICODE(1);
osgGA::SimpleViewer viewer;
osgViewer::SimpleViewer viewer;
viewer.setSceneData(loadedModel.get());
viewer.setCameraManipulator(new osgGA::TrackballManipulator);
viewer.getEventQueue()->windowResize(0, 0, windowWidth, windowHeight );

72
include/osgViewer/Export Normal file
View File

@ -0,0 +1,72 @@
/* -*-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.
*/
// The following symbol has a underscore suffix for compatibility.
#ifndef OSGVIEWER_EXPORT_
#define OSGVIEWER_EXPORT_ 1
#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__))
#pragma warning( disable : 4244 )
#pragma warning( disable : 4251 )
#pragma warning( disable : 4267 )
#pragma warning( disable : 4275 )
#pragma warning( disable : 4290 )
#pragma warning( disable : 4786 )
#pragma warning( disable : 4305 )
#pragma warning( disable : 4996 )
#endif
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
# if defined( OSG_LIBRARY_STATIC )
# define OSGVIEWER_EXPORT
# elif defined( OSGVIEWER_LIBRARY )
# define OSGVIEWER_EXPORT __declspec(dllexport)
# else
# define OSGVIEWER_EXPORT __declspec(dllimport)
#endif
#else
#define OSGVIEWER_EXPORT
#endif
#endif
/**
\namespace osgViewer
The 'GA' in osgViewer stands for 'GUI Abstraction'; the osgViewer namespace provides facilities to
help developers write the glue to allow the osg to work with varying window systems.
As a cross-platform, window system-agnostic class library, the OpenSceneGraph
has no direct ties to any given windowing environment. Viewers, however, must at
some level interact with a window system - where Window system may refer to a windowing
API, e.g. GLUT, Qt, FLTK, MFC, ...
There is much commonality in the implementation of Viewers for varying windowing
environments. E.g. most Viewers will update a Camera position in response to a mouse
event, and may request that a timer be started as a result of a model being 'spun'.
The purpose of the osgViewer namespace is to centralise the common areas of this
functionality. The viewer writer needs then only write a GUIEventAdapter, a
GUIActionAdapter, and assemble a collection of GUIEventHandlers
as appropriate for the viewer.
Events from the windowing environment are adpated, and then fed into the GUIEventHandlers.
The GUIEventHandlers analyse and take action, and make requests of the windowing
environemnt via the GUIActionAdapter. The viewer writer should then honour these
requests, translating them into calls to the windowing API.
*/

View File

@ -11,15 +11,17 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_GRAPHICWINDOW
#define OSG_GRAPHICWINDOW 1
#ifndef OSGVIEWER_GRAPHICWINDOW
#define OSGVIEWER_GRAPHICWINDOW 1
#include <osg/GraphicsContext>
#include <osg/Notify>
#include <osgGA/EventQueue>
namespace osgGA {
#include <osgViewer/Export>
namespace osgViewer {
/** Base class for providing Windowing API agnostic access to creating and managing graphisc window and events.
* Note, the GraphicsWindow is subclassed from osg::GraphicsContext, and to provide an implemention you'll need to implement its
@ -27,7 +29,7 @@ namespace osgGA {
* GraphicsWindow adds the event queue ontop of the GraphicsContext, thereby adding a mechnism for adapting Windowing events
* as well as basics graphics context work, you should wire up custom GraphicsWindowImplementation to push their events through
* into the EventQueue. */
class OSGGA_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgGA::GUIActionAdapter
class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgGA::GUIActionAdapter
{
public:

View File

@ -11,21 +11,22 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGGA_SimpleViewer
#define OSGGA_SimpleViewer 1
#ifndef OSGVIEWER_SimpleViewer
#define OSGVIEWER_SimpleViewer 1
#include <osgGA/EventVisitor>
#include <osgGA/MatrixManipulator>
#include <osgGA/GraphicsWindow>
#include <osgViewer/GraphicsWindow>
#include <osgDB/DatabasePager>
#include <list>
namespace osgGA{
namespace osgViewer{
/** SimpleViewer provide a simple interface for setting up rendering of an scene graph, using a single camera view within a single window.*/
class OSGGA_EXPORT SimpleViewer : public virtual osgGA::GraphicsWindow
class OSGVIEWER_EXPORT SimpleViewer : public virtual osgViewer::GraphicsWindow
{
public:
@ -39,14 +40,14 @@ class OSGGA_EXPORT SimpleViewer : public virtual osgGA::GraphicsWindow
osg::CameraNode* getCamera();
const osg::CameraNode* getCamera() const;
void setCameraManipulator(MatrixManipulator* manipulator);
MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
const MatrixManipulator* getCameraManipulator() const { return _cameraManipulator.get(); }
void setCameraManipulator(osgGA::MatrixManipulator* manipulator);
osgGA::MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
const osgGA::MatrixManipulator* getCameraManipulator() const { return _cameraManipulator.get(); }
typedef std::list< osg::ref_ptr<GUIEventHandler> > EventHandlers;
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
void addEventHandler(GUIEventHandler* eventHandler);
void addEventHandler(osgGA::GUIEventHandler* eventHandler);
EventHandlers& getEventHandlers() { return _eventHandlers; }
const EventHandlers& getEventHandlers() const { return _eventHandlers; }

48
include/osgViewer/Version Normal file
View File

@ -0,0 +1,48 @@
/* -*-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 OSGVIEWER_VERSION
#define OSGVIEWER_VERSION 1
#include <osgViewer/Export>
extern "C" {
/**
* osgViewerGetVersion() returns the library version number.
* Numbering convention : OpenSceneGraph-1.0 will return 1.0 from osgViewerGetVersion.
*
* This C function can be also used to check for the existence of the OpenSceneGraph
* library using autoconf and its m4 macro AC_CHECK_LIB.
*
* Here is the code to add to your configure.in:
\verbatim
#
# Check for the OpenSceneGraph (OSG) utility library
#
AC_CHECK_LIB(osg, osgViewerGetVersion, ,
[AC_MSG_ERROR(OpenSceneGraph utility library not found. See http://www.openscenegraph.org)],)
\endverbatim
*/
extern OSGVIEWER_EXPORT const char* osgViewerGetVersion();
/**
* getLibraryName_osgViewer() returns the library name in human friendly form.
*/
extern OSGVIEWER_EXPORT const char* osgViewerGetLibraryName();
}
#endif

View File

@ -14,7 +14,6 @@ CXXFILES = \
GUIEventHandler.cpp\
KeySwitchMatrixManipulator.cpp\
StateSetManipulator.cpp\
SimpleViewer.cpp\
TerrainManipulator.cpp\
NodeTrackerManipulator.cpp\
TrackballManipulator.cpp\
@ -22,7 +21,7 @@ CXXFILES = \
DEF += -DOSGGA_LIBRARY
LIBS += -losgDB -losgUtil -losg $(GL_LIBS) $(OTHER_LIBS)
LIBS += -losgUtil -losg $(GL_LIBS) $(OTHER_LIBS)
TARGET_BASENAME = osgGA
LIB = $(LIB_PREFIX)$(TARGET_BASENAME).$(LIB_EXT)

16
src/osgViewer/GNUmakefile Normal file
View File

@ -0,0 +1,16 @@
TOPDIR = ../..
include $(TOPDIR)/Make/makedefs
CXXFILES = \
SimpleViewer.cpp\
Version.cpp\
DEF += -DOSGVIEWER_LIBRARY
LIBS += -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(OTHER_LIBS)
TARGET_BASENAME = osgViewer
LIB = $(LIB_PREFIX)$(TARGET_BASENAME).$(LIB_EXT)
include $(TOPDIR)/Make/makerules

View File

@ -11,10 +11,9 @@
* OpenSceneGraph Public License for more details.
*/
#include <osgGA/SimpleViewer>
#include <osgGA/TrackballManipulator>
#include <osgViewer/SimpleViewer>
using namespace osgGA;
using namespace osgViewer;
SimpleViewer::SimpleViewer():
_firstFrame(true)
@ -80,7 +79,7 @@ const osg::CameraNode* SimpleViewer::getCamera() const
return _sceneView->getCamera();
}
void SimpleViewer::setCameraManipulator(MatrixManipulator* manipulator)
void SimpleViewer::setCameraManipulator(osgGA::MatrixManipulator* manipulator)
{
if (_cameraManipulator == manipulator) return;
@ -94,7 +93,7 @@ void SimpleViewer::setCameraManipulator(MatrixManipulator* manipulator)
}
}
void SimpleViewer::addEventHandler(GUIEventHandler* eventHandler)
void SimpleViewer::addEventHandler(osgGA::GUIEventHandler* eventHandler)
{
_eventHandlers.push_back(eventHandler);
}

12
src/osgViewer/Version.cpp Normal file
View File

@ -0,0 +1,12 @@
#include <osgGA/Version>
const char* osgGAGetVersion()
{
return "1.2";
}
const char* osgGAGetLibraryName()
{
return "OpenSceneGraph Gui Adapter Library";
}