Example #1
0
        public override void InitNode()
        {
            base.InitNode();

            if (ElevationProducerGameObject != null)
            {
                if (ElevationProducer == null)
                {
                    ElevationProducer = ElevationProducerGameObject.GetComponent <TileProducer>();
                }
            }

            var tileSize          = Cache.GetStorage(0).TileSize;
            var elevationTileSize = ElevationProducer.Cache.GetStorage(0).TileSize;

            if (tileSize != elevationTileSize)
            {
                throw new InvalidParameterException("Tile size must equal elevation tile size" + string.Format(": {0}-{1}", tileSize, elevationTileSize));
            }

            if (GetBorder() != ElevationProducer.GetBorder())
            {
                throw new InvalidParameterException("Border size must be equal to elevation border size");
            }

            if (!(Cache.GetStorage(0) is GPUTileStorage))
            {
                throw new InvalidStorageException("Storage must be a GPUTileStorage");
            }
        }
Example #2
0
 public CreateTileTask(TileProducer owner, int level, int tx, int ty, List <TileStorage.Slot> slot)
 {
     Owner = owner;
     Level = level;
     Tx    = tx;
     Ty    = ty;
     Slot  = slot;
 }
Example #3
0
        public override void InitNode()
        {
            Producer    = GetComponent <TileProducer>();
            TerrainNode = GetComponentInParent <TerrainNode>();
            uniforms    = new Uniforms(Producer.Name);

            Producer.InitNode();
        }
Example #4
0
        protected override void Start()
        {
            base.Start();

            if (TerrainNode == null)
            {
                TerrainNode = transform.parent.GetComponent <TerrainNode>();
            }
            if (TerrainNode.ParentBody == null)
            {
                TerrainNode.ParentBody = transform.parent.GetComponentInParent <Body>();
            }
            if (NormalsProducer == null)
            {
                NormalsProducer = NormalsProducerGameObject.GetComponent <TileProducer>();
            }
            if (NormalsProducer.Cache == null)
            {
                NormalsProducer.InitCache();
            }
            if (ElevationProducer == null)
            {
                ElevationProducer = ElevationProducerGameObject.GetComponent <TileProducer>();
            }
            if (ElevationProducer.Cache == null)
            {
                ElevationProducer.InitCache();
            }

            var tileSize          = Cache.GetStorage(0).TileSize;
            var normalsTileSize   = NormalsProducer.Cache.GetStorage(0).TileSize;
            var elevationTileSize = ElevationProducer.Cache.GetStorage(0).TileSize;

            if (tileSize != normalsTileSize)
            {
                throw new InvalidParameterException("Tile size must equal normals tile size" + string.Format(": {0}-{1}", tileSize, normalsTileSize));
            }

            if (tileSize != elevationTileSize)
            {
                throw new InvalidParameterException("Tile size must equal elevation tile size" + string.Format(": {0}-{1}", tileSize, elevationTileSize));
            }

            if (GetBorder() != NormalsProducer.GetBorder())
            {
                throw new InvalidParameterException("Border size must be equal to normals border size");
            }

            if (GetBorder() != ElevationProducer.GetBorder())
            {
                throw new InvalidParameterException("Border size must be equal to elevation border size");
            }

            if (!(Cache.GetStorage(0) is GPUTileStorage))
            {
                throw new InvalidStorageException("Storage must be a GPUTileStorage");
            }
        }
Example #5
0
        protected override void Start()
        {
            base.Start();

            if (TerrainNode == null)
            {
                TerrainNode = transform.parent.GetComponent <TerrainNode>();
            }
            if (TerrainNode.ParentBody == null)
            {
                TerrainNode.ParentBody = transform.parent.GetComponentInParent <Body>();
            }

            if (ResidualProducerGameObject != null)
            {
                if (ResidualProducer == null)
                {
                    ResidualProducer = ResidualProducerGameObject.GetComponent <TileProducer>();
                }
                if (ResidualProducer.Cache == null)
                {
                    ResidualProducer.InitCache();
                }
            }

            var tileSize = GetTileSize(0);

            if ((tileSize - GetBorder() * 2 - 1) % (TerrainNode.ParentBody.GridResolution - 1) != 0)
            {
                throw new InvalidParameterException("Tile size - border * 2 - 1 must be divisible by grid mesh resolution - 1" + string.Format(": {0}-{1}", tileSize, GetBorder()));
            }

            if (ResidualProducer != null)
            {
                if (ResidualProducer.GetTileSize(0) != tileSize)
                {
                    throw new InvalidParameterException("Residual tile size must match elevation tile size!");
                }
                if (!(ResidualProducer.Cache.GetStorage(0) is GPUTileStorage))
                {
                    throw new InvalidStorageException("Residual storage must be a GPUTileStorage");
                }
            }

            var storage = Cache.GetStorage(0) as GPUTileStorage;

            if (storage == null)
            {
                throw new InvalidStorageException("Storage must be a GPUTileStorage");
            }

            if (storage.FilterMode != FilterMode.Point)
            {
                throw new InvalidParameterException("GPUTileStorage filter must be point. There will be seams in the terrain otherwise");
            }
        }
Example #6
0
        public override void InitNode()
        {
            base.InitNode();

            if (SourceProducerGameObject != null)
            {
                if (SourceProducer == null)
                {
                    SourceProducer = SourceProducerGameObject.GetComponent <TileProducer>();
                }
            }

            if (TargetProducerGameObject != null)
            {
                if (TargetProducer == null)
                {
                    TargetProducer = TargetProducerGameObject.GetComponent <TileProducer>();
                }
            }

            if (SourceProducer == null)
            {
                throw new NullReferenceException("Source producer is null!");
            }
            if (TargetProducer == null)
            {
                throw new NullReferenceException("Target producer is null!");
            }

            var targetSize = TargetProducer.Cache.GetStorage(0).TileSize;
            var sourceSize = SourceProducer.Cache.GetStorage(0).TileSize;

            if (targetSize != sourceSize && targetSize != sourceSize - 1)
            {
                throw new InvalidParameterException("Target tile size must equal source tile size or source tile size-1");
            }

            if (TargetProducer.GetBorder() != SourceProducer.GetBorder())
            {
                throw new InvalidParameterException("Target border size must be equal to source border size");
            }

            var storage = TargetProducer.Cache.GetStorage(0) as GPUTileStorage;

            if (storage == null)
            {
                throw new InvalidStorageException("Target storage must be a GPUTileStorage");
            }

            storage = SourceProducer.Cache.GetStorage(0) as GPUTileStorage;

            if (storage == null)
            {
                throw new InvalidStorageException("Source storage must be a GPUTileStorage");
            }
        }
Example #7
0
 public void InsertProducer(int id, TileProducer producer)
 {
     if (Producers.ContainsKey(id))
     {
         Debug.Log(string.Format("TileCache: Producer with {0} already inserted!", id));
     }
     else
     {
         Producers.Add(id, producer);
     }
 }