获取以米为单位的TransformableNode大小

时间:2018-10-12 13:03:18

标签: android arcore sceneform

我最初是在Vector3中设置TransformableNode Size的。然后,我缩放了TransformableNode。 我现在想要在Vector3中以米为单位的缩放后的TransformableNode大小。 请帮助我。 我尝试了这些但没有任何解决方案:

Vector3 vec = transformableNode.getLocalPosition();
Vector3 vector = transformableNode.getWorldPosition();
Vector3 vector31 = transformableNode.getWorldScale();
Vector3 vector32 = transformableNode.getLocalScale();
Log.e("Vector Local Position: ", String.valueOf(vec.x + " " + vec.y + " " + vec.z));
Log.e("Vector World Position: ", String.valueOf(vector.x + " " + vector.y + " " + vector.z));
Log.e("Vector World Scale: ", String.valueOf(vector31.x + " " + vector31.y + " " + vector31.z));
Log.e("Vector Local Scale: ", String.valueOf(vector32.x + " " + vector32.y + " " + vector32.z));

1 个答案:

答案 0 :(得分:2)

要获取可渲染的尺寸(以米为单位),您可以执行以下操作:

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

一旦有了可渲染对象的大小,就可以通过将可渲染对象的大小乘以比例来获得TransformableNode的最终大小:

Vector3 transformableNodeScale = transformableNode.getWorldScale();
  Vector3 finalSize =
      new Vector3(
          renderableSize.x * transformableNodeScale.x,
          renderableSize.y * transformableNodeScale.y,
          renderableSize.z * transformableNodeScale.z);