Hey Rodrigo,

You have to set the home position of your camera manipulator and make a
call to home(1). You can force the delta time with a 1.

Sam

On Mon, Jan 7, 2019 at 6:48 PM Rodrigo Dias <rodrigo1...@gmail.com> wrote:

> Hi,
>
> I'm able to change the camera's position with TrackballManipulator.
> However, I'd like to change the camera's initial position, but all the
> examples I've found just won't work. My source code is:
>
>
> Code:
> #include <iostream>
> #include <osg/Camera>
> #include <osgDB/ReadFile>
> #include <osgGA/TrackballManipulator>
> #include <osgViewer/Viewer>
> #include <osgEarth/ImageLayer>
> #include <osgEarth/Map>
> #include <osgEarth/MapNode>
> #include <osgEarthDrivers/tms/TMSOptions>
> #include <osgEarthDrivers/gdal/GDALOptions>
>
> using namespace std;
> using namespace osg;
> using namespace osgEarth;
> using namespace osgEarth::Drivers;
>
> int main (int argc, char** argv) {
>         MapOptions mapOpt;
>         mapOpt.coordSysType() = MapOptions::CSTYPE_PROJECTED;
>         mapOpt.profile() = ProfileOptions("plate-carre");
>         osg::ref_ptr<Map> map = new Map(mapOpt);
>         {
>                 GDALOptions gdal;
>                 gdal.url() = "br_modified.tif";
>                 osg::ref_ptr<ImageLayer> layer = new ImageLayer( "BR",
> gdal );
>                 map->addLayer( layer );
>         }
>         {
>                 GDALOptions gdal;
>                 gdal.url() = "BRalt.tif";
>                 osg::ref_ptr<ElevationLayer> layer = new ElevationLayer(
> "SRTM", gdal );
>                 map->addLayer( layer );
>         }
>         osg::ref_ptr<MapNode> mapNode = new MapNode( map );
>         osgViewer::Viewer viewer;
>         viewer.setSceneData( mapNode.get() );
>         viewer.setCameraManipulator( new osgGA::TrackballManipulator );
>
>         Vec3 eye( 10000.0, 50000.0, 100000.0 ); // The position of your
> camera
>         Vec3 center( 0.0, 0.0, 0.0 ); // The point your camera is looking
> at
>         Vec3 up( 0.0, 1.0, 0.0 ); // The up-vector of your camera - this
> controls how your viewport will be rotated about its center and should be
> equal to [0, 1, 0] in a conventional graphics coordinate system
>         viewer.getCamera()->setViewMatrixAsLookAt( eye, center, up );
>         while ( !viewer.done() ) {
>                 viewer.frame();
>         }
>         return 0;
> }
>
>
>
>
> No matter which values I use for "eye", the camera always begins in the
> same position. Why is that?
>
> Thank you!
>
> Cheers,
> Rodrigo
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75411#75411
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to