예제 #1
0
    // Update is called once per frame
    void Update()
    {
        MeshFilter meshFilter = this.GetComponent <MeshFilter>();
        // one submesh for each face
        Vector3 center = new Vector3(0, 0, 0);

        mc.Clear(); // Clear internal lists and mesh



        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                center.Set(j * size.x * (float)distance,
                           0,
                           i * size.z * (float)distance);

                vfxList[i, j].transform.position = new Vector3(j * size.x * (float)distance, 0, i * size.z * (float)distance);
                CreateCube(center, center.x, center.z, i, j);
            }
        }

        if (!animateVFX)
        {
            meshFilter.mesh = mc.CreateMesh();
        }
    }
예제 #2
0
    protected void Update()
    {
        meshCreator.Clear();

        Vector3 center = transform.localPosition;

        CreateCube(center, Time.deltaTime);

        meshFilter.mesh = meshCreator.CreateMesh();
    }
    void Update()
    {
        // float height = 1 + 0.9f * Perlin.Noise(col * size.x * (float)1.2, row * size.z * (float)1.2, Random.Range(0.05f, 0.5f));
        float vertexChange = 1 + 0.9f * Perlin.Noise((float)1.2, radius * (float)1.2, Random.Range(1.0f, 2.5f));
        // Mesh sphereMesh = GetComponent<MeshFilter>().mesh = SphereCreator.Create(subdivisions, radius);
        MeshFilter meshFilter = GetComponent <MeshFilter>();

        meshFilter.mesh = SphereCreator.Create(subdivisions, radius, vertexChange);;


        mc.Clear(); // Clear internal lists and mesh
    }
예제 #4
0
    void Update()
    {
        mc.Clear();

        // add vertices
        for (int i = 0; i <= width; i++)
        {
            float x = i * squareSize;
            for (int j = 0; j <= depth; j++)
            {
                float z = j * squareSize;

                // compute noise at given space time point
                float noiseOut = Perlin.Noise(noiseScale.x * i, noiseScale.y * Time.time, noiseScale.z * j);

                // normalize noise
                noiseOut += 1;
                noiseOut /= 2;

                // compute y-value from noise
                float y = noiseOut * maxHeight;

                // compute uv
                float u = (float)i / width;
                float v = (float)j / depth;

                // compute color from noise

                Color color = minColor + noiseOut * (maxColor - minColor);

                // add the vertex
                vertices[i, j] = new ColoredPoint(x, y, z, color.r, color.g, color.b);
            }
        }

        // build triangles out of those vertices
        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < depth; j++)
            {
                ColoredPoint a = vertices[i, j];
                ColoredPoint b = vertices[i + 1, j];
                ColoredPoint c = vertices[i, j + 1];
                ColoredPoint d = vertices[i + 1, j + 1];

                mc.BuildTriangle(d, b, a);
                mc.BuildTriangle(c, d, a);
            }
        }

        meshFilter.mesh = mc.CreateMesh();
    }
예제 #5
0
    private void Update()
    {
        // Clear the mesh data
        meshCreator.Clear();

        // Loop to obtain grids of terrain
        for (int x = 0; x < width; ++x)
        {
            for (int y = 0; y < width; ++y)
            {
                CreateTerrainSqure(x, y);
            }
        }
        meshFilter.mesh = meshCreator.CreateMesh();
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        MeshFilter meshFilter = this.GetComponent <MeshFilter>();
        // one submesh for each face
        Vector3 center = new Vector3(0, 0, 0);

        mc.Clear(); // Clear internal lists and mesh

        for (int i = 0; i < cubeCout; i++)
        {
            // center.Set(i * size.x * (float)1.2 * Mathf.PI, 0, i * size.z * (float)1.2 * Mathf.PI);
            center.Set(Mathf.Sin((360 / cubeCout) * i * Mathf.PI / 180) * radius, 0, Mathf.Cos((360 / cubeCout) * i * Mathf.PI / 180) * radius);
            CreateCube(center, i);
        }

        meshFilter.mesh = mc.CreateMesh();
    }
    // Update is called once per frame
    void Update()
    {
        MeshFilter meshFilter = this.GetComponent <MeshFilter>();
        // one submesh for each face
        Vector3 center = new Vector3(0, 0, 0);

        mc.Clear(); // Clear internal lists and mesh

        for (int row = 0; row < 50; row++)
        {
            for (int col = 0; col < 50; col++)
            {
                center.Set(col * size.x, 0, row * size.z);
                CreateCube(center);
            }
        }

        meshFilter.mesh = mc.CreateMesh();
    }
