Пример #1
0
    void Update()
    {
        //Swap frames, so we update everything at 30 FPS, for descrete voxel space it still nice.
        //And we have a massive perfomance boost.
        frame = !frame;


        if (frame)
        {
            //Begin draw.
            voxelRender.BeginDraw();
            //Draw random boxes to static layer.
            //Random position.
            int x = Random.Range(0, voxelRender.Width);
            int y = 0;
            int z = Random.Range(0, voxelRender.Width);
            //Random size.
            int width  = Random.Range(1, 10);
            int height = Random.Range(1, 64);
            int depth  = Random.Range(1, 10);
            //Random color from palette.
            byte color = (byte)Random.Range(1, 255);
            //And put it to static layer.
            voxelRender.DrawBox(x, y, z, width, height, depth, color, Layer.Static);
            //End draw, it starts a multithreading geometry building.
            voxelRender.EndDraw();
        }
        else
        {
            //Wait geometry.
            voxelRender.WaitGeometry();
        }
    }
Пример #2
0
    void Update()
    {
        //Begin draw.
        voxelRender.BeginDraw();

        //Update count.
        count += 0.05f;

        //Draw Lines.
        for (int i = 0; i < 72; i++)
        {
            float x1 = 96 + 84 * Mathf.Sin(count + i * 5 * 0.0174f);
            float y1 = 24 + 8 * Mathf.Sin(count * 0.5f + i * 5 * 0.0174f);
            float z1 = 96 + 84 * Mathf.Cos(count + i * 5 * 0.0174f);

            float x2 = 96 + 84 * Mathf.Sin(count * 1.2f + (i - 1) * 5 * 0.0174f);
            float y2 = 24 + 16 * Mathf.Sin(count * 0.8f + (i - 1) * 5 * 0.0174f);
            float z2 = 96 + 84 * Mathf.Cos(count * 1.2f + (i - 1) * 5 * 0.0174f);

            //Vector3 center = new Vector3(x, y, z);
            voxelRender.DrawLine(new Vector3(x1, y1, z1), new Vector3(x2, y2, z2), (byte)(i + 1), Layer.Dynamic);
        }



        //End draw, it starts a multithreading geometry building.
        voxelRender.EndDraw();

        //Wait geometry.
        voxelRender.WaitGeometry();
    }
Пример #3
0
    void Update()
    {
        //Begin draw.
        voxelRender.BeginDraw();

        count += 0.02f;

        //Draw Cut Spheres
        for (int i = 0; i < 8; i++)
        {
            float   x        = 96 + Mathf.Cos(i * 0.2f + count * 2) * 80;
            float   z        = 96 + (Mathf.Sin(i * 0.7f + count * 1.8f) + Mathf.Sin(i * 0.3f + count * 3)) * 40;
            float   y        = 4 + 2 * Mathf.Cos(i * 0.4f + count * 4);
            Vector3 position = new Vector3(x, y, z);

            //Cut From Static Level, if color=0
            voxelRender.DrawSphere(position, 4, 0, Layer.Static);
            //Draw Dynamic
            voxelRender.DrawSphere(position, 4, (byte)(i + 1), Layer.Dynamic);
        }

        //End draw, it starts a multithreading geometry building.
        voxelRender.EndDraw();

        //Wait geometry.
        voxelRender.WaitGeometry();
    }
Пример #4
0
    void Update()
    {
        //Begin draw.
        voxelRender.BeginDraw();

        count += 0.02f;
        //Draw voxel meshes.
        for (int i = 0; i < 8; i += 2)
        {
            float x = 96 + 64 * Mathf.Sin(count + i * 0.262f);
            float y = 32 + 8 * Mathf.Sin(count * 4 + i * 0.262f);
            float z = 96 + 64 * Mathf.Cos(count + i * 0.262f);
            voxelRender.DrawMesh(voxelMesh, new Vector3(x, y, z), Layer.Dynamic);
        }

        //And put a static mesh to level.
        float xx = 96 + 86 * Mathf.Sin(count * 0.5f);
        float zz = 96 + 86 * Mathf.Cos(count * 0.5f);

        voxelRender.DrawMesh(voxelMesh, new Vector3(xx, voxelMesh.height / 2, zz), Layer.Static);


        //End draw, it starts a multithreading geometry building.
        voxelRender.EndDraw();

        //Wait geometry.
        voxelRender.WaitGeometry();
    }
Пример #5
0
    void Update()
    {
        //Begin draw.
        voxelRender.BeginDraw();

        //Inc counters.
        count  += 0.02f;
        count2 += 0.1f;

        //Calculate some voxels.
        int  x     = (int)(96 + 80 * Mathf.Sin(count * 0.6f - count2 * 0.3f));
        int  z     = (int)(80 + 80 * Mathf.Sin(-0.4f * count + count2 * 0.2f));
        int  y     = (int)(8 + 8 * Mathf.Sin(0.4f * count + count2 * 0.4f + z * 0.1f));
        byte color = (byte)Random.Range(1, 255);

        //Put it to level.
        for (int i = 4; i < 16; i++)
        {
            voxelRender.SetVoxel(x, y + i, z, color, Layer.Static);
        }


        //End draw, it starts a multithreading geometry building.
        voxelRender.EndDraw();

        //Wait geometry.
        voxelRender.WaitGeometry();
    }
Пример #6
0
    void Update()
    {
        //Swap frames, so we update everything at 30 FPS, for descrete voxel space it still nice.
        //And we have a massive perfomance boost.
        frame = !frame;

        if (frame)
        {
            //Begin draw.
            voxelRender.BeginDraw();


            //Draw some dynamic voxels.
            //Update count.
            count += 0.02f;

            for (int x = 0; x < voxelRender.Width; x++)
            {
                for (int z = 0; z < voxelRender.Depth; z++)
                {
                    float height = 16 + 8 * Mathf.PerlinNoise((float)x * 0.025f, (float)z * 0.025f) + 8 * Mathf.Sin(count + x * 0.01f + z * 0.01f);
                    voxelRender.SetVoxel(x, (int)height, z, (byte)(height + 1), Layer.Dynamic);
                }
            }


            //End draw, it starts a multithreading geometry building.
            voxelRender.EndDraw();
        }
        else
        {
            //Wait geometry.
            voxelRender.WaitGeometry();
        }
    }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        //Begin draw.
        voxelRender.BeginDraw();

        //Scroll by sin.
        float xView = 64 + 64 * Mathf.Sin(count);
        float zView = 64 + 64 * Mathf.Cos(count);

        //Update count
        count += 0.02f;
        //Update viewpos
        voxelRender.SetViewportPosition(xView, zView);


        //End draw, it starts a multithreading geometry building.
        voxelRender.EndDraw();

        //Wait geometry.
        voxelRender.WaitGeometry();
    }