OSG working back. Ready to implement Split-Screen support.

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5209 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: ddc1bb5146098456b3956529f720c190a9889c17
Former-commit-id: 4b07172a22688c6ea87dec0ef258d2e4edfd9d8d
This commit is contained in:
rvlander 2013-02-26 09:17:12 +00:00
parent 33c03434ea
commit 058b769a4d
4 changed files with 27 additions and 27 deletions

View file

@ -20,16 +20,16 @@
#include <tgfclient.h>
#include <osgViewer/CompositeViewer>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/Viewer>
#include <osgViewer/GraphicsWindow>
#include "OsgScreens.h"
SDScreens::SDScreens()
{
viewer = new osgViewer::CompositeViewer();
viewer = new osgViewer::Viewer();
}
void SDScreens::Init(int x,int y, int width, int height, osg::ref_ptr<osg::Group> m_sceneroot){
@ -40,22 +40,23 @@ void SDScreens::Init(int x,int y, int width, int height, osg::ref_ptr<osg::Group
int grWinw = width;
int grWinh = height;
osgViewer::View * osgView = new osgViewer::View;
osgViewer::GraphicsWindow *gw = new osgViewer::GraphicsWindow();
viewer->addView(osgView);
view = new SDViewer(osgView);
view = new SDViewer(viewer->getCamera());
viewer->setThreadingModel(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext);
view->getOsgView()->setUpViewInWindow(0, 0, grWinw, grWinh,0);
osgView->getCamera()->setName("Cam one");
osgView->getCamera()->setViewport(new osg::Viewport(0, 0, grWinw, grWinh));
osgView->getCamera()->setGraphicsContext(gw);
osgView->getCamera()->setProjectionMatrixAsPerspective(67.5f, static_cast<double>((float)grWinw / (float)grWinh), 0.1f, 12000.0f);
osgView->setSceneData(m_sceneroot.get());
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = viewer->setUpViewerAsEmbeddedInWindow(0, 0, grWinw, grWinh);
//view->getOsgView()->setUpViewInWindow(0, 0, grWinw, grWinh,0);
viewer->getCamera()->setName("Cam one");
viewer->getCamera()->setViewport(new osg::Viewport(0, 0, grWinw, grWinh));
viewer->getCamera()->setGraphicsContext(gw);
viewer->getCamera()->setProjectionMatrixAsPerspective(67.5f, static_cast<double>((float)grWinw / (float)grWinh), 0.1f, 12000.0f);
viewer->setSceneData(m_sceneroot.get());
//viewer->realize();
@ -71,7 +72,7 @@ void SDScreens::InitCars(tSituation *s){
void SDScreens::update(tSituation * s,SDFrameInfo* fi){
view->update(s,fi);
//if (!viewer->done())
if (!viewer->done())
viewer->frame();
}

View file

@ -23,7 +23,7 @@
#include <osgViewer/Viewer>
#include <raceman.h> //tSituation
#include "OsgView.h"
@ -31,7 +31,7 @@
class SDScreens
{
protected:
osgViewer::CompositeViewer *viewer;
osgViewer::Viewer *viewer;
SDViewer * view;
// int mirrorFlag;

View file

@ -19,7 +19,7 @@
#include <osgViewer/View>
#include <osg/Camera>
#include <tgfclient.h>
@ -32,9 +32,9 @@ static char buf[1024];
static char path[1024];
static char path2[1024];
SDViewer::SDViewer(osgViewer::View * v)
SDViewer::SDViewer(osg::Camera * c)
{
view = v;
cam = c;
id = 0;
curCar = NULL;
//curCam = NULL;
@ -82,7 +82,6 @@ void SDViewer::switchMirror(void)
void SDViewer::Init(tSituation *s)
{
view = new osgViewer::View();
loadParams(s);
}
@ -212,9 +211,9 @@ void SDViewer::update(tSituation *s, const SDFrameInfo* frameInfo)
//osg::Camera * camera = m_sceneViewer->getCamera();
//view->getCamera()>setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
cam->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
view->getCamera()->setViewMatrixAsLookAt( eye, center, up);
cam->setViewMatrixAsLookAt( eye, center, up);
}

View file

@ -37,7 +37,7 @@ class SDViewer
{
protected:
osgViewer::View * view;
osg::Camera * cam;
int id;
@ -71,7 +71,7 @@ class SDViewer
void loadParams(tSituation *s); // Load from parameters files.
public:
SDViewer(osgViewer::View * v);
SDViewer(osg::Camera * c);
~SDViewer();
void Init(tSituation *s);
@ -109,7 +109,7 @@ class SDViewer
inline int getScrW (void) { return scrw; }
inline int getScrH (void) { return scrh; }
inline osgViewer::View * getOsgView(void) { return view; }
inline osg::Camera * getOsgCam(void) { return cam; }
//inline int getBoardWidth(void) { return boardWidth; }
};