Как отключить облака точек в ARkit только после размещения 3D-контента на плоскости в Unity3d? - PullRequest
0 голосов
/ 12 июня 2019

После того, как плоскость обнаружена, как удалить облака точек, как только плоскость обнаружена, или после того, как я поместил 3d-модель на касание плоскости (используя UnityHitTest), облака точек должны исчезнуть. Мне удалось скрыть синие плоскости, которыеприходит, когда плоскость обнаружена, но мне нужно также избегать облаков точек. Сначала я хочу показать облако точек для сканирования после HitTest, я хочу скрыть его.

Мое реальное приложение заключается в отключении облаков точек после arworldmapЗагружается. Есть идеи?Я добавил некоторый код ниже, чтобы скрыть облака точек для поиска метода частицoffoffck () в классе 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");

}

}
...