Ejemplo n.º 1
0
 // Use this for initialization
 public void Init(Quad q)
 {
     _planet = QTManager.Instance.activePlanet;
     _planet.map.GenerateMap(QTManager.Instance.activePlanet.seed + (int)q);
     heightMap           = _planet.map.GetHeightMap();
     activeNodeListArray = new List <QTNode> [_planet.maxLodLevel + 1];
     allNodeListArray    = new List <QTNode> [_planet.maxLodLevel + 1];
     for (int i = 0; i <= _planet.maxLodLevel; i++)
     {
         activeNodeListArray [i] = new List <QTNode> ();
         allNodeListArray [i]    = new List <QTNode> ();
     }
     _rootNode = new RootNode(_planet.sphereDiameter);
     TryGenerateBorder();
     CalculateMesh();
 }
Ejemplo n.º 2
0
        public void Init(QTNode parent, int quadrantID)
        {
            QTTerrain activeTerrain = QTManager.Instance.activeTerrain;
            QTPlanet  activePlanet  = QTManager.Instance.activePlanet;

            this.parent     = parent;
            lodLevel        = parent.lodLevel - 1;
            this.quadrantID = quadrantID;
            length          = parent.length * 0.5f;
            float offSet = length * 0.5f;

            center = new Vector3(parent.center.x + ((quadrantID == 0 || quadrantID == 3) ? offSet : -offSet), parent.center.y,
                                 parent.center.z + ((quadrantID == 0 || quadrantID == 1) ? offSet : -offSet));
            sphereCenter = MathExtra.FastNormalize(center) * activePlanet.sphereRadius;
            sphereLength = activePlanet.lengthArray[this.lodLevel];
            if (parent.borderStatus != BorderStatus.NotBorder)
            {
                if (((parent.borderStatus & BorderStatus.UpBorder) == BorderStatus.UpBorder) && (quadrantID == 0 || quadrantID == 1))
                {
                    borderStatus &= BorderStatus.UpBorder;
                }
                if (((parent.borderStatus & BorderStatus.RightBorder) == BorderStatus.RightBorder) && (quadrantID == 0 || quadrantID == 3))
                {
                    borderStatus &= BorderStatus.RightBorder;
                }
                if (((parent.borderStatus & BorderStatus.DownBorder) == BorderStatus.DownBorder) && (quadrantID == 2 || quadrantID == 3))
                {
                    borderStatus &= BorderStatus.DownBorder;
                }
                if (((parent.borderStatus & BorderStatus.LeftBorder) == BorderStatus.LeftBorder) && (quadrantID == 1 || quadrantID == 2))
                {
                    borderStatus &= BorderStatus.LeftBorder;
                }
            }
            fullGenerateWidth  = ((parent.fullGenerateWidth - 1) >> 1) + 1;
            fullGenerateOffset = fullGenerateWidth - 1;
            switch (quadrantID)
            {
            case 0:
                fullGenerateOrigin = parent.fullGenerateOrigin + new Vector2(fullGenerateOffset, fullGenerateOffset);
                break;

            case 1:
                fullGenerateOrigin = parent.fullGenerateOrigin + new Vector2(0, fullGenerateOffset);
                break;

            case 2:
                fullGenerateOrigin = parent.fullGenerateOrigin;
                break;

            case 3:
                fullGenerateOrigin = parent.fullGenerateOrigin + new Vector2(this.fullGenerateOffset, 0);
                break;
            }
            //terrainCenter = sphereCenter*(1f+activeTerrain.heightMap[activePlanet.vectorToHeightMapTable[         (int)((fullGenerateOrigin.x+(int)(fullGenerateOffset/2f))*activePlanet.mapScale),
            //	(int)((fullGenerateOrigin.y+(int)(fullGenerateOffset/2f))*activePlanet.mapScale)    ]]*activePlanet.heightScale);
            //terrainCenter = activeTerrain.transform.TransformPoint(terrainCenter);
            sphereCenter        = activeTerrain.transform.TransformPoint(sphereCenter);
            fullGenerateOffset /= activePlanet.splitCount;
            activeTerrain.allNodeListArray [lodLevel].Add(this);
            CheckForLOD();
        }
Ejemplo n.º 3
0
 public void Enter(QTPlanet planet)
 {
     activePlanet = planet;
     planet.Enter();
 }