IEnumerator Load() { DebugLog("START-PyriteQuery.LoadAll()"); tempPosition = transform.position; transform.position = Vector3.zero; pyriteQuery = new PyriteQuery(this, SetName, ModelVersion, PyriteServer); yield return StartCoroutine(pyriteQuery.LoadAll()); DebugLog("END-PyriteQuery.LoadAll()"); DebugLog("Pyrite Detail Levels Count: " + pyriteQuery.DetailLevels.Count); pyriteLevel = pyriteQuery.DetailLevels[DetailLevel]; //var centerVector = pyriteLevel.ModelBoundsMax - pyriteLevel.ModelBoundsMin; //var region = pyriteLevel.Octree.Octants; var setSize = pyriteLevel.SetSize; Debug.Log("Set Size " + setSize); //var camPos = new Vector3(setSize.x/2, setSize.y/2, 1.5f); //var octIntCubes = pyriteLevel.Octree.AllIntersections(new BoundingBox(centerPos, centerPos)); //var octIntCubes = pyriteLevel.Octree.AllIntersections(new BoundingSphere(centerPos, setSize.x / 6f)); //var octIntCubes = pyriteLevel.Octree.AllIntersections(new BoundingSphere(new Vector3(4.5f, 4.5f, 0f), 1f)); //var octIntCubes = pyriteLevel.Octree.AllIntersections(new BoundingBox(new Vector3(3, 3, 0), new Vector3(3f, 3f, 0f))); //var octIntCubes = pyriteLevel.Octree.AllIntersections(new Microsoft.Xna.Framework.BoundingBox(new Vector3(3, 3, 0), new Vector3(3f, 3f, 0f))); //var octIntCubes = pyriteLevel.Octree.AllIntersections(new Microsoft.Xna.Framework.BoundingSphere(new Vector3(3, 3, 0), 1f)); //var octIntCubes = pyriteLevel.Octree.AllIntersections(new BoundingSphere(centerVector, 2f)); cubeCamPos = pyriteLevel.GetCubeForWorldCoordinates(CameraRig.transform.position); LoadCamCubes(); var worldObject = new GameObject("WorldParent") as GameObject; worldObject.transform.position = Vector3.zero; worldObject.transform.rotation = Quaternion.identity; foreach (var i in pyriteLevel.Octree.AllItems()) { var pCube = CreateCubeFromCubeBounds(i); var cubePos = pyriteLevel.GetWorldCoordinatesForCube(pCube); var loc = Instantiate(WorldLocatorCube, cubePos, Quaternion.identity) as GameObject; loc.transform.localScale = new Vector3( pyriteLevel.WorldCubeScale.x, pyriteLevel.WorldCubeScale.z, pyriteLevel.WorldCubeScale.y); loc.transform.parent = worldObject.transform; } //var octCubes2 = pyriteLevel.Octree.AllItems(); //foreach (var octCube in octCubes2) //{ // var pCube = CreateCubeFromCubeBounds(octCube); // var cubePos = pyriteLevel.GetWorldCoordinatesForCube(pCube); // var loc = Instantiate(LocatorCube, cubePos, Quaternion.identity) as GameObject; // loc.transform.parent = gameObject.transform; //} transform.position = tempPosition; DataReady = true; }
void Update() { if (DataReady) { cubeCamPosNew = pyriteLevel.GetCubeForWorldCoordinates(CameraRig.transform.position); if (!cubeCamPos.Equals(cubeCamPosNew)) { //Debug.Log("NEW CUBE POSITION"); cubeCamPos = cubeCamPosNew; LoadCamCubes(); } var planePoint = CameraRig.transform.position; planePoint.y = 0f; Debug.DrawLine(CameraRig.transform.position, planePoint, Color.green, 0f, true); } }