Inheritance: MonoBehaviour
Exemple #1
0
    // Start is called before the first frame update
    public void GenerateMap(Vector3 position)
    {
        voxelMap = new VoxelMap(size);
        for (int x = 0; x < size.x; x++)
        {
            for (int y = 0; y < size.y; y++)
            {
                for (int z = 0; z < size.z; z++)
                {
                    Vector3 currentPosition = new Vector3(x, y, z);
                    currentPosition.Scale(perlinMultiplier);
                    //float perlinValue = Perlin.Noise(perlinPosition + currentPosition);
                    Vector3 usePosition  = position + currentPosition;
                    float   perlinValue1 = Mathf.PerlinNoise(usePosition.x, usePosition.y);
                    float   perlinValue2 = Mathf.PerlinNoise(usePosition.z, usePosition.y);
                    float   perlinValue  = (perlinValue1 + perlinValue2) / 2;
                    if (perlinValue >= solidThreshold)
                    {
                        voxelMap.CreateVoxel(x, y, z);
                    }
                }
            }
        }

        Mesh mesh = voxelMap.CreateMesh(voxelSize);

        mesh.name = "VoxelMesh";
        //mesh.Optimize();
        GetComponent <MeshFilter>().mesh         = mesh;
        GetComponent <MeshCollider>().sharedMesh = mesh;
    }
Exemple #2
0
    public void Startup(VoxelMap map)
    {
        var blockTypeNames = System.Enum.GetNames(typeof(BlockType));

        foreach (var blockType in blockTypeNames)
        {
            FillTypeNames.Add(blockType);
        }

        voxelResolution = map.voxelResolution;
        chunkResolution = map.chunkResolution;
        viewDistance    = map.viewDistance;
        existingChunks  = map.existingChunks;
        voxelMap        = map;
        mainCamera      = Camera.main;
        terrainMap      = FindObjectOfType <TerrainMap>();

        voxelMesh     = FindObjectOfType <VoxelMesh>();
        chunkCollider = FindObjectOfType <ChunkCollider>();

        box = gameObject.GetComponent <BoxCollider>();
        if (box != null)
        {
            DestroyImmediate(box);
        }

        box        = gameObject.AddComponent <BoxCollider>();
        box.center = Vector3.one * (voxelResolution / 2f);
        box.size   = new Vector3((chunkResolution - viewDistance) * voxelResolution,
                                 (chunkResolution - viewDistance) * voxelResolution);
    }
Exemple #3
0
    private int GetAdjacentVoxel(VoxelMap map, IntVector3 key, FaceDirection dir, out IntVector3 adjacentVoxel)
    {
        switch (dir)
        {
        case FaceDirection.TOP: adjacentVoxel = key.Translate(0, 1, 0); break;

        case FaceDirection.BOTTOM: adjacentVoxel = key.Translate(0, -1, 0); break;

        case FaceDirection.RIGHT: adjacentVoxel = key.Translate(1, 0, 0); break;

        case FaceDirection.LEFT: adjacentVoxel = key.Translate(-1, 0, 0); break;

        case FaceDirection.FRONT: adjacentVoxel = key.Translate(0, 0, 1); break;

        case FaceDirection.BACK: adjacentVoxel = key.Translate(0, 0, -1); break;

        default:
            adjacentVoxel = IntVector3.ZERO;
            return(0);
        }

        if (adjacentVoxel.x < 0 ||
            adjacentVoxel.y < 0 ||
            adjacentVoxel.z < 0 ||
            adjacentVoxel.x >= map.Columns ||
            adjacentVoxel.y >= map.Rows ||
            adjacentVoxel.z >= map.Pages)
        {
            return(0);
        }
        else
        {
            return(VoxelMap[adjacentVoxel]);
        }
    }
