◆ PrefabTransform
Enumerator |
---|
Undefined | |
FlipX | |
FlipY | |
FlipZ | |
RotateZ90 | |
RotateZ180 | |
RotateZ270 | |
◆ Autocrop()
static Prefab essentials.Prefabs.PrefabExtensions.Autocrop |
( |
this Prefab |
prefab, |
|
|
Vector3i? |
center = null |
|
) |
| |
|
static |
Attribute: x,y,z
!= 0)
35 int minX =
int.MaxValue;
36 int minY =
int.MaxValue;
37 int minZ =
int.MaxValue;
38 int maxX = -
int.MaxValue;
39 int maxY = -
int.MaxValue;
40 int maxZ = -
int.MaxValue;
42 for (
int x=0; x<prefab.Width; ++x)
44 for (
int y=0; y<prefab.Length; ++y)
46 for (
int z=0; z<prefab.Height; ++z)
48 if (prefab[x,y,z] != 0)
50 minX = Math.Min(minX, x);
51 minY = Math.Min(minY, y);
52 minZ = Math.Min(minZ, z);
54 maxX = Math.Max(maxX, x);
55 maxY = Math.Max(maxY, y);
56 maxZ = Math.Max(maxZ, z);
62 return SubPrefab(prefab,
new Vector3i(minX, minY, minZ),
new Size3i(maxX - minX, maxY - minY, maxZ - minZ), center);
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
static Prefab SubPrefab(this Prefab prefab, Vector3i offset, Size3i size, Vector3i? center=null)
Definition: PrefabExtensions.cs:8
◆ SubPrefab()
Attribute: pt] = prefab[origPoint
;
10 Vector3i newCenter = center ?? prefab.Center - offset;
11 var cropped =
new Prefab(size, newCenter);
13 for (
int x=0; x<size.
Width; ++x)
15 for (
int y=0; y<size.
Length; ++y)
17 for (
int z=0; z<size.
Height; ++z)
21 if (origPoint.
X >= 0 && origPoint.
Y >= 0 && origPoint.
Z >= 0
22 && origPoint.
X < prefab.Width && origPoint.
Y < prefab.Length && origPoint.
Z < prefab.Height)
24 cropped[pt] = prefab[origPoint];
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
int Height
Definition: Size3i.cs:8
int Y
The Y coordinate
Definition: Vector3i.cs:23
int Width
Definition: Size3i.cs:8
int Length
Definition: Size3i.cs:8
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13
int X
The X coordinate
Definition: Vector3i.cs:18
int Z
The Z coordinate
Definition: Vector3i.cs:28
◆ Transform() [1/2]
Attribute: transform(new Vector3i(x, y, z))] = prefab[x, y, z
;
67 var l0 = transform(
new Vector3i(-1, -1, -1));
68 var l1 = transform((
Vector3i)prefab.Size);
71 var ret =
new Prefab(size, transform(prefab.Center));
73 for (
int x=0; x<prefab.Width; ++x)
75 for (
int y=0; y<prefab.Length; ++y)
77 for (
int z=0; z<prefab.Height; ++z)
79 ret[transform(
new Vector3i(x, y, z))] = prefab[x, y, z];
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13
◆ Transform() [2/2]
100 Func<Vector3i, Vector3i> transformer;
104 transformer = vec =>
new Vector3i(prefab.Width - vec.X - 1, vec.Y, vec.Z);
107 transformer = vec =>
new Vector3i(vec.X, prefab.Length - vec.Y - 1, vec.Z);
110 transformer = vec =>
new Vector3i(vec.X, vec.Y, prefab.Height - vec.Z - 1);
113 transformer = vec =>
new Vector3i(vec.Y, vec.X, vec.Z);
116 transformer = vec =>
new Vector3i(prefab.Width - vec.X - 1, prefab.Length - vec.Y - 1, vec.Z);
119 transformer = vec =>
new Vector3i(prefab.Length - vec.Y - 1, prefab.Width - vec.X - 1, vec.Z);
122 throw new ArgumentException(
"Invalid transform",
"transform");
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
PrefabTransform
Definition: PrefabExtensions.cs:87
static Prefab Transform(this Prefab prefab, Func< Vector3i, Vector3i > transform)
Definition: PrefabExtensions.cs:65
The documentation for this class was generated from the following file: