ArCore: Get Pose for object oriented normally to plane but, rotated in direction of camera

308 Views Asked by At

I am writing an application using ArCore. I am getting an object's pose as a Hitresult, therefore the object is placed correctly in the plane, but not correctly orientated/rotated towards the smartphone. For a more complete problem description: The object is a 2d rectangle and is intended to stay inside the plane (= same normal vectors). The rectangle also needs to "point" to the camera (= nearest border needs to be aligned with the smartphone screen).

currentObstaclePose = hit.getHitPose().extractTranslation().compose(frame.getCamera().getPose().extractRotation())

Using this approach I do not get matching normal vectors for object and plane.

I have no idea how to construct the objects quaternions in a manner to achieve my goal. Thanks in advance for your help.

1

There are 1 best solutions below

0
On

It sounds like you want to set the 'look direction' of the renderable.

Assuming you are using Scenefrom, which I see is tagged, you can use a TransformableNode and the method setLookDirection.

The example below will set the direction of the renderable, depending on the value you set for lookDirection:

            var newAnchorNode:AnchorNode = AnchorNode(newAnchor)
            var transNode = TransformableNode(arFragment.transformationSystem)
            transNode.setLookDirection(Vector3(0f, xPoint.toFloat(), yPoint.toFloat()), lookDirectionValue) 
            transNode.renderable = yourRenderable
            transNode.setParent(newAnchorNode)
            newAnchorNode.setParent(arFragment.arSceneView.scene)
            setAnchorNodes.add(newAnchorNode)