Exemple #4
0
    public void StartUp(VoxelMap map, WorldScriptableObject worldObject)
    {
        voxelMesh     = FindObjectOfType <VoxelMesh>();
        terrainNoise  = FindObjectOfType <TerrainNoise>();
        terrainMap    = FindObjectOfType <TerrainMap>();
        chunkCollider = FindObjectOfType <ChunkCollider>();

        recycleableChunks     = map.recycleableChunks;
        regionResolution      = map.regionResolution;
        chunkResolution       = map.chunkResolution;
        voxelResolution       = map.voxelResolution;
        viewDistance          = map.viewDistance;
        chunks                = map.chunks;
        existingChunks        = map.existingChunks;
        useVoxelReferences    = map.useVoxelReferences;
        colliderRadius        = map.colliderRadius;
        useColliders          = map.useColliders;
        player                = map.player;
        chunkSaveLoadManager  = map.chunkSaveLoadManager;
        worldScriptableObject = worldObject;

        playerRb = player.GetComponent <Rigidbody2D>();

        terrainNoise.seed = worldScriptableObject.seed;
        terrainNoise.Startup(voxelResolution, chunkResolution);
        voxelMesh.Startup(voxelResolution, chunkResolution, viewDistance, useColliders, colliderRadius);

        InvokeRepeating(nameof(UpdateMap), 0.0f, terrainMap.updateInterval);
    }
Exemple #5
0
    public void TestSerializationDeserialization()
    {
        map[0, 0, 0] = 1;
        map[1, 0, 0] = 2;
        map[0, 1, 0] = 3;
        map[0, 0, 1] = 4;
        map[1, 1, 1] = 5;

        string json = map.ToJson();

        Debug.Log($"Data: {json}");

        VoxelMap newMap = new VoxelMap();

        newMap.FromJson(json);

        Assert.AreEqual(map.Columns, newMap.Columns);
        Assert.AreEqual(map.Rows, newMap.Rows);
        Assert.AreEqual(map.Pages, newMap.Pages);
        Assert.AreEqual(map.Count, newMap.Count);
        Assert.AreEqual(map.Size, newMap.Size);

        Assert.AreEqual(map[0, 0, 0], newMap[0, 0, 0]);
        Assert.AreEqual(map[1, 0, 0], newMap[1, 0, 0]);
        Assert.AreEqual(map[0, 1, 0], newMap[0, 1, 0]);
        Assert.AreEqual(map[0, 0, 1], newMap[0, 0, 1]);
        Assert.AreEqual(map[1, 1, 1], newMap[1, 1, 1]);

        string newJson = newMap.ToJson();

        Assert.AreEqual(json, newJson);
    }
        public void PlaceVoxel(short x, short y, byte z, byte color)
        {
            WaitWebsocketConnected();
            if (disposed)
            {
                logger.LogDebug($"PlaceVoxel(): already disposed");
                return;
            }
            VoxelMap.AbsoluteToRelative(x, out byte chunkX, out byte relativeX);
            VoxelMap.AbsoluteToRelative(y, out byte chunkY, out byte relativeY);
            byte[] offsetBytes = BitConverter.GetBytes(VoxelMap.RelativeToOffset(relativeX, relativeY, z));

            byte[] data = new byte[7]
            {
                (byte)Opcode.PixelUpdate,
                chunkX,
                chunkY,
                offsetBytes[2],
                offsetBytes[1],
                offsetBytes[0],
                color
            };
            logger.LogDebug($"PlaceVoxel(): Sending data {DataToString(data)}");
            webSocket.Send(data);
        }
        public override void DrawContent()
        {
            base.DrawContent();

            VoxelMap map = voxelMap;

            voxelMap = (VoxelMap)EditorGUILayout.ObjectField(voxelMap, typeof(VoxelMap), true);
            if (voxelMap != map)
            {
                OnVoxelMapChanged();
            }

            if (voxelMap != null)
            {
                VoxelSwatch swatch = voxelSwatch;
                voxelSwatch = (VoxelSwatch)EditorGUILayout.ObjectField(voxelSwatch, typeof(VoxelSwatch), true);

                if (voxelSwatch != swatch)
                {
                    OnVoxelSwatchChanged();
                }

                if (voxelSwatch != null)
                {
                    if (GUILayout.Button("Reload Swatch."))
                    {
                        voxelSwatch.LoadSwatches();
                    }
                }
            }
        }
