[osg-users] [forum] Change the position and rotation angle of the camera

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Tue May 12 12:06:24 PDT 2020


Hi Becky,

I managed to change the camera position using a manipulator called 
controller.

    viewer.setCameraManipulator(controller);
    viewer.realize();
    // osg::Matrix matrix;
    // matrix.makeLookAt( osg::Vec3(), osg::Vec3(), osg::Vec3() );
    osg::Quat quad;
    // matrix.get(quad);
    controller->setTransformation(osg::Vec3(-54.4f,-14.3f,80.0f), quad );
    while ( !viewer.done() )
    {
        viewer.frame();
    }
    return 0;

The commented lines were not necessary for me, but may be in other 
situations.

Best,
Rodrigo.


On Tuesday, April 1, 2014 at 6:37:24 AM UTC-3, ying song wrote:
>
> Hi, 
>
> I draw a box using addDrawable. Then I want to change the position and 
> rotation angle of the camera  by: 
>
> viewer->getCamera()->setViewMatrix(cameraTranslationMatrix); 
>
> But actually it makes no change to the camera. The cube is still in the 
> center of the screen after run the scene. 
>
> I also tried to update the frame by using the following code, but also 
> failed: 
>
> while(!viewer->done()) 
> { 
>         viewer->getCamera()->setViewMatrixAsLookAt(eye,center,up); 
>         viewer->frame(); 
> } 
>
>
> Would anyone tell me what could I do to move the camera? 
>
> Thank you! 
>
> Cheers, 
> Becky 
>
> ------------------ 
> Read this topic online here: 
> http://forum.openscenegraph.org/viewtopic.php?p=58769#58769 
>
>
>
>
>
> _______________________________________________ 
> osg-users mailing list 
> osg-... at lists.openscenegraph.org <javascript:> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
>

-- 
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/f32cce3f-4ae4-45b4-8efe-be93a362a1a3%40googlegroups.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200512/0ad23eaa/attachment.html>


More information about the osg-users mailing list