Re: [osg-users] setViewMatrixAsLookAt not working to set the initial camera position

2020-05-12 Thread OpenSceneGraph Users
Hi Rodrigo, 


are you sure about the values of your eye point. As you say your map is
georeferenced but it is certanly projected. So you should check the
projection system used by your map (maybe have a look at
https://epsg.io/?q=Brazil%20kind%3APROJCRS). I think the main problem
may be there. Have you tried maybe by opening your map with an modified
osgviewer and check what the eye position is by default ? 

Cheers, 


Christian

Le 2020-05-12 11:04, OpenSceneGraph Users a écrit :

Back at it again... 

I'm using a Brazil georeferenced map, so I know what coordinates are good enough to be above the country, high enough to see it all, looking down: 

(...) 
osgViewer::Viewer viewer;

viewer.setSceneData( root.get() );
osg::ref_ptr controller = new OVNIController(); // my 
own WASD flying controller
viewer.setCameraManipulator(controller);
viewer.getCamera()->setViewMatrixAsLookAt( osg::Vec3(-55.0f,-15.0f,50.0f), 
osg::Vec3(), osg::Y_AXIS ); // eye (lon, lat, alt), center, up
viewer.getCameraManipulator()->home(1);
viewer.realize();
while ( !viewer.done() ) { viewer.frame(); }
return 0;

I don't know if setViewMatrixAsLookAt() and home() should go before or after realize(). Played with the axis as 3rd parameter for setViewMatrixAsLookAt, but the camera just won't move! Any help, please? 

On Tuesday, January 8, 2019 at 1:39:53 AM UTC-2, sam wrote: 

After you set the home position try: viewer.getCameraManipulator()->home(1); 

Sorry I'm not right in front of my computer right now. 


On Mon, Jan 7, 2019 at 7:26 PM Rodrigo Dias  wrote: Hi 
Sam,

By "home" I think you mean

Code:
viewer.getCameraManipulator()->setHomePosition( eye, center, up );

This really changed camera's position, though it's totally freaking out now 
(I'm still fiddling with the values in eye, center and up).

But I have no idea what you meant by "delta time", something to go inside the 
loop?

Thank you!

Cheers,
Rodrigo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75413#75413 [2]

___
osg-users mailing list
osg-...@lists.openscenegraph.org [1]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org [3]


--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/osg-users/9bf0c1bb-6a74-4050-b6a5-6e99b2eac70f%40googlegroups.com
[4]. 
___

osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Links:
--
[1] http://webmail.onera.fr/./#NOP
[2] http://forum.openscenegraph.org/viewtopic.php?p=75413#75413
[3]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[4]
https://groups.google.com/d/msgid/osg-users/9bf0c1bb-6a74-4050-b6a5-6e99b2eac70f%40googlegroups.com?utm_medium=emailutm_source=footer___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] setViewMatrixAsLookAt not working to set the initial camera position

2020-05-12 Thread OpenSceneGraph Users
Back at it again...

I'm using a Brazil georeferenced map, so I know what coordinates are good 
enough to be above the country, high enough to see it all, looking down:

(...)
osgViewer::Viewer viewer;
viewer.setSceneData( root.get() );
osg::ref_ptr controller = new OVNIController(); 
// my own WASD flying controller
viewer.setCameraManipulator(controller);
viewer.getCamera()->setViewMatrixAsLookAt( 
osg::Vec3(-55.0f,-15.0f,50.0f), osg::Vec3(), osg::Y_AXIS ); // eye (lon, 
lat, alt), center, up
viewer.getCameraManipulator()->home(1);
viewer.realize();
while ( !viewer.done() ) { viewer.frame(); }
return 0;

I don't know if setViewMatrixAsLookAt() and home() should go before or 
after realize(). Played with the axis as 3rd parameter for 
setViewMatrixAsLookAt, but the camera just won't move! Any help, please?


On Tuesday, January 8, 2019 at 1:39:53 AM UTC-2, sam wrote:
>
> After you set the home position try: 
> viewer.getCameraManipulator()->home(1); 
>
> Sorry I'm not right in front of my computer right now.
>
> On Mon, Jan 7, 2019 at 7:26 PM Rodrigo Dias  > wrote:
>
>> Hi Sam,
>>
>> By "home" I think you mean
>>
>>
>> Code:
>> viewer.getCameraManipulator()->setHomePosition( eye, center, up );
>>
>>
>>
>>
>> This really changed camera's position, though it's totally freaking out 
>> now (I'm still fiddling with the values in eye, center and up).
>>
>> But I have no idea what you meant by "delta time", something to go inside 
>> the loop?
>>
>> Thank you!
>>
>> Cheers,
>> Rodrigo
>>
>> --
>> Read this topic online here:
>> http://forum.openscenegraph.org/viewtopic.php?p=75413#75413
>>
>>
>>
>>
>>
>> ___
>> osg-users mailing list
>> osg-...@lists.openscenegraph.org 
>> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osg-users/9bf0c1bb-6a74-4050-b6a5-6e99b2eac70f%40googlegroups.com.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] setViewMatrixAsLookAt not working to set the initial camera position

2019-01-07 Thread Rodrigo Dias
I just tried it, but still the camera is messed up. No matter which numbers I 
choose to eye, center and up, it never behaves as default. I have not even a 
clue about the difference between 10, 100 and 1000, which one should I use? 
(I'm using osgEarth's Map and MapNode, btw, which are displaying a whole flat 
white Earth, with only the desired country drawn with a texture) I tried using 
getViewMatrixAsLookAt with the default values, but it's still a mess. I've 
looked at many questions here, and in some of the source code, but nothing 
clears this up.

Thank you!

Cheers,
Rodrigo

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] setViewMatrixAsLookAt not working to set the initial camera position

2019-01-07 Thread sam
After you set the home position try:
viewer.getCameraManipulator()->home(1);

Sorry I'm not right in front of my computer right now.

On Mon, Jan 7, 2019 at 7:26 PM Rodrigo Dias  wrote:

> Hi Sam,
>
> By "home" I think you mean
>
>
> Code:
> viewer.getCameraManipulator()->setHomePosition( eye, center, up );
>
>
>
>
> This really changed camera's position, though it's totally freaking out
> now (I'm still fiddling with the values in eye, center and up).
>
> But I have no idea what you meant by "delta time", something to go inside
> the loop?
>
> Thank you!
>
> Cheers,
> Rodrigo
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75413#75413
>
>
>
>
>
> ___
> 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


Re: [osg-users] setViewMatrixAsLookAt not working to set the initial camera position

2019-01-07 Thread Rodrigo Dias
Hi Sam,

By "home" I think you mean


Code:
viewer.getCameraManipulator()->setHomePosition( eye, center, up );




This really changed camera's position, though it's totally freaking out now 
(I'm still fiddling with the values in eye, center and up).

But I have no idea what you meant by "delta time", something to go inside the 
loop?

Thank you!

Cheers,
Rodrigo

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] setViewMatrixAsLookAt not working to set the initial camera position

2019-01-07 Thread sam
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  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 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
>
> 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 = new Map(mapOpt);
> {
> GDALOptions gdal;
> gdal.url() = "br_modified.tif";
> osg::ref_ptr layer = new ImageLayer( "BR",
> gdal );
> map->addLayer( layer );
> }
> {
> GDALOptions gdal;
> gdal.url() = "BRalt.tif";
> osg::ref_ptr layer = new ElevationLayer(
> "SRTM", gdal );
> map->addLayer( layer );
> }
> osg::ref_ptr mapNode = new MapNode( map );
> osgViewer::Viewer viewer;
> viewer.setSceneData( mapNode.get() );
> viewer.setCameraManipulator( new osgGA::TrackballManipulator );
>
> Vec3 eye( 1.0, 5.0, 10.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


[osg-users] setViewMatrixAsLookAt not working to set the initial camera position

2019-01-07 Thread Rodrigo Dias
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 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

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 = new Map(mapOpt);
{
GDALOptions gdal;
gdal.url() = "br_modified.tif";
osg::ref_ptr layer = new ImageLayer( "BR", gdal );
map->addLayer( layer );
}
{
GDALOptions gdal;
gdal.url() = "BRalt.tif";
osg::ref_ptr layer = new ElevationLayer( 
"SRTM", gdal );
map->addLayer( layer );
}
osg::ref_ptr mapNode = new MapNode( map );
osgViewer::Viewer viewer;
viewer.setSceneData( mapNode.get() );
viewer.setCameraManipulator( new osgGA::TrackballManipulator );

Vec3 eye( 1.0, 5.0, 10.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