/// <summary> /// Get the info of a cell which belongs to neighboring trunks. /// </summary> public Int3 GetCrossBoundaryCellInfo(Int3 cellCoord, out VoxelTrunk otherTrunk) { if (ownerEntity == null) { // No world assigned, so there is no adjacent trunks info, return null value otherTrunk = null; return(Int3.Zero); } var otherTrunkCoord = coordinate; var otherCellCoord = cellCoord; for (int dim = 0; dim < 3; dim++) { if (cellCoord[dim] >= dimension[dim]) { otherTrunkCoord = otherTrunkCoord.Offset(dim, 1); otherCellCoord = otherCellCoord.Offset(dim, -dimension.x); } else if (cellCoord[dim] < 0) { otherTrunkCoord = otherTrunkCoord.Offset(dim, -1); otherCellCoord = otherCellCoord.Offset(dim, dimension[dim]); } } otherTrunk = ownerEntity.GetTrunk(otherTrunkCoord); //if(otherCellCoord.y < 0) // Debug.Log("before:" + cellCoord + ", after: " + otherCellCoord); return(otherCellCoord); }
public VoxelData(VoxelTrunk trunk, Int3 dimension, Vector3 cellSize) { this.trunk = trunk; this.dimension = dimension; this.cellSize = cellSize; fill = new byte[dimension.x, dimension.y, dimension.z]; }
public SurfaceNetTrigSolver(VoxelTrunk trunk) : base(trunk) { // Stores all the lookups var lookups = SurfaceNetTrigLookups.Instance; vertexPosLookup = lookups.vertexPosLookup; intersectionVertLookup = lookups.intersectionVertLookup; intersectionAxisLookup = lookups.intersectionAxisLookup; cellOffsetsLookup = lookups.cellOffsetsLookup; vertices = new List <Vector3>(); triangles = new List <int>(); normals = new List <Vector3>(); cellToVertIndexLookup = new Dictionary <int, int>(); }
public override void Apply(VoxelTrunk trunk, Vector3 centerPosition) { var centerCoord = trunk.GetCoordByWorldPos(centerPosition); Int3 radiusByCell = new Int3( Mathf.RoundToInt(radius / trunk.cellSize.x), Mathf.RoundToInt(radius / trunk.cellSize.y), Mathf.RoundToInt(radius / trunk.cellSize.z)); if (radiusByCell.x <= 0 || radiusByCell.y <= 0 || radiusByCell.z <= 0) { // If brush radius is zero, skip. return; } // Loop through all cells in brush range for (int i = -radiusByCell.x; i <= radiusByCell.x; i++) { for (int j = -radiusByCell.y; j <= radiusByCell.y; j++) { for (int k = -radiusByCell.z; k <= radiusByCell.z; k++) { var coord = centerCoord.Offset(i, j, k); //Debug.Log("Paint at coord:" + coord + ", Inside:" + trunk.data.ContainsCell(coord)); if (!trunk.data.ContainsCell(coord)) { // If cell is not inside trunk, skip continue; } float t = new Vector3((float)i / radiusByCell.x, (float)j / radiusByCell.y, (float)k / radiusByCell.z).magnitude; if (t > 1) { continue; } var currentStrength = curve.Evaluate(t) * strength; trunk.data.PaintFill(coord, currentStrength); } } } }
public TriangulationSolver(VoxelTrunk trunk) { this.trunk = trunk; data = trunk.data; }
// Use this for initialization void Awake() { trunk = GetComponent <VoxelTrunk>(); }
public abstract void Apply(VoxelTrunk trunk, Vector3 centerPosition);