7 points[1] =
Vector(max[0], min[1], min[2]);
8 points[2] =
Vector(max[0], max[1], min[2]);
9 points[3] =
Vector(min[0], max[1], min[2]);
13 points[5] =
Vector(min[0], min[1], max[2]);
14 points[6] =
Vector(min[0], max[1], max[2]);
17 points[7] =
Vector(min[0], max[1], min[2]);
18 points[8] =
Vector(max[0], max[1], min[2]);
22 points[10] =
Vector(min[0], max[1], max[2]);
23 points[11] =
Vector(min[0], min[1], max[2]);
24 points[12] =
Vector(max[0], min[1], max[2]);
28 points[14] =
Vector(max[0], max[1], min[2]);
29 points[15] =
Vector(max[0], min[1], min[2]);
32 points[16] =
Vector(max[0], min[1], max[2]);
33 points[17] =
Vector(min[0], min[1], max[2]);
39 GetBoundsPoints(min, max, points);
52 static Resource CreateAreaMesh(array<vector> positions,
float height,
string material,
bool strechMaterial)
57 int resolution = positions.Count();
58 if (resolution == 0)
return null;
60 if (resolution * 12 > 720)
62 Print(
string.Format(
"Cannot generate shape, resolution %1 is above maximum value %2!", resolution, 720 / 12),
LogLevel.ERROR);
70 float dirStep =
Math.PI2 / resolution;
71 float uvsTemplate[] = {0,0, 0,1, 1,0, 1,1};
72 int vertsTemplate[] = {0,2,1, 1,2,3, 3,2,1, 1,2,0};
73 int indicesMod = 4 * resolution;
76 vector pos0, pos1, pos2, pos3;
79 for (
int v = -1; v < resolution; v++)
93 if (
id < 0)
id += resolution;
95 pos3 = pos2 + vectorUp;
99 verts[vI] = pos3; vI++;
100 verts[vI] = pos2; vI++;
101 verts[vI] = pos1; vI++;
102 verts[vI] = pos0; vI++;
105 for (
int i = 0; i < 12; i++)
107 indices[iI] = (vI + vertsTemplate[iI - iIS]) % indicesMod; iI++;
110 for (
int i = 0; i < 4; i++)
114 uvs[uI] = (resolution - v + uvsTemplate[uI - uIS]) / resolution;
115 if (v == 0) uvs[uI] = uvs[uI] - 1;
119 uvs[uI] = uvsTemplate[uI - uIS];
122 uvs[uI] = uvsTemplate[uI - uIS]; uI++;
130 int numVertices[] = {vI};
131 int numIndices[] = {iI};
132 string materials[1] = {material};
135 MeshObject meshObject = res.GetResource().ToMeshObject();
136 meshObject.UpdateVerts(0, verts, uvs);
137 meshObject.UpdateIndices(0, indices);
153 static void DrawCircle(
vector transform[4],
float radius,
int colorOutline,
int colorPlane,
ShapeFlags shapeFlags)
156 const int sectionCount = 36;
157 const int linesCount = sectionCount + 1;
158 const int trisCount = sectionCount * 3;
163 float sectionStep = -360 / sectionCount;
165 vector pivot = transform[3];
166 vector point = (
vector.Forward * radius).Multiply4(transform);
168 for (
int i; i < sectionCount; i++)
172 tris[i*3 + 1] = point;
173 point = (
Vector(sectionStep * (i + 1), 0, 0).AnglesToVector() * radius);
174 point = point.Multiply4(transform);
175 tris[i*3 + 2] = point;
179 lines[sectionCount] = point;
181 Shape.CreateLines(colorOutline, shapeFlags, lines, linesCount);
182 Shape.CreateTris(colorPlane, shapeFlags, tris, sectionCount);