google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

How do you detect that a camera node in a scene collides with a node in an AR scene? #664

Open Chen-Alexander opened 5 years ago

Chen-Alexander commented 5 years ago

It is best to get the collision event through the callback, because I need to know which two nodes have collided, the specific location of the collision point. PS:By scene.hitTest (Ray), it is not suitable for me, I have tested it.

Thanks!

stewe93 commented 5 years ago

On every frame, I check with this with the following code:

collisionRay = Ray(camera.worldPosition, camera.forward)
        val result = scene.hitTest(collisionRay)
        if (result != null && result.distance < 0.2f) {
            when (result.node.name) {

You could determine the exact node by setting its name parameter and look for it when collision happens. The exact collision point is out of my scope but I will look for a solution later. I hope this helps

Chen-Alexander commented 5 years ago

I already solve this question. but , thank you very much.

------------------ 原始邮件 ------------------ 发件人: "Béri István"notifications@github.com; 发送时间: 2019年5月22日(星期三) 上午6:04 收件人: "google-ar/sceneform-android-sdk"sceneform-android-sdk@noreply.github.com; 抄送: "魑魅魍魉"1401429109@qq.com;"Author"author@noreply.github.com; 主题: Re: [google-ar/sceneform-android-sdk] How do you detect that a cameranode in a scene collides with a node in an AR scene? (#664)

On every frame, I check with this with the following code: collisionRay = Ray(camera.worldPosition, camera.forward) val result = scene.hitTest(collisionRay) if (result != null && result.distance < 0.2f) { when (result.node.name) {
You could determine the exact node by setting its name parameter and look for it when collision happens. The exact collision point is out of my scope but I will look for a solution later. I hope this helps

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.