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; }
private void LoadDefaultMaterials(PyriteSetVersionDetailLevel detailLevel, List<MaterialData> materiaDatas) { for (int textureX = 0; textureX < detailLevel.TextureSetSize.x; textureX++) { for (int textureY = 0; textureY < detailLevel.TextureSetSize.y; textureY++) { CubeBuilderHelpers.SetDefaultMaterialData(materiaDatas, textureX, textureY, detailLevel.Value); } } }
public IEnumerator DownloadTextures(PyriteSetVersionDetailLevel detailLevel) { DetailLevel = detailLevel; TextureCount = (int) detailLevel.TextureSetSize.x*(int) detailLevel.TextureSetSize.y; foreach (var md in MaterialDataList) { var texPath = Query.GetTexturePath(detailLevel.Name, md.X, md.Y); md.DiffuseTexPath = texPath; yield return ThreadPool.QueueUserWorkItem(StartDownloadTexture, texPath); } }