void Update() { if (Loaded) { var adjustedPos = new Vector3( -CameraRig.transform.position.x, -CameraRig.transform.position.z, CameraRig.transform.position.y - WorldYOffset); cubeCamPosNew = pyriteLevel.GetCubeForWorldCoordinates(adjustedPos); if (!cubeCamPos.Equals(cubeCamPosNew)) { if (DebugLogs) { Debug.Log(String.Format("NEW CUBE POSITION: ({0},{1},{2})", cubeCamPosNew.X, cubeCamPosNew.Y, cubeCamPosNew.Z)); } cubeCamPos = cubeCamPosNew; LoadCamCubes(); } // Debugging Option if (ShowDebugCubes) { var planePoint = CameraRig.transform.position; planePoint.y = 0f; Debug.DrawLine(CameraRig.transform.position, planePoint, Color.green, 0f, true); } ProcessQueues(); } }
IEnumerator Load() { tempPosition = transform.position; transform.position = Vector3.zero; pyriteQuery = new PyriteQuery(this, SetName, ModelVersion, PyriteServer, UpgradeFactor, UpgradeConstant, DowngradeFactor, DowngradeConstant); yield return(StartCoroutine(pyriteQuery.LoadAll(FilterDetailLevels ? DetailLevelsToFilter : null))); pyriteLevel = pyriteQuery.DetailLevels[DetailLevel]; var setSize = pyriteLevel.SetSize; if (DebugLogs) { Debug.Log("Set Size " + setSize); } var adjustedPos = new Vector3( -CameraRig.transform.position.x, -CameraRig.transform.position.z, CameraRig.transform.position.y - WorldYOffset); cubeCamPos = pyriteLevel.GetCubeForWorldCoordinates(adjustedPos); var worldObject = new GameObject("OctreeParent") as GameObject; worldObject.transform.position = Vector3.zero; worldObject.transform.rotation = Quaternion.identity; OctreeTracking = new GameObject("OctreeTracking") as GameObject; OctreeTracking.transform.position = Vector3.zero; OctreeTracking.transform.rotation = Quaternion.identity; if (ShowCubes) { foreach (var i in pyriteLevel.Octree.AllItems()) { var pCube = CreateCubeFromCubeBounds(i); var cubePos = pyriteLevel.GetWorldCoordinatesForCube(pCube); var adjustedCubePos = new Vector3( -cubePos.x, cubePos.z + WorldYOffset, -cubePos.y); var loc = Instantiate(TranslucentCube, adjustedCubePos, Quaternion.identity) as GameObject; loc.name = string.Format("Mesh:{0},{1},{2}", pCube.X, pCube.Y, pCube.Z); loc.transform.localScale = new Vector3( pyriteLevel.WorldCubeScale.x, pyriteLevel.WorldCubeScale.z, pyriteLevel.WorldCubeScale.y); loc.transform.parent = worldObject.transform; } } transform.position = tempPosition; LoadCamCubes(); }