arfoundation-samples icon indicating copy to clipboard operation
arfoundation-samples copied to clipboard

About scaling content and how to reset the plane

Open Leiong opened this issue 8 years ago • 13 comments

Hi Unity, Question 1: I want to scale the content rendered by ARSessionOrigin, arsessionOrigin.transform.localScale = Vector3.one * scaleValue, but it will affect the point cloud particle effects. It looks strange, is it something I missed?

Problem 2: Disable ARsession, then enable ARSession, the previous plane still appears and cannot be cleared. I need to implement enable AR, reset AR, close AR, how do I need to set it up; aaaa Thanks!

Leiong avatar Jul 11 '18 10:07 Leiong

Hi Leiong,

Question 1: I want to scale the content rendered by ARSessionOrigin, arsessionOrigin.transform.localScale = Vector3.one * scaleValue, but it will affect the point cloud particle effects. It looks strange, is it something I missed?

Could you post a screen shot of the "strange" result?

Problem 2: Disable ARsession, then enable ARSession, the previous plane still appears and cannot be cleared. I need to implement enable AR, reset AR, close AR, how do I need to set it up;

Thanks for the code snippet. You should not set ARSubsystemManager.systemState yourself (the setter should be private -- it's a mistake that it isn't). The correct way to reset the session is to Destroy it and re-add it, though there are some known issues with this, particularly on ARKit. This will be fixed in the next preview release. I'm also going to add a method Reset to the ARSession to make this easier.

ghost avatar Jul 17 '18 05:07 ghost

Hi Timm, Question 1: When I want to scale the content rendered by ARSessionOrigin, the position of the particle effect is wrong, and the size of the border changes. This is not the result I want. img_0033 img_0034 Question 2:After the Cube is generated, is there a way to remove the particle effects and planes? This will not affect my observation of the object. (Sorry, this is the text of Google Translate, I hope you can understand it......)

Leiong avatar Jul 17 '18 07:07 Leiong

Question 1: When I want to scale the content rendered by ARSessionOrigin, the position of the particle effect is wrong, and the size of the border changes. This is not the result I want.

Does your point cloud prefab have a non-zero position? It looks like an extra offset is being applied. The line renderer being affected by scale is currently expected. The outline is mostly for debugging purposes. You can simply remove the line renderer from your prefab if you don't want it.

Question 2:After the Cube is generated, is there a way to remove the particle effects and planes? This will not affect my observation of the object.

Yes. To disable plane detection and point cloud updates, you can disable their managers: ARPlaneManager and ARPointCloudManager, respectively. To remove existing planes/point cloud from the scene, you can disable or remove their GameObjects. You can get all the planes with ARPlaneManager.GetAllPlanes and the point cloud with ARPointCloudManager.pointCloud

ghost avatar Jul 18 '18 21:07 ghost

I was having a similar issue to this and scaling the point cloud prefab by the same scale as the ARSessionOrigin resolved the issue for me.

southrop avatar Jul 23 '18 07:07 southrop

I was having a similar issue to this and scaling the point cloud prefab by the same scale as the ARSessionOrigin resolved the issue for me.

That sounds odd. What does your scene hierarchy look like? Does your point cloud prefab have an identity transform?

ghost avatar Jul 23 '18 15:07 ghost

Yes. To disable plane detection and point cloud updates, you can disable their managers: ARPlaneManager and ARPointCloudManager, respectively. To remove existing planes/point cloud from the scene, you can disable or remove their GameObjects. You can get all the planes with ARPlaneManager.GetAllPlanes and the point cloud with ARPointCloudManager.pointCloud

After the Cube is generated,remove existing planes/point cloud from the scene 001 But the planes/point cloud did not appear when ARSession.Reset();
002

Does your point cloud prefab have a non-zero position? It looks like an extra offset is being applied. The line renderer being affected by scale is currently expected. The outline is mostly for debugging purposes. You can simply remove the line renderer from your prefab if you don't want it. 003

the point cloud prefab have a non-zero position, but this problem will still appear,Is the method like this? 004

Leiong avatar Jul 24 '18 03:07 Leiong

That sounds odd. What does your scene hierarchy look like? Does your point cloud prefab have an identity transform?

My scene hierarchy looks like this. Aside from a few UI-related addition and a camera clipping plane tweak (to account for the 300 scale), it's identical to the sample.

image

I use the default point cloud prefab generated from the Right-Click menu entry, and it has a completely zero'd out transform with the exception of scale.

southrop avatar Jul 24 '18 03:07 southrop

@Leiong Thanks for the screenshots! Very helpful.

But the planes/point cloud did not appear when ARSession.Reset();

Did you also re-enable the point cloud and plane managers? It looks like you disable them, then reset the ARSession, but don't re-enable them. If those managers are disabled, then plane detection and point cloud updates are disabled.

the point cloud prefab have a non-zero position, but this problem will still appear

The image you posted is of the plane prefab. Can you double check the point cloud prefab?

Is the method like this?

That is the correct way to scale the ARSessionOrigin, yes.

ghost avatar Jul 25 '18 17:07 ghost

@southrop Hmm. Could you share your project? Either here or send it to me at [email protected]

ghost avatar Jul 25 '18 17:07 ghost

@timm-unity I've sent you an email with a replication

southrop avatar Jul 26 '18 04:07 southrop

@southrop Thanks; was able to repro, and I know what the issue is. This should solve @Leiong 's problem too.

In your point cloud prefab, change the "Scaling Mode" to "Hierarchy": scalemodehierarchy

This is what I use to test, but for some reason the point cloud created from the XR menu produces one with Scaling Mode set to "Local". I'll fix the generation util to use the correct setting.

ghost avatar Jul 26 '18 06:07 ghost

@timm-unity Brilliant, that resolves it!

While you're making changes to the generation util, perhaps it's worth mentioning that the default point cloud gameobject gets created with the name AR Default Point Cloud with a space at the end. Not really a big issue but seems unintentional.

southrop avatar Jul 26 '18 06:07 southrop

Nice catch; will do!

ghost avatar Jul 26 '18 06:07 ghost