Moved the include/osgTXP back into src/osgPlugins/txp as a seperate include directory is no longer required.
Removed the osgtxp demo as it is no longer required.
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
osgtxp.cpp\
|
||||
TrPageViewer.cpp\
|
||||
|
||||
LIBS += $(OSG_LIBS) $(GLUT_LIB) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
LIBS += -losgTXP
|
||||
|
||||
INSTFILES = \
|
||||
$(CXXFILES)\
|
||||
Makefile.inst=Makefile
|
||||
|
||||
EXEC = osgtxp
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <osg/GL>
|
||||
#include <osgGLUT/glut>
|
||||
|
||||
#include <stdlib.h>
|
||||
#if (!defined(WIN32) && !defined(macintosh)) || defined(__CYGWIN__)
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include <osg/Math>
|
||||
#include <osg/Statistics>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <osgGLUT/Viewer>
|
||||
#include <osgGLUT/GLUTEventAdapter>
|
||||
|
||||
#include <osg/Switch>
|
||||
#include <osg/Billboard>
|
||||
#include <osg/LOD>
|
||||
#include <osg/Light>
|
||||
#include <osg/LightSource>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Group>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/LineSegment>
|
||||
#include <osg/PolygonMode>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/LightModel>
|
||||
#include <osg/ShadeModel>
|
||||
#include <osg/Notify>
|
||||
#include <osg/CollectOccludersVisitor>
|
||||
|
||||
#include <osg/Fog>
|
||||
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
#include <osgUtil/IntersectVisitor>
|
||||
#include <osgUtil/DisplayListVisitor>
|
||||
#include <osgUtil/SmoothingVisitor>
|
||||
#include <osgUtil/TriStripVisitor>
|
||||
#include <osgUtil/DisplayRequirementsVisitor>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
|
||||
#include <osg/Version>
|
||||
#include <osgUtil/Version>
|
||||
|
||||
#ifdef WIN32
|
||||
#define USE_FLTK
|
||||
#define USE_GLUT
|
||||
#endif
|
||||
|
||||
#include <osgTXP/TrPageArchive.h>
|
||||
#include "TrPageViewer.h"
|
||||
|
||||
/*
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
#include <sys/timeb.h>
|
||||
#else
|
||||
#endif
|
||||
*/
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgUtil;
|
||||
using namespace osgGLUT;
|
||||
using namespace osgGA;
|
||||
|
||||
using namespace std;
|
||||
using namespace txp;
|
||||
|
||||
PagingViewer::PagingViewer() : Viewer()
|
||||
{
|
||||
pageManage = NULL;
|
||||
}
|
||||
|
||||
bool PagingViewer::Init(OSGPageManager *in_manage,OSGPageManager::ThreadMode threadMode)
|
||||
{
|
||||
pageManage = in_manage;
|
||||
|
||||
// Start up the thread if needed
|
||||
if (threadMode != OSGPageManager::ThreadNone) {
|
||||
ThreadID newThread;
|
||||
pageManage->StartThread(threadMode,newThread);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* App call
|
||||
This replaces the app() call for the base viewer.
|
||||
In this one, we ask the page manager to load stuff in.
|
||||
*/
|
||||
float PagingViewer::app(unsigned int viewport)
|
||||
{
|
||||
osg::Timer_t beforeApp = _timer.tick();
|
||||
|
||||
// update the camera manipulator.
|
||||
osg::ref_ptr<GLUTEventAdapter> ea = new GLUTEventAdapter;
|
||||
ea->adaptFrame(_frameStamp->getReferenceTime());
|
||||
|
||||
bool handled = false;
|
||||
for (EventHandlerList::iterator eh = _viewportList[viewport]._eventHandlerList.begin(); eh != _viewportList[viewport]._eventHandlerList.end();
|
||||
eh++ )
|
||||
{
|
||||
if ( eh->valid() )
|
||||
{
|
||||
if ( (*eh)->handle(*ea,*this) )
|
||||
{
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_viewportList[viewport]._cameraManipulator->handle(*ea,*this);
|
||||
|
||||
if (getRecordingAnimationPath() && getAnimationPath())
|
||||
{
|
||||
osg::Camera* camera = getViewportSceneView(viewport)->getCamera();
|
||||
osg::Matrix matrix;
|
||||
matrix.invert(camera->getModelViewMatrix());
|
||||
osg::Quat quat;
|
||||
quat.set(matrix);
|
||||
getAnimationPath()->insert(_frameStamp->getReferenceTime(),osg::AnimationPath::ControlPoint(matrix.getTrans(),quat));
|
||||
}
|
||||
|
||||
// Update the paging
|
||||
if (pageManage) {
|
||||
int numTile = 1;
|
||||
osgUtil::SceneView *sceneView = getViewportSceneView(viewport);
|
||||
osg::Camera *camera = sceneView->getCamera();
|
||||
const Vec3 &eyePt = camera->getEyePoint();
|
||||
double eyeX = eyePt[0];
|
||||
double eyeY = eyePt[1];
|
||||
|
||||
/* If we're in ThreadFree mode, merge in whatever may be ready.
|
||||
If we're in non-thread mode, load in the given number of tiles (maximum).
|
||||
*/
|
||||
if (pageManage->GetThreadMode() == OSGPageManager::ThreadFree) {
|
||||
pageManage->MergeUpdateThread((osg::Group *)sceneView->getSceneData());
|
||||
pageManage->UpdatePositionThread(eyeX,eyeY);
|
||||
} else {
|
||||
pageManage->UpdateNoThread((osg::Group *)sceneView->getSceneData(),eyeX,eyeY,numTile);
|
||||
}
|
||||
}
|
||||
|
||||
// do app traversal.
|
||||
|
||||
getViewportSceneView(viewport)->setFrameStamp(_frameStamp.get());
|
||||
getViewportSceneView(viewport)->app();
|
||||
|
||||
osg::Timer_t beforeCull = _timer.tick();
|
||||
|
||||
return _timer.delta_m(beforeApp,beforeCull);
|
||||
}
|
||||
|
||||
bool PagingViewer::run()
|
||||
{
|
||||
updateFrameTick();
|
||||
return Window::run();
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* **************************************************************************
|
||||
* OpenSceneGraph loader for Terrapage format database
|
||||
*
|
||||
* That loader is redistributed under the terms listed on Terrain Experts
|
||||
* website (www.terrex.com/www/pages/technology/technologypage.htm)
|
||||
*
|
||||
* "TerraPage is provided as an Open Source format for use by anyone...
|
||||
* We supply the TerraPage C++ source code free of charge. Anyone
|
||||
* can use it and redistribute it as needed (including our competitors).
|
||||
* We do, however, ask that you keep the TERREX copyrights intact."
|
||||
*
|
||||
* Copyright Terrain Experts Inc. 1999.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _TRPAGEVIEWER_H_
|
||||
#define _TRPAGEVIEWER_H_
|
||||
|
||||
#include <osg/Light>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Timer>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include <osgUtil/SceneView>
|
||||
|
||||
#include <osgGLUT/Window>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <osgTXP/trPagePageManager.h>
|
||||
|
||||
namespace txp
|
||||
{
|
||||
/* Paging Viewer
|
||||
Variant of the regular viewer which knows to call
|
||||
the Page Manager at the beginning of each app() phase.
|
||||
*/
|
||||
class PagingViewer : public osgGLUT::Viewer {
|
||||
public:
|
||||
PagingViewer();
|
||||
bool Init(OSGPageManager *,txp::OSGPageManager::ThreadMode = txp::OSGPageManager::ThreadNone);
|
||||
|
||||
// called on each frame redraw..return the time in ms for each operation.
|
||||
virtual float app(unsigned int viewport);
|
||||
// The default Viewer resets the cameras at the beginning of the run()
|
||||
// This is annoying.
|
||||
bool run();
|
||||
protected:
|
||||
OSGPageManager *pageManage;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,179 +0,0 @@
|
||||
#include <osg/GL>
|
||||
#include <osgGLUT/glut>
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
|
||||
#include <osgTXP/TrPageArchive.h>
|
||||
#include "TrPageViewer.h"
|
||||
|
||||
|
||||
void write_usage(std::ostream& out,const std::string& name)
|
||||
{
|
||||
out << std::endl;
|
||||
out <<"usage:"<< std::endl;
|
||||
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
|
||||
out << std::endl;
|
||||
out <<"options:"<< std::endl;
|
||||
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
|
||||
out <<" i.e. -l osgdb_pfb"<< std::endl;
|
||||
out <<" Useful for loading reader/writers which can load"<< std::endl;
|
||||
out <<" other file formats in addition to its extension."<< std::endl;
|
||||
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
|
||||
out <<" i.e. -e pfb"<< std::endl;
|
||||
out <<" Useful short hand for specifying full library name as"<< std::endl;
|
||||
out <<" done with -l above, as it automatically expands to"<< std::endl;
|
||||
out <<" the full library name appropriate for each platform."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
|
||||
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
|
||||
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
|
||||
out <<" further details on setting up accurate stereo "<< std::endl;
|
||||
out <<" for your system. "<< std::endl;
|
||||
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
|
||||
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
|
||||
out <<std::endl;
|
||||
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
|
||||
out <<" also allows the depth complexity statistics mode"<< std::endl;
|
||||
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
|
||||
out <<" -f - start with a full screen, borderless window." << std::endl;
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
using namespace txp;
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// initialize the GLUT
|
||||
glutInit( &argc, argv );
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
write_usage(std::cout,argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// create the commandline args.
|
||||
std::vector<std::string> commandLine;
|
||||
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
|
||||
|
||||
// initialize the viewer.
|
||||
PagingViewer *viewer = new PagingViewer();
|
||||
viewer->setWindowTitle(argv[0]);
|
||||
|
||||
// configure the viewer from the commandline arguments, and eat any
|
||||
// parameters that have been matched.
|
||||
viewer->readCommandLine(commandLine);
|
||||
|
||||
// configure the plugin registry from the commandline arguments, and
|
||||
// eat any parameters that have been matched.
|
||||
//osgDB::readCommandLine(commandLine);
|
||||
|
||||
// Initialize the TXP database
|
||||
bool loadAll = false;
|
||||
bool threadIt = false;
|
||||
std::string fileName;
|
||||
for(std::vector<std::string>::iterator itr=commandLine.begin();
|
||||
itr!=commandLine.end();
|
||||
++itr)
|
||||
{
|
||||
if ((*itr)[0]!='-')
|
||||
{
|
||||
fileName = (*itr);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Look for switches we want
|
||||
if (*itr=="-loadall")
|
||||
{
|
||||
loadAll = true;
|
||||
continue;
|
||||
}
|
||||
if (*itr=="-thread")
|
||||
{
|
||||
threadIt = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fileName.empty()) {
|
||||
fprintf(stderr,"No TerraPage file specified on command line.\n");
|
||||
return 1;
|
||||
}
|
||||
// Open the TXP database
|
||||
TrPageArchive *txpArchive = new TrPageArchive();
|
||||
if (!txpArchive->OpenFile(fileName.c_str()))
|
||||
{
|
||||
fprintf(stderr,"Couldn't load TerraPage archive %s.\n",fileName.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Note: Should be checking the return values
|
||||
txpArchive->LoadMaterials();
|
||||
// txpArchive->LoadModels();
|
||||
|
||||
// Might need a page manager if we're paging
|
||||
OSGPageManager *pageManager = new OSGPageManager(txpArchive);
|
||||
osg::Group *rootNode=NULL;
|
||||
if (loadAll) {
|
||||
// Load the whole scenegraph
|
||||
rootNode = txpArchive->LoadAllTiles();
|
||||
if (!rootNode) {
|
||||
fprintf(stderr,"Couldn't load whole TerraPage archive %s.\n",fileName.c_str());
|
||||
return 1;
|
||||
}
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer->addViewport( rootNode );
|
||||
} else {
|
||||
viewer->Init(pageManager,(threadIt ? txp::OSGPageManager::ThreadFree : txp::OSGPageManager::ThreadNone));
|
||||
rootNode = new osg::Group();
|
||||
viewer->addViewport(rootNode);
|
||||
}
|
||||
|
||||
// run optimization over the scene graph
|
||||
// osgUtil::Optimizer optimzer;
|
||||
// optimzer.optimize(rootnode);
|
||||
|
||||
|
||||
// register trackball, flight and drive.
|
||||
viewer->registerCameraManipulator(new osgGA::TrackballManipulator);
|
||||
viewer->registerCameraManipulator(new osgGA::FlightManipulator);
|
||||
viewer->registerCameraManipulator(new osgGA::DriveManipulator);
|
||||
|
||||
// Recenter the camera to the middle of the database
|
||||
osg::Vec3 center;
|
||||
txpArchive->GetCenter(center); center[2] += 200;
|
||||
osgUtil::SceneView *sceneView = viewer->getViewportSceneView(0);
|
||||
osg::Camera *camera = sceneView->getCamera();
|
||||
osg::Vec3 eyePt = center;
|
||||
eyePt[0] -= 1000;
|
||||
osg::Vec3 upVec( 0, 0, 1 );
|
||||
camera->setLookAt(eyePt,center,upVec);
|
||||
|
||||
// open the viewer window.
|
||||
viewer->open();
|
||||
|
||||
// fire up the event loop.
|
||||
viewer->run();
|
||||
|
||||
|
||||
// Close things down
|
||||
// (note from Robert Osfield, umm.... we should be using ref_ptr<> for handling memory here, this isn't robust..)
|
||||
delete pageManager;
|
||||
delete txpArchive;
|
||||
delete viewer;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user