25 int heightsCount = heights.Count();
28 Print(
string.Format(
"Resolution of height values (%1) doesn't match the resolution attribute (%2)",
Math.Sqrt(heightsCount),
m_iResolution),
LogLevel.WARNING);
36 int vI, iI, uI, row, column;
44 x / resolution1 - 0.5,
50 uvs[uI] = x / resolution1; uI++;
51 uvs[uI] = 1 - y / resolution1; uI++;
69 if (column == resolution1)
75 int pointBottomLeft = s;
76 int pointBottomRight = s + 1;
80 indices[iI] = pointBottomLeft; iI++;
81 indices[iI] = pointTopLeft; iI++;
82 indices[iI] = pointTopRight; iI++;
84 indices[iI] = pointTopRight; iI++;
85 indices[iI] = pointBottomRight; iI++;
86 indices[iI] = pointBottomLeft; iI++;
89 int numVertices[] = {vI};
90 int numIndices[] = {iI};
91 string materials[] = {material};
94 MeshObject meshObject = res.GetResource().ToMeshObject();
95 meshObject.UpdateVerts(0, verts, uvs);
96 meshObject.UpdateIndices(0, indices);
97 SetObject(meshObject,
"");
98 Physics.CreateStatic(
this, 0xffffffff);
109 return {
new WB_UIMenuItem(
"Generate from the current terrain", 0) };
113 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
114 if (!worldEditor)
return;
119 BaseWorld world = api.GetWorld();
122 vector min, max,
size;
124 worldEditor.GetTerrainBounds(min, max);
128 float heightMax = max[1] - Math.Max(min[1], 0);
131 bool addComma =
false;
133 float posX, posY, posZ;
138 if (addComma) value +=
",";
139 posX = min[0] +
size[0] * x / resolution1;
140 posY = min[2] +
size[2] * y / resolution1;
141 posZ = Math.Max(world.GetSurfaceY(posX, posY), 0) / heightMax;
142 value += posZ.ToString();
148 api.BeginEntityAction();
149 api.SetVariableValue(api.EntityToSource(
this), null,
"m_aHeights", value);
150 api.EndEntityAction();
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.