Exemplo n.º 1
0
    private void SpheresTest()
    {
        const int   numVoxels = 8;
        const float voxelSize = 1f;

        var uniformGrid = UniformGrid.CreateUniformGrid(Vector3.zero, numVoxels, voxelSize);

        Debug.LogWarning(GridUtils.GridStartPos(uniformGrid.transform.position, numVoxels, voxelSize));
        Debug.LogWarning(GridUtils.GridEndPos(uniformGrid.transform.position, numVoxels, voxelSize));

        var spheres = TestUtils.CreateSpheres(uniformGrid.transform.position, 100, 10f);

        CheckSpheres(uniformGrid, spheres, numVoxels, voxelSize);
    }
Exemplo n.º 2
0
    private void GridPosTest2(Vector3 startPos, int numVox, float voxSize)
    {
        var testGrid = UniformGrid.CreateUniformGrid(startPos, numVox, voxSize);

        Vector3 p1      = new Vector3(0.05f, 0.12f, 0.07f);
        int     p1Voxel = GridUtils.World2Voxel(p1, testGrid.transform.position, numVox, voxSize);

        Debug.Log(p1Voxel);
        System.Diagnostics.Debug.Assert(p1Voxel == 9);

        Vector3 voxPos = GridUtils.VoxelPosition(testGrid.transform.position, numVox, voxSize, p1Voxel);

        Debug.Log(voxPos);
        System.Diagnostics.Debug.Assert(TestUtils.Vec3Equal(voxPos, new Vector3(0.05f, 0.15f, 0.05f)));
    }