コード例 #1
0
ファイル: ChunkPresenter.cs プロジェクト: ryo0ka/MinAR
        public void Initiate(Vector3i chunkPosition)
        {
            Clear();

            _renderer.sharedMaterials = _source.BlockMaterials;
            _filter.sharedMesh        = new Mesh {
                indexFormat = IndexFormat.UInt32
            };

            _meshBuilder = new VoxelMeshBuilder(1024, VoxelConsts.BlockCount);
            _quadBuilder = new VoxelQuadBuilder(1024, VoxelConsts.ChunkLength, blockPosition =>
            {
                Vector3i p = VoxelUtils.LocalToWorld(VoxelConsts.ChunkLength, chunkPosition, blockPosition);
                return(_globalLookup.Lookup(p));
            });

            InitiateUpdaters();
        }
コード例 #2
0
        void Start()
        {
            _meshBuilder = new VoxelMeshBuilder(128, VoxelConsts.DamageLength);

            // Initialize mesh
            _mesh = new Mesh {
                indexFormat = IndexFormat.UInt16
            };
            _filter.sharedMesh = _mesh;

            // Initialize materials
            Material[] materials = new Material[VoxelConsts.DamageLength];
            for (int i = 0; i < VoxelConsts.DamageLength; i++)
            {
                Material mat = Instantiate(_source.DamageMaterial);
                mat.SetFloat(VoxelConsts.DamageIndexKey, i);
                materials[i] = mat;
            }

            _renderer.sharedMaterials = materials;
        }