仅在将3d内容放置在Unity3d中的平面上之后,如何关闭ARkit中的点云?

时间:2019-06-12 07:08:32

标签: ios unity3d arkit point-clouds

在检测到飞机后,一旦检测到飞机,或者我将3d模型放置在触摸飞机上(使用UnityHitTest)之后,该点云应该消失了。我设法隐藏了蓝色飞机在检测到飞机时出现,但我也要避开点云。最初,我想在HitTest之后显示要扫描的点云,然后将其隐藏。

我真正的应用程序位于这里,在加载arworldmap后禁用点云。 我在下面添加了一些代码以隐藏点云,以在PointCloudParticleExample类中寻找微粒关闭检查()方法。

在课堂上进行某些操作时需要关闭粒子的情况

//Calling method to turn off the point clouds
    public void Loaddata()
    {
       pointinstance. PointCloudParticleExample.particlesoffcheck();
    }

PointCloud类

public class PointCloudParticleExample : MonoBehaviour 
{
public ParticleSystem pointCloudParticlePrefab;
public int maxPointsToShow;
public float particleSize = 1.0f;
Vector3[] m_PointCloudData;
bool frameUpdated = false;
public ParticleSystem currentPS;
ParticleSystem.Particle [] particles;
//added
int loadcheck=0;



//For creating instance of class
public static PointCloudParticleExample pointinstance;

// Use this for initialization
void Start () 
{
    UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated;

    currentPS = Instantiate (pointCloudParticlePrefab);

    m_PointCloudData = null;
    frameUpdated = false;
    pointinstance = this;
}

public void ARFrameUpdated(UnityARCamera camera)
{
    if (camera.pointCloud != null)
    {
       m_PointCloudData = camera.pointCloud.Points;
    }
    frameUpdated = true;
}

// Update is called once per frame
void Update () 
{

    if (frameUpdated) 
    {
        if (m_PointCloudData != null && m_PointCloudData.Length > 0 && maxPointsToShow > 0 ) 
        {
            int numParticles = Mathf.Min (m_PointCloudData.Length, maxPointsToShow);
            ParticleSystem.Particle[] particles = new ParticleSystem.Particle[numParticles];
            int index = 0;
            foreach (Vector3 currentPoint in m_PointCloudData) 
            {     
                particles [index].position = currentPoint;
                particles [index].startColor = new Color (1.0f, 1.0f, 1.0f);
                particles [index].startSize = particleSize;
                index++;
                Debug.Log("Points set to 0 called");
                if (index >= numParticles) break;
            }
            currentPS.SetParticles (particles, numParticles);


        } 
        else 
        {
            ParticleSystem.Particle[] particles = new ParticleSystem.Particle[1];
            particles [0].startSize = 0.0f;
            currentPS.SetParticles (particles, 1);
            Debug.Log("Points set to 1 called");
        }


        frameUpdated = false;
    }
}



//Added to turn off the pointcloud
public void particlesoffcheck()
{

    particles[0].startSize = 0.0f;
    currentPS.SetParticles(particles, 0);
    Debug.Log("Load points off");

}

}

0 个答案:

没有答案