[osg-users] Eye position and 2nd slave camera

petr srom srom at jkzsim.cz
Tue Mar 31 01:20:01 PDT 2009


Hi,

please, can you tell me why the camera_slave have got the same position (eye) as the camera_main? What I'am doing wrong? I cannot set different position and frustum than is in camera_main? The camera slave take (inherit) the setting of camera main? Here is the code:

void MultiCameras::multipleCameras(osgViewer::Viewer *viewer)
{
	camera_main_create(viewer);
	camera_slave_create(viewer);
}

void MultiCameras::camera_main_create(osgViewer::Viewer *viewer)
{	
	osg::ref_ptr<osg::Camera> camera = new osg::Camera;
	camera->setGraphicsContext(gc);
	camera->setViewport(0, 0, 650, 500);
	GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; 	
	camera->setDrawBuffer(buffer); 
	camera->setReadBuffer(buffer);
	camera->setClearColor(mv4f_clearcolor);
                camera->setProjectionMatrixAsFrustum(-2.0,2.0,-2.0,2.0,5.0,50.0); 
	mv3f_eye.set(20.0f,20.0f,3.0f);
	camera->setViewMatrixAsLookAt(mv3f_eye, mv3f_center, mv3f_up);
	viewer->setCamera( camera );
}

void MultiCameras::camera_slave_create(osgViewer::Viewer *viewer)
{
	osg::ref_ptr<osg::Camera> camera = new osg::Camera;
	camera->setGraphicsContext(gc);
	camera->setViewport(0, 510, 650, 200);
	GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; 		
	camera->setDrawBuffer(buffer); 
	camera->setReadBuffer(buffer);
	camera->setClearColor(mv4f_clearcolor);
	camera->setProjectionMatrixAsFrustum(-8.0,8.0,-2.0,2.0,5.0,50.0);
	mv3f_eye.set(20.0f,5.0f,0.0f);  //it doesn't work ? 
	camera->setViewMatrixAsLookAt(mv3f_eye, mv3f_center, mv3f_up);
	viewer->addSlave(camera.get()); 	
}

Thank you.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=9479#9479








More information about the osg-users mailing list