Esempio n. 1
0
        /// <summary>
        /// Initialize the mesh based on the component's settings
        /// </summary>
        public void InitMesh()
        {
            meshRenderer.sharedMaterial = material ? material : new Material(Shader.Find("Standard"));

            Mesh newMesh = new Mesh();

            switch (meshType)
            {
            case MeshType.Triangle:
            {
                newMesh = MeshLibrary.Triangle(radius);
                break;
            }

            case MeshType.Quad:
            {
                newMesh = MeshLibrary.Quad(width, height);
                break;
            }

            case MeshType.Circle:
            {
                newMesh = MeshLibrary.Circle(radius, numVertices);
                break;
            }
            }
            if (messUp)
            {
                newMesh = MeshLibrary.MessedUp(newMesh, messUpRadius);
            }
            meshFilter.mesh = newMesh;
        }
Esempio n. 2
0
    public int ml_idx;//This material's index in the GridMap's MeshLibrary

    public Material(string name)
    {
        this.tex = GD.Load <Texture>(String.Format("res://textures/{0}.png", name));
        MeshLibrary ml = GD.Load <MeshLibrary>("res://Blocks_ML.meshlib");

        this.ml_idx = ml.FindItemByName(name);
    }
Esempio n. 3
0
        /// <summary>
        /// Viewing mode for the application.
        /// This requests the application to read the shapes
        /// and let the user view and analyse them themselves.
        /// </summary>
        private static void DisplayShapes()
        {
            MeshLibrary meshes = Settings.FileManager.ProcessedMeshes;

            Settings.DirectShutDown = false;
            do
            {
                Logger.Log(string.Empty);                    // Empty line for clearance.
                Logger.Log(I_ShapeSelect_Prompt, ExitArguments.FirstOrDefault());

                string input = System.Console.ReadLine();
                if (IsExitArgument(input))
                {
                    Settings.DirectShutDown = true;
                }
                else if (meshes.Names.Contains(input))
                {
                    RunWindow(meshes[input].Mesh);
                }
                else
                {
                    Logger.Log(I_UnknownCommand, input);
                }
            } while (!Settings.DirectShutDown);
        }
Esempio n. 4
0
        /// <summary>
        /// Tell the user how many shapes are currently loaded.
        /// </summary>
        private static void ShowShapeCount()
        {
            MeshLibrary meshes = Settings.FileManager.ProcessedMeshes;

            Logger.Log(I_ShapeCount, meshes.Count);
            foreach (string name in meshes.Names)
            {
                Logger.Log($"\t- {name}");
            }
        }
Esempio n. 5
0
    public void InitTerrain(string terrainFile)
    {
        PackedScene ps       = (PackedScene)GD.Load(terrainFile);
        Node        instance = ps.Instance();

        AddChild(instance);
        terrain = (Spatial)instance;

        // Everything below this line is a dirty hack to work around a bug.
        GridMap gm = Util.GetChildByName(terrain, "Map") as GridMap;

        MeshLibrary    theme  = gm.Theme;
        List <Vector3> colors = new List <Vector3> {
            new Vector3(0.537f, 0.101f, 0.101f),
            new Vector3(0.141f, 0.313f, 0.125f),
            new Vector3(0.137f, 0.215f, 0.521f),
            new Vector3(0.690f, 0.321f, 0.129f),
            new Vector3(0.490f, 0.168f, 0.490f),
            new Vector3(0.717f, 0.694f, 0.203f),
            new Vector3(1, 1, 1),
            new Vector3(0, 0, 0)
        };

        for (int i = 0; i < 8; i++)
        {
            ArrayMesh       arrMesh  = theme.GetItemMesh(i) as ArrayMesh;
            SpatialMaterial material = GFX.GetColorSpatialMaterial(colors[i]) as SpatialMaterial;

            material.EmissionEnabled = true;
            material.Emission        = GFX.Color(colors[i]);
            material.EmissionEnergy  = 0.5f;

            material.TransmissionEnabled = true;
            material.Transmission        = GFX.Color(colors[i]);

            material.RefractionEnabled = false;

            material.Metallic = 1f;

            material.Roughness = 0.5f;

            arrMesh.SurfaceSetMaterial(0, material);
        }
    }
Esempio n. 6
0
    public void generateMaze2D()
    {
        //modification des materiaux
        MeshLibrary ml = MeshLibrary;

        //creation du sol
        for (int x = 0; x <= tx; x++)
        {
            for (int z = 0; z <= tx; z++)
            {
                SetCellItem(x, floor_item, z, 0);
            }
        }
        //creation des murs
        for (int x = 0; x <= tx; x++)
        {
            for (int z = 0; z <= tx; z++)
            {
                SetCellItem(x, 1, z, wall_item);
            }
        }
        //on remove les murs
        Random rand = new Random();

        depx = rand.Next(1, tx - 1);
        depz = rand.Next(1, tz - 1);
        depy = 2;
        SetCellItem(depx, -1, depz, -1);
        int ax = depx;
        int az = depz;

        for (int w = 0; w < nbchem; w++)
        {
            if (rand.Next(1, 3) == 1)
            {
                if (rand.Next(1, 3) == 1)
                {
                    ax += 1;
                }
                else
                {
                    ax -= 1;
                }
            }
            else
            {
                if (rand.Next(1, 3) == 1)
                {
                    az += 1;
                }
                else
                {
                    az -= 1;
                }
            }
            if (ax <= 0)
            {
                ax = 1;
            }
            if (az <= 0)
            {
                az = 1;
            }
            if (ax >= tx)
            {
                ax = tx - 1;
            }
            if (az >= tx)
            {
                az = tz - 1;
            }
            SetCellItem(ax, 1, az, -1);
        }
        finx = ax;
        finy = 1;
        finz = az;
        for (int x = 0; x <= tx; x++)
        {
            for (int z = 0; z <= tx; z++)
            {
                int item = GetCellItem(x, 1, z);
                if (item == wall_item)
                {
                    var mur  = ResourceLoader.Load("res://assets/mur.tscn");
                    var mure = new mur();
                    mure.Name        = "mur-" + x + "-" + z;
                    mure.Translation = new Vector3(x * CellSize.x * CellScale, 1 * CellSize.y * CellScale, z * CellSize.z * CellScale);
                    AddChild(mure);
                }
            }
        }
    }
Esempio n. 7
0
    public static MeshLibrary GetTheme()
    {
        MeshLibrary ret = ResourceLoader.Load("res://Terrain/Terrain.meshlib") as MeshLibrary;

        return(ret);
    }