SDScreen class in OSG for multiview support.
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5205 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 2cc206894d6cad488b23fb4408610da4d76cfc74 Former-commit-id: 1dd920233285372af0b16e4d01dab181aa13693c
This commit is contained in:
parent
1caa4dec8d
commit
78f6d7dc67
2 changed files with 142 additions and 0 deletions
84
src/modules/graphic/osggraph/OsgScreens.cpp
Executable file
84
src/modules/graphic/osggraph/OsgScreens.cpp
Executable file
|
@ -0,0 +1,84 @@
|
|||
/***************************************************************************
|
||||
|
||||
file : OsgViewer.cpp
|
||||
created : Sun Jan 13 22:11:03 CEST 2013
|
||||
copyright : (C) 2013 by Xavier Bertaux
|
||||
email : bertauxx@yahoo.fr
|
||||
version : $Id$
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <tgfclient.h>
|
||||
|
||||
|
||||
#include <osgViewer/CompositeViewer>
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include "OsgScreens.h"
|
||||
|
||||
|
||||
SDScreens::SDScreens()
|
||||
{
|
||||
viewer = new osgViewer::CompositeViewer();
|
||||
}
|
||||
|
||||
void SDScreens::Init(int x,int y, int width, int height, osg::ref_ptr<osg::Group> m_sceneroot){
|
||||
|
||||
|
||||
//int grWinx = x;
|
||||
//int grWiny = y;
|
||||
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);
|
||||
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());
|
||||
//viewer->realize();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SDScreens::InitCars(tSituation *s){
|
||||
view->Init(s);
|
||||
}
|
||||
|
||||
void SDScreens::update(tSituation * s,SDFrameInfo* fi){
|
||||
view->update(s,fi);
|
||||
|
||||
//if (!viewer->done())
|
||||
viewer->frame();
|
||||
}
|
||||
|
||||
SDScreens::~SDScreens()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
58
src/modules/graphic/osggraph/OsgScreens.h
Executable file
58
src/modules/graphic/osggraph/OsgScreens.h
Executable file
|
@ -0,0 +1,58 @@
|
|||
/***************************************************************************
|
||||
|
||||
file : OsgScreens.h
|
||||
created : Sat Feb 2013 15:52:19 CEST 2013
|
||||
copyright : (C) 2013 by Gaëtan André
|
||||
email : gaetan.andre@gmail.com
|
||||
version : $Id$
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _OSGSCREENS_H_
|
||||
#define _OSGSCREENS_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <raceman.h> //tSituation
|
||||
#include "OsgView.h"
|
||||
|
||||
|
||||
class SDScreens
|
||||
{
|
||||
protected:
|
||||
osgViewer::CompositeViewer *viewer;
|
||||
SDViewer * view;
|
||||
|
||||
// int mirrorFlag;
|
||||
// void loadParams(tSituation *s); // Load from parameters files.
|
||||
|
||||
public:
|
||||
SDScreens();
|
||||
~SDScreens();
|
||||
|
||||
|
||||
void Init(int x, int y, int width, int height, osg::ref_ptr<osg::Group> m_sceneroot);
|
||||
void InitCars(tSituation *s);
|
||||
void update(tSituation *s,SDFrameInfo* fi);
|
||||
|
||||
|
||||
|
||||
// void activate(int x, int y, int w, int h, float v);
|
||||
// inline void deactivate(void) { active = false; }
|
||||
|
||||
|
||||
// inline void setCurrentCar(tCarElt *newCurCar) { curCar = newCurCar; }
|
||||
};
|
||||
|
||||
#endif //_OSGSCREENS_H_
|
Loading…
Reference in a new issue