예제 #8
0
    void Update()
    {
        mc.Clear();

        Vector3 cubeSize = size * 0.5f;

        // top of the cube
        Vector3 t0 = new Vector3(cubeSize.x, cubeSize.y, -cubeSize.z);
        Vector3 t1 = new Vector3(-cubeSize.x, cubeSize.y, -cubeSize.z);
        Vector3 t2 = new Vector3(-cubeSize.x, cubeSize.y, cubeSize.z);
        Vector3 t3 = new Vector3(cubeSize.x, cubeSize.y, cubeSize.z);

        // bottom of the cube
        Vector3 b0 = new Vector3(cubeSize.x, -cubeSize.y, -cubeSize.z);
        Vector3 b1 = new Vector3(-cubeSize.x, -cubeSize.y, -cubeSize.z);
        Vector3 b2 = new Vector3(-cubeSize.x, -cubeSize.y, cubeSize.z);
        Vector3 b3 = new Vector3(cubeSize.x, -cubeSize.y, cubeSize.z);

        // Top square
        mc.BuildTriangle(t0, t1, t2);
        mc.BuildTriangle(t0, t2, t3);

        // Bottom square
        mc.BuildTriangle(b2, b1, b0);
        mc.BuildTriangle(b3, b2, b0);

        // Back square
        mc.BuildTriangle(b0, t1, t0);
        mc.BuildTriangle(b0, b1, t1);

        mc.BuildTriangle(b1, t2, t1);
        mc.BuildTriangle(b1, b2, t2);

        mc.BuildTriangle(b2, t3, t2);
        mc.BuildTriangle(b2, b3, t3);

        mc.BuildTriangle(b3, t0, t3);
        mc.BuildTriangle(b3, b0, t0);

        meshFilter.mesh = mc.CreateMesh();
    }
예제 #9
0
    // Update is called once per frame
    void Update()
    {
        move = move + 0.01f;
        MeshFilter meshFilter = this.GetComponent <MeshFilter>();
        // one submesh for each face
        Vector3 center = new Vector3(0, 0, 0);

        mc.Clear(); // Clear internal lists and mesh

        for (int row = 0; row < 20; row++)
        {
            for (int col = 0; col < 20; col++)
            {
                // center.Set(col * size.x * (float)1.2, Perlin.Noise(col * size.x * (float)0.5f+move,row * size.z * (float)1f+move), row * size.z * (float)1.2);
                center.Set(col * size.x * (float)1.2, 0.25f * m_audioTest.clipRange(row, col), row * size.z * (float)1.2);

                CreateCube(center);
            }
        }

        meshFilter.mesh = mc.CreateMesh();
    }
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        loudness = this.GetComponent <AudioSourceLoudnessTester>().clipLoudness;
        // print(loudness);

        MeshFilter meshFilter = this.GetComponent <MeshFilter>();
        // one submesh for each face
        Vector3 center = new Vector3(0, 0, 0);

        mc.Clear(); // Clear internal lists and mesh

        for (int row = 0; row < 20; row++)
        {
            for (int col = 0; col < 20; col++)
            {
                float height = 1 + 0.9f * Perlin.Noise(col * size.x * (float)1.2, row * size.z * (float)1.2, loudness * 30);
                center.Set(col * size.x * (float)1.2, 0, row * size.z * (float)1.2);
                CreateCube(center, height);
            }
        }

        meshFilter.mesh = mc.CreateMesh();
    }
    // Update is called once per frame
    void Update()
    {
        MeshFilter meshFilter = this.GetComponent <MeshFilter>();
        // one submesh for each face
        Vector3 center = new Vector3(0, 0, 0);

        mc.Clear(); // Clear internal lists and mesh

        //Inputs to increase and decrese grid numbers
        if (Input.GetKeyDown(KeyCode.Space))
        {
            gridCubes += 10;
        }

        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            gridCubes -= 10;
        }

        //Inputs to increase and decrease the spacing between the cubes
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            distBetween -= 0.2;
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            distBetween += 0.2;
        }

        //Inputs for switching color
        if (Input.GetKeyDown(KeyCode.G))
        {
            //Alter the color
            altColor.g += 0.1f;
            //Assign the changed color to the material.
            rend.material.color = altColor;
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            //Alter the color
            altColor.r += 0.1f;
            //Assign the changed color to the material.
            rend.material.color = altColor;
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            //Alter the color
            altColor.b += 0.1f;
            //Assign the changed color to the material.
            rend.material.color = altColor;
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            //Alter the color
            altColor.a += 0.1f;
            //Assign the changed color to the material.
            rend.material.color = altColor;
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            //Alter the color
            altColor.a += 0.1f;
            //Assign the changed color to the material.
            altColor            = orColor;
            rend.material.color = altColor;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            partSpawn = true;
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            partSpawn = false;
        }

        //Creating the cubes grid
        for (int row = 0; row < gridCubes; row++)
        {
            for (int col = 0; col < gridCubes; col++)
            {
                center.Set(col * size.x * (float)distBetween, 0, row * size.z * (float)distBetween);
                CreateCube(center);
            }
        }

        meshFilter.mesh = mc.CreateMesh();
    }
