{"id":273311,"date":"2016-02-01T11:04:03","date_gmt":"2016-02-01T08:04:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=273311"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=273311","title":{"rendered":"\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043a\u0430\u0440\u0442\u044b \u043c\u0438\u0440\u0430 \u043d\u0430 Unity C#, \u0447\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b0c\/73f\/8b4\/b0c73f8b487c4da38778d99e99d9bdac.png\" alt=\"image\"\/><\/p>\n<p>  \u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Unity \u0438 C# \u043a\u0430\u0440\u0442\u0430\u0445 \u043c\u0438\u0440\u0430. \u0426\u0438\u043a\u043b \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0441\u0442\u0430\u0442\u0435\u0439.<br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/b><\/p>\n<p>  <a href=\"https:\/\/habrahabr.ru\/post\/276251\/\">\u0427\u0430\u0441\u0442\u044c 1<\/a>:<\/p>\n<p>  \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<br \/>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0443\u043c\u0430<br \/>  \u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<br \/>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442<\/p>\n<p>  \u0427\u0430\u0441\u0442\u044c 2 (\u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f):<\/p>\n<p>  \u0421\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043e\u0441\u0438<br \/>  \u0421\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u043d\u0430 \u043e\u0431\u0435\u0438\u0445 \u043e\u0441\u044f\u0445<br \/>  \u041f\u043e\u0438\u0441\u043a \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<br \/>  \u0411\u0438\u0442\u043e\u0432\u044b\u0435 \u043c\u0430\u0441\u043a\u0438<br \/>  \u0417\u0430\u043b\u0438\u0432\u043a\u0430<\/p>\n<p>  \u0427\u0430\u0441\u0442\u044c 3:<\/p>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b<br \/>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u0432\u043e\u0434\u044b<br \/>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u043a<\/p>\n<p>  \u0427\u0430\u0441\u0442\u044c 4:<\/p>\n<p>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u043e\u043c\u043e\u0432<br \/>  \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0430\u0440\u0442<\/p>\n<p>  <b>\u0421\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u043e\u0441\u0438<\/b><\/p>\n<p>  <i>(\u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430: \u044f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e wrapping \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u00ab\u0441\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435\u00bb. \u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u043d\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0442\u0435\u0440\u043c\u0438\u043d, \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044e.)<\/i><\/p>\n<p>  \u0412 <a href=\"https:\/\/habrahabr.ru\/post\/276251\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0446\u0438\u043a\u043b\u0430 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u044b. \u041a\u0430\u0440\u0442\u0443 \u0432\u044b\u0441\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043b\u0435\u0438\u0442\u044c \u0432\u0441\u0442\u044b\u043a.<\/p>\n<p>  \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0448\u0443\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435. \u0414\u043b\u044f \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u043e\u0433\u043e \u0441\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0438\u0440\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0432 \u043d\u0430\u0448 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0448\u0443\u043c\u0430.<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0440\u0443\u0433\u043e\u0432\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u043e\u0441\u0438. \u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0446\u0438\u043b\u0438\u043d\u0434\u0440 \u0432 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/036\/498\/594\/036498594a2541ca8fa648f49a78b345.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043b\u0438 \u044d\u0442\u043e\u0442 \u0446\u0438\u043b\u0438\u043d\u0434\u0440 \u0438 \u0440\u0430\u0441\u0441\u0442\u0435\u043b\u0438\u043b\u0438 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438\u043c \u043c\u044b \u0438 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f. \u041a\u0440\u0430\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043b\u0438 \u0446\u0438\u043b\u0438\u043d\u0434\u0440, \u043f\u0440\u0438 \u0441\u043a\u043b\u0435\u0439\u043a\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0433\u043e \u0448\u0432\u0430.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetData \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Generator.<\/p>\n<pre><code class=\"cs\">private void GetData(ImplicitModuleBase module, ref MapData mapData) {     mapData = new MapData (Width, Height);       \/\/ \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 x,y - \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u0442\u044b     for (var x = 0; x &lt; Width; x++) {         for (var y = 0; y &lt; Height; y++) {               \/\/\u041f\u0440\u0435\u0434\u0435\u043b\u044b \u0448\u0443\u043c\u0430             float x1 = 0, x2 = 1;             float y1 = 0, y2 = 1;                            float dx = x2 - x1;             float dy = y2 - y1;               \/\/\u0421\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c \u0448\u0443\u043c \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438             float s = x \/ (float)Width;             float t = y \/ (float)Height;               \/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b             float nx = x1 + Mathf.Cos (s * 2 * Mathf.PI) * dx \/ (2 * Mathf.PI);             float ny = x1 + Mathf.Sin (s * 2 * Mathf.PI) * dx \/ (2 * Mathf.PI);             float nz = t;               float heightValue = (float)HeightMap.Get (nx, ny, nz);               \/\/ \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f             if (heightValue &gt; mapData.Max)                 mapData.Max = heightValue;             if (heightValue &lt; mapData.Min)                 mapData.Min = heightValue;               mapData.Data [x, y] = heightValue;         }     } } <\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0441\u0438 X.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/72a\/9df\/d3d\/72a9dfd3da114959873aee5dcf7682a8.png\" alt=\"image\"\/><\/p>\n<p>  <b>\u0421\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u043d\u0430 \u043e\u0431\u0435\u0438\u0445 \u043e\u0441\u044f\u0445<\/b><\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0430 \u043a\u0430\u0440\u0442\u0430 \u043c\u043e\u0433\u043b\u0430 \u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0431\u0435\u0438\u0445 \u043e\u0441\u044f\u0445, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u0448\u0443\u043c. \u042d\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u044f\u0441\u043d\u0438\u0442\u044c, \u043d\u0430\u0448\u0435\u043c\u0443 \u043c\u043e\u0437\u0433\u0443 \u0441\u043b\u043e\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u0432 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u043e \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u043c \u0448\u0443\u043c\u043e\u043c.<\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0446\u0438\u043b\u0438\u043d\u0434\u0440\u0430 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u0434\u0432\u0430 \u0446\u0438\u043b\u0438\u043d\u0434\u0440\u0430, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0432 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435.<\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0435\u043c \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0445.<\/p>\n<p>  \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f GetData() \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">private void GetData(ImplicitModuleBase module, ref MapData mapData) {     mapData = new MapData (Width, Height);       \/\/ \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 x,y - \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u0442\u044b     for (var x = 0; x &lt; Width; x++) {         for (var y = 0; y &lt; Height; y++) {               \/\/ \u041f\u0440\u0435\u0434\u0435\u043b\u044b \u0448\u0443\u043c\u0430             float x1 = 0, x2 = 2;             float y1 = 0, y2 = 2;                            float dx = x2 - x1;             float dy = y2 - y1;               \/\/ \u0421\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c \u0448\u0443\u043c \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438             float s = x \/ (float)Width;             float t = y \/ (float)Height;                       \/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b             float nx = x1 + Mathf.Cos (s*2*Mathf.PI) * dx\/(2*Mathf.PI);             float ny = y1 + Mathf.Cos (t*2*Mathf.PI) * dy\/(2*Mathf.PI);             float nz = x1 + Mathf.Sin (s*2*Mathf.PI) * dx\/(2*Mathf.PI);             float nw = y1 + Mathf.Sin (t*2*Mathf.PI) * dy\/(2*Mathf.PI);                       float heightValue = (float)HeightMap.Get (nx, ny, nz, nw);                           \/\/ \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f             if (heightValue &gt; mapData.Max) mapData.Max = heightValue;             if (heightValue &lt; mapData.Min) mapData.Min = heightValue;               mapData.Data[x,y] = heightValue;         }     } } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u0443\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443, \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cbf\/7c9\/d57\/cbf7c9d57e99498ab0f8a9bff1946b87.png\" alt=\"image\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438\u0437\u0443\u0447\u0438\u0442\u0435 <a href=\"http:\/\/ronvalstar.nl\/creating-tileable-noise-maps\">\u044d\u0442\u0443<\/a> \u0438 <a href=\"http:\/\/www.gamedev.net\/blog\/33\/entry-2138456-seamless-noise\/\">\u044d\u0442\u0443<\/a> \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  <b>\u041f\u043e\u0438\u0441\u043a \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/b><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0430 \u0432\u044b\u0441\u043e\u0442, \u0438 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0446\u0435\u043b\u0438. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0435 Tile.<\/p>\n<p>  \u0411\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 Tile \u0438\u043c\u0435\u043b \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0432\u0435\u0440\u0445\u043d\u0438\u0439, \u043d\u0438\u0436\u043d\u0438\u0439, \u043f\u0440\u0430\u0432\u044b\u0439 \u0438 \u043b\u0435\u0432\u044b\u0439). \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u0442\u0435\u0439, \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0441\u043e\u043a \u0438 \u0437\u0430\u043b\u0438\u0432\u043a\u0438. \u041f\u043e\u0437\u0436\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u0438 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Tile:<\/p>\n<pre><code class=\"cs\">public Tile Left; public Tile Right; public Tile Top; public Tile Bottom; <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430. \u041c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0442\u0430\u0439\u043b\u0443, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u043a \u043d\u0435\u043c\u0443 \u0442\u0430\u0439\u043b\u044b. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 Generator, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Tile.<\/p>\n<pre><code class=\"cs\">private Tile GetTop(Tile t) {     return Tiles [t.X, MathHelper.Mod (t.Y - 1, Height)]; } private Tile GetBottom(Tile t) {     return Tiles [t.X, MathHelper.Mod (t.Y + 1, Height)]; } private Tile GetLeft(Tile t) {     return Tiles [MathHelper.Mod(t.X - 1, Width), t.Y]; } private Tile GetRight(Tile t) {     return Tiles [MathHelper.Mod (t.X + 1, Width), t.Y]; } <\/code><\/pre>\n<p>  MathHelper.Mod() \u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f x \u0438 y \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0448\u0438\u0440\u0438\u043d\u044b \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u043a\u0430\u0440\u0442\u044b. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u043c \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043a\u0430\u0440\u0442\u044b.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0443\u044e \u0441\u043e\u0441\u0435\u0434\u0435\u0439.<\/p>\n<pre><code class=\"cs\">private void UpdateNeighbors() {     for (var x = 0; x &lt; Width; x++)     {         for (var y = 0; y &lt; Height; y++)         {             Tile t = Tiles[x,y];                           t.Top = GetTop(t);             t.Bottom = GetBottom (t);             t.Left = GetLeft (t);             t.Right = GetRight (t);         }     } } <\/code><\/pre>\n<p>  \u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043e\u043d\u0430 \u043f\u043e\u043a\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u043c\u043d\u043e\u0433\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 Tile \u00ab\u0437\u043d\u0430\u0435\u0442\u00bb \u0441\u0432\u043e\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0448\u0430\u0433\u043e\u0432.<\/p>\n<p>  <b>\u0411\u0438\u0442\u043e\u0432\u044b\u0435 \u043c\u0430\u0441\u043a\u0438<\/b><\/p>\n<p>  \u042f \u0440\u0435\u0448\u0438\u043b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u044e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0437 \u044d\u0441\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u2014 \u044d\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0430\u0439\u043b\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0435\u0433\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u0443 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044e:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/363\/83b\/4eb\/36383b4eb9be4040beb2eab8f609b690.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0442\u0430\u0439\u043b\u0430 \u043c\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0431\u0438\u0442\u043e\u0432\u0443\u044e \u043c\u0430\u0441\u043a\u0443, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0441\u043b\u0435\u0432\u0430 \u043d\u0430 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0412\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0431\u043b\u043e\u043a\u0430.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0430\u0439\u043b\u0430, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u044b \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c\u0438 \u0438 \u043c\u0435\u043d\u0435\u0435 \u0437\u0435\u0440\u043d\u0438\u0441\u0442\u044b\u043c\u0438.<\/p>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u043d\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0442\u0430\u0439\u043b\u0430 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e 15, \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0439\u043d\u0438\u043c \u0442\u0430\u0439\u043b\u043e\u043c \u043a\u0430\u0440\u0442\u044b.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043a\u043b\u0430\u0441\u0441 Tile \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041c\u044b \u0431\u0435\u0440\u0435\u043c \u0432 \u0440\u0430\u0441\u0447\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0442\u0438\u043f \u0432\u044b\u0441\u043e\u0442\u044b, \u0447\u0442\u043e \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0442\u0430\u0439\u043b.<\/p>\n<pre><code class=\"cs\">public void UpdateBitmask() {     int count = 0;           if (Top.HeightType == HeightType)         count += 1;     if (Right.HeightType == HeightType)         count += 2;     if (Bottom.HeightType == HeightType)         count += 4;     if (Left.HeightType == HeightType)         count += 8;           Bitmask = count; } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0442\u0430\u0439\u043b\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u043b\u0438 \u0442\u0438\u043f \u0432\u044b\u0441\u043e\u0442\u044b (HeightType), \u044d\u0442\u043e\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u0435\u043d. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043a\u043b\u0430\u0441\u0441 Generator \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0430\u0439\u043b\u043e\u0432:<\/p>\n<pre><code class=\"cs\">private void UpdateBitmasks() {     for (var x = 0; x &lt; Width; x++) {         for (var y = 0; y &lt; Height; y++) {             Tiles [x, y].UpdateBitmask ();         }     } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448 TextureGenerator \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">\/\/\u0437\u0430\u0442\u0435\u043c\u043d\u044f\u0435\u043c \u0446\u0432\u0435\u0442 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043b\u0430 if (tiles[x,y].Bitmask != 15)     pixels[x + y * width] = Color.Lerp(pixels[x + y * width], Color.black, 0.4f); <\/code><\/pre>\n<p>  \u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0447\u0435\u0442\u043a\u0443\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u0430\u043c\u0438 \u0432\u044b\u0441\u043e\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b0c\/73f\/8b4\/b0c73f8b487c4da38778d99e99d9bdac.png\" alt=\"image\"\/><\/p>\n<p>  <b>\u0417\u0430\u043b\u0438\u0432\u043a\u0430<\/b><\/p>\n<p>  \u0411\u044b\u043b\u043e \u0431\u044b \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438:<\/p>\n<ul>\n<li> \u0433\u0434\u0435 \u043e\u0437\u0435\u0440\u0430?<\/li>\n<li> \u0433\u0434\u0435 \u043e\u043a\u0435\u0430\u043d\u044b?<\/li>\n<li> \u0433\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0443\u0448\u0438?<\/li>\n<li> \u043a\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445?<\/li>\n<\/ul>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043d\u0430\u0448\u0438\u0445 \u0442\u0430\u0439\u043b\u0430\u0445:<\/p>\n<pre><code class=\"cs\">using UnityEngine; using System.Collections.Generic;   public enum TileGroupType {     Water,      Land }   public class TileGroup  {           public TileGroupType Type;     public List&lt;Tile&gt; Tiles;       public TileGroup()     {         Tiles = new List&lt;Tile&gt; ();     } } <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 TileGroup \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0430\u0439\u043b\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043d\u0430\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0432\u043e\u0434\u043e\u0439 \u0438\u043b\u0438 \u0441\u0443\u0448\u0435\u0439.<\/p>\n<p>  \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0441\u0443\u0448\u0438 \u0438 \u0432\u043e\u0434\u044b \u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 TileGroup.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Tile, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0434\u0432\u0435 \u043d\u043e\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"cs\">public bool Collidable; public bool FloodFilled; <\/code><\/pre>\n<p>  Collidable \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 LoadTiles(). \u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0434\u043d\u044b\u043c \u0442\u0430\u0439\u043b\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u00ab\u0438\u0441\u0442\u0438\u043d\u0430\u00bb \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 Collidable. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f FloodFilled \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0439\u043b\u043e\u0432, \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0437\u0430\u043b\u0438\u0432\u043a\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441 Generator \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u0430 \u043f\u0430\u0440\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 TileGroup:<\/p>\n<pre><code class=\"cs\">List&lt;TileGroup&gt; Waters = new List&lt;TileGroup&gt; (); List&lt;TileGroup&gt; Lands = new List&lt;TileGroup&gt; (); <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0443\u0448\u0438 \u0438 \u0432\u043e\u0434\u044b \u043d\u0430 \u043d\u0430\u0448\u0435\u0439 \u043a\u0430\u0440\u0442\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u0430\u0440\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0443\u044e \u0437\u0430\u043b\u0438\u0432\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<pre><code class=\"cs\">private void FloodFill() {     \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0442\u0435\u043a \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438     Stack&lt;Tile&gt; stack = new Stack&lt;Tile&gt;();           for (int x = 0; x &lt; Width; x++) {         for (int y = 0; y &lt; Height; y++) {                           Tile t = Tiles[x,y];               \/\/\u0422\u0430\u0439\u043b \u0443\u0436\u0435 \u0437\u0430\u043b\u0438\u0442, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0435\u0433\u043e             if (t.FloodFilled) continue;               \/\/ \u0421\u0443\u0448\u0430             if (t.Collidable)                {                 TileGroup group = new TileGroup();                 group.Type = TileGroupType.Land;                 stack.Push(t);                                   while(stack.Count &gt; 0) {                     FloodFill(stack.Pop(), ref group, ref stack);                 }                                   if (group.Tiles.Count &gt; 0)                     Lands.Add (group);             }             \/\/ \u0412\u043e\u0434\u0430             else {                               TileGroup group = new TileGroup();                 group.Type = TileGroupType.Water;                 stack.Push(t);                                   while(stack.Count &gt; 0)   {                     FloodFill(stack.Pop(), ref group, ref stack);                 }                                   if (group.Tiles.Count &gt; 0)                     Waters.Add (group);             }         }     } }     private void FloodFill(Tile tile, ref TileGroup tiles, ref Stack&lt;Tile&gt; stack) {     \/\/ \u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f     if (tile.FloodFilled)          return;     if (tiles.Type == TileGroupType.Land && !tile.Collidable)         return;     if (tiles.Type == TileGroupType.Water && tile.Collidable)         return;       \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 TileGroup     tiles.Tiles.Add (tile);     tile.FloodFilled = true;       \/\/ \u0437\u0430\u043b\u0438\u0432\u043a\u0430 \u0441\u043e\u0441\u0435\u0434\u0435\u0439     Tile t = GetTop (tile);     if (!t.FloodFilled && tile.Collidable == t.Collidable)         stack.Push (t);     t = GetBottom (tile);     if (!t.FloodFilled && tile.Collidable == t.Collidable)         stack.Push (t);     t = GetLeft (tile);     if (!t.FloodFilled && tile.Collidable == t.Collidable)         stack.Push (t);     t = GetRight (tile);     if (!t.FloodFilled && tile.Collidable == t.Collidable)         stack.Push (t); } <\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0443\u0448\u0438 \u0438 \u0432\u043e\u0434\u044b, \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0438\u0445 \u0432 TileGroups<\/p>\n<p>  \u042f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0430\u0440\u0443 \u0442\u0435\u043a\u0441\u0442\u0443\u0440, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d58\/aa2\/46c\/d58aa246c01642c389341ac19ab8f778.png\" alt=\"image\"\/> <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9bd\/bcf\/c92\/9bdbcfc9275d4f758edc4f873df44a01.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430 \u043b\u0435\u0432\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435 \u0442\u0430\u0439\u043b\u044b \u0441\u0443\u0448\u0438 \u0437\u0430\u043b\u0438\u0442\u044b \u0447\u0435\u0440\u043d\u044b\u043c. \u0422\u0430\u0439\u043b\u044b \u043e\u043a\u0435\u0430\u043d\u0430 \u0441\u0438\u043d\u0438\u0435, \u0430 \u0442\u0430\u0439\u043b\u044b \u043e\u0437\u0435\u0440 \u0433\u043e\u043b\u0443\u0431\u044b\u0435.<\/p>\n<p>  \u041d\u0430 \u043f\u0440\u0430\u0432\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435 \u0442\u0430\u0439\u043b\u044b \u0432\u043e\u0434\u044b \u0441\u0438\u043d\u0438\u0435. \u0411\u043e\u043b\u044c\u0448\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u0443\u0448\u0438 \u0438\u043c\u0435\u044e\u0442 \u0442\u0435\u043c\u043d\u043e-\u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 \u043e\u0441\u0442\u0440\u043e\u0432\u0430 \u2014 \u0441\u0432\u0435\u0442\u043b\u043e-\u0437\u0435\u043b\u0435\u043d\u044b\u0439.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0435, \u0438 \u044d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u0441\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0441 github: <a href=\"https:\/\/github.com\/jongallant\/WorldGeneratorPart2\">World Generator Part 2<\/a>.       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/276281\/\"> https:\/\/habrahabr.ru\/post\/276281\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b0c\/73f\/8b4\/b0c73f8b487c4da38778d99e99d9bdac.png\" alt=\"image\"\/><\/p>\n<p>  \u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Unity \u0438 C# \u043a\u0430\u0440\u0442\u0430\u0445 \u043c\u0438\u0440\u0430. \u0426\u0438\u043a\u043b \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0441\u0442\u0430\u0442\u0435\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-273311","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=273311"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273311\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=273311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=273311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}