Updates to the osgproducer demo.

This commit is contained in:
Robert Osfield
2003-01-15 19:23:16 +00:00
parent 7bf60026f7
commit 5ad9602673
4 changed files with 250 additions and 22 deletions

View File

@@ -8,6 +8,7 @@
// graphics drawing with Producer::RenderSurface
#include <Producer/Camera>
#include <Producer/CameraConfig>
#include <Producer/OsgCameraGroup>
#include <Producer/OsgSceneHandler>
#include <Producer/InputArea>
@@ -20,6 +21,42 @@
#include "MyKeyboardMouseCallback"
static Producer::CameraConfig *BuildConfig(void)
{
Producer::RenderSurface *rs1 = new Producer::RenderSurface;
rs1->setScreenNum(0);
// rs1->useBorder(false);
// rs1->setWindowRect(0,0,640,480);
rs1->setWindowRect(10,10,620,480);
Producer::Camera *camera1 = new Producer::Camera;
camera1->setRenderSurface(rs1);
camera1->setOffset( 1.0, 0.0 );
Producer::RenderSurface *rs2 = new Producer::RenderSurface;
rs2->setScreenNum(0);
// rs2->useBorder(false);
// rs2->setWindowRect(640,0,640,480);
rs2->setWindowRect(650,10,620,480);
Producer::Camera *camera2 = new Producer::Camera;
camera2->setRenderSurface(rs2);
camera2->setOffset( -1.0, 0.0 );
Producer::CameraConfig *cfg = new Producer::CameraConfig;
cfg->addCamera("Camera 1",camera1);
cfg->addCamera("Camera 2", camera2);
Producer::InputArea *ia = new Producer::InputArea;
ia->addInputRectangle( rs1, Producer::InputRectangle(0.0,0.5,0.0,1.0));
ia->addInputRectangle( rs2, Producer::InputRectangle(0.5,1.0,0.0,1.0));
cfg->setInputArea(ia);
return cfg;
}
int main( int argc, char **argv )
{
@@ -33,31 +70,37 @@ int main( int argc, char **argv )
osgUtil::Optimizer optimizer;
optimizer.optimize(scene.get());
#define USE_BUILD_CONFIG
Producer::Camera camera1;
Producer::RenderSurface *rs1 = camera1.getRenderSurface();
rs1->setWindowRect(10,10,620,480);
camera1.setOffset( 1.0, 0.0 );
camera1.setSceneHandler(new Producer::OsgSceneHandler);
#ifdef USE_BUILD_CONFIG
Producer::Camera camera2;
Producer::RenderSurface *rs2 = camera2.getRenderSurface();
rs2->setWindowRect(650,10,620,480);
camera2.setOffset( -1.0, 0.0 );
camera2.setSceneHandler(new Producer::OsgSceneHandler);
Producer::CameraConfig *cfg = BuildConfig();
Producer::OsgCameraGroup *cg = new Producer::OsgCameraGroup(cfg);
Producer::InputArea *ia = new Producer::InputArea;
ia->addInputRectangle( rs1, Producer::InputRectangle(0.0,0.5,0.0,1.0));
ia->addInputRectangle( rs2, Producer::InputRectangle(0.5,1.0,0.0,1.0));
#elif USE_PARSE_CONFIG
Producer::CameraConfig cfg;
cfg.addCamera("Camera 1", &camera1);
cfg.addCamera("Camera 2", &camera2);
Producer::CameraConfig *cfg = new Producer::CameraConfig;
cfg->parseFile("twoWindows.cfg");
Producer::OsgCameraGroup cg(&cfg);
cg.setSceneData(scene.get());
Producer::OsgCameraGroup *cg = new Producer::OsgCameraGroup(cfg);
#else
Producer::OsgCameraGroup *cg = new Producer::OsgCameraGroup();
// ackk we need a CameraConfig to get the InputArea from, as CameraGroup
// doesn't have its own InputArea... perhaps there should be a
// getOrCreateInputArea on the CameraGroup & CameraConfig classes to help
// out setting up the input area appropriatly.
#endif
// set up a scene handler for each camera.
for( int i = 0; i < cg->getNumberOfCameras(); i++ )
cg->getCamera(i)->setSceneHandler( new Producer::OsgSceneHandler );
Producer::InputArea *ia = cfg->getInputArea();
Producer::KeyboardMouse kbm(ia);
bool done = false;
@@ -68,16 +111,19 @@ int main( int argc, char **argv )
Producer::Trackball tb;
tb.setOrientation( Producer::Trackball::Y_UP );
cg->setSceneData(scene.get());
// cg.realize(Producer::CameraGroup::ThreadPerCamera);
cg.realize(Producer::CameraGroup::SingleThreaded);
cg->realize(Producer::CameraGroup::SingleThreaded);
while( !done )
{
tb.input( kbmcb.mx(), kbmcb.my(), kbmcb.mbutton() );
cg.setView(tb.getMatrix().ptr());
cg->setView(tb.getMatrix().ptr());
cg.frame();
cg->frame();
}
return 0;
}