Exemple #8
0
        private void FindViableAsteroid(out Vector3D validPosition, out Vector3D asteroidPosition)
        {
            validPosition    = Vector3D.Zero;
            asteroidPosition = Vector3D.Zero;

            List <VoxelMap> voxelMaps = SectorObjectManager.Instance.GetTypedInternalData <VoxelMap>( );

            for (int r = 0; r < voxelMaps.Count; r++)
            {
                int      choice   = _random.Next(0, voxelMaps.Count - r);
                VoxelMap voxelMap = voxelMaps[choice];
                voxelMaps.RemoveAt(choice);

                if (PluginSettings.Instance.NewUserTransportAsteroidDistance > 0 && Vector3D.Distance(voxelMap.Position, Vector3D.Zero) > PluginSettings.Instance.NewUserTransportAsteroidDistance)
                {
                    continue;
                }

                Essentials.Log.Info("Found asteroid with viable materials: {0} - {1}", voxelMap.Name, voxelMap.Materials.Count);
                asteroidPosition = voxelMap.Position;
                validPosition    = MathUtility.RandomPositionFromPoint(asteroidPosition, PluginSettings.Instance.NewUserTransportDistance);
                break;

                /*
                 * if (voxelMap.Materials.Count > 3)
                 * {
                 *      Log.Info(string.Format("Found asteroid with viable materials: {0} - {1}", voxelMap.Name, voxelMap.Materials.Count()));
                 *      asteroidPosition = voxelMap.Position;
                 *      validPosition = MathUtility.RandomPositionFromPoint(asteroidPosition, PluginSettings.Instance.NewUserTransportDistance);
                 *      break;
                 * }
                 */
            }
        }
Exemple #9
0
    public PolygonizableVoxelMap(VoxelMap voxelMap)
    {
        this.fieldValues = new float[voxelMap.Width, voxelMap.Height, voxelMap.Depth];

        for (int x = 0; x < voxelMap.Width; x++)
        {
            for (int y = 0; y < voxelMap.Height; y++)
            {
                for (int z = 0; z < voxelMap.Depth; z++)
                {
                    int neighbourCount = 0;

                    for (int i = -1; i <= 1; i++)
                    {
                        for (int j = -1; j <= 1; j++)
                        {
                            for (int k = -1; k <= 1; k++)
                            {
                                if (voxelMap.CheckVoxelAt(x + i, y + j, z + k))
                                {
                                    neighbourCount++;
                                }
                            }
                        }
                    }

                    fieldValues[x, y, z] = neighbourCount / 27.0f;
                }
            }
        }
    }
        public override void DrawContent () {
            base.DrawContent();

            VoxelMap map = voxelMap;
            voxelMap = (VoxelMap)EditorGUILayout.ObjectField(voxelMap, typeof(VoxelMap), true);
            if (voxelMap != map) {

                OnVoxelMapChanged();

            }

            if (voxelMap != null) {

                VoxelSwatch swatch = voxelSwatch;
                voxelSwatch = (VoxelSwatch)EditorGUILayout.ObjectField(voxelSwatch, typeof(VoxelSwatch), true);

                if (voxelSwatch != swatch) {

                    OnVoxelSwatchChanged();

                }

                if (voxelSwatch != null) {

                    if (GUILayout.Button("Reload Swatch.")) {

                        voxelSwatch.LoadSwatches();

                    }

                }

            }

        }
