28 var mesh =
new Mesh();
36 for (
int x=0; x<prefab.Width; ++x)
38 for (
int y=0; y<prefab.Length; ++y)
40 for (
int z=0; z<prefab.Height; ++z)
42 var block = prefab[x, y, z];
45 const float size = 1f;
46 var position =
new Vector3i(x, y, z) - prefab.Center;
49 if (!
Clip || !prefab.InBounds(x,y,z+1) || prefab[x,y,z+1] == 0)
51 new Vertex(
new Vector3(size, size, size) + position,
new Vector2(1f, 1f), Vector3.UnitZ),
52 new Vertex(
new Vector3(size, 0, size) + position,
new Vector2(1f, 0f), Vector3.UnitZ),
53 new Vertex(
new Vector3(0, 0, size) + position,
new Vector2(0f, 0f), Vector3.UnitZ),
54 new Vertex(
new Vector3(0, size, size) + position,
new Vector2(0f, 1f), Vector3.UnitZ),
59 if (!
Clip || !prefab.InBounds(x,y,z-1) || prefab[x,y,z-1] == 0)
61 new Vertex(
new Vector3(size, size, 0) + position,
new Vector2(1f, 1f), -Vector3.UnitZ),
62 new Vertex(
new Vector3(size, 0, 0) + position,
new Vector2(1f, 0f), -Vector3.UnitZ),
63 new Vertex(
new Vector3(0, 0, 0) + position,
new Vector2(0f, 0f), -Vector3.UnitZ),
64 new Vertex(
new Vector3(0, size, 0) + position,
new Vector2(0f, 1f), -Vector3.UnitZ),
69 if (!
Clip || !prefab.InBounds(x-1,y,z) || prefab[x-1,y,z] == 0)
71 new Vertex(
new Vector3(0, size, size) + position,
new Vector2(1f, 1f), -Vector3.UnitX),
72 new Vertex(
new Vector3(0, 0, size) + position,
new Vector2(0f, 1f), -Vector3.UnitX),
73 new Vertex(
new Vector3(0, 0, 0) + position,
new Vector2(0f, 0f), -Vector3.UnitX),
74 new Vertex(
new Vector3(0, size, 0) + position,
new Vector2(1f, 0f), -Vector3.UnitX),
79 if (!
Clip || !prefab.InBounds(x+1,y,z) || prefab[x+1,y,z] == 0)
81 new Vertex(
new Vector3(size, size, size) + position,
new Vector2(1f, 1f), Vector3.UnitX),
82 new Vertex(
new Vector3(size, 0, size) + position,
new Vector2(0f, 1f), Vector3.UnitX),
83 new Vertex(
new Vector3(size, 0, 0) + position,
new Vector2(0f, 0f), Vector3.UnitX),
84 new Vertex(
new Vector3(size, size, 0) + position,
new Vector2(1f, 0f), Vector3.UnitX),
89 if (!
Clip || !prefab.InBounds(x,y-1,z) || prefab[x,y-1,z] == 0)
91 new Vertex(
new Vector3(size, 0, size) + position,
new Vector2(1f, 1f), -Vector3.UnitY),
92 new Vertex(
new Vector3(size, 0, 0) + position,
new Vector2(1f, 0f), -Vector3.UnitY),
93 new Vertex(
new Vector3(0, 0, 0) + position,
new Vector2(0f, 0f), -Vector3.UnitY),
94 new Vertex(
new Vector3(0, 0, size) + position,
new Vector2(0f, 1f), -Vector3.UnitY),
99 if (!
Clip || !prefab.InBounds(x,y+1,z) || prefab[x,y+1,z] == 0)
101 new Vertex(
new Vector3(size, size, size) + position,
new Vector2(1f, 1f), Vector3.UnitY),
102 new Vertex(
new Vector3(size, size, 0) + position,
new Vector2(1f, 0f), Vector3.UnitY),
103 new Vertex(
new Vector3(0, size, 0) + position,
new Vector2(0f, 0f), Vector3.UnitY),
104 new Vertex(
new Vector3(0, size, size) + position,
new Vector2(0f, 1f), Vector3.UnitY),
A raw, un-optimize, fully mutable, representation of a static mesh
Definition: Mesh.cs:13
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
Rgba GridColor
Definition: PrefabPreviewBuilder.cs:16
Definition: Material.cs:6
bool Clip
Definition: PrefabPreviewBuilder.cs:18
string TextureFile
Definition: PrefabPreviewBuilder.cs:17