Needed help...local coordinate system for trackNode and mouse coordinates... #1954
-
I'm in need of some help with a problem I'm trying to solve... I have a trackNode that has just one drawable (no icon, no schema) which draws a single line segment. I set it this way so I can pick the line in the drawable of the trackNode. The first vertex of the line remains fixed at (0,0) in the local coordinate system of the trackNode and the second vertex is offset from the origin at (0,20). What I would like to do is pick the line (which I can do) and change the endpoint of the line by dragging it around using the mouse. The first vertex would remain fixed at the origin of the trackNode. My thought is to transform the mouse coordinates in viewport space to the local coordinate screen space of the drawable to update the line endpoint as I drag the mouse around but I'm not sure if this is possible. Is there a transform that maps mouse coordinates into the local screen coordinates used by the trackNode for drawables? I've also looked at using draggers to manipulate the line endpoint with the mouse but those only work with map coordinates. Our application is using a Mercator projection mapNode. Any help or suggestions on how I can solve this problem would be appreciated... |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
It sounds like you want to convert from the https://github.com/gwaldron/osgearth/blob/master/src/osgEarth/ScreenSpaceLayoutDeclutter#L198 That matrix will transform from a "TrackNode local" coord to a viewport coord. The inverse will go in the other direction. |
Beta Was this translation helpful? Give feedback.
-
So...I tried Glenn's suggestion and it doesn't seem correct in transforming the TrackNode drawable vertex into Viewport CS and back. Per the suggestion, here's the code I'm using to test. It attempts to transform the trackNode line from it's space into viewport space. For a sanity check it then transforms that result back into trackNode space...
The line in the trackNode drawable is defined as (0,0 and (0, 50) for both endpoints. The window size is 800 x 600. The output is as follows transforming the point (0,50) into viewport space and back into trackNode space.
These results look wrong. I'd expect the transformed point into the viewport space to be somewhere other than the middle of the screen. I'd expect the transformed y-coordinate to be larger. The second line is just transforming back into TrackNode space which I expect it to be at (0,50). Perhaps I'm not doing something correctly or something is missing? |
Beta Was this translation helpful? Give feedback.
-
Glenn,
The suggestion didn't work. See my comment on the discussion topic.
Shayne
… On 01/31/2022 7:33 AM Glenn ***@***.***> wrote:
It sounds like you want to convert from the TrackNode coordinate space to viewport space. This is a standard MVPW (modelview->projection->window) transformation, which is constructed here:
https://github.com/gwaldron/osgearth/blob/master/src/osgEarth/ScreenSpaceLayoutDeclutter#L198
That matrix will transform from a "TrackNode local" coord to a viewport coord. The inverse will go in the other direction.
—
Reply to this email directly, view it on GitHub #1954 (comment) , or unsubscribe https://github.com/notifications/unsubscribe-auth/ATC464OSDBVA357O7PDNWRDUY2MU3ANCNFSM5NFDAPTQ .
Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
So...just a follow up to my previous problem... When I changed from a mapNode using a Mercator projection to a Geocentric mapNode, everything above works as expected with the world to window transformation. I need to find out why the MVPW transformation doesn't work with Mercator... Any suggestions or ideas on why using a mapNode with Mercator fails to give a proper world-to-window transform? |
Beta Was this translation helpful? Give feedback.
-
A follow up to my previous follow up... There were two problems.
Now everything works. Glenn's tip of using the MVPW transform helped me get the rest of the way through so thank you. |
Beta Was this translation helpful? Give feedback.
It sounds like you want to convert from the
TrackNode
coordinate space to viewport space. This is a standard MVPW (modelview->projection->window) transformation, which is constructed here:https://github.com/gwaldron/osgearth/blob/master/src/osgEarth/ScreenSpaceLayoutDeclutter#L198
That matrix will transform from a "TrackNode local" coord to a viewport coord. The inverse will go in the other direction.