void Update() { return; featureUpdateTimer -= Time.deltaTime; if (featureUpdateTimer < 0) { featureUpdateTimer = Random.Range(0.3f, 0.7f); GetCurrentFeatures(); foreach (CurrentFeature cf in currentFeatures) { int numGreenDotsVisible = 0; int numBrownDotsVisible = 0; if (Utils2.PointVisibleToCamera(cf.point, Camera.main)) { // green if (cf.color.g > 0.6f) { numGreenDotsVisible++; } else { numBrownDotsVisible++; } } DebugText.SetBrownDots(numBrownDotsVisible.ToString()); DebugText.SetGreenDots(numGreenDotsVisible.ToString()); FindObjectOfType <BatteryUpload> ().SetFillAmount((float)numGreenDotsVisible / 50f); } } }
public void DrawMap() { currentGreenPoints.Clear(); if (LibPlacenote.Instance.GetStatus() != LibPlacenote.MappingStatus.RUNNING) { return; } LibPlacenote.PNFeaturePointUnity[] map = LibPlacenote.Instance.GetMap(); if (map == null) { return; } Vector3[] points = new Vector3[map.Length]; Color[] colors = new Color[map.Length]; int totBrown = 0; int totGreen = 0; for (int i = 0; i < map.Length; ++i) { points [i].x = map [i].point.x; points [i].y = map [i].point.y; points [i].z = -map [i].point.z; colors [i].r = 1 - map [i].measCount / 10f; colors [i].b = 0; colors [i].g = map [i].measCount / 10f; if (map [i].measCount > 6) { currentGreenPoints.Add(new Vector3(map [i].point.x, map [i].point.y, map [i].point.z)); totGreen++; } else { totBrown++; } if (map [i].measCount < 4) { colors [i].a = 0f; } else { colors [i].a = 0.2f + 0.8f * (map [i].measCount / 10f); } } DebugText.SetGreenDots(totGreen.ToString()); DebugText.SetBrownDots(totBrown.ToString()); FindObjectOfType <BatteryUpload> ().SetFillAmount((float)totGreen / 50f); // Need to update indicies too! int[] indices = new int[map.Length]; for (int i = 0; i < map.Length; ++i) { indices [i] = i; } // Create GameObject container with mesh components for the loaded mesh. Mesh mesh = new Mesh(); mesh.vertices = points; mesh.colors = colors; mesh.SetIndices(indices, MeshTopology.Points, 0); MeshFilter mf = mMap.GetComponent <MeshFilter> (); if (mf == null) { mf = mMap.AddComponent <MeshFilter> (); } mf.mesh = mesh; MeshRenderer mr = mMap.GetComponent <MeshRenderer> (); if (mr == null) { mr = mMap.AddComponent <MeshRenderer> (); } mr.material = mPtCloudMat; }