Hi,
are you saving in the camera callback?
jp
On 22/04/10 19:29, Vedran Pavlic wrote:
Hi,
I need to render the same scene from two angles. So i tried to create a
osg::Viewer and set its scene data. Then I add the first camera to the viewer. And
the scene renders fine. After that i tried to add the second camera to the viewer
so i call viewer->addslave().
Cameras write to osg::image which i will be sending as data over the network at
a later point, but this is irrelevant now.
I created an event on ctrl click which writes the osg::Image data to the hard
drive. The master camera saves fine, but the slave camera saves a blank image
file. So i guess i didn't set up the cameras correctly. This is the code in
which i set up the cameras:
Code:
#include "Renderer.h"
#include<osgViewer/ViewerEventHandlers>
#include<osgDB/ReadFile>
#include "ApplicationEngine.h"
#include<osgGA/TrackballManipulator>
#include<osg/Image>
#include<osgDB/WriteFile>
#define VIEWPOINTDISTANCE 10
Renderer::Renderer()
:
sceneManager(SceneManager::instance())
{
mountedObject = NULL;
masterImage = new osg::Image();
masterImage->allocateImage(100, 100, 24, GL_RGB, GL_UNSIGNED_BYTE);
layoutImage = new osg::Image();
layoutImage->allocateImage(100, 100, 24, GL_RGB, GL_UNSIGNED_BYTE);
cout<<"Stvaram View.\n";
masterCamera = new osg::Camera();
masterCamera->setProjectionMatrixAsPerspective(60.0, 1, 1, 1000.0);
masterCamera->setViewMatrixAsLookAt(osg::Vec3(0, 40, 0), osg::Vec3(0,
-5, 0), osg::Vec3(0, 0, 1));
layoutCamera = new osg::Camera();
layoutCamera->setProjectionMatrixAsOrtho(-200, 200, 200, -200, 1,
1000.0);
layoutCamera->setViewMatrixAsLookAt(osg::Vec3(0, 0, 100), osg::Vec3(0,
0, -5), osg::Vec3(0, 1, 0));
viewer = new osgViewer::Viewer();
viewer->setCamera(masterCamera);
masterCamera->attach(osg::Camera::COLOR_BUFFER, masterImage, 0, 0);
layoutCamera->attach(osg::Camera::COLOR_BUFFER, layoutImage, 0, 0);
viewer->addSlave(layoutCamera);
viewer->addEventHandler(new osgViewer::StatsHandler());
viewer->addEventHandler(ApplicationEngine::instance());
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
viewer->setSceneData(sceneManager->getRootNode());
viewer->realize();
sceneManager->attach(this);
}
void Renderer::renderScene()
{
viewer->frame();
}
Also if there is a better way to get this screen image on every frame feel free
to say so.Thank you!
Cheers,
Vedran[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=27164#27164
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org