private void ChangeVoxelMaterial(DetectedPlaneVisualizer newPlane, HashEntry hashEntry, Material material)
        {
            switch (Optimization.DoRayCastFromHashEntryToPlane(newPlane, hashEntry))
            {
            case Optimization.VoxelPlaneCollision.DOWN:
                //hashEntry.voxel.gameObject.GetComponent<MeshRenderer>().material = m_CustomMaterialRed;
                m_Reconstructor.GetSpatialHashing().setRemoved(hashEntry.hash);
                break;

            case Optimization.VoxelPlaneCollision.UP:
                //hashEntry.voxel.gameObject.GetComponent<MeshRenderer>().material = m_CustomMaterialGreen;
                m_Reconstructor.GetSpatialHashing().setRemoved(hashEntry.hash);
                break;

            case Optimization.VoxelPlaneCollision.INSIDE:
                //hashEntry.voxel.gameObject.GetComponent<MeshRenderer>().material = material;
                m_Reconstructor.GetSpatialHashing().RemoveCollider(hashEntry);
                m_Reconstructor.GetSpatialHashing().setRemoved(hashEntry.hash);
                //m_Reconstructor.GetSpatialHashing().RemoveFromTable(hashEntry.hash);
                break;

            default:
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// The Unity Update method.
        /// </summary>
        public void Update()
        {
            // Check that motion tracking is tracking.
            if (Session.Status != SessionStatus.Tracking)
            {
                return;
            }

            // Iterate over planes found in this frame and instantiate corresponding GameObjects to visualize them.
            Session.GetTrackables <DetectedPlane>(m_NewPlanes, TrackableQueryFilter.New);

            for (int i = 0; i < m_NewPlanes.Count; i++)
            {
                // Instantiate a plane visualization prefab and set it to track the new plane. The transform is set to
                // the origin with an identity rotation since the mesh for our prefab is updated in Unity World
                // coordinates.
                GameObject planeObject           = Instantiate(DetectedPlanePrefab, Vector3.zero, Quaternion.identity, transform);
                DetectedPlaneVisualizer planeGen = planeObject.GetComponent <DetectedPlaneVisualizer>();

                if (m_NewPlanes[i].CenterPose.position[1] < floorLevel)
                {
                    floorLevel = m_NewPlanes[i].CenterPose.position[1];
                    floorPlane.transform.position = new Vector3(m_NewPlanes[i].CenterPose.position[0], m_NewPlanes[i].CenterPose.position[1], m_NewPlanes[i].CenterPose.position[2]);
                }

                planeGen.Initialize(m_NewPlanes[i]);
            }
        }
 public void CheckCurrentPointsWithNewPlane(DetectedPlaneVisualizer newPlane)
 {
     foreach (DictionaryEntry entry in m_Reconstructor.GetSpatialHashing().GetHashtable())
     {
         HashEntry hashEntry = (HashEntry)entry.Value;
         if (hashEntry.remove)
         {
             continue;
         }
         ChangeVoxelMaterial(newPlane, hashEntry, m_CustomMaterialGreen);
     }
 }