Esempio n. 1
0
        public ExperimentBase CreateExperiment(string name, string fishID)
        {
            string           folder = Path.Combine(Properties.Settings.Default.SavePath, "CircularGradient");
            CircularGradient cgrad  = new CircularGradient(HabituationLength, PreLength, GradientLength, NTrials, Properties.Settings.Default.FrameRate, Properties.Settings.Default.PixelsPermm, folder, name, fishID);

            cgrad.CenterLaserPower = CenterLaserPower;
            cgrad.EdgeLaserPower   = EdgeLaserPower;
            return(cgrad);
        }
Esempio n. 2
0
    /*void OnValidate(){
     *  GenerateMesh();
     * }*/
    void GenerateMesh()
    {
        if (resolution == 0)
        {
            return;
        }

        //var verticesTwo = new List<Vector3>();
        var colors           = new List <Color>();
        var triangles        = new List <int>();
        var trianglesTwo     = new List <int>();
        var trianglesAll     = new List <int>();
        var vertices         = new List <Vector3>();
        var verticesCollider = new List <Vector3>();
        var axisA            = new Vector3(Vector3.up.y, Vector3.up.z, Vector3.up.x);
        var axisB            = Vector3.Cross(Vector3.up, axisA);

        noise            = new Noise(noiseSettings);
        circularGradient = new CircularGradient(new Vector3(size / 2, 0, size / 2), circularGradientSettings);
        colorGenerator   = new ColorGenerator(colorSettings);
        detailsGenerator = new DetailsGenerator(detailsSettings, size, new Vector2(0, -(size * 2)));
        detailPoints     = detailsGenerator.ComputedPoints();
        //Debug.Log(detailPoints[0].Length);

        int i = 0;

        for (int z = 0; z < size; z++)
        {
            for (int x = 0; x < size; x++)
            {
                Vector3 sercent             = new Vector3((float)x / size - 1, 0, (float)z / size - 1);
                float   elevation           = noise.Calculate(sercent.x + seed, sercent.z + seed) * circularGradient.Calculate(x, z);
                float   elevationNormalized = Mathf.Clamp01(elevation / (noiseSettings.rougness + circularGradientSettings.rougness));

                colors.Add(colorGenerator.Calculate(elevationNormalized));

                Vector3 point = Vector3.up + (x - .5f) * 2 * axisA + (z - .5f) * 2 * axisB;
                point.y = elevation;
                verticesCollider.Add(point);
                point.y += Random.Range(-1f, 1f) * lowPolyEffect;
                point.x += Random.Range(-1f, 1f) * lowPolyEffect;
                point.z += Random.Range(-1f, 1f) * lowPolyEffect;
                vertices.Add(point);
                //verticesTwo.Add(point);
                i++;
            }
        }

        i = 0;
        for (int z = 0; z < size; z++)
        {
            for (int x = 0; x < size; x++)
            {
                if (x != size - 1 && z != size - 1)
                {
                    triangles.Add(i);
                    triangles.Add(i + size + 1);
                    triangles.Add(i + size);

                    // triangles.Add(i);
                    // triangles.Add(i+1);
                    // triangles.Add(i+size+1);

                    trianglesTwo.Add(i);
                    trianglesTwo.Add(i + 1);
                    trianglesTwo.Add(i + size + 1);
                }

                i++;
            }
        }
        islandMesh.GenerateMesh(vertices.ToArray(), triangles.ToArray(), colors.ToArray());
        islandMesh2.GenerateMesh(vertices.ToArray(), trianglesTwo.ToArray(), colors.ToArray());

        trianglesAll.AddRange(triangles);
        trianglesAll.AddRange(trianglesTwo);
        if (!meshCollider.sharedMesh)
        {
            meshCollider.sharedMesh = new Mesh();
        }
        var colliderMesh = meshCollider.sharedMesh;

        colliderMesh.vertices = verticesCollider.ToArray();

        colliderMesh.triangles = trianglesAll.ToArray();
        colliderMesh.RecalculateNormals();
        meshCollider.sharedMesh = colliderMesh;

        navMeshSurface.BuildNavMesh();
    }