ARCore – How to set default scale for a Transformable node?
Asked Answered
K

4

5

I am using Transformable node and able to set minimum and maximum scale values. But I am using a model whose default size is much bigger so I have to use gestures to make it small.

How is it possible to set default scale value of a model / Transformable node?

Kovar answered 16/5, 2018 at 6:46 Comment(0)
R
9

i think you can use TransformableNode's setLocalScale method before it set a actual Renderable. like the code below

TransformableNode andy = new TransformableNode(arFragment.getTransformationSystem());
      andy.setLocalScale(new Vector3(0.1f, 0.1f, 0.1f));
      andy.setParent(anchorNode);
      andy.setRenderable(andyRenderable);
      andy.select();

I used 0.1f for x, y, z value, then it looks better

Reexamine answered 17/5, 2018 at 9:55 Comment(3)
Note that the scale is bounded by the max/min values of the ScaleController of the TransformableNode. You can change it with transformableNode.getScaleController().setMaxScale(maxScale) and transformableNode.getScaleController().setMinScale(minScale).Whiles
Can you please tell me how to get the TransformableNode scaled size in meters. Suppose I scaled a cube in y direction. Now I want to get the scaled size of it in unit meters. Please help me how to do that?Lexy
If the above solution doesn't work, you may have to set the minimum scale by doing the following. In my case, the existing minScale was .75f andy.getScaleController().setMinScale(0.1f));Impressionable
M
3

You can easily use this code for setting a default scale for a Transformable nodes:

TransformationSystem arTS;
arTS = MainActivity.getArFragment().getTransformationSystem();

TransformableNode node = new TransformableNode(arTS);
node.setRenderable(modelRenderable);
node.getScaleController().setMinScale(0.1999f);
node.getScaleController().setMaxScale(0.2000f);
node.setLocalScale(exhibit.getModelScale());
node.setLocalPosition(exhibit.getModelPosition());
//node.setParent(anchorNode);
node.setParent(sceneView.getScene());

node.getRotationController().setEnabled(true);
node.getScaleController().setEnabled(true);

sceneView.getScene().addChild(node);
node.select();
Miniaturist answered 22/4, 2019 at 19:30 Comment(2)
I get java.lang.IllegalStateException: maxScale must be greater than minScale when I do this. Are you sure MinScale and MaxScale can be equal?Queridas
In such a case you can set it like this: .setMinScale(0.1999f).Miniaturist
S
0

imho easiest way to set default scale for node is to define scale attribute of 3d model in sfa-file

Starch answered 5/4, 2020 at 9:29 Comment(0)
D
0

In your .sfa file, change the default value of scale, then load the models and re-build the application

Dumont answered 29/6, 2021 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.