#Making a tiling effect with my point data

1 messages · Page 1 of 1 (latest)

quick bay
#

In my VoroGrid object, I use this to take a file containing point position data, and parse the data to produce a set of Vector3 positions.

This is a simplified overview of it:

public class VoroGrid : MonoBehaviour
{
  TextAsset _tableResource;  // text file where each line holds a {x,y,z}
  CSVTable _table = new CSVTable(_tableResource);
}

public struct CSVTable
{
  public CSVRecord[] Records; // synonymously a Vector3

  public CSVTable(TextAsset table)
  {
    Parse(table); // each line in the table is turned a CSVRecord
  }
}```
It works well enough, but its currently limited to my VoroGrid only holding a single 1x1 table. I'm not sure how best to explain, but in the second image I take a 1x1 grid and tile it into a 4x4 grid. Thats the desired effect with my VoroGrid.

Pretty much the same sort of effect you would get when you scale a UV texture down, you get a repeating texture.
If I could scale the "space" my table exists in, it would allow a single CSVTable struct to have a repeating pattern.
#

I mention UV space as thats how this effect is achieved outside of Unity, the initial random points have been scattered using the UV texture which means I can offset the points and they wrap around.

I basically need some way to take an initial Vector3[] which has the original points, apply some kind of transformation to its contents, and out from that I gain a new Vector3[] with all the new positions

#

Could such a thing be achieved?

mint scarab
#

Sounds like you want modulo?

quick bay
# mint scarab Sounds like you want modulo?

That would be part of it, but say that the input points I had were:

{-0.3, 0, 0.3}
{-0.1, 0, -0.2}
{0.4, 0, 0.1}```
if I altered its scale so that it tiles to a 2x2 pattern, I would go from 3 points, up to needing 12 points
mint scarab
#

Tiling is just duplicating and then remapping.

#

If you have a value in [0, 1], say 0.3, and now you want to shrink it and tile it into [0, 0.5] and [0.5, 1], you would get 0.15 and 0.65. The same math works for nD points.

#

Mathematics package even provides math.remap.

quick bay
#

So I just need to take the initial array of points, run that through a transform matrix(?), and then replace the original array with the new values?

mint scarab
#

That's the remapping part, you still need to do the tiling.

quick bay
#

the tiling im unsure on, but hopefully I can do without it for the moment. For the moment I probably wont need to alter the scale

#

as long as I can make the 1x1 grid be offset around that should be enough, as it would wrarp around anyway

mint scarab
#

If you aren't going to scale, then yes it would just be simple modulo math.

#

If you are going to scale, then you would need to tile and remap to all the new tiles.