OSG Camera:setViewMatrixAsLookAt

setViewMatrixAsLookAt: Set viewMatrix, the equivalent of how to position the camera

Parameters: void setViewMatrixAsLookAt (const osg :: Vec3d & eye, const osg :: Vec3d & center, const osg :: Vec3d & up);

eye: indicates the position of the camera,

center: represents the center point of the camera to see,

up: indicate which direction is a positive direction

eye and two center points is subtracted viewdireciton

eye point to be able to see the image behind the center point under normal circumstances.

    camera->setViewMatrixAsLookAt(osg::Vec3f(0.0f, -10.0f, 0.0f),
        osg::Vec3f(0.0f, 0.0f, 0.0f),
        osg::Vec3f(0.0f, 0.0, 1.0f));

OSG is because the right-handed coordinate system, x-axis to the right, the Z-axis,

 

 

 But if the point up to -1,

camera->setViewMatrixAsLookAt(osg::Vec3f(0.0f, -10.0f, 0.0f),
        osg::Vec3f(0.0f, 0.0f, 0.0f),
        osg::Vec3f(0.0f, 0.0, -1.0f));

Then the coordinate system would look like the following

 

 

 Also, if the viewer is set robots, these functions will not work:

m_viewer->setCameraManipulator(m_manipulatorManager);

Such calls setViewMatrixAsLookAt no effect.

Guess you like

Origin www.cnblogs.com/bingbingzhe/p/12185354.html