Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Adding an object on vertical plane always rotated. #65

Closed
jagsrajput21 opened this issue Jun 4, 2018 · 6 comments
Closed

Adding an object on vertical plane always rotated. #65

jagsrajput21 opened this issue Jun 4, 2018 · 6 comments
Labels

Comments

@jagsrajput21
Copy link

I am adding a TV Model on a vertical plane. TV is always rotated in the y-axis.

screenshot_20180604-122250

It should be parallel to the horizontal plane.

My code for placing TV object on vertical Plane is -

AnchorNode anchorNode = new AnchorNode(hit.createAnchor());
TransformableNode node = new TransformableNode(fragment.getTransformationSystem());
node.setRenderable(renderable);
node.setParent(anchorNode);
fragment.getArSceneView().getScene().addChild(anchorNode);

@malik-at-work
Copy link

The Transformation System was designed for horizontal user experiences. We worked closely with our UX designers and researchers to design it in Sceneform 1.0.

Our upcoming release will address vertical experiences.

In the meantime I might suggest inserting a node to add a rotation.

@jagsrajput21
Copy link
Author

@malik-at-work How inserting a node to add a rotation will solve this problem? Can you please elaborate?

@khonakr
Copy link

khonakr commented Jun 5, 2018

+1
@malik-at-work I would like to know how to change axis of rotation using a node as well.
My models are on horizontal surface but they rotate in an incorrect axis and would like to know a work around.

@dsternfeld7
Copy link

When the anchor is created, that anchor includes a rotation where the up direction of the node is along the surface normal of the plane, and also faces roughly towards the user's device. A more detailed description of this is here.

After setting parent of the TV node to the anchor, you can change the TV nodes rotation so that it is always facing in the correct direction you want:

if (plane.getType() == Type.VERTICAL) {
            Vector3 anchorUp = anchorNode.getUp();
            andy.setLookDirection(Vector3.up(), anchorUp);
}

@khonakr I believe the question you are asking is slightly different. The axis of rotation for a TransformableNode is always the up direction of the anchor (aka the surface normal of the plane). You may want to do the following:

  1. Create a new Node and set its parent to the TransformableNode.
  2. Set the Renderable on the new node, not the transformable node itself.
  3. Rotate the new node by 90 degrees.

This way, the TransformableNode is still rotated along the surface normal of the plane, but the rendered object is rotated relative to that. One important note is that the TransformableNode still needs its own collision shape so that the node can be selected and dragged (which by default comes from the Renderable).

There is an example here that does something similar that will help show you how to add a child to the TransformableNode and setup the collision shapes correctly.

@khurramengr
Copy link

@jagsrajput21 did you manage to solve this issue?

@SarvagyaVaish
Copy link

            Vector3 anchorUp = anchorNode.getUp();
            andy.setLookDirection(Vector3.up(), anchorUp);

^^ this fixed the issue for me :)

Also, thank you @dsternfeld7 for the link describing the coordinate system setup for anchors based on plane type.

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

No branches or pull requests

6 participants