Esempio n. 1
0
    public void Set(PlanetSide newPlanetSide, int newIPos, int newJPos, int newKPos, byte newBlock)
    {
        if ((newPlanetSide == this.planetSide) &&
            (newIPos == this.iPos) &&
            (newJPos == this.jPos) &&
            (newKPos == this.kPos) &&
            (newBlock == this.block))
        {
            return;
        }

        this.planetSide = newPlanetSide;
        this.iPos       = newIPos;
        this.jPos       = newJPos;
        this.kPos       = newKPos;
        this.block      = newBlock;

        this.C_MeshFilter.sharedMesh = this.planetSide.planet.WorldPositionToBlockMesh(this.iPos, this.jPos, this.kPos, this.block);

        if (this.block == 0)
        {
            this.C_Renderer.sharedMaterials = this.eraserMaterials;
        }
        else
        {
            this.C_Renderer.sharedMaterials = this.planetMaterials;
        }

        this.transform.parent        = newPlanetSide.transform;
        this.transform.localPosition = Vector3.zero;
        this.transform.localRotation = Quaternion.identity;
    }
Esempio n. 2
0
    public void TestWorldPosTo()
    {
        Debug.Log("# TEST WORLD POS TO #");

        Vector3    position   = this.transform.position;
        PlanetSide planetSide = target.WorldPositionToPlanetSide(position);

        Debug.Log("PlanetSide : " + planetSide.name);

        PlanetChunck planetChunck;
        int          iPos, jPos, kPos;

        target.WorldPositionToIJK(position, out planetChunck, out iPos, out jPos, out kPos);

        Debug.Log("PlanetChunck : " + planetChunck.name);
        Debug.Log("IPos : " + iPos);
        Debug.Log("JPos : " + jPos);
        Debug.Log("KPos : " + kPos);

        byte data = target.WorldPositionToData(position);

        Debug.Log("Data : " + data);

        Debug.Log("# OVER : TEST WORLD POS TO #");
    }
Esempio n. 3
0
    // PLANET SIDES
    private PlanetSide[] InitializeSides(Vector2[] points)
    {
        PlanetSide[] sd = new PlanetSide[points.Length];

        Vector2 pt, pt2;

        for (int i = 0; i < points.Length; i++) {
            pt = points[i];
            pt2 = points[(i + 1) % points.Length];

            Vector2 r = pt2 - pt;
            Vector2 n = Vector3.Cross (new Vector3(0.0f, 0.0f, 1.0f), r.normalized);

            sd[i] = new PlanetSide(pt, n, r);
        }

        return sd;
    }
Esempio n. 4
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);
        }
    }