Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

touch the scene, get lat/long position and add new object with this coordinates #112

Open
openmotion opened this issue Jan 18, 2020 · 1 comment

Comments

@openmotion
Copy link

openmotion commented Jan 18, 2020

hello
how can i get latitude / longitude when i touch a virtual ground

i added touchlistener to arsceneview
arSceneView .getScene() .setOnTouchListener( (HitTestResult hitTestResult, MotionEvent event) -> { return gestureDetector.onTouchEvent(event); });
my gesture detector
` // Set up a tap gesture detector.
gestureDetector =
new GestureDetector(
this,
new GestureDetector.SimpleOnGestureListener() {
@OverRide
public boolean onSingleTapUp(MotionEvent e) {
onSingleTap(e);
return true;
}

                        @Override
                        public boolean onDown(MotionEvent e) {
                            return true;
                        }
                    });`

my onsingletap

`private void onSingleTap(MotionEvent tap) {
Log.d(TAG,"single tap X1");

    float centerX = tap.getX();
    float centerY = tap.getY();

    Log.d(TAG,"centerX : "+centerX);
    Log.d(TAG,"centerY : "+centerY);

    Frame frame = arSceneView.getArFrame();
    if (frame != null) {
        Log.d(TAG,"single tap X2");


        Collection<Plane> planes = frame.getUpdatedTrackables(Plane.class);
        for (Plane plane : planes) {

            Log.d(TAG,"liste plan : "+plane.getType());

            if (plane.getTrackingState() == TrackingState.TRACKING && plane.getType() == Plane.Type.HORIZONTAL_UPWARD_FACING) {
                List<HitResult> hitResults = frame.hitTest(centerX, centerY);

                int count_hit = hitResults.size();
                        Log.d(TAG,"count_hit : "+count_hit);

                if (hitResults.size() > 0) {
                    Anchor Nanchor = hitResults.get(0).createAnchor(); // how can i have lat / lng coordinate here ? thanks ?
                    float[] Xaxis = Nanchor.getPose().getXAxis();
                    Log.d(TAG,"Xaxis : "+Xaxis[0]);
                    // return hitResults.get(0).createAnchor();
                }
            }
        }
    }
}`

thanks

@openmotion openmotion changed the title click on ground and add object touch the scene, get lat/long position and add new object with this coordinates Jan 18, 2020
@VishalAr1996
Copy link

Hey had you found anything related to this??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants