예제 #1
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");
            }
        }
예제 #2
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");
            }
        }