Ejemplo n.º 1
0
 // Update is called once per frame
 public void Execute()
 {
     _tempNode = null;
     for (int i = 0; i < activeNodeListArray.Length; i++)
     {
         for (int m = 0; m < activeNodeListArray[i].Count; m++)
         {
             _tempNode = activeNodeListArray [i] [m];
             if (_tempNode.lodLevel > 0 && QTManager.Instance.CanGenerate(_tempNode))
             {
                 _tempNode.Generate();
             }
             else
             {
                 if (_tempNode.lodLevel < _planet.maxLodLevel && QTManager.Instance.NeedBack(_tempNode.parent))
                 {
                     _tempNode.parent.Back();
                 }
             }
         }
     }
 }
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 bool NeedBack(QTNode node)
 {
     return(MathExtra.GetV3L(playerPos - node.sphereCenter) * GetDisPower() / node.sphereLength >= (QTManager.Instance.activePlanet.cl + backBuffer));
     //&&(MathExtra.GetV3L (QTManager.Instance.playerTrans.position - node.terrainCenter)*GetDisPower() / node.sphereLength >= (QTManager.Instance.activePlanet.cl+backBuffer));
 }
Ejemplo n.º 4
0
 public bool CanGenerate(QTNode node)
 {
     return(MathExtra.GetV3L(playerPos - node.sphereCenter) * GetDisPower() / node.sphereLength < QTManager.Instance.activePlanet.cl);
     //||(MathExtra.GetV3L (QTManager.Instance.playerTrans.position - node.terrainCenter)*GetDisPower() / node.sphereLength < QTManager.Instance.activePlanet.cl);
 }
Ejemplo n.º 5
0
 public void RemoveFromUpdateList(QTNode node)
 {
     updateList.Remove(node);
 }
Ejemplo n.º 6
0
 public void AddToUpdateList(QTNode node)
 {
     updateList.Add(node);
 }