Exemple #11
0
    public void StartUp(VoxelMap map)
    {
        voxelMap   = map;
        mainCamera = Camera.main;

        terrainMap    = FindObjectOfType <TerrainMap>();
        voxelMesh     = FindObjectOfType <VoxelMesh>();
        chunkCollider = FindObjectOfType <ChunkCollider>();
        worldManager  = FindObjectOfType <WorldManager>();
        uiHotBar      = FindObjectOfType <UI_HotBar>();

        var blockCollection = BlockManager.Read();

        if (worldManager.creativeMode)
        {
            foreach (var block in blockCollection.blocks)
            {
                fillTypeNames.Add(block.blockType.ToString());
            }
        }

        boxCollider = gameObject.GetComponent <BoxCollider>();
        if (boxCollider != null)
        {
            DestroyImmediate(boxCollider);
        }

        boxCollider      = gameObject.AddComponent <BoxCollider>();
        boxCollider.size = new Vector3((voxelMap.chunkResolution - voxelMap.viewDistance) * voxelMap.voxelResolution,
                                       (voxelMap.chunkResolution - voxelMap.viewDistance) * voxelMap.voxelResolution);
    }
 public byte GetVoxelColor(short x, short y, byte z)
 {
     VoxelMap.AbsoluteToRelative(x, out byte chunkX, out byte relativeX);
     VoxelMap.AbsoluteToRelative(y, out byte chunkY, out byte relativeY);
     try
     {
         byte[,,] chunkMap = CachedChunks[(chunkX, chunkY)];
Exemple #13
0
 // Events/Init
 protected override void OnInitialized(EventArgs e)
 {
     base.OnInitialized(e);
     Map            = Application.Current.GetContainer()?.GetRequiredService <VoxelMap>();
     Content.Source = Map;
     //AddHandler( UIElement.MouseDownEvent, (MouseButtonEventHandler) OnMouseDown, true );
     //AddHandler( UIElement.MouseMoveEvent, (MouseEventHandler) OnMouseMove, true );
 }
Exemple #14
0
 // Use this for initialization
 void Start()
 {
     voxelMap = GetComponent <VoxelMap>();
     if (voxelMap == null)
     {
         Debug.Log("No voxel map found on game object");
         enabled = false;
     }
 }
Exemple #15
0
    // Use this for initialization
    void Start()
    {
        VoxelMap = new VoxelMap();
        VoxelMap.FromJson(VoxelMapData.text);

        halfScale  = VoxelMap.Scale / 2.0f;
        directions = System.Enum.GetValues(typeof(FaceDirection));

        StartCoroutine(BuildMesh());
    }
Exemple #16
0
    private void Start()
    {
        mapMaterial  = map.GetComponent <Image>().material;
        player       = FindObjectOfType <PlayerController>().transform;
        terrainNoise = FindObjectOfType <TerrainNoise>();
        voxelMap     = FindObjectOfType <VoxelMap>();

        RefreshColors();

        NewTexture();
    }
Exemple #17
0
    void Start()
    {
        voxelMap = new VoxelMap(width, height);

        ThreadWorkManager.RequestWork(() =>
        {
            GenerateMap();

            SpawnMap();
            SpawnMarchingMap();
        });
    }
Exemple #18
0
    //this function takes some resolution (how many cubes per chunk), and some size (the size of the cubes)
    public void Initialize(int x, int y, int z, int i, VoxelMap m)
    {
        cX                           = x;
        cY                           = y;
        cZ                           = z;
        ciD                          = i;
        parentMap                    = m;
        chunkMeshCollider            = GetComponent <MeshCollider>();
        chunkMeshCollider.sharedMesh = null;

        GetComponent <MeshFilter>().mesh = chunkMesh = new Mesh();
        chunkMesh.name = "VoxelGrid Mesh";
    }
Exemple #19
0
    void Start()
    {
        ConfigManager.Init("Assets/config.json");

        string json = FileHandler.Read(ConfigManager.config.voxelMap.fileName);

        if (json != "")
        {
            map = JsonConvert.DeserializeObject <VoxelMap>(json);
        }

        map.CreateGameObjects();
    }
    void Start()
    {
        //boxGen();
        VoxelMap  myMap      = new VoxelMap(iArenaWidth, cube);
        levelData myLevel    = new levelData(iArenaWidth, minRooms, minWidth, maxWidth);
        levelData smallRooms = new levelData(iArenaWidth, 0, 4, 8);

        myMap.buildLevel(myLevel, smallRooms);
        myMap.cullHidden();
        myMap.instantiate();
        player = Instantiate(player);
        player.transform.position = myMap.startPosition();
        //turret.transform.position = myMap.startPosition();
    }
 public ChunkCache3D(IEnumerable <Voxel> voxels, Logger logger, CanvasType canvas)
 {
     interactiveMode = true;
     this.canvas     = canvas;
     this.logger     = logger;
     logger.LogTechState("Calculating list of chunks...");
     chunks = voxels.AsParallel().Select(p =>
     {
         VoxelMap.AbsoluteToRelative(p.Item1, out byte chunkX, out _);
         VoxelMap.AbsoluteToRelative(p.Item2, out byte chunkY, out _);
         return(chunkX, chunkY);
     }).Distinct().ToList();
     logger.LogTechInfo("Chunk list is calculated");
 }
Exemple #22
0
    public override void OnInspectorGUI()
    {
        VoxelMap myTarget = (VoxelMap)target;

        serializedObject.Update();

        EditorGUILayout.LabelField("Basic Settings");
        EditorGUILayout.PropertyField(_voxelPieceIdentifier);

        EditorGUILayout.PropertyField(_generationType);

        switch (_generationType.intValue)
        {
        case (int)Generator.Type.WFC:
            EditorGUILayout.PropertyField(_groundPiece);
            EditorGUILayout.PropertyField(_sizeX);
            EditorGUILayout.PropertyField(_sizeY);
            EditorGUILayout.PropertyField(_sizeZ);
            break;
        }

        EditorGUILayout.PropertyField(_visualizationType);

        switch (_visualizationType.intValue)
        {
        case (int)MapVisualization.Type.Mesh:
            EditorGUILayout.PropertyField(_dfltMat);
            break;
        }


        serializedObject.ApplyModifiedProperties();

        if (GUILayout.Button("Generate"))
        {
            myTarget.Initialize();
            myTarget.Generate();
        }

        if (GUILayout.Button("Update"))
        {
            myTarget.Update();
        }

        if (GUILayout.Button("Clear"))
        {
            myTarget.Clear();
        }
    }
        protected override void LogMapChanged(object sender, MapChangedEventArgs e)
        {
            foreach (MapChange c in e.Changes)
            {
                MessageGroup msgGroup;
                VoxelMap.OffsetToRelative(c.Offset, out byte rx, out byte ry, out byte z);
                short x = VoxelMap.RelativeToAbsolute(e.Chunk.Item1, rx);
                short y = VoxelMap.RelativeToAbsolute(e.Chunk.Item2, ry);

                if (!placed.Remove((x, y, z, c.Color)))
                {
                    try
                    {
                        int irx = x - options.MinX;
                        int iry = y - options.MinY;
                        int irz = z - options.BottomZ;

                        if (irx < 0 || irx >= sizeX || iry < 0 || iry >= sizeY || irz < 0 || irz > height)
                        {
                            //beyond image
                            msgGroup = MessageGroup.PixelInfo;
                        }
                        else
                        {
                            byte desiredColor = imageVoxels[x - options.MinX, y - options.MinY, z - options.BottomZ];
                            if (desiredColor == c.Color)
                            {
                                msgGroup = MessageGroup.Assist;
                                builtInLastMinute++;
                            }
                            else
                            {
                                msgGroup = MessageGroup.Attack;
                                griefedInLastMinute++;
                                gotGriefed?.Set();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.LogDebug($"LogMapChanged: unhandled exception - {ex}");
                        msgGroup = MessageGroup.PixelInfo;
                    }
                    logger.LogVoxel($"Received voxel update:", e.DateTime, msgGroup, x, y, z, colorNameResolver.GetName(c.Color));
                }
Exemple #24
0
    public void StartUp(VoxelMap map)
    {
        voxelMesh            = FindObjectOfType <VoxelMesh>();
        terrainNoise         = FindObjectOfType <TerrainNoise>();
        terrainMap           = FindObjectOfType <TerrainMap>();
        chunkCollider        = FindObjectOfType <ChunkCollider>();
        chunkObjectSpawner   = FindObjectOfType <ChunkObjectSpawner>();
        chunkSaveLoadManager = FindObjectOfType <ChunkSaveLoadManager>();
        playerRb             = FindObjectOfType <PlayerController>().GetComponent <Rigidbody2D>();

        voxelMap = map;

        terrainNoise.seed = voxelMap.worldScriptableObject.seed;
        terrainNoise.StartUp(voxelMap.voxelResolution, voxelMap.chunkResolution);
        voxelMesh.StartUp(voxelMap.voxelResolution, voxelMap.chunkResolution, voxelMap.viewDistance, useColliders, colliderRadius);

        InvokeRepeating(nameof(UpdateMap), 0.0f, terrainMap.updateInterval);
    }
Exemple #25
0
        /// <summary>
        /// Called when the VoxelMap is changed.
        /// </summary>
        /// <param name="_map">The map that it is changed into.</param>
        private void FileManager_OnVoxelMapChangedEvent(VoxelMap _map)
        {
            if (_map != null)  //If theres no map selected.

            {
                chunkPanel.SetState(true);
                swatchPanel.SetState(true);
                swatchPanel.SetVoxelSwatch(_map.voxelSwatch);
                chunkPanel.SetVoxelMap(_map);
            }
            else    //If there is a map selected.

            {
                chunkPanel.SetState(false);
                swatchPanel.SetState(false);
                swatchPanel.SetVoxelSwatch(null);
                chunkPanel.SetVoxelMap(null);
            }
        }
Exemple #26
0
    private void Awake()
    {
        player               = FindObjectOfType <PlayerController>().transform;
        voxelMap             = FindObjectOfType <VoxelMap>();
        chunkSaveLoadManager = FindObjectOfType <ChunkSaveLoadManager>();
        worldManager         = FindObjectOfType <WorldManager>();
        terrainNoise         = FindObjectOfType <TerrainNoise>();
        worldDataHandler     = FindObjectOfType <WorldDataHandler>();

        isActive = false;

        debugInfo     = transform.GetChild(0);
        worldNameText = debugInfo.GetChild(0).GetComponent <TextMeshProUGUI>();
        worldSeedText = debugInfo.GetChild(1).GetComponent <TextMeshProUGUI>();
        gameModeText  = debugInfo.GetChild(2).GetComponent <TextMeshProUGUI>();
        playerPosText = debugInfo.GetChild(3).GetComponent <TextMeshProUGUI>();
        chunkPosText  = debugInfo.GetChild(4).GetComponent <TextMeshProUGUI>();
        regionPosText = debugInfo.GetChild(5).GetComponent <TextMeshProUGUI>();
        mousePosText  = debugInfo.GetChild(6).GetComponent <TextMeshProUGUI>();

        SetInfoState(isActive);
    }
    //当这个物体变成可用时,进行绘制前的初始化
    void OnEnable()
    {
        //将选中的实例作为目标类型传递给变量
        voxelMap = target as VoxelMap;

        //如果没有用于保存所有准备绘制方块所需的父对象,则新建一个
        if (voxelMap.voxelLowerBlocks == null)
        {
            var go = new GameObject("voxelLowerBlocks");
            go.transform.SetParent(voxelMap.transform);
            go.transform.position = Vector3.zero;

            //在脚本中保存所有的方块数据
            VoxelBlocks voxelBlocks = go.AddComponent <VoxelBlocks> ();
            voxelBlocks.MapSize       = voxelMap.mapSize;
            voxelBlocks.BlockSize     = voxelMap.GetBlockSize();
            voxelMap.voxelLowerBlocks = go;
        }

        if (voxelMap.voxelUpperBlocks == null)
        {
            var go = new GameObject("voxelUpperBlocks");
            go.transform.SetParent(voxelMap.transform);
            go.transform.position = Vector3.zero;

            VoxelBlocks voxelBlocks = go.AddComponent <VoxelBlocks> ();
            voxelBlocks.MapSize       = voxelMap.mapSize;
            voxelBlocks.BlockSize     = voxelMap.GetBlockSize();
            voxelMap.voxelUpperBlocks = go;
        }

        //重新计算gizmo中方块的大小,并且新建一个笔刷
        if (voxelMap.basicBlock != null)
        {
            UpdateCalculations();
            NewBrush();
        }
    }
Exemple #28
0
    private void Awake()
    {
        resolution = chunkGridResolution * chunksMultiplier * isoMultiplier;
        Vector3Int center = new Vector3Int(resolution / 2,
                                           resolution / 2,
                                           resolution / 2);

        surfaceMap = new SurfaceMap(resolution);
        SurfaceMap layer1 = new SurfaceMap(resolution);

        DrawSurface.Sphere(layer1, center, radius, 3, true);
        DrawSurface.NoiseSettings.lacunarity  = 1;
        DrawSurface.NoiseSettings.persistance = 0;
        DrawSurface.NoiseSettings.octaves     = 1;
        DrawSurface.NoiseSettings.frequency   = 3;
        DrawSurface.NoiseSettings.gain        = 5;
        DrawSurface.ApplyNoiseToSphere(layer1, center);
        SurfaceMap.MergeMaterialLayers(surfaceMap, layer1, 1);

        //SurfaceMap.MergeMaterialLayers(surfaceMap, layer1, 0);
        //DrawSurface.Cylinder(surfaceMap, new Vector3Int(7, 7, 7), new Vector3Int(13, 13, 10), 6, 2, 0);

        /*//DrawSurface.Line(layer1, new Vector3Int(1, 0, 0), new Vector3Int(1, 5, 0), 2, 1, false, 0);
         *
         * DrawSurface.NoiseSettings.lacunarity = 1;
         * DrawSurface.NoiseSettings.persistance = 0;
         * DrawSurface.NoiseSettings.octaves = 1;
         * DrawSurface.NoiseSettings.frequency = 1;
         * DrawSurface.NoiseSettings.gain = 20;
         * DrawSurface.ApplyNoiseToSphere(layer1, center);
         * SurfaceMap.MergeMaterialLayers(surfaceMap, layer1, 1);*/
        voxelMap.size            = size;
        voxelMap.chunkResolution = chunksMultiplier;
        voxelMap.voxelResolution = chunkGridResolution;
        voxelMapObject           = Instantiate <VoxelMap>(voxelMap, position, rotation);
        Refresh();
    }
Exemple #29
0
        /// <summary>
        /// Called when the VoxelMap is changed.
        /// </summary>
        /// <param name="_map">The map that it is changed into.</param>
        private void FileManager_OnVoxelMapChangedEvent (VoxelMap _map) {

            if (_map != null) {//If theres no map selected.

                chunkPanel.SetState(true);
                swatchPanel.SetState(true);
                swatchPanel.SetVoxelSwatch(_map.voxelSwatch);
                chunkPanel.SetVoxelMap(_map);

            } else {//If there is a map selected.

                chunkPanel.SetState(false);
                swatchPanel.SetState(false);
                swatchPanel.SetVoxelSwatch(null);
                chunkPanel.SetVoxelMap(null);

            }

        }
Exemple #30
0
 private void Awake()
 {
     terrainNoise = FindObjectOfType <TerrainNoise>();
     voxelMap     = FindObjectOfType <VoxelMap>();
 }
Exemple #31
0
        protected bool RunEntityReflectionUnitTests()
        {
            bool result = true;

            if (!BaseObject.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BaseObject reflection validation failed!");
            }

            if (!BaseEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BaseEntity reflection validation failed!");
            }

            if (!BaseEntityNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("BaseEntityNetworkManager reflection validation failed!");
            }

            if (!CubeGridEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CubeGridEntity reflection validation failed!");
            }

            if (!CubeGridManagerManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CubeGridManagerManager reflection validation failed!");
            }

            if (!CubeGridNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CubeGridNetworkManager reflection validation failed!");
            }

            if (!CubeGridThrusterManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CubeGridThrusterManager reflection validation failed!");
            }

            if (!SectorObjectManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("SectorObjectManager reflection validation failed!");
            }

            if (!CharacterEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CharacterEntity reflection validation failed!");
            }

            if (!CharacterEntityNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("CharacterEntityNetworkManager reflection validation failed!");
            }

            if (!FloatingObject.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("FloatingObject reflection validation failed!");
            }

            if (!FloatingObjectManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("FloatingObjectManager reflection validation failed!");
            }

            if (!InventoryEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("InventoryEntity reflection validation failed!");
            }

            if (!InventoryItemEntity.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("InventoryItemEntity reflection validation failed!");
            }

            if (!PowerProducer.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("PowerProducer reflection validation failed!");
            }

            if (!PowerReceiver.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("PowerReceiver reflection validation failed!");
            }

            if (!VoxelMap.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("VoxelMap reflection validation failed!");
            }

            if (!VoxelMapMaterialManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("VoxelMapMaterialManager reflection validation failed!");
            }

            if (result)
            {
                Console.WriteLine("All entity types passed reflection unit tests!");
            }

            return(result);
        }
Exemple #32
0
        /// <summary>
        /// Changes the voxel map reference.
        /// </summary>
        /// <param name="_map">the new reference.</param>
        public void SetVoxelMap(VoxelMap _map) {

            map = _map;
            RebuildChunkList();

        }
Exemple #33
0
 /// <summary>
 /// Changes the voxel map reference.
 /// </summary>
 /// <param name="_map">the new reference.</param>
 public void SetVoxelMap(VoxelMap _map)
 {
     map = _map;
     RebuildChunkList();
 }