Renamed osgProducer::CameraGroup and SceneHandler to OsgCameraGroup and
OsgSceneHandler to avoid the namespace bug under VS6. Removed the osgproducer demo (its now been replaced by examples/osgviewer.)
This commit is contained in:
parent
b32c8c65f3
commit
2f74b2cf7c
@ -108,7 +108,6 @@ DEMOS_DIRS = \
|
||||
osgoccluder\
|
||||
osgparticle\
|
||||
osgprerender\
|
||||
osgproducer\
|
||||
osgshadowtexture\
|
||||
osgreflect\
|
||||
osgscribe\
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <osgGA/KeySwitchCameraManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
|
||||
#include <osgProducer/CameraGroup>
|
||||
#include <osgProducer/SceneHandler>
|
||||
#include <osgProducer/OsgCameraGroup>
|
||||
#include <osgProducer/OsgSceneHandler>
|
||||
#include <osgProducer/KeyboardMouseCallback>
|
||||
#include <osgProducer/ActionAdapter>
|
||||
|
||||
@ -53,9 +53,9 @@ int main( int argc, char **argv )
|
||||
|
||||
|
||||
// create the camera group.
|
||||
osgProducer::CameraGroup *cg = configFile.empty() ?
|
||||
(new osgProducer::CameraGroup()):
|
||||
(new osgProducer::CameraGroup(configFile));
|
||||
osgProducer::OsgCameraGroup *cg = configFile.empty() ?
|
||||
(new osgProducer::OsgCameraGroup()):
|
||||
(new osgProducer::OsgCameraGroup(configFile));
|
||||
|
||||
// set up the maximum number of graphics contexts, before loading the scene graph
|
||||
// to ensure that texture objects and display buffers are configured to the correct size.
|
||||
|
@ -11,26 +11,14 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#include <osgProducer/Viewer>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgProducer/Viewer>
|
||||
|
||||
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Notify>
|
||||
#include <osg/MatrixTransform>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgGLUT/glut>
|
||||
#include <osgGLUT/Viewer>
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
@ -116,7 +104,7 @@ int main( int argc, char **argv )
|
||||
viewer.realize(Producer::CameraGroup::ThreadPerCamera);
|
||||
|
||||
// set all the sceneview's up so that their left and right add cull masks are set up.
|
||||
for(osgProducer::CameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin();
|
||||
for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin();
|
||||
itr!=viewer.getSceneHandlerList().end();
|
||||
++itr)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ class FrameStatsHandler : public Producer::CameraGroup::StatsHandler, public Pro
|
||||
double x1=0.0, x2=0.0, y1=0.0, y2=0.0;
|
||||
for(unsigned int frame = 0; frame < _fs.size(); frame++ )
|
||||
{
|
||||
CameraGroup::FrameStats fs = _fs[(lindex + frame) % _fs.size()];
|
||||
Producer::CameraGroup::FrameStats fs = _fs[(lindex + frame) % _fs.size()];
|
||||
y1 = 0.0;
|
||||
y2 = y1 + 10;
|
||||
x1 = fs._startOfUpdate - zero;
|
||||
|
@ -11,8 +11,8 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSG_CAMERA_GROUP_H
|
||||
#define OSG_CAMERA_GROUP_H
|
||||
#ifndef OSGPRODUCER_OSGCAMERAGROUP_H
|
||||
#define OSGPRODUCER_OSGCAMERAGROUP_H 1
|
||||
|
||||
|
||||
#include <Producer/CameraGroup>
|
||||
@ -23,26 +23,26 @@
|
||||
#include <osg/FrameStamp>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
#include <osgProducer/SceneHandler>
|
||||
#include <osgProducer/OsgSceneHandler>
|
||||
|
||||
namespace osgProducer {
|
||||
|
||||
class OSGPRODUCER_EXPORT CameraGroup : public Producer::CameraGroup
|
||||
class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
{
|
||||
public :
|
||||
|
||||
CameraGroup();
|
||||
OsgCameraGroup();
|
||||
|
||||
CameraGroup(Producer::CameraConfig *cfg);
|
||||
OsgCameraGroup(Producer::CameraConfig *cfg);
|
||||
|
||||
CameraGroup(const std::string& configFile);
|
||||
OsgCameraGroup(const std::string& configFile);
|
||||
|
||||
CameraGroup(osg::ArgumentParser& arguments);
|
||||
OsgCameraGroup(osg::ArgumentParser& arguments);
|
||||
|
||||
virtual ~CameraGroup() {}
|
||||
virtual ~OsgCameraGroup() {}
|
||||
|
||||
|
||||
typedef std::vector <osgProducer::SceneHandler *> SceneHandlerList;
|
||||
typedef std::vector <osgProducer::OsgSceneHandler*> SceneHandlerList;
|
||||
|
||||
|
||||
SceneHandlerList& getSceneHandlerList() { return _shvec;}
|
@ -11,8 +11,8 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGPRODUCER_SCENEHANDLER
|
||||
#define OSGPRODUCER_SCENEHANDLER 1
|
||||
#ifndef OSGPRODUCER_OSGSCENEHANDLER
|
||||
#define OSGPRODUCER_OSGSCENEHANDLER 1
|
||||
|
||||
#include <osgProducer/Export>
|
||||
|
||||
@ -22,11 +22,11 @@
|
||||
|
||||
namespace osgProducer {
|
||||
|
||||
class OSGPRODUCER_EXPORT SceneHandler : public Producer::Camera::SceneHandler, public osgUtil::SceneView
|
||||
class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler, public osgUtil::SceneView
|
||||
{
|
||||
public :
|
||||
|
||||
SceneHandler( osg::DisplaySettings *ds = NULL);
|
||||
OsgSceneHandler( osg::DisplaySettings *ds = NULL);
|
||||
|
||||
/// override the init method to force it be run one at a time.
|
||||
virtual void init();
|
||||
@ -40,7 +40,7 @@ class OSGPRODUCER_EXPORT SceneHandler : public Producer::Camera::SceneHandler, p
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~SceneHandler() {}
|
||||
virtual ~OsgSceneHandler() {}
|
||||
|
||||
osg::ref_ptr<osg::RefMatrix> mm;
|
||||
osg::ref_ptr<osg::RefMatrix> pm;
|
@ -23,14 +23,14 @@
|
||||
#include <osgGA/GUIEventHandler>
|
||||
#include <osgGA/KeySwitchCameraManipulator>
|
||||
|
||||
#include <osgProducer/CameraGroup>
|
||||
#include <osgProducer/OsgCameraGroup>
|
||||
#include <osgProducer/KeyboardMouseCallback>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace osgProducer {
|
||||
|
||||
class OSGPRODUCER_EXPORT Viewer : public CameraGroup, public osgGA::GUIActionAdapter
|
||||
class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIActionAdapter
|
||||
{
|
||||
public :
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
TOPDIR = ../../../
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
osgproducer_viewer.cpp\
|
||||
|
||||
LIBS += -losgProducer -lProducer $(OSG_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
INSTFILES = \
|
||||
$(CXXFILES)\
|
||||
Makefile.inst=Makefile
|
||||
|
||||
EXEC = osgproducer
|
||||
|
||||
CXXFLAGS += $(PRODUCER_INCLUDE_DIR)
|
||||
LDFLAGS += $(PRODUCER_LIB_DIR)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
||||
|
@ -1,15 +0,0 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
osgproducer_viewer.cpp\
|
||||
|
||||
LIBS += -losgProducer -lProducer $(OSG_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
EXEC = osgproducer
|
||||
|
||||
CXXFLAGS += $(PRODUCER_INCLUDE_DIR)
|
||||
LDFLAGS += $(PRODUCER_LIB_DIR)
|
||||
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
@ -1,220 +0,0 @@
|
||||
//C++ source file - Open Producer - Copyright (C) 2002 Don Burns
|
||||
//Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
// Simple example of use of Producer::RenderSurface
|
||||
// The myGraphics class is a simple sample of how one would implement
|
||||
// graphics drawing with Producer::RenderSurface
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Producer/Camera>
|
||||
#include <Producer/CameraConfig>
|
||||
#include <Producer/InputArea>
|
||||
#include <Producer/KeyboardMouse>
|
||||
|
||||
#include <osg/Timer>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgUtil/UpdateVisitor>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/FlightManipulator>
|
||||
#include <osgGA/DriveManipulator>
|
||||
#include <osgGA/KeySwitchCameraManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
|
||||
#include <osgProducer/CameraGroup>
|
||||
#include <osgProducer/SceneHandler>
|
||||
#include <osgProducer/KeyboardMouseCallback>
|
||||
#include <osgProducer/ActionAdapter>
|
||||
|
||||
#include <list>
|
||||
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// threading model.
|
||||
Producer::CameraGroup::ThreadingModel threadingModel = Producer::CameraGroup::SingleThreaded;
|
||||
threadingModel = Producer::CameraGroup::ThreadPerCamera;
|
||||
|
||||
// configuration file.
|
||||
std::string configFile;
|
||||
//configFile = "twoWindows.cfg";
|
||||
|
||||
// set up the database files to read.
|
||||
std::vector<std::string> filenameList;
|
||||
if (argc>1) filenameList.push_back(argv[1]);
|
||||
else filenameList.push_back("cow.osg");
|
||||
|
||||
|
||||
|
||||
// create the camera group.
|
||||
osgProducer::CameraGroup *cg = configFile.empty() ?
|
||||
(new osgProducer::CameraGroup()):
|
||||
(new osgProducer::CameraGroup(configFile));
|
||||
|
||||
// set up the maximum number of graphics contexts, before loading the scene graph
|
||||
// to ensure that texture objects and display buffers are configured to the correct size.
|
||||
osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts( cg->getNumberOfCameras() );
|
||||
|
||||
|
||||
// read the scene.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(filenameList);
|
||||
if (!loadedModel) return 1;
|
||||
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get());
|
||||
|
||||
|
||||
// set up the keyboard and mouse handling.
|
||||
Producer::InputArea *ia = cg->getCameraConfig()->getInputArea();
|
||||
Producer::KeyboardMouse *kbm = ia ?
|
||||
(new Producer::KeyboardMouse(ia)) :
|
||||
(new Producer::KeyboardMouse(cg->getCamera(0)->getRenderSurface()));
|
||||
|
||||
// set up the time and frame counter.
|
||||
unsigned int frameNumber = 0;
|
||||
osg::Timer timer;
|
||||
osg::Timer_t start_tick = timer.tick();
|
||||
|
||||
// set the keyboard mouse callback to catch the events from the windows.
|
||||
bool done = false;
|
||||
osgProducer::KeyboardMouseCallback kbmcb(done);
|
||||
kbmcb.setStartTick(start_tick);
|
||||
|
||||
// register the callback with the keyboard mouse manger.
|
||||
kbm->setCallback( &kbmcb );
|
||||
//kbm->allowContinuousMouseMotionUpdate(true);
|
||||
kbm->startThread();
|
||||
|
||||
|
||||
|
||||
// set the globa state
|
||||
osg::ref_ptr<osg::StateSet> globalStateSet = new osg::StateSet;
|
||||
globalStateSet->setGlobalDefaults();
|
||||
cg->setGlobalStateSet(globalStateSet.get());
|
||||
|
||||
|
||||
// add either a headlight or sun light to the scene.
|
||||
osg::LightSource* lightsource = new osg::LightSource;
|
||||
osg::Light* light = new osg::Light;
|
||||
lightsource->setLight(light);
|
||||
lightsource->setReferenceFrame(osg::LightSource::RELATIVE_TO_ABSOLUTE); // headlight.
|
||||
lightsource->setLocalStateSetModes(osg::StateAttribute::ON);
|
||||
|
||||
lightsource->addChild(loadedModel.get());
|
||||
|
||||
|
||||
// set the scene to render
|
||||
// cg->setSceneData(scene.get());
|
||||
cg->setSceneData(lightsource);
|
||||
|
||||
// set up the pthread stack size to large enough to run into problems.
|
||||
cg->setStackSize( 20*1024*1024);
|
||||
|
||||
// create the windows and run the threads.
|
||||
cg->realize(threadingModel);
|
||||
|
||||
osg::ref_ptr<osg::FrameStamp> frameStamp = cg->getFrameStamp();
|
||||
|
||||
osgUtil::UpdateVisitor update;
|
||||
update.setFrameStamp(frameStamp.get());
|
||||
|
||||
|
||||
|
||||
// create a camera to use with the manipulators.
|
||||
osg::ref_ptr<osg::Camera> old_style_osg_camera = new osg::Camera;
|
||||
|
||||
osg::ref_ptr<osgGA::KeySwitchCameraManipulator> keyswitchManipulator = new osgGA::KeySwitchCameraManipulator;
|
||||
keyswitchManipulator->addNumberedCameraManipulator(new osgGA::TrackballManipulator);
|
||||
keyswitchManipulator->addNumberedCameraManipulator(new osgGA::FlightManipulator);
|
||||
keyswitchManipulator->addNumberedCameraManipulator(new osgGA::DriveManipulator);
|
||||
|
||||
keyswitchManipulator->setCamera(old_style_osg_camera.get());
|
||||
keyswitchManipulator->setNode(loadedModel.get());
|
||||
|
||||
|
||||
osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
|
||||
statesetManipulator->setStateSet(globalStateSet.get());
|
||||
|
||||
// create an event handler list, we'll dispatch our event to these..
|
||||
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlerList;
|
||||
EventHandlerList eventHandlerList;
|
||||
eventHandlerList.push_back(keyswitchManipulator.get());
|
||||
eventHandlerList.push_back(statesetManipulator.get());
|
||||
|
||||
// create a dummy action adapter right now.
|
||||
osgProducer::ActionAdapter actionAdapter;
|
||||
|
||||
osg::ref_ptr<osgProducer::EventAdapter> init_event = new osgProducer::EventAdapter;
|
||||
init_event->adaptFrame(0.0);
|
||||
keyswitchManipulator->getCurrentCameraManipulator()->home(*init_event,actionAdapter);
|
||||
|
||||
double previous_time_since_start = 0.0f;
|
||||
int number_frames_since_last_print = 0;
|
||||
int number_of_frame_samples = 10;
|
||||
bool printOutFrameStats=true;
|
||||
while( !done )
|
||||
{
|
||||
// syncronize to screen refresh.
|
||||
cg->sync();
|
||||
|
||||
// set the frame stamp for the new frame.
|
||||
double time_since_start = timer.delta_s(start_tick,timer.tick());
|
||||
frameStamp->setFrameNumber(frameNumber);
|
||||
frameStamp->setReferenceTime(time_since_start);
|
||||
|
||||
if (printOutFrameStats)
|
||||
{
|
||||
if (number_frames_since_last_print==number_of_frame_samples)
|
||||
{
|
||||
cout << "frame rate = "<< (double)number_of_frame_samples/(time_since_start-previous_time_since_start)<<endl;
|
||||
previous_time_since_start = time_since_start;
|
||||
number_frames_since_last_print = 0;
|
||||
} else ++number_frames_since_last_print;
|
||||
}
|
||||
|
||||
// get the event since the last frame.
|
||||
osgProducer::KeyboardMouseCallback::EventQueue queue;
|
||||
kbmcb.getEventQueue(queue);
|
||||
|
||||
// create an event to signal the new frame.
|
||||
osg::ref_ptr<osgProducer::EventAdapter> frame_event = new osgProducer::EventAdapter;
|
||||
frame_event->adaptFrame(frameStamp->getReferenceTime());
|
||||
queue.push_back(frame_event);
|
||||
|
||||
// dispatch the events in order of arrival.
|
||||
for(osgProducer::KeyboardMouseCallback::EventQueue::iterator event_itr=queue.begin();
|
||||
event_itr!=queue.end();
|
||||
++event_itr)
|
||||
{
|
||||
bool handled = false;
|
||||
for(EventHandlerList::iterator handler_itr=eventHandlerList.begin();
|
||||
handler_itr!=eventHandlerList.end() && !handled;
|
||||
++handler_itr)
|
||||
{
|
||||
handled = (*handler_itr)->handle(*(*event_itr),actionAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
// update the scene by traversing it with the the update visitor which will
|
||||
// call all node update callbacks and animations.
|
||||
cg->getSceneData()->accept(update);
|
||||
|
||||
|
||||
// update the main producer camera
|
||||
cg->setView(old_style_osg_camera->getModelViewMatrix().ptr());
|
||||
|
||||
// fire off the cull and draw traversals of the scene.
|
||||
cg->frame();
|
||||
|
||||
// increment the frame number ready for the next frame
|
||||
++frameNumber;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,98 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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.
|
||||
*/
|
||||
|
||||
#include <osg/ArgumentParser>
|
||||
#include <osg/ApplicationUsage>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgProducer/Viewer>
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
osg::ArgumentParser arguments(&argc,argv);
|
||||
|
||||
// set up the usage document, in case we need to print out how to use this program.
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
|
||||
|
||||
// construct the viewer.
|
||||
osgProducer::Viewer viewer(arguments);
|
||||
|
||||
// set up the value with sensible default event handlers.
|
||||
viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
|
||||
|
||||
// get details on keyboard and mouse bindings used by the viewer.
|
||||
viewer.getUsage(*arguments.getApplicationUsage());
|
||||
|
||||
// if user request help write it out to cout.
|
||||
if (arguments.read("-h") || arguments.read("--help"))
|
||||
{
|
||||
arguments.getApplicationUsage()->write(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// any option left unread are converted into errors to write out later.
|
||||
arguments.reportRemainingOptionsAsUnrecognized();
|
||||
|
||||
// report any errors if they have occured when parsing the program aguments.
|
||||
if (arguments.errors())
|
||||
{
|
||||
arguments.writeErrorMessages(std::cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// read the scene from the list of file specified commandline args.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
|
||||
|
||||
// if no model has been successfully loaded report failure.
|
||||
if (!loadedModel)
|
||||
{
|
||||
std::cout << arguments.getProgramName() <<": No data loaded" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// optimize the scene graph, remove rendundent nodes and state etc.
|
||||
osgUtil::Optimizer optimizer;
|
||||
optimizer.optimize(loadedModel.get());
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(loadedModel.get());
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize(Producer::CameraGroup::ThreadPerCamera);
|
||||
|
||||
while( !viewer.done() )
|
||||
{
|
||||
// wait for all cull and draw threads to complete.
|
||||
viewer.sync();
|
||||
|
||||
// update the scene by traversing it with the the update visitor which will
|
||||
// call all node update callbacks and animations.
|
||||
viewer.update();
|
||||
|
||||
// fire off the cull and draw traversals of the scene.
|
||||
viewer.frame();
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ TOPDIR = ../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
CameraGroup.cpp\
|
||||
EventAdapter.cpp\
|
||||
KeyboardMouseCallback.cpp\
|
||||
SceneHandler.cpp\
|
||||
OsgCameraGroup.cpp\
|
||||
OsgSceneHandler.cpp\
|
||||
StatsEventHandler.cpp\
|
||||
Viewer.cpp\
|
||||
|
||||
|
@ -1,8 +1,17 @@
|
||||
//Open Producer - Copyright (C) 2002 Don Burns
|
||||
//Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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.
|
||||
*/
|
||||
|
||||
#include <osgProducer/CameraGroup>
|
||||
#include <osgProducer/OsgCameraGroup>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
using namespace osgProducer;
|
||||
@ -22,30 +31,30 @@ std::string extractCameraConfigFile(osg::ArgumentParser& arguments)
|
||||
}
|
||||
|
||||
|
||||
CameraGroup::CameraGroup() : Producer::CameraGroup()
|
||||
OsgCameraGroup::OsgCameraGroup() : Producer::CameraGroup()
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
||||
CameraGroup::CameraGroup(Producer::CameraConfig *cfg):
|
||||
OsgCameraGroup::OsgCameraGroup(Producer::CameraConfig *cfg):
|
||||
Producer::CameraGroup(cfg)
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
||||
CameraGroup::CameraGroup(const std::string& configFile):
|
||||
OsgCameraGroup::OsgCameraGroup(const std::string& configFile):
|
||||
Producer::CameraGroup(findCameraConfigFile(configFile))
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
||||
CameraGroup::CameraGroup(osg::ArgumentParser& arguments):
|
||||
OsgCameraGroup::OsgCameraGroup(osg::ArgumentParser& arguments):
|
||||
Producer::CameraGroup(extractCameraConfigFile(arguments))
|
||||
{
|
||||
_init();
|
||||
}
|
||||
|
||||
void CameraGroup::_init()
|
||||
void OsgCameraGroup::_init()
|
||||
{
|
||||
_scene_data = NULL;
|
||||
_global_stateset = NULL;
|
||||
@ -65,7 +74,7 @@ void CameraGroup::_init()
|
||||
|
||||
}
|
||||
|
||||
void CameraGroup::setSceneData( osg::Node *scene )
|
||||
void OsgCameraGroup::setSceneData( osg::Node *scene )
|
||||
{
|
||||
if (_scene_data==scene) return;
|
||||
|
||||
@ -84,7 +93,7 @@ void CameraGroup::setSceneData( osg::Node *scene )
|
||||
setUpSceneViewsWithData();
|
||||
}
|
||||
|
||||
void CameraGroup::setSceneDecorator( osg::Group* decorator)
|
||||
void OsgCameraGroup::setSceneDecorator( osg::Group* decorator)
|
||||
{
|
||||
if (_scene_decorator==decorator) return;
|
||||
|
||||
@ -98,7 +107,7 @@ void CameraGroup::setSceneDecorator( osg::Group* decorator)
|
||||
}
|
||||
|
||||
|
||||
void CameraGroup::setUpSceneViewsWithData()
|
||||
void OsgCameraGroup::setUpSceneViewsWithData()
|
||||
{
|
||||
for(SceneHandlerList::iterator p = _shvec.begin(); p != _shvec.end(); p++ )
|
||||
{
|
||||
@ -122,33 +131,33 @@ void CameraGroup::setUpSceneViewsWithData()
|
||||
}
|
||||
|
||||
|
||||
void CameraGroup::setFrameStamp( osg::FrameStamp* fs )
|
||||
void OsgCameraGroup::setFrameStamp( osg::FrameStamp* fs )
|
||||
{
|
||||
_frameStamp = fs;
|
||||
setUpSceneViewsWithData();
|
||||
}
|
||||
|
||||
|
||||
void CameraGroup::setGlobalStateSet( osg::StateSet *sset )
|
||||
void OsgCameraGroup::setGlobalStateSet( osg::StateSet *sset )
|
||||
{
|
||||
_global_stateset = sset;
|
||||
setUpSceneViewsWithData();
|
||||
}
|
||||
|
||||
void CameraGroup::setBackgroundColor( const osg::Vec4& backgroundColor )
|
||||
void OsgCameraGroup::setBackgroundColor( const osg::Vec4& backgroundColor )
|
||||
{
|
||||
_background_color = backgroundColor;
|
||||
setUpSceneViewsWithData();
|
||||
}
|
||||
|
||||
void CameraGroup::setLODScale( float scale )
|
||||
void OsgCameraGroup::setLODScale( float scale )
|
||||
{
|
||||
// need to set a local variable?
|
||||
_LODScale = scale;
|
||||
setUpSceneViewsWithData();
|
||||
}
|
||||
|
||||
void CameraGroup::setFusionDistance( osgUtil::SceneView::FusionDistanceMode mode,float value)
|
||||
void OsgCameraGroup::setFusionDistance( osgUtil::SceneView::FusionDistanceMode mode,float value)
|
||||
{
|
||||
// need to set a local variable?
|
||||
_fusionDistanceMode = mode;
|
||||
@ -156,13 +165,13 @@ void CameraGroup::setFusionDistance( osgUtil::SceneView::FusionDistanceMode mode
|
||||
setUpSceneViewsWithData();
|
||||
}
|
||||
|
||||
void CameraGroup::advance()
|
||||
void OsgCameraGroup::advance()
|
||||
{
|
||||
if( !_initialized ) return;
|
||||
Producer::CameraGroup::advance();
|
||||
}
|
||||
|
||||
void CameraGroup::realize( ThreadingModel thread_model)
|
||||
void OsgCameraGroup::realize( ThreadingModel thread_model)
|
||||
{
|
||||
if( _initialized ) return;
|
||||
|
||||
@ -174,7 +183,7 @@ void CameraGroup::realize( ThreadingModel thread_model)
|
||||
for( unsigned int i = 0; i < _cfg->getNumberOfCameras(); i++ )
|
||||
{
|
||||
Producer::Camera *cam = _cfg->getCamera(i);
|
||||
osgProducer::SceneHandler *sh = new osgProducer::SceneHandler(_ds.get());
|
||||
osgProducer::OsgSceneHandler *sh = new osgProducer::OsgSceneHandler(_ds.get());
|
||||
sh->setDefaults();
|
||||
if( _global_stateset != NULL )
|
||||
sh->setGlobalStateSet( _global_stateset.get() );
|
||||
@ -203,11 +212,11 @@ void CameraGroup::realize( ThreadingModel thread_model)
|
||||
}
|
||||
|
||||
|
||||
Producer::CameraGroup::realize( thread_model );
|
||||
CameraGroup::realize( thread_model );
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
osg::Node* CameraGroup::getTopMostSceneData()
|
||||
osg::Node* OsgCameraGroup::getTopMostSceneData()
|
||||
{
|
||||
if (_scene_decorator.valid())
|
||||
return _scene_decorator.get();
|
||||
@ -215,7 +224,7 @@ osg::Node* CameraGroup::getTopMostSceneData()
|
||||
return _scene_data.get();
|
||||
}
|
||||
|
||||
const osg::Node* CameraGroup::getTopMostSceneData() const
|
||||
const osg::Node* OsgCameraGroup::getTopMostSceneData() const
|
||||
{
|
||||
if (_scene_decorator.valid())
|
||||
return _scene_decorator.get();
|
||||
@ -223,12 +232,12 @@ const osg::Node* CameraGroup::getTopMostSceneData() const
|
||||
return _scene_data.get();
|
||||
}
|
||||
|
||||
void CameraGroup::frame()
|
||||
void OsgCameraGroup::frame()
|
||||
{
|
||||
osg::Node* node = getTopMostSceneData();
|
||||
if (node) node->getBound();
|
||||
|
||||
Producer::CameraGroup::frame();
|
||||
CameraGroup::frame();
|
||||
_frameStamp->setFrameNumber( _frameStamp->getFrameNumber() + 1 );
|
||||
}
|
||||
|
67
src/osgProducer/OsgSceneHandler.cpp
Normal file
67
src/osgProducer/OsgSceneHandler.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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.
|
||||
*/
|
||||
|
||||
#include <osgProducer/OsgSceneHandler>
|
||||
#include <Producer/Mutex>
|
||||
|
||||
using namespace osgUtil;
|
||||
using namespace osgProducer;
|
||||
|
||||
OsgSceneHandler::OsgSceneHandler( osg::DisplaySettings *ds) :
|
||||
osgUtil::SceneView(ds)
|
||||
{
|
||||
mm = new osg::RefMatrix;
|
||||
pm = new osg::RefMatrix;
|
||||
}
|
||||
|
||||
void OsgSceneHandler::init()
|
||||
{
|
||||
static Producer::Mutex mutex;
|
||||
osg::notify(osg::INFO)<<"entering "<<this<<" init."<<std::endl;
|
||||
mutex.lock();
|
||||
osg::notify(osg::INFO)<<" running "<<this<<" init."<<std::endl;
|
||||
|
||||
SceneView::init();
|
||||
|
||||
osg::notify(osg::INFO)<<" done "<<this<<" init."<<std::endl;
|
||||
mutex.unlock();
|
||||
osg::notify(osg::INFO)<<" unlocked "<<this<<" init."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
void OsgSceneHandler::cull(Producer::Camera &cam)
|
||||
{
|
||||
|
||||
pm->set(cam.getProjectionMatrix());
|
||||
mm->set(cam.getPositionAndAttitudeMatrix());
|
||||
setProjectionMatrix( pm.get() );
|
||||
setModelViewMatrix( mm.get() );
|
||||
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
cam.getProjectionRect( x, y, w, h );
|
||||
|
||||
setViewport( x, y, w, h );
|
||||
|
||||
SceneView::cull();
|
||||
}
|
||||
|
||||
void OsgSceneHandler::draw(Producer::Camera &)
|
||||
{
|
||||
SceneView::draw();
|
||||
}
|
||||
|
||||
void OsgSceneHandler::setContextID( int id )
|
||||
{
|
||||
getState()->setContextID( id );
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
//Open Producer - Copyright (C) 2002 Don Burns
|
||||
//Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#include <osgProducer/SceneHandler>
|
||||
#include <Producer/Mutex>
|
||||
|
||||
using namespace osgUtil;
|
||||
using namespace osgProducer;
|
||||
|
||||
SceneHandler::SceneHandler( osg::DisplaySettings *ds) :
|
||||
osgUtil::SceneView(ds)
|
||||
{
|
||||
mm = new osg::RefMatrix;
|
||||
pm = new osg::RefMatrix;
|
||||
}
|
||||
|
||||
void SceneHandler::init()
|
||||
{
|
||||
static Producer::Mutex mutex;
|
||||
osg::notify(osg::INFO)<<"entering "<<this<<" init."<<std::endl;
|
||||
mutex.lock();
|
||||
osg::notify(osg::INFO)<<" running "<<this<<" init."<<std::endl;
|
||||
|
||||
SceneView::init();
|
||||
|
||||
osg::notify(osg::INFO)<<" done "<<this<<" init."<<std::endl;
|
||||
mutex.unlock();
|
||||
osg::notify(osg::INFO)<<" unlocked "<<this<<" init."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
void SceneHandler::cull(Producer::Camera &cam)
|
||||
{
|
||||
// static Producer::Mutex mutex;
|
||||
// osg::notify(osg::INFO)<<"entering "<<this<<" cull."<<std::endl;
|
||||
// mutex.lock();
|
||||
// osg::notify(osg::INFO)<<" running "<<this<<" cull."<<std::endl;
|
||||
|
||||
pm->set(cam.getProjectionMatrix());
|
||||
mm->set(cam.getPositionAndAttitudeMatrix());
|
||||
setProjectionMatrix( pm.get() );
|
||||
setModelViewMatrix( mm.get() );
|
||||
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
cam.getProjectionRect( x, y, w, h );
|
||||
|
||||
setViewport( x, y, w, h );
|
||||
|
||||
SceneView::cull();
|
||||
|
||||
// osg::notify(osg::INFO)<<" done "<<this<<" cull."<<std::endl;
|
||||
// mutex.unlock();
|
||||
// osg::notify(osg::INFO)<<" unlocked "<<this<<" cull."<<std::endl;
|
||||
}
|
||||
|
||||
void SceneHandler::draw(Producer::Camera &)
|
||||
{
|
||||
// static Producer::Mutex mutex;
|
||||
// osg::notify(osg::INFO)<<"entering "<<this<<" draw."<<std::endl;
|
||||
// mutex.lock();
|
||||
// osg::notify(osg::INFO)<<" running "<<this<<" draw."<<std::endl;
|
||||
//
|
||||
SceneView::draw();
|
||||
|
||||
// osg::notify(osg::INFO)<<" done "<<this<<" draw."<<std::endl;
|
||||
// mutex.unlock();
|
||||
// osg::notify(osg::INFO)<<" unlocked "<<this<<" draw."<<std::endl;
|
||||
}
|
||||
|
||||
void SceneHandler::setContextID( int id )
|
||||
{
|
||||
getState()->setContextID( id );
|
||||
}
|
@ -26,7 +26,7 @@ Viewer::Viewer():
|
||||
}
|
||||
|
||||
Viewer::Viewer(Producer::CameraConfig *cfg):
|
||||
CameraGroup(cfg),
|
||||
OsgCameraGroup(cfg),
|
||||
_done(false),
|
||||
_frameNumber(0),
|
||||
_kbmcb(0)
|
||||
@ -34,7 +34,7 @@ Viewer::Viewer(Producer::CameraConfig *cfg):
|
||||
}
|
||||
|
||||
Viewer::Viewer(const std::string& configFile):
|
||||
CameraGroup(configFile),
|
||||
OsgCameraGroup(configFile),
|
||||
_done(false),
|
||||
_frameNumber(0),
|
||||
_kbmcb(0)
|
||||
@ -42,7 +42,7 @@ Viewer::Viewer(const std::string& configFile):
|
||||
}
|
||||
|
||||
Viewer::Viewer(osg::ArgumentParser& arguments):
|
||||
CameraGroup(arguments),
|
||||
OsgCameraGroup(arguments),
|
||||
_done(false),
|
||||
_frameNumber(0),
|
||||
_kbmcb(0)
|
||||
@ -182,14 +182,14 @@ void Viewer::realize( ThreadingModel thread_model)
|
||||
_keyswitchManipulator->home(*init_event,*this);
|
||||
}
|
||||
|
||||
CameraGroup::realize( thread_model );
|
||||
OsgCameraGroup::realize( thread_model );
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Viewer::sync()
|
||||
{
|
||||
CameraGroup::sync();
|
||||
OsgCameraGroup::sync();
|
||||
|
||||
// set the frame stamp for the new frame.
|
||||
double time_since_start = _timer.delta_s(_start_tick,_timer.tick());
|
||||
|
Loading…
Reference in New Issue
Block a user