public IEnumerator onDownloadedGlyph(Glyph newGlyph) { // if doesnt contain glyph, create a new glyph sphere for it if (newGlyph != null) { bool contains = false; foreach (GlyphSphere sphere in glyphSpheres) { if (sphere.getGlyph().Equals(newGlyph)) { contains = true; break; } } if (!contains) { GameObject go = Instantiate(glyphSpherePrefab); GlyphSphere sphere = go.GetComponent <GlyphSphere> (); sphere.setGlyph(newGlyph); glyphSpheres.Add(sphere); glyphSpheres.Add(sphere); } reevaluateGlyphUniverseByLocation(); } yield return("Done"); }
private void loadOwnedGlyphSpheres() { foreach (OwnedGlyphEvent glyph in LoggedInUser.GetLoggedInUser().ownedGlyphs) { GameObject go = Instantiate(glyphSpherePrefab); GlyphSphere sphere = go.GetComponent <GlyphSphere> (); sphere.setGlyph(glyph.GetGlyph()); glyphSpheres.Add(sphere); } }
private bool isWithinRenderAngle(GlyphSphere sphere) { Vector3 targetDir = sphere.getGlyphSpherePosition() - playerCamera.transform.position; Vector3 forward = playerCamera.transform.forward; float angle = Vector3.Angle(forward, targetDir); Debug.Log("Angle to Glyph " + sphere.getGlyph().GetGlyphId() + " is:" + angle); return(angle <= RENDERINGANGLE); }
private Vector3 getNewGlyphSpherePosition(GlyphSphere glyphSphere) { GPSLocation glyphLocation = glyphSphere.getGlyph().GetGpsLocation(); Vector2 offsetInM = currentPlayerLocation.calculatePolarizedOffsetInMeters(glyphLocation); float unityPositionZ = offsetInM.x * M_TO_UNITY_SCALAR; //latitude float unityPositionX = offsetInM.y * M_TO_UNITY_SCALAR; //longitude float unityPositionY = 0.0f; //altitude return(new Vector3(unityPositionX, unityPositionY, unityPositionZ)); }
private List <GlyphSphere> enableOnlyCloseGlyphs() { GPSLocation[] closeBounds = currentPlayerLocation.calculateLatLongBoundingBox(MAX_RENDER_DISTANCE); List <GlyphSphere> activeSpheres = new List <GlyphSphere> (); for (int i = 0; i < glyphSpheres.Count; i++) { GlyphSphere sphere = glyphSpheres [i]; GPSLocation glyphLocation = glyphSpheres [i].getGlyph().GetGpsLocation(); bool glyphSphereIsInsideBounds = glyphLocation.isInsideBounds(closeBounds); Debug.LogError("Bounds : " + sphere.getGlyph().GetGlyphId() + " " + glyphSphereIsInsideBounds); sphere.setSphereActive(glyphSphereIsInsideBounds); if (sphere.isSphereActive()) { activeSpheres.Add(sphere); } } return(activeSpheres); }
private void renderClosestGlyphInRenderArea() { if (playerCamera == null) { return; } GlyphSphere closestGlyphInRenderArea = null; Vector3 cameraPosition = playerCamera.transform.position; float closestGlyphDistance = FARTHEST_SPHERE_RENDER_DISTANCE; foreach (GlyphSphere sphere in activeSpheres) { Debug.Log("*******************************************************"); Debug.LogWarning("*******************************************************"); Debug.LogError("*******************************************************"); Debug.Log("Checking if " + sphere.getGlyph().GetGlyphId() + " inside render bounds"); float distanceToGlyph = Vector3.Distance(playerCamera.transform.position, sphere.getGlyphSpherePosition()); if (CLOSEST_SPHERE_RENDER_DISTANCE <= distanceToGlyph && distanceToGlyph <= FARTHEST_SPHERE_RENDER_DISTANCE) { Debug.Log("Glyph " + sphere.getGlyph().GetGlyphId() + " inside render bounds"); sphere.setSphereColor(Color.blue); Debug.Log("Checking if " + sphere.getGlyph().GetGlyphId() + " is in viewing angle..."); if (isWithinRenderAngle(sphere)) { Debug.Log("Glyph " + sphere.getGlyph().GetGlyphId() + " in viewing angle"); Debug.Log("Checking if " + sphere.getGlyph().GetGlyphId() + " closest glyph"); if (distanceToGlyph < closestGlyphDistance) { Debug.Log("Glyph " + sphere.getGlyph().GetGlyphId() + " qualified as closest glyph"); closestGlyphDistance = distanceToGlyph; closestGlyphInRenderArea = sphere; } else { if (closestGlyphInRenderArea != null) { Debug.LogWarning("Glyph " + closestGlyphInRenderArea.getGlyph().GetGlyphId() + " closer than " + sphere.getGlyph().GetGlyphId()); } } } else { Debug.LogWarning("Glyph " + sphere.getGlyph().GetGlyphId() + " not in viewing angle"); } } else { Debug.LogWarning("Glyph " + sphere.getGlyph().GetGlyphId() + " not inside render bounds"); sphere.setSphereColor(Color.red); } } if (closestGlyphInRenderArea == null) { Debug.Log("Render: No closest glyph"); sphereToRender = null; fireStopRenderring(); } else if (closestGlyphInRenderArea != sphereToRender) { sphereToRender = closestGlyphInRenderArea; fireStartRenderring(sphereToRender.getGlyph()); } else { Debug.Log("Render: Glyph already renderred"); } }