{"id":4199,"date":"2018-07-13T21:56:00","date_gmt":"2018-07-13T13:56:00","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=4199"},"modified":"2018-10-14T21:17:20","modified_gmt":"2018-10-14T13:17:20","slug":"opengl_sight","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/opengl_sight\/","title":{"rendered":"OpenGL\u4e4b\u6e96\u661f"},"content":{"rendered":"<figure id=\"attachment_4201\" aria-describedby=\"caption-attachment-4201\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4201\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight2.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight2.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight2-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight2-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-4201\" class=\"wp-caption-text\">OpenGL\u4e4b\u6e96\u661f<\/figcaption><\/figure>\n<figure id=\"attachment_4200\" aria-describedby=\"caption-attachment-4200\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4200\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/07\/OpenGL_sight-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-4200\" class=\"wp-caption-text\">\u6e96\u661f\u7d0b\u7406<\/figcaption><\/figure>\n<p>\u5c04\u64ca\u904a\u6232\u5728\u5c4f\u5e55\u4e2d\u756b\u6709\u300e\u6e96\u661f\u300f\u7528\u65bc\u5c04\u64ca\u602a\u7378.\u56e0\u70ba\u300e\u6e96\u661f\u300f\u56fa\u5b9a\u5728\u5c4f\u5e55\u4e2d\u5fc3.\u7576\u4f60\u79fb\u52d5\u6ed1\u9f20\u6642.\u76f8\u6a5f\u8996\u89d2\u4e5f\u96a8\u4e4b\u6539\u8b8a.\u800c\u7576\u4f60\u8981\u79fb\u52d5\u5c04\u64ca\u4f4d\u7f6e\u53ef\u901a\u904e\u6309\u9375\u76e4\u4e0a\u4e0b\u9375<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"94\">\u79fb\u52d5\u6ed1\u9f20<\/td>\n<td width=\"180\">\u97ff\u61c9<\/td>\n<td width=\"279\">\u89d2\u5ea6<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u5de6\u79fb<\/td>\n<td width=\"180\">\u76f8\u6a5f\u8996\u89d2\u7e5eY\u8ef8\u5de6\u8f49<\/td>\n<td width=\"279\">if (y &gt;= 360.0f) y = 0.0f;<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u53f3\u79fb<\/td>\n<td width=\"180\">\u76f8\u6a5f\u8996\u89d2\u7e5eY\u8ef8\u53f3\u8f49<\/td>\n<td width=\"279\">if (y &lt;= -360.0f) y = 0.0f;<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u4e0a\u79fb<\/td>\n<td width=\"180\">\u76f8\u6a5f\u8996\u89d2\u7e5eZ\u8ef8\u53f3\u8f49<\/td>\n<td width=\"279\">if (z &gt; 60.0f) z = 60.0f;<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u4e0b\u79fb<\/td>\n<td width=\"180\">\u76f8\u6a5f\u8996\u89d2\u7e5eZ\u8ef8\u5de6\u8f49<\/td>\n<td width=\"279\">if (z &lt; -60.0f) z = -60.0f;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"94\">\u9375\u76e4\u9375<\/td>\n<td width=\"161\">\u97ff\u61c9<\/td>\n<td width=\"298\">\u4f4d\u7f6e\u8207\u89d2\u5ea6<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u4e0a\u9375<\/td>\n<td width=\"161\">\u4f4d\u7f6e\u524d\u79fb<\/td>\n<td rowspan=\"2\" width=\"298\">x = x &#8211; (speed * cos(DEG_TO_RAD(y)));<\/p>\n<p>z = z &#8211; (speed * sin(DEG_TO_RAD(y)));<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u4e0b\u9375<\/td>\n<td width=\"161\">\u4f4d\u7f6e\u5f8c\u79fb<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u5de6\u9375<\/td>\n<td width=\"161\">\u76f8\u6a5f\u8996\u89d2\u7e5eY\u8ef8\u5de6\u8f49<\/td>\n<td width=\"298\">if (y &gt;= 360.0f) y = 0.0f;<\/td>\n<\/tr>\n<tr>\n<td width=\"94\">\u53f3\u9375<\/td>\n<td width=\"161\">\u76f8\u6a5f\u8996\u89d2\u7e5eY\u8ef8\u53f3\u8f49<\/td>\n<td width=\"298\">if (y &lt;= -360.0f) y = 0.0f;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u66f4\u65b0\u76f8\u6a5f\u4f4d\u7f6e\u8207\u89d2\u5ea6<\/p>\n<p>1.\u65cb\u8f49\u89d2\u5ea6 deltaTime\u70ba\u6642\u9593\u9593\u9694<\/p>\n<p>rot.x = rot.x + dx * 60 *deltaTime;<\/p>\n<p>rot.y = rot.y + dy * 60 *deltaTime;<\/p>\n<p>rot.z = rot.z + dz * 60 *deltaTime;<\/p>\n<p>2.\u9650\u5236\u8996\u53e3\u89d2\u5ea6\u5426\u5247\u6703\u4e0a\u4e0b\u6416\u604d<\/p>\n<p>if ( rot.y &gt;= 360.0f || rot.y &lt;= -360.0f)<\/p>\n<p>player-&gt;rot.y = 0.0f;<\/p>\n<p>if (player-&gt;rot.z &gt; 60.0f)<\/p>\n<p>player-&gt;rot.z = 60.0f;<\/p>\n<p>if (player-&gt;rot.z &lt; -60.0f)<\/p>\n<p>player-&gt;rot.z = -60.0f;<\/p>\n<p>3.\u89d2\u5ea6\u8f49\u5f27\u5ea6<\/p>\n<p>float radian = 3.141592654f * player-&gt;rot.y \/ 180.0f;<\/p>\n<p>\u8a08\u7b97\u79fb\u52d5\u901f\u5ea6<\/p>\n<p>4.float speed = dx * 3 *deltaTime;<\/p>\n<p>5.\u8a08\u7b97\u4f4d\u7f6e<\/p>\n<p>pos.x = (float)(pos.x &#8211; (speed * cos(radian)));<\/p>\n<p>pos.z = (float)(pos.z &#8211; (speed * sin(radian)));<\/p>\n<p>radian = 3.141592654f * rot.z \/ 180.0f; \/\/ \u5f27\u5ea6<\/p>\n<p>pos.y = (float)(pos.y &#8211; (speed * sin(radian)));<\/p>\n<p>6.UVN\u76f8\u6a5f\u6a21\u578b<\/p>\n<p><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_lookat\/\">LookAt_Camera3D();<\/a><\/p>\n<p>\u6700\u5f8c\u88fd\u4f5c\u6e96\u661f\u7d0b\u7406<\/p>\n<ol>\n<li>\u7e6a\u88fd\u767d\u8272\u6e96\u661f<\/li>\n<li>\u80cc\u666f\u8272\u586b\u5145\u70ba\u9ed1\u8272<\/li>\n<li>\u6a21\u8272\u8a2d\u70ba\u300e\u7d22\u5f15\u8272\u300f256\u8272<\/li>\n<li>\u8a2d\u5b9a\u900f\u9762\u8272\u70ba\u9ed1\u8272glAlphaFunc(GL_GREATER, 0);<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u5c04\u64ca\u904a\u6232\u5728\u5c4f\u5e55\u4e2d\u756b\u6709\u300e\u6e96\u661f\u300f\u7528\u65bc\u5c04\u64ca\u602a\u7378.\u56e0\u70ba\u300e\u6e96\u661f\u300f\u56fa\u5b9a\u5728\u5c4f\u5e55\u4e2d\u5fc3.\u7576\u4f60\u79fb\u52d5\u6ed1\u9f20\u6642.\u76f8\u6a5f\u8996\u89d2\u4e5f\u96a8\u4e4b\u6539\u8b8a.\u800c\u7576 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_sight\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">OpenGL\u4e4b\u6e96\u661f<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[50],"class_list":["post-4199","post","type-post","status-publish","format-standard","hentry","category-opengl","tag-opengl","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/comments?post=4199"}],"version-history":[{"count":1,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4199\/revisions"}],"predecessor-version":[{"id":4202,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4199\/revisions\/4202"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=4199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=4199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=4199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}