Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I resize an object in ARCore?

I show the 3D object in ArFragment. So I put .obj file and .mtl file at sampledata folder. And I right click on obj file, and select Import Sceneform Asset to add .sfa / .sfb file.

So I can show the 3d object when I mark the image, but the object is too big.

This is my .sfa file detail

{
   bound_relative_root: {
      x: 0.5,
      y: 0,
      z: 0.5,
   },
   materials: [
      {
         name: "Material.001",
         parameters: [
            {
               baseColor: null,
            },
            {
               baseColorTint: [
                  0.80000000000000004,
                  0.80000000000000004,
                  0.80000000000000004,
                  1,
               ],
            },
            {
               metallic: 1,
            },
            {
               roughness: 0.120695,
            },
            {
               opacity: null,
            },
         ],
         source: "build/sceneform_sdk/default_materials/obj_material.sfm",
      },
   ],
   model: {
      attributes: [
         "Position",
         "TexCoord",
         "Orientation",
      ],
      collision: {},
      file: "sampledata/dongbaek.obj",
      name: "dongbaek",
      recenter: "root",
      scale: 0.200000
   },
   version: "0.52:1",
}

I think it can resize by scale part, but I change the value, it dosen't change. same size

So How I can resize 3d object?

Is there any problem at add 3d object file to make .sfa / .sfb file?(Import Sceneform Asset)

If you know about it, please help me.

like image 947
Polaris Nation Avatar asked Oct 10 '18 09:10

Polaris Nation


3 Answers

Different approaches depending on your project:

  1. Change the scale value, regenerate your sfb files
  2. Put your node into a TransformableNode and let ScaleController scale your model
  3. Directly use setLocalScale or setWorldScale
  4. Scale your .obj file, and then generate the .sfa and .sfb files
like image 53
ManuelTS Avatar answered Oct 06 '22 04:10

ManuelTS


Object scaling is changed by the Scale Controller. By setting minScale and maxScale value. Before setting parent - anchor node. See example below.

      // Create the Anchor.
      Anchor anchor = hitResult.createAnchor();
      AnchorNode anchorNode = new AnchorNode(anchor);
      anchorNode.setParent(arFragment.getArSceneView().getScene());

      // Create the transformable andy and add it to the anchor.
      TransformableNode node = new TransformableNode(arFragment.getTransformationSystem());
// Maxscale must be greater than minscale
        node.getScaleController().setMaxScale(0.02f);
        node.getScaleController().setMinScale(0.01f);

        node.setParent(anchorNode);
        node.setRenderable(renderable);
        node.select();
like image 31
LadyWoodi Avatar answered Oct 06 '22 04:10

LadyWoodi


Use the following code to resize your model in ARCore:

TransformationSystem transSys;
transSys = MainActivity.getArFragment().getTransformationSystem();
TransformableNode myNode = new TransformableNode(transSys);

myNode.setLocalScale(new Vector3(0.25f, 0.25f, 0.25f));
myNode.setParent(anchorNode);
//myNode.setParent(sceneView.getScene());
myNode.setRenderable(myModelRenderable);

sceneView.getScene().addChild(node);
myNode.select();
like image 40
Andy Jazz Avatar answered Oct 06 '22 04:10

Andy Jazz