View File

@@ -0,0 +1,82 @@
#define SINGLE_PIPE
#define ASSYMETRICAL_FRUSTUM
Camera "Camera 1"
{
RenderSurface "Window 1"
{
Visual { SetSimple };
#ifdef SINGLE_PIPE
Screen 0;
WindowRectangle 0 0 426 512;
#else
Screen 2;
#endif
Border off;
};
Lens {
Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0;
};
Offset {
#ifdef ASSYMETRICAL_FRUSTUM
Shear 2.0 0.0;
#else
Rotate -90.0 1 0 0;
Rotate -45.0 0 0 1;
Rotate 90.0 1 0 0;
#endif
};
}
Camera "Camera 2"
{
RenderSurface "Window 2"
{
Visual { SetSimple };
Screen 0;
#ifdef SINGLE_PIPE
WindowRectangle 426 0 426 512;
#endif
Border off;
};
Lens {
Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0;
};
}
Camera "Camera 3"
{
RenderSurface "Window 3"
{
Visual { SetSimple };
#ifdef SINGLE_PIPE
Screen 0;
WindowRectangle 852 0 426 512;
#else
Screen 1;
#endif
Border off;
};
Lens {
Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0;
};
Offset {
#ifdef ASSYMETRICAL_FRUSTUM
Shear -2.0 0.0;
#else
Rotate -90.0 1 0 0;
Rotate 45.0 0 0 1;
Rotate 90.0 1 0 0;
#endif
};
}
InputArea
{
RenderSurface "Window 1" : -1.0 0.0 0.0 1.0;
RenderSurface "Window 2" : 0.0 1.0 0.0 1.0;
RenderSurface "Window 3" : 1.0 2.0 0.0 1.0;
}

View File

@@ -0,0 +1,64 @@
/*#define SINGLE_PIPE */
#define ASSYMETRICAL_FRUSTUM
Camera "Camera 1"
{
RenderSurface "Window 1"
{
Visual { SetSimple };
Screen 0;
#ifdef SINGLE_PIPE
WindowRectangle 0 0 426 512;
#else
#endif
Border off;
};
Lens {
Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0;
};
Offset {
#ifdef ASSYMETRICAL_FRUSTUM
Shear 1.0 0.0;
#else
Rotate -90.0 1 0 0;
Rotate -22.5 0 0 1;
Rotate 90.0 1 0 0;
#endif
};
}
Camera "Camera 2"
{
RenderSurface "Window 2"
{
Visual { SetSimple };
#ifdef SINGLE_PIPE
Screen 0;
WindowRectangle 426 0 426 512;
#else
Screen 1;
#endif
Border off;
};
Lens {
Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0;
};
Offset {
#ifdef ASSYMETRICAL_FRUSTUM
Shear -1.0 0.0;
#else
Rotate -90.0 1 0 0;
Rotate 22.5 0 0 1;
Rotate 90.0 1 0 0;
#endif
};
}
InputArea
{
RenderSurface "Window 1" : -1.0 0.0 0.0 1.0;
RenderSurface "Window 2" : 0.0 1.0 0.0 1.0;
}

View File

@@ -0,0 +1,36 @@
Camera "Camera 1"
{
RenderSurface "Pipe 0"
{
Visual { SetSimple };
Screen 0;
Border off;
WindowRect 0 0 640 480;
};
Lens {
Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0;
};
Offset {
Shear 0.8 0.0;
};
}
Camera "Camera 2"
{
RenderSurface "Pipe 1"
{
Visual { SetSimple };
Screen 0;
Border off;
WindowRect 640 0 640 480;
};
Lens {
Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0;
};
Offset {
Shear -0.8 0.0;
};
}