How to place a chair object in arcore with exact size of chair in real life?

Viewed 825

I want to place a chair in arcore using sceneform so that it will take exact space in the room as a real chair will take space.

1 Answers

I did work on a ARCore project.
and I had to show the real world size in centimeter.
so i used code below.

    Box box = (Box) transformableNode.getRenderable().getCollisionShape();
    Vector3 size = box.getSize();

    Vector3 transformableNodeScale = transformableNode.getWorldScale();


    Vector3 finalSize =
            new Vector3(
                    (float) (Math.round((size.x * transformableNodeScale.x * 100) * 10) / 10.0),
                    (float) (Math.round((size.y * transformableNodeScale.y * 100) * 10) / 10.0),
                    (float) (Math.round((size.z * transformableNodeScale.z * 100) * 10) / 10.0));


    x_cm = String.valueOf(finalSize.x); //세로
    y_cm = String.valueOf(finalSize.y); //높이
    z_cm = String.valueOf(finalSize.z); //가로
    mtextView.setText("( 가로 : " + z_cm + "cm " + "세로 : " + x_cm + "cm " + "높이 : " + y_cm +"cm )");

so adding some explanation, create a box which covering the currently rendered model,
and get the worldscale of it.
since Unity is using meter, convert it to centimeter and show the size on the screen.

i'm not sure it's gonna work, but i guess you can get the world scale size using this
and use it when you scale your model (maybe getting input from user (seekbar etc.)).

Sorry If this one doesn't meet your needs.

Related