Hi David, The OSG's default for model coordinates is Z up, Y to the north, X to the east.
While the Camera's view matrix moves from the model coordinates in eye coordinates, and the slave view and projection matrix offsets are post multiplied to give the final view and projection matrix for the slave camera, so these offset matrices are in eye coordinates. Eye coordinates are just standard OpenGL eye coordinates, so Z is out from the screen, Y is up the screen, and X is to the right. My guess is that you are thinking about rotations in model coordinates rather eye coordinates. Robert. On Thu, Jul 16, 2009 at 8:32 AM, David Tapia<[email protected]> wrote: > Hi people, > > I have a scene with master camera and 4 slave cameras. > > I try to change the angle HPR on my slave cameras, but when that change the > Heading angle, which makes changing the roll, > and when change Roll angle, what it does is change the Heading. However the > pitch is working well. > > What am I doing wrong? > > Example code: > > int main(int, char **) > { > osgViewer::Viewer viewer; > viewer.setSceneData(osgDB::readNodeFile("cow.osg")); > > osg::GraphicsContext::WindowingSystemInterface* wsi = > osg::GraphicsContext::getWindowingSystemInterface(); > > unsigned int width, height; > wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), > width, height); > > osg::ref_ptr<osg::GraphicsContext::Traits> traits = new > osg::GraphicsContext::Traits; > traits->x = 0; > traits->y = 0; > traits->width = width; > traits->height = height; > traits->windowDecoration = true; > traits->doubleBuffer = true; > traits->sharedContext = 0; > > osg::ref_ptr<osg::GraphicsContext> gc = > osg::GraphicsContext::createGraphicsContext(traits.get()); > > unsigned int numCameras = 4; > double aspectRatioScale = 1.0;//(double)numCameras; > for(unsigned int i=0; i<numCameras;++i) > { > osg::ref_ptr<osg::Camera> camera = new osg::Camera; > camera->setGraphicsContext(gc.get()); > camera->setViewport(new > osg::Viewport((i*width)/numCameras,(i*height)/numCameras, width/numCameras, > height/numCameras)); > GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; > camera->setDrawBuffer(buffer); > camera->setReadBuffer(buffer); > > viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd()); > } > > double angle(0.); > > osg::Matrix rot = osg::Matrix::identity(); > > // CHANGE HEADING > osg::Vec3 hpr; > hpr[0] = 10.0f; > hpr[1] = 0.0f; > hpr[2] = 0.0f; > > osg::Matrix H; > H.makeRotate(osg::DegreesToRadians(hpr[0]), osg::Vec3(0,0,1)); // > heading -> > > osg::Matrix P; > P.makeRotate(osg::DegreesToRadians(hpr[1]), osg::Vec3(1,0,0)); // pitch > -> > > osg::Matrix R; > R.makeRotate(osg::DegreesToRadians(hpr[2]), osg::Vec3(0,1,0)); // roll > -> > > rot = H*P*R; > > viewer.getSlave(0)._viewOffset = rot; > > // CHANGE PITCH > hpr[0] = 0.0f; > hpr[1] = 10.0f; > hpr[2] = 0.0f; > > H = osg::Matrix::identity(); > P = osg::Matrix::identity(); > R = osg::Matrix::identity(); > > H.makeRotate(osg::DegreesToRadians(hpr[0]), osg::Vec3(0,0,1)); // > heading -> > > P.makeRotate(osg::DegreesToRadians(hpr[1]), osg::Vec3(1,0,0)); // pitch > -> > > R.makeRotate(osg::DegreesToRadians(hpr[2]), osg::Vec3(0,1,0)); // roll > -> > > rot = H*P*R; > > viewer.getSlave(1)._viewOffset = rot; > > // CHANGE ROLL > hpr[0] = 0.0f; > hpr[1] = 0.0f; > hpr[2] = 10.0f; > > H = osg::Matrix::identity(); > P = osg::Matrix::identity(); > R = osg::Matrix::identity(); > > H.makeRotate(osg::DegreesToRadians(hpr[0]), osg::Vec3(0,0,1)); // > heading -> > > P.makeRotate(osg::DegreesToRadians(hpr[1]), osg::Vec3(1,0,0)); // pitch > -> > > R.makeRotate(osg::DegreesToRadians(hpr[2]), osg::Vec3(0,1,0)); // roll > -> > > rot = H*P*R; > > viewer.getSlave(2)._viewOffset = rot; > > viewer.run(); > } > > -- > DTC > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