예제 #12
0
 // Update is called once per frame
 void Update()
 {
     mc.Clear();
     CreatePlane(length, width);
 }
    // Update is called once per frame
    void Update()
    {
        float[] spectrum = new float[256];
        AudioListener.GetSpectrumData(spectrum, 0, FFTWindow.Rectangular);


        MeshFilter meshFilter = this.GetComponent <MeshFilter>();
        Mesh       mesh       = this.GetComponent <MeshFilter>().mesh;

        Vector3[] vertices = mesh.vertices;


        // one submesh for each face
        Vector3 center = new Vector3(0, 0, 0);

        mc.Clear(); // Clear internal lists and mesh

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            resize++;
        }
        if (Input.GetKeyDown(KeyCode.DownArrow) && resize > 1.0f)
        {
            resize--;
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            distance += 0.1f;
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) && distance > 1.2f)
        {
            distance -= 0.1f;
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            for (int i = 0; i < vertices.Length; i++)
            {
                this.GetComponent <MeshRenderer>().material.color = Color.Lerp(Color.yellow, Color.blue, vertices[i].y);
            }
        }


        for (int j = 0; j < 20; j++)
        {
            for (int i = 0; i < 20; i++)
            {
                Vector3 cubeSize = size * 0.5f;
                //float timepass = 0;
                float timepass = Time.deltaTime * 20f;
                //timepass +=Time.deltaTime* 10.0f;

                float noisy = cubeSize.y + Perlin.Noise(cubeSize.x + size.x * i * 0.12f * spectrum[i] * 100.0f + timepass, 0, -cubeSize.z + size.z * j * 0.12f * spectrum[i] * 100.0f + timepass);
                //float noisy = cubeSize.y + Perlin.Noise(cubeSize.x + size.x * i * 0.12f + timepass, 0, -cubeSize.z + size.z * j * 0.12f + timepass);

                // top of the cube
                // t0 is top left point
                Vector3 t0 = new Vector3(cubeSize.x + size.x * i * distance, noisy * resize, -cubeSize.z + size.z * j * distance);
                Vector3 t1 = new Vector3(-cubeSize.x + size.x * i * distance, noisy * resize, -cubeSize.z + size.z * j * distance);
                Vector3 t2 = new Vector3(-cubeSize.x + size.x * i * distance, noisy * resize, cubeSize.z + size.z * j * distance);
                Vector3 t3 = new Vector3(cubeSize.x + size.x * i * distance, noisy * resize, cubeSize.z + size.z * j * distance);

                // bottom of the cube
                Vector3 b0 = new Vector3(cubeSize.x + size.x * i * distance, -cubeSize.y, -cubeSize.z + size.z * j * distance);
                Vector3 b1 = new Vector3(-cubeSize.x + size.x * i * distance, -cubeSize.y, -cubeSize.z + size.z * j * distance);
                Vector3 b2 = new Vector3(-cubeSize.x + size.x * i * distance, -cubeSize.y, cubeSize.z + size.z * j * distance);
                Vector3 b3 = new Vector3(cubeSize.x + size.x * i * distance, -cubeSize.y, cubeSize.z + size.z * j * distance);

                // Top square
                mc.BuildTriangle(t0, t1, t2);
                mc.BuildTriangle(t0, t2, t3);

                // Bottom square
                mc.BuildTriangle(b2, b1, b0);
                mc.BuildTriangle(b3, b2, b0);

                // Back square
                mc.BuildTriangle(b0, t1, t0);
                mc.BuildTriangle(b0, b1, t1);

                mc.BuildTriangle(b1, t2, t1);
                mc.BuildTriangle(b1, b2, t2);

                mc.BuildTriangle(b2, t3, t2);
                mc.BuildTriangle(b2, b3, t3);

                mc.BuildTriangle(b3, t0, t3);
                mc.BuildTriangle(b3, b0, t0);

                meshFilter.mesh = mc.CreateMesh();

                if (noisy > 1.1f)
                {
                    Instantiate(particlesystem, new Vector3(i * 2.0F, noisy * resize * 2, 0), Quaternion.identity);
                }
            }
        }
    }
 private void Update()
 {
     _meshCreator.Clear();
     GenerateTerrainMesh();
 }
예제 #15
0
 public void ClearWorld(MeshCreator world)
 {
     world.Clear();
 }