glob3mobile / g3m

The multiplatform advanced visualization framework
http://www.glob3mobile.com/
Other
116 stars 56 forks source link

point2Pixel method problem #115

Open DimitrisMarm opened 9 years ago

DimitrisMarm commented 9 years ago

Hey all,

I use the point2Pixel() method of the Camera class to find the exact position in pixels of a marker obect relatively to the viewport.
While method seems to function well upon marker's placement on the map, it fails to return the correct pixels when viewport moves (while marker remains within the visible sector). 

Is there something I miss or is it a bug of the method or anyhting else I can't perceive right now? 

Thanks a lot, Jim

DiegoGomezDeck commented 9 years ago

Hi @DimitrisMarm

I'm quiet sure this method (point2Pixel) works well as it's being used in several places. Can you include here the code that's not working for you?

DimitrisMarm commented 9 years ago

Hi @DiegoGomezDeck

Well i use it first in ICameraConstrainer myCameraConstrainer = new ICameraConstrainer() { ...... public boolean onCameraChange(Planet planet, final Camera previousCamera, final Camera nextCamera) {

            Vector2F dim = nextCamera.point2Pixel(new Vector3D(users.get(0)
                    .getUserPosition()._latitude._degrees, users.get(0)
                    .getUserPosition()._longitude._degrees, users.get(0)
                    .getUserPosition()._height));
                      ......

}

and then in builder.getPlanetRendererBuilder().addVisibleSectorListener( new VisibleSectorListener() {

                @Override
                public void onVisibleSectorChange(
                        final Sector visibleSector,
                        Geodetic3D cameraPosition) {

                                                     .............

Vector2F dim = _g3mWidget.getNextCamera().point2Pixel(new Vector3D(users.get(0).getUserPosition()._latitude._degrees, users.get(0) .getUserPosition()._longitude._degrees, users.get(0) .getUserPosition()._height)) ;

                          ...................
    }

}

is something wrong in my code or the method doesn't work in this way?

DiegoGomezDeck commented 9 years ago

Hi @DimitrisMarm

The VisibleSectorListener mechanism produces just an approximation of the visible Sector (merging all the sectors of the visible tiles). As a consequence of it, the "changed' event is not fired for small camera movements.

I suggest you to try updating the position in each camera frame (you can do it just in the CameraConstraint method).

BTW, we're just coding now a new mechanism to detect if the camera was changed between the previous and the current frame... when we merge this new stuff, you can avoid updating the position in every frame and just do it only when the camera position changes. Please keep tuned to "purgatory" changes, I guess sometime in the next week we'll able to merge it.

DiegoGomezDeck commented 8 years ago

Hi @DimitrisMarm

Did it help? Can I close this issue?

DimitrisMarm commented 8 years ago

Hi @DiegoGomezDeck

sorry for the delayed response but i was away for a while.
It help me a lot. yes you can close the issue.

thanks a lot, Jim