Repositioning the Origin

classic Classic list List threaded Threaded
6 messages Options
Nonsanity Nonsanity
Reply | Threaded
Open this post in threaded view
|

Repositioning the Origin

I have a flat projection of a small map in osgEarth, and I want to move the map so that the loaded section is centered at the world origin. I don't want to break anything in the process, like ObjectPlacer.

Is the best method just to use a PositionAttitudeTransform above the whole osgEarth graph, or is there something built into the code to do this?

 ~ Chris Innanen
 ~ Nonsanity
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Repositioning the Origin

Chris,

osgEarth is designed to always operate in real world coordinates. There's nothing in the code to do what you want.

Can you elaborate on why you want to re-position the terrain at the origin? Knowing your motivation might help in figuring out the best approach.

Glenn
Glenn Waldron / Pelican Mapping
JesseStimpson JesseStimpson
Reply | Threaded
Open this post in threaded view
|

Re: Repositioning the Origin

In reply to this post by Nonsanity
For what it's worth, I had to do the same thing for my application. What I did is to put a MatrixTransform above the osgEarth subgraph that translates the entire thing into my own coordinate system. I determined the UTM point (e,n) that I want to be at the origin and translated by

mtrix.makeTranslate(osg::Vec3d(-e,-n,0.0));

I don't use the ObjectPlacer, but I think you're right in assuming that it will return a position in osgEarth's coordinate system (UTM for me). So you'd have to transform that by the same matrix as well.

Hope that helps,
Jesse
Nonsanity Nonsanity
Reply | Threaded
Open this post in threaded view
|

Re: Repositioning the Origin

In reply to this post by gwaldron
I'm attempting to combine osgEarth and osgOcean, something I haven't seen done anywhere else yet. I described some of the problems I've been having on the osgOcean forum and this repositioning to the origin was suggested there. I don't know if it will help, but it's worth a try.

And I'm glad a simple transform will work. That's what I'm about to try even now.

And even with ObjectPlacer, as long as what it is placing is also below this offset matrix, no further conversion need take place.

 ~ Chris Innanen
 ~ Nonsanity
Nonsanity Nonsanity
Reply | Threaded
Open this post in threaded view
|

Re: Repositioning the Origin

What about scaling? It looks like osgEarth uses the lat and long as x and y values in flat projections. I could slap a scale matrix over it all, but then I'd have to rescale the normals as well to get it lit properly, which is computationally expensive. Is it possible to tell osgEarth to, say, multiply the lat and long by 110844.41 (which would make integers into meters at my chosen latitude) when it creates the terrain?

 ~ Chris Innanen
 ~ Nonsanity
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Repositioning the Origin

Chris,

osgEarth uses whatever SRS you tell it to use in flat/projected. If you don't specify one, it takes it from the first layer. If you ask for WGS84, then you will get X=long and Y=lat (plate carre). If you want a local projection in meters (e.g. UTM), define one using the <profile> tag.

See http://www.osgearth.org/wiki/MapElementProfile or refer the "dc_state_plane.earth" sample.

hth, Glenn
Glenn Waldron / Pelican Mapping