示例#1
0
    public void Update()
    {
        float t0 = Time.realtimeSinceStartup;
        float t1 = Time.realtimeSinceStartup;

        for (int i = 0; i < anglesComputeByFrame; i++)
        {
            cursor = (cursor + 1) % Instances.Count;
            PlanetChunck planetChunck = Instances[cursor];
            Instances[cursor].AngleToReferential = Vector3.Angle(PlanetChunckManager.Instance.Referential.position - planetChunck.transform.position, planetChunck.transform.TransformVector(planetChunck.LocalUp));
        }
        Instances = Instances.OrderBy(p => p.AngleToReferential).ToList();

        if (workingLock)
        {
            return;
        }

        foreach (PlanetChunck instance in Instances)
        {
            if (!instance.MeshSet)
            {
                if (instance.AngleToReferential < 90f)
                {
                    instance.SetMesh();
                    t1         = Time.realtimeSinceStartup;
                    updateTime = t1 - t0;
                    return;
                }
            }
        }
        t1         = Time.realtimeSinceStartup;
        updateTime = t1 - t0;
    }
        public void OnTriggerEnter(Collider c)
        {
            PlanetChunck pChunck = c.GetComponent <PlanetChunck> ();

            if (pChunck != null)
            {
                this.pChuncks.Add(pChunck);
            }
        }
示例#3
0
    public void CreateTree(PlanetSide planetSide, int iPos, int jPos, int kPos)
    {
        List <PlanetChunck> planetChuncks = new List <PlanetChunck>();
        int h = Random.Range(4, 8);

        Debug.Log("H = " + h);
        int bpi = Random.Range(1, h / 2);

        Debug.Log("BPI = " + bpi);
        int bmi = Random.Range(1, h / 2);

        Debug.Log("BMI = " + bmi);
        int bpj = Random.Range(1, h / 2);

        Debug.Log("BPJ = " + bpj);
        int bmj = Random.Range(1, h / 2);

        Debug.Log("BMJ = " + bmj);
        int bup = Random.Range(1, h / 2);

        Debug.Log("BUP = " + bup);

        int[][] allSides = new int[14][];
        allSides[0] = new int[] { 1, 0, 0 };
        allSides[1] = new int[] { -1, 0, 0 };
        allSides[2] = new int[] { 0, 1, 0 };
        allSides[3] = new int[] { 0, -1, 0 };
        allSides[4] = new int[] { 0, 0, 1 };
        allSides[5] = new int[] { 0, 0, -1 };

        allSides[6] = new int[] { 1, 0, -1 };
        allSides[7] = new int[] { -1, 0, -1 };
        allSides[8] = new int[] { 0, 1, -1 };
        allSides[9] = new int[] { 0, -1, -1 };

        allSides[10] = new int[] { 1, 1, 0 };
        allSides[11] = new int[] { -1, 1, 0 };
        allSides[12] = new int[] { -1, 1, 0 };
        allSides[13] = new int[] { -1, -1, 0 };

        for (int k = 0; k <= h; k++)
        {
            PlanetChunck planetChunck = target.SetDataAtIJKPos(planetSide, iPos, jPos, kPos + k, 133, false, false, false);
            if (planetChunck != null)
            {
                if (!planetChuncks.Contains(planetChunck))
                {
                    planetChuncks.Add(planetChunck);
                }
            }
        }
        for (int k = 0; k <= bup; k++)
        {
            PlanetChunck planetChunck = target.SetDataAtIJKPos(planetSide, iPos, jPos, kPos + h + k, 133, false, false, false);
            if (planetChunck != null)
            {
                if (!planetChuncks.Contains(planetChunck))
                {
                    planetChuncks.Add(planetChunck);
                }
            }
            for (int a = 0; a < allSides.Length; a++)
            {
                planetChunck = target.SetDataAtIJKPos(planetSide, iPos + allSides[a][0], jPos + allSides[a][1], kPos + h + k + allSides[a][2], 134, true, false, false);
                if (planetChunck != null)
                {
                    if (!planetChuncks.Contains(planetChunck))
                    {
                        planetChuncks.Add(planetChunck);
                    }
                }
            }
        }
        for (int i = -bmi; (i <= bpi); i++)
        {
            PlanetChunck planetChunck = target.SetDataAtIJKPos(planetSide, iPos + i, jPos, kPos + h, 133, false, false, false);
            if (planetChunck != null)
            {
                if (!planetChuncks.Contains(planetChunck))
                {
                    planetChuncks.Add(planetChunck);
                }
            }
            for (int a = 0; a < allSides.Length; a++)
            {
                planetChunck = target.SetDataAtIJKPos(planetSide, iPos + i + allSides[a][0], jPos + allSides[a][1], kPos + h + allSides[a][2], 134, true, false, false);
                if (planetChunck != null)
                {
                    if (!planetChuncks.Contains(planetChunck))
                    {
                        planetChuncks.Add(planetChunck);
                    }
                }
            }
        }
        for (int j = -bmj; (j <= bpj); j++)
        {
            PlanetChunck planetChunck = target.SetDataAtIJKPos(planetSide, iPos, jPos + j, kPos + h, 133, false, false, false);;
            if (planetChunck != null)
            {
                if (!planetChuncks.Contains(planetChunck))
                {
                    planetChuncks.Add(planetChunck);
                }
            }
            for (int a = 0; a < allSides.Length; a++)
            {
                planetChunck = target.SetDataAtIJKPos(planetSide, iPos + allSides[a][0], jPos + j + allSides[a][1], kPos + h + allSides[a][2], 134, true, false, false);
                if (planetChunck != null)
                {
                    if (!planetChuncks.Contains(planetChunck))
                    {
                        planetChuncks.Add(planetChunck);
                    }
                }
            }
        }

        foreach (PlanetChunck p in planetChuncks)
        {
            p.SetMesh();
            PlanetUtility.Save(p.PlanetName, p.data, p.iPos, p.jPos, p.kPos, p.planetSide.side);
            PlanetUtility.SaveForBabylonJSVersion(p.PlanetName, p.data, p.iPos, p.jPos, p.kPos, p.planetSide.side);
        }
    }