Skip to content

Instantly share code, notes, and snippets.

@CarloCattano
Last active December 11, 2019 17:22
Show Gist options
  • Save CarloCattano/30aa265616767769a7057f10cd495356 to your computer and use it in GitHub Desktop.
Save CarloCattano/30aa265616767769a7057f10cd495356 to your computer and use it in GitHub Desktop.
Ar core snippets to learn from
//// DETECT PLANE ROUTINE DetectedPlaneGenerator.cs
private List<DetectedPlane> m_NewPlanes = new List<DetectedPlane>();
//// 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);
planeObject.GetComponent<DetectedPlaneVisualizer>().Initialize(m_NewPlanes[i]);
}
}
//// PointCloudVisualizer.cs
public int MaxPointsToAddPerFrame = 1; ??? try to change it
//// PlaneDiscoveryGuide.cs
/// <summary>
/// A list to hold detected planes ARCore is tracking in the current frame.
/// </summary>
private List<DetectedPlane> m_DetectedPlanes = new List<DetectedPlane>();
{...}
foreach (DetectedPlane plane in m_DetectedPlanes)
{
if (plane.TrackingState == TrackingState.Tracking)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment