コード例 #1
0
        // Create new mesh zone
        public VCube(Bounds bounds, VTerrain terrain)
        {
            // Limit to this zone
            _minX = (int) bounds.min.x;
            _minY = (int) bounds.min.y;
            _minZ = (int) bounds.min.z;
            _maxX = (int) bounds.max.x;
            _maxY = (int) bounds.max.y;
            _maxZ = (int) bounds.max.z;
            _bounds = bounds;

            // Limit to all zone
            _terrain = terrain;
            _object = terrain.AddObject();
            _mesh = _object.GetComponent<MeshFilter>().mesh;
            _mesh.bounds = _bounds;
        }
コード例 #2
0
    public void Start()
    {
        if(_instance==null)
            _instance = this;

        _cubes					= new List<VCube>();
        _reBuild				= new List<VCube>();
        _reBuildCollider		= new List<VCube>();
        _reBuildColliderCount	= 0;

        _map					= new byte[width+1, height+1, depth+1];
        _colors					= new Color[width+1, height+1, depth+1];

        // Instantiate all cube
        for(int x=0; x<width/RES; x++)
        for(int y=0; y<height/RES; y++)
        for(int z=0; z<depth/RES; z++)
        {
            Bounds cubeBounds = new Bounds();
            cubeBounds.min = new Vector3(x, y, z)*RES;
            cubeBounds.max = cubeBounds.min + new Vector3(RES, RES, RES);
            VCube cube = new VCube(cubeBounds, this);
            _cubes.Add(cube);
        }

        // Initialise all point in map
        ResetMap();
    }