Exemplo n.º 1
0
    private Vector3 toVoxelGridSpace(Vector3 worldSpace)
    {
        Vector3 grid = new Vector3((int)(worldSpace.x + hit.x), (int)(worldSpace.y + hit.y), (int)(worldSpace.z + hit.z));

        if (grid.x < 0 || grid.y < 0 || grid.z < 0)
        {
            return(Vector3.zero);
        }
        if (grid.x >= aabcGrid.GetSize().x || grid.y >= aabcGrid.GetSize().y || grid.z >= aabcGrid.GetSize().z)
        {
            return(Vector3.zero);
        }
        if (aabcGrid.IsAABCSet((short)grid.x, (short)grid.y, (short)grid.z))
        {
            return(grid);
        }
        return(Vector3.zero);
    }
Exemplo n.º 2
0
 void DrawMeshShell()
 {
     if (grid != null)
     {
         if (drawMeshShell && (grid != null))
         {
             var cubeSize = new Vector3(cubeSide, cubeSide, cubeSide);
             var gridSize = grid.GetSize();
             for (short x = 0; x < gridSize.x; ++x)
             {
                 for (short y = 0; y < gridSize.y; ++y)
                 {
                     for (short z = 0; z < gridSize.z; ++z)
                     {
                         var cubeCenter = grid.GetAABCCenterFromGridCenter(x, y, z) +
                                          grid.GetCenter() +
                                          meshShellPositionFromObject;
                         if (grid.IsAABCSet(x, y, z))
                         {
                             Color color;
                             if (colors.TryGetValue(colouring[x, y, z], out color))
                             {
                                 Gizmos.color = color;
                                 Gizmos.DrawCube(cubeCenter, cubeSize);
                             }
                         }
                         else if (drawEmptyCube)
                         {
                             Gizmos.color = new Color(0f, 1f, 0f, 1f);
                             Gizmos.DrawCube(cubeCenter, cubeSize);
                         }
                     }
                 }
             }
         }
     }
 }