{"id":256844,"date":"2015-05-08T15:04:02","date_gmt":"2015-05-08T11:04:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=256844"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=256844","title":{"rendered":"Frogger HD \u0438 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u043b\u043d \u0432 \u043f\u0440\u0443\u0434\u0443"},"content":{"rendered":"<p>     \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/9b8\/727\/388\/9b8727388c894d6fa52fde6becbf646c.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/post\/256409\/\">\u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e CGA<\/a> \u043e\u0442  <a href=\"http:\/\/habrahabr.ru\/users\/sly_g\/\" class=\"user_link\">SLY_G<\/a> \u044f \u043d\u0435\u043e\u0431\u044b\u0447\u0430\u0439\u043d\u043e \u0432\u043e\u0437\u0431\u0443\u0434\u0438\u043b\u0441\u044f. \u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u044e\u043d\u043e\u0441\u0442\u044c, IBM PC\/XT \u0438 \u0438\u0433\u0440\u0443 frogger jr, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u044f\u0433\u0443\u0448\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u044c \u0434\u043e\u0440\u043e\u0433\u0443, \u0438\u0437\u0431\u0435\u0436\u0430\u0432 \u043a\u043e\u043b\u0435\u0441 \u0431\u0435\u0448\u0435\u043d\u043e \u043c\u0447\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0431\u0430\u0439\u043a\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u043f\u043e \u0431\u0440\u0435\u0432\u043d\u0430\u043c \u0434\u043e\u043f\u0440\u044b\u0433\u0430\u0442\u044c \u0434\u043e \u0442\u0438\u0445\u043e\u0439 \u0437\u0430\u0432\u043e\u0434\u0438. \u0418 \u0442\u0430\u043a \u0434\u043e \u0441\u043c\u0435\u0440\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0438 4 \u0448\u0442\u0443\u043a\u0438. \u0424\u0440\u0430\u044e \u0432\u044b\u0434\u0430\u043b\u0438 666, \u043d\u043e \u044f \u043d\u0435 \u041c\u0430\u043a\u0441.<br \/>  \u041f\u043e\u043f\u043b\u0430\u043a\u0430\u0432 \u043e \u0431\u0435\u0437\u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u043d\u044b\u0445 \u0433\u043e\u0434\u0430\u0445, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439 \u0438 \u0441\u0434\u0435\u043b\u0430\u043b \u0440\u0435\u043c\u0435\u0439\u043a \u0438\u0433\u0440\u044b \u043f\u043e\u0434 iPad.<\/p>\n<p>  \u0414\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432\u043e\u0434\u044b \u0432 \u0440\u0435\u0447\u043a\u0435 \u0440\u0435\u0448\u0438\u043b \u0441\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e-\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c\u0443, \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443.<br \/>  \u041e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0437\u0435\u0440\u043d\u044b\u0445 \u0432\u043e\u043b\u043d \u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u043b\u044c\u0448\u0435.<br \/>  \u0414\u0430! \u0437\u0430\u0431\u044b\u043b \u0441\u043a\u0430\u0437\u0430\u0442\u044c.<br \/>  \u0422\u0435\u043c, \u043a\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c   <\/p>\n<blockquote><p>T T F S E&#8230;   <\/p><\/blockquote>\n<p>\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/302\/b00\/12b\/302b0012b7fe459f98d4e4889024547b.png\" alt=\"image\"\/><\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u043e\u0434\u0430. \u0427\u0438\u0441\u043b\u0435\u043d\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u041d\u043e\u0432\u044c\u0435-\u0421\u0442\u043e\u043a\u0441\u0430 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0435\u0449\u0435 \u0440\u0430\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0432\u0437\u044f\u043b \u043c\u043e\u0434\u0435\u043b\u044c, \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u043d\u043d\u0443\u044e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0433\u043e \u0433\u043e\u0441\u043f\u043e\u0434\u0438\u043d\u0430  <a href=\"http:\/\/habrahabr.ru\/users\/blind_designer\/\" class=\"user_link\">blind_designer<\/a>. \u0412 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043b\u0435\u043f\u043e\u0433\u043e \u041f\u044c\u044e \u043e\u043f\u0438\u0441\u0430\u043d \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u042f \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043b \u0434\u043e \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e.<\/p>\n<h4>\u041c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0434\u044b.<\/h4>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u0442\u043a\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c M*N. \u0421\u0435\u0442\u043a\u0430 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u0437\u0435\u043c\u043b\u0435, \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0442\u043e\u0440\u0447\u0438\u0442 \u043f\u043e \u043f\u0440\u0443\u0436\u0438\u043d\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u043e\u0439 Lx0[i,j]. \u0423\u043f\u0440\u0443\u0433\u043e\u0441\u0442\u044c \u043f\u0440\u0443\u0436\u0438\u043d\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0451 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u043c kx[i,j]. <\/p>\n<p>  \u041d\u0430\u0431\u0440\u043e\u0441\u0438\u043c \u043b\u0435\u0433\u043a\u043e\u0435 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u043b\u043e \u043d\u0430 \u043f\u0440\u0443\u0436\u0438\u043d\u043a\u0438 \u2014 \u044d\u0442\u043e \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u043b\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0435\u0440\u043a\u0430\u043b\u043e \u0432\u043e\u0434\u043e\u0435\u043c\u0430.<\/p>\n<p>  \u041f\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0441\u0438\u043b (\u043a\u0430\u043c\u0435\u043d\u044c \u0443\u043f\u0430\u043b), \u0434\u043b\u0438\u043d\u044b \u043f\u0440\u0443\u0436\u0438\u043d\u043e\u043a Lx[i,j] \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f. \u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c \u0438\u0437 \u0436\u0438\u0437\u043d\u0438, \u0432\u043e\u043b\u043d\u044b \u043e\u0442 \u0431\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u043c\u043d\u044f \u0440\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u0443\u0441\u043f\u043e\u043a\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f. <\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u044f\u0437\u043a\u043e\u0441\u0442\u0438 \u043f\u0440\u0443\u0436\u0438\u043d\u044b mx[i,j]. \u0415\u0441\u043b\u0438 \u0432\u044f\u0437\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u0443\u0436\u0438\u043d\u044b \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0430\u0432\u043d\u043e\u0439 0, \u0442\u043e \u0432\u043e\u043b\u043d\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0438 \u0431\u0443\u0434\u0443\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0434\u043e\u043b\u0433\u043e \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0431\u0435\u0440\u0435\u0433\u043e\u0432.<\/p>\n<p>  \u0427\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u0443\u0436\u0438\u043d\u043e\u043a \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 (\u0437\u0430\u043a\u043e\u043d \u0413\u0443\u043a\u0430 \u0441 \u0434\u0438\u0441\u0441\u0438\u043f\u0430\u0446\u0438\u0435\u0439) <\/p>\n<pre><code class=\"cpp\">   for (int i=0; i&lt;n; i++) {         float x = Lx[i] - Lx0[i];         float acceleration = -kx[i] * x - mx[i]*Wx[i];         Lx[i] += Wx[i]*dt;         Wx[i] += acceleration*dt;     }  <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432 Wx[i,j] \u2014 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0440\u0443\u0436\u0438\u043d\u043a\u0438. \u0412\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u0443\u0436\u0438\u043d\u044b \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0443 \u0443\u043f\u0440\u0443\u0433\u043e\u0441\u0442\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u043d\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435. \u0410 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u2014 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b \u043e\u0442 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f. \u0410 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u2014 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u043b \u043e\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. \u0428\u0430\u0433 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 dt=1, \u0432\u0432\u0435\u0434\u0435\u043d \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u0433\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435, \u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u0440\u0443\u0436\u0438\u043d\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043f\u0440\u0443\u0436\u0438\u043d\u043e\u043a. \u0412 \u0436\u0438\u0437\u043d\u0438 \u043d\u0435 \u0442\u0430\u043a, \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0435\u0434\u044f\u043c\u0438 \u0435\u0441\u0442\u044c \u0441\u0432\u044f\u0437\u044c. \u042d\u0442\u0443 \u0441\u0432\u044f\u0437\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0438\u0444\u0444\u0443\u0437\u0438\u0438 \u0438\u043b\u0438 (\u0434\u043b\u044f \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u043e\u0432) \u0447\u0435\u0440\u0435\u0437 \u0444\u0438\u043b\u044c\u0442\u0440 \u0448\u0438\u0440\u0438\u043d\u043e\u0439 9 \u043f\u0440\u0443\u0436\u0438\u043d\u043e\u043a. \u0424\u0438\u043b\u044c\u0442\u0440 \u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0440\u0443\u0436\u0438\u043d\u044b \u043f\u043e 4 \u0441\u043e\u0441\u0435\u0434\u044f\u043c \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0441\u0432\u0435\u0442\u0430, \u0447\u0442\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u0432\u043e\u043b\u043d\u044b.<\/p>\n<p>  \u0421\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u0446\u0438\u043a\u043b\u043e\u043c<\/p>\n<pre><code class=\"cpp\">    float spread  = 0.025;          \/\/ do some passes where springs pull on their neighbours     for (int iki = 0; iki &lt; 4; iki++) {      \/\/ 4 \u0441\u043e\u0441\u0435\u0434\u0430 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442             \/\/ \u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e \u043e\u0441\u0438 \u0445          for (int j = 0; j &lt; ny; j++) {             for (int k = 1; k &lt; nx-1; k++) {                 int i = k + j*nx;                 lp[i] = spread * (Lx[i] - Lx[i-1]);                 Wx[i - 1] += lp[i];                 rp[i] = spread * (Lx[i] - Lx[i + 1]);                 Wx[i + 1] += rp[i];             }         }         for (int j = 0; j &lt; ny; j++) {             for (int k = 1; k &lt; nx-1; k++) {                 int i = k + j*nx;                 Lx[i - 1] += lp[i];                 Lx[i + 1] += rp[i];             }         }                       \/\/ \u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e \u043e\u0441\u0438 y        for (int j = 1; j &lt; ny-1; j++) {             for (int k = 0; k &lt; nx; k++) {                 int i = k + j*nx;                 lp[i] = spread * (Lx[i] - Lx[i-nx]);                 Wx[i - nx] += lp[i];                 rp[i] = spread * (Lx[i] - Lx[i + nx]);                 Wx[i + nx] += rp[i];             }         }         for (int j = 1; j &lt; ny-1; j++) {             for (int k = 0; k &lt; nx; k++) {                 int i = k + j*nx;                 Lx[i - nx] += lp[i];                 Lx[i + nx] += rp[i];             }         }     }  <\/code><\/pre>\n<p>  \u041c\u0430\u0441\u0441\u0438\u0432\u044b lp[] \u0438 rp[] \u2014 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0430\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0435 \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438.<br \/>  nx \u2014 \u0447\u0438\u0441\u043b\u043e \u0443\u0437\u043b\u043e\u0432 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 x, ny \u2014 \u0447\u0438\u0441\u043b\u043e \u0443\u0437\u043b\u043e\u0432 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 y.<\/p>\n<p>  \u0412\u0441\u0435 \u044f\u0441\u043d\u043e? \u041f\u043e-\u043c\u043e\u0435\u043c\u0443, \u0432\u043f\u043e\u043b\u043d\u0435, \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435, \u043a \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<h4>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u0443\u044e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c. \u0410 \u044f \u0434\u0430\u0432\u043d\u043e \u0443\u0448\u0435\u043b \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043c\u0430 OpenGL \u0438 \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u043e\u043b\u043d\u044b \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435. \u041a\u0430\u043a \u0431\u044b \u0432\u0438\u0434 \u0441 \u0432\u0435\u0440\u0442\u043e\u043b\u0435\u0442\u0430, \u0437\u0430\u0432\u0438\u0441\u0448\u0435\u0433\u043e \u043d\u0430\u0434 \u043e\u0437\u0435\u0440\u043e\u043c. \u041f\u0438\u043a\u0430\u0441\u0441\u043e \u0441\u0434\u0435\u043b\u0430\u043b \u0431\u044b \u0442\u0430\u043a \u0436\u0435. \u0411\u0435\u0440\u0451\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443, \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c\u0438 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043d\u0430\u0448\u0435\u0439 \u0441\u0435\u0442\u043a\u0435.<br \/>  \u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0430 \u043f\u043e \u0446\u0432\u0435\u0442\u043e\u043e\u0449\u0443\u0449\u0435\u043d\u0438\u044f\u043c \u043d\u0430 \u0432\u043e\u0434\u0443 \u0432 \u0431\u0430\u0441\u0441\u0435\u0439\u043d\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/61a\/d92\/934\/61ad92934bfe470aa284ba88126cfa5b.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. \u041f\u0438\u0436\u0436\u0435\u043d\u043d\u043e \u0443 \u0437\u0435\u043f\u0442\u043e\u043b\u0430\u0431\u043e\u0432.<\/p>\n<p>  \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 rawData \u043f\u0438\u043a\u0441\u0435\u043b\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b \u2014 4 \u0431\u0430\u0439\u0442\u0430 \u0438\u043b\u0438 RGBA \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438.  <\/p>\n<pre><code class=\"cpp\">    myUIImage = [UIImage imageNamed:@&quot;ground_2&quot;];     n = nx*ny;     CGImageRef image = [myUIImage CGImage];     NSUInteger width2 = CGImageGetWidth(image);     NSUInteger height2 = CGImageGetHeight(image);     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();     bytesPerPixel2 = 4;     bytesPerRow2 = bytesPerPixel2 * width2;     NSUInteger bitsPerComponent = 8;     rawData = malloc(height2 * width2 * 4);     CGContextRef context = CGBitmapContextCreate(rawData, width2, height2, bitsPerComponent, bytesPerRow2, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);     CGColorSpaceRelease(colorSpace);     CGContextDrawImage(context, CGRectMake(0, 0, width2, height2), image);     CGContextRelease(context); <\/code><\/pre>\n<p>  \u0423 \u043d\u0430\u0441 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <br \/>  \u0415\u0441\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u2014 rawData[i,j].<br \/>  \u0415\u0441\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0434\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u2014 Lx[i,j].<br \/>  \u0415\u0441\u0442\u044c \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0434\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u2014 Wx[i,j].<\/p>\n<p>  \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u0443\u0449\u0435\u043d\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044f\u043c\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443. \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0431\u0443\u0434\u0435\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 pixel[]. <\/p>\n<pre><code class=\"cpp\">-(void) renderWater {     size_t width = nx*2;     size_t height = ny*2;          size_t bytesPerRow = 4*width;     memset(pixel, 0, bytesPerRow*height);     float zz = -1.9;     for (int j=0;j&lt;height;j++) {         for (int k=0;k&lt;width;k++) {             int i2 = (int) (k*4 + j*bytesPerRow);             int k4 = k\/2;             int j4 = j\/2;             int s1 = k%2;             int s2 = 2-s1;             int s3 = j%2;             int s4 = 2-s3;             int i4 = k4 + nx * j4;             float h2 = Lx[i4] - Lx0[i4];             h2 = (Wx[i4]*s2*s4 + Wx[i4+1]*s1*s4 + Wx[i4+nx+1]*s1*s3 + Wx[i4+nx]*s2*s3) \/ 4.0;             int a = 255.0*h2*h2*0.15;                          if (a&gt;255) a = 255;                          float x2 = (k4&gt;0 && k4&lt;nx-1) ? Lx[i4-1] - Lx[i4+1] : 0;             float y2 = (j4&gt;0 && j4&lt;ny-1) ? Lx[i4-nx] - Lx[i4+nx] : 0;                          int k2 = k+zz*x2;             int j2 = j+zz*y2;                          if (k2&lt;1) k2 = 0;             if (k2&gt;width-1) k2 = (int) width-1;                          if (j2&lt;1) j2 = 0;             if (j2&gt;height-1) j2 = (int) height-1;                          int byteIndex = (int) ((bytesPerRow2 * j2) + k2 * bytesPerPixel2);                          int red = rawData[byteIndex];             int green = rawData[byteIndex+1];             int blue =  rawData[byteIndex+2];                 pixel[i2+0] = red;             pixel[i2+1] = green;             pixel[i2+2] = blue;             pixel[i2+3] = 255-a;         }     }                    CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();     CGContextRef context=CGBitmapContextCreate(pixel, width, height, 8, bytesPerRow, colorSpace,                                                kCGBitmapByteOrder32Big |kCGImageAlphaPremultipliedLast);          CGImageRef image=CGBitmapContextCreateImage(context);     CGContextRelease(context);     CGColorSpaceRelease(colorSpace);     UIImage *resultUIImage=[UIImage imageWithCGImage:image];     CGImageRelease(image);     water.image = resultUIImage;      }  <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e. \u0418\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0438 \u043d\u0430 iPhone 4S. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0438 \u0432 4 \u0440\u0430\u0437\u0430 \u043f\u043e\u0432\u044b\u0441\u0438\u043b \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041d\u0430 \u0448\u0435\u0441\u0442\u043e\u043c \u0430\u0439\u0444\u043e\u043d\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e, \u043e\u043d \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0441\u0435\u0442\u043a\u043e\u0439 160 \u043d\u0430 284. <\/p>\n<p>  \u041f\u043b\u044e\u0441, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u043e\u0434\u044b \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u044f \u043c\u0435\u043d\u044f\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0442 0 \u0434\u043e 255.<\/p>\n<p>  \u0412\u0441\u0435. \u042d\u0442\u043e\u0442 \u0446\u0438\u043a\u043b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u0430\u0436\u0435 \u043d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c iPhone 4S \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 20 \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443.<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043f\u043e\u0434 iPad \u0438 \u0435\u0449\u0435 \u0432 \u0434\u0432\u0443\u0445 \u043f\u043e\u0434 iPhone.<\/p>\n<p>  <a href=\"https:\/\/itunes.apple.com\/us\/app\/haken\/id989538948?ls=1&amp;mt=8\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/e8a\/e2d\/d52\/e8ae2dd52a7e4481911ecf91f21ad3ef.png\" alt=\"image\"\/><\/a><br \/>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <a href=\"https:\/\/itunes.apple.com\/us\/app\/haken\/id989538948?ls=1&amp;mt=8\">Haken<\/a>.<\/p>\n<p>  <a href=\"https:\/\/itunes.apple.com\/us\/app\/frogger-hd\/id989649231?ls=1&amp;mt=8\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/835\/af3\/687\/835af3687a4b494ab00b1f9cf2018cc6.png\" alt=\"image\"\/><\/a><br \/>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 <a href=\"https:\/\/itunes.apple.com\/us\/app\/frogger-hd\/id989649231?ls=1&amp;mt=8\">Frogger<\/a>.<\/p>\n<p>  \u0412\u0441\u0435\u0445 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0438 \u0441\u0432\u0435\u0442\u043b\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0435\u0434\u043a\u0430\u043c.     \t<\/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=\"http:\/\/habrahabr.ru\/post\/257555\/\"> http:\/\/habrahabr.ru\/post\/257555\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/9b8\/727\/388\/9b8727388c894d6fa52fde6becbf646c.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/post\/256409\/\">\u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e CGA<\/a> \u043e\u0442  <a href=\"http:\/\/habrahabr.ru\/users\/sly_g\/\" class=\"user_link\">SLY_G<\/a> \u044f \u043d\u0435\u043e\u0431\u044b\u0447\u0430\u0439\u043d\u043e \u0432\u043e\u0437\u0431\u0443\u0434\u0438\u043b\u0441\u044f. \u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u044e\u043d\u043e\u0441\u0442\u044c, IBM PC\/XT \u0438 \u0438\u0433\u0440\u0443 frogger jr, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u044f\u0433\u0443\u0448\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u044c \u0434\u043e\u0440\u043e\u0433\u0443, \u0438\u0437\u0431\u0435\u0436\u0430\u0432 \u043a\u043e\u043b\u0435\u0441 \u0431\u0435\u0448\u0435\u043d\u043e \u043c\u0447\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0431\u0430\u0439\u043a\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u043f\u043e \u0431\u0440\u0435\u0432\u043d\u0430\u043c \u0434\u043e\u043f\u0440\u044b\u0433\u0430\u0442\u044c \u0434\u043e \u0442\u0438\u0445\u043e\u0439 \u0437\u0430\u0432\u043e\u0434\u0438. \u0418 \u0442\u0430\u043a \u0434\u043e \u0441\u043c\u0435\u0440\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0438 4 \u0448\u0442\u0443\u043a\u0438. \u0424\u0440\u0430\u044e \u0432\u044b\u0434\u0430\u043b\u0438 666, \u043d\u043e \u044f \u043d\u0435 \u041c\u0430\u043a\u0441.<br \/>  \u041f\u043e\u043f\u043b\u0430\u043a\u0430\u0432 \u043e \u0431\u0435\u0437\u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043d\u043e \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u043d\u044b\u0445 \u0433\u043e\u0434\u0430\u0445, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439 \u0438 \u0441\u0434\u0435\u043b\u0430\u043b \u0440\u0435\u043c\u0435\u0439\u043a \u0438\u0433\u0440\u044b \u043f\u043e\u0434 iPad.<\/p>\n<p>  \u0414\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432\u043e\u0434\u044b \u0432 \u0440\u0435\u0447\u043a\u0435 \u0440\u0435\u0448\u0438\u043b \u0441\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e-\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c\u0443, \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443.<br \/>  \u041e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0437\u0435\u0440\u043d\u044b\u0445 \u0432\u043e\u043b\u043d \u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u043b\u044c\u0448\u0435.<br \/>  \u0414\u0430! \u0437\u0430\u0431\u044b\u043b \u0441\u043a\u0430\u0437\u0430\u0442\u044c.<br \/>  \u0422\u0435\u043c, \u043a\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c   <\/p>\n<blockquote><p>T T F S E&#8230;   <\/p><\/blockquote>\n<p>\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.  <\/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-256844","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256844","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=256844"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256844\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}