private static void DrawMatrix(LevelVisionData data) { var main = data.WorldToCell; var sec = data.CellToWorld; DrawMatrix(main, Color.white, Color.red, Color.green, Color.blue); DrawMatrix(sec, Color.black, Color.cyan, Color.magenta, Color.yellow); Gizmos.color = Color.black; Gizmos.DrawWireCube(sec.GetColumn(3), Vector3.one); }
private static void DrawCells(LevelVisionData data, Color fill, Color invalid) { var cellCount = data.CellCount; var cellSize = data.CellSize; var cellHalfSize = cellSize / 1f; var cachedColor = Gizmos.color; var xzOffset = new Vector3(0.5f, 0, 0.5f); for (var x = 0; x < cellCount.x; x++) { for (var z = 0; z < cellCount.z; z++) { var cell = data.Grid[x, z]; var y = cell.Height; var validHeight = y >= 0; if (validHeight) { Gizmos.color = fill; var baseCenter = data.GetWorld(new int3(x, 0, z), xzOffset); if (y == 0) { var size = new Vector3(cellHalfSize.x, 0, cellHalfSize.z); Gizmos.DrawWireCube(baseCenter, size); } else { var topCenter = data.GetWorld(new int3(x, y, z), xzOffset); var center = (topCenter + baseCenter) / 2; var size = new Vector3(cellHalfSize.x, topCenter.y - baseCenter.y, cellHalfSize.z); Gizmos.DrawWireCube(center, size); } } else { Gizmos.color = invalid; var center = data.GetWorld(new int3(x, 0, z), xzOffset); var size = new Vector3(cellHalfSize.x, 0, cellHalfSize.z); Gizmos.DrawWireCube(center, size); } } } Gizmos.color = cachedColor; }
public void Create() { var shift = Bound.size / 2f; var t = Bound.transform; var xShift = t.right * shift.x; var yShift = t.up * shift.y; var zShift = t.forward * shift.z; var origin = Bound.center - (xShift + yShift + zShift); var rot = t.rotation; var scale = Vector3.Scale(Bound.size, CellCount.AsVector3().Inverse()); if (SceneAsset == null) { SceneAsset = LevelVisionData.Create(origin, rot, scale, CellCount); Save(); } else { SceneAsset.SetMatrix(origin, rot, scale); SceneAsset.SetCellCount(CellCount); EditorUtility.SetDirty(SceneAsset); } }