Esempio n. 1
0
 private void addChildren(Camera camera)
 {
     IsLeafNode = false;
     for (var x = 0; x < 2; x++)
     {
         for (var z = 0; z < 2; z++)
         {
             var pos  = Position + new Vector2(x * (size / 2.0f), z * (size / 2.0f));
             var node = new TerrainNode(pos, Lod + 1, new Vector2(x, z));
             node.UpdateQuadTree(camera);
             Children[z * 2 + x] = node;
         }
     }
 }
Esempio n. 2
0
        public TerrainNode(Vector2 position, int lod, Vector2 index)
        {
            Children  = new TerrainNode[4];
            Lod       = lod;
            Index     = index;
            size      = 1.0f / (TerrainConfig.RootNodes * MathF.Pow(2.0f, Lod));
            worldSize = size * Map.MapData.MapSize;
            Position  = position;
            Depth     = (float)Lod / (float)TerrainConfig.RootNodes;

            var localScaling     = new Vector3(size, 0.0f, size);
            var localTranslation = new Vector3(Position.X, 0.0f, Position.Y);

            localTransform = Matrix4.CreateScale(localScaling) * Matrix4.CreateTranslation(localTranslation);
            worldPosition  = new Vector3(Position.X + (size / 2.0f), 0.0f, Position.Y + (size / 2.0f)) * Map.MapData.MapSize - new Vector3(Map.MapData.MapSize / 2.0f, 0.0f, Map.MapData.MapSize / 2.0f);
        }