{"id":4188,"date":"2018-06-28T10:33:47","date_gmt":"2018-06-28T02:33:47","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=4188"},"modified":"2018-10-14T21:35:23","modified_gmt":"2018-10-14T13:35:23","slug":"opengl_hockey","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/opengl_hockey\/","title":{"rendered":"OpenGL\u4e4b\u66f2\u68cd\u7403"},"content":{"rendered":"<figure id=\"attachment_4189\" aria-describedby=\"caption-attachment-4189\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/OpenGL_Hockey.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4189\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/OpenGL_Hockey.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/OpenGL_Hockey.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/OpenGL_Hockey-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/OpenGL_Hockey-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-4189\" class=\"wp-caption-text\">OpenGL\u4e4b\u66f2\u68cd\u7403<\/figcaption><\/figure>\n<p>\u300e\u66f2\u68cd\u7403\u300f\u662f\u78b0\u649e\u7b97\u6cd5\u6700\u597d\u6f14\u793a,\u5728\u904a\u6232\u4e2d\u300e\u7403\u81fa\u300f\u5bec300\u9577500,\u4e26\u4e14\u6709\u56db\u689d\u570d\u908a,\u78ba\u4fdd\u300e\u66f2\u68cd\u7403\u300f\u5728\u300e\u7403\u81fa\u300f\u570d\u908a\u7bc4\u570d\u5167\u79fb\u52d5. \u300e\u7403\u81fa\u300f\u6703\u7d66\u300e\u66f2\u68cd\u7403\u300f\u5e36\u4f86\u300e\u78e8\u64e6\u300f\u5f8c\u6162\u6162\u6162\u843d\u4f86\u4e26\u6700\u5f8c\u505c\u4f4e.\u800c\u300e\u73a9\u5bb6\u7403\u300f\u5247\u901a\u904e\u9f20\u6a19\u79fb\u52d5\u63a7\u5236.\u901a\u904e\u8207\u300e\u66f2\u68cd\u7403\u300f\u76f8\u78b0\u7d66\u300e\u66f2\u68cd\u7403\u300f\u5e36\u4f86\u52d5\u529b.\u6f14\u793a\u7a0b\u5f0f:<a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/Hockey.zip\">\u4e0b\u8f09<\/a>.\u6211\u6703\u7d66\u51fa\u904a\u6232\u8a2d\u8a08\u91cd\u9ede,\u4e26\u7d66\u51fa\u95dc\u9375\u4ee3\u78bc<\/p>\n<p>1.\u300e\u51b0\u7403\u300f\u904b\u52d5\u6838\u5fc3\u662f\u78b0\u649e\u7b97\u6cd5.\u4f60\u8a66\u60f3\u4e0b\u7576\u300e\u51b0\u7403\u300f\u9ad8\u901f\u904b\u52d5\u6642\u6709\u53ef\u80fd\u6703\u7a7f\u8d8a\u570d\u908a(<a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_plane\/\">\u570d\u908a\u4f7f\u7528\u5e73\u9762\u5b9a\u7fa9<\/a>).\u6240\u4ee5\u4f60\u9700\u8981\u6e96\u78ba\u8a08\u7b97\u78b0\u649e\u6642\u9593.\u78b0\u649e\u4ee3\u78bc\u7747\u300e<a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_collision_time\/\">\u78b0\u649e\u6642\u9593<\/a>\u300f<\/p>\n<p>2.\u63a7\u5236\u300e\u73a9\u5bb6\u89d2\u8272\u300f\u901a\u904e\u7372\u53d6\u6ed1\u9f20\u6a19\u504f\u79fb\u91cf\u8207\u4f4d\u7f6e\u76f8\u52a0\u79fb\u52d5\u300e\u73a9\u5bb6\u89d2\u8272\u300f.\u4f60\u9700\u8981\u901a\u904e<a href=\"https:\/\/www.bookcard.net\/wordpress\/directinput_mouse\/\">DirectInput\u7372\u5f97\u6ed1\u9f20\u504f\u79fb\u91cf<\/a>. \u4e26\u4e14\u78ba\u4fdd\u4e0d\u8981\u79fb\u51fa\u7403\u81fa\u570d\u908a.\u82e5\u8207\u300e\u51b0\u7403\u300f\u5247\u91cd\u65b0\u8a08\u7b97\u8fd4\u5c04\u65b9\u5411\u8207\u901f\u5ea6<\/p>\n<p>\u6839\u64da\u9f20\u6a19\u904b\u52d5\u8a08\u7b97\u901f\u5ea6::<a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_vector3d\/\">Init_VECTOR3D<\/a>(&amp;player-&gt;velocity, diffX, 0, diffY);<\/p>\n<p>\u8a08\u7b97\u4f4d\u7f6eplayer-&gt;position = player-&gt;position + player-&gt;velocity;<\/p>\n<p>\u300e\u73a9\u5bb6\u89d2\u8272\u300f\u8207\u300e\u51b0\u7403\u300f\u78b0\u649e\u4f7f\u7528\u300e<a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_sphere\/\">\u908a\u754c\u7403<\/a>\u300f\u9032\u884c\u6aa2\u6e2c\u4e26\u91cd\u65b0\u8a08\u7b97\u8fd4\u5c04\u65b9\u5411\u8207\u901f\u5ea6<\/p>\n<p>puck-&gt;velocity = <a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_reflection\/\">Reflection_VECTOR3D<\/a>(&amp;puck-&gt;velocity,&amp;(puck-&gt;velocity ^ player-&gt;velocity)) + player-&gt;velocity*500;<\/p>\n<p>3.\u8a2d\u5b9a\u300e\u7403\u81fa\u300f\u7d50\u69cb\u8207\u300e<a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_plane\/\">\u570d\u908a\u5e73\u9762<\/a>\u300f<\/p>\n<p>typedef struct TABLE_TPY {<\/p>\n<p><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_texture\/\">TEXTURE<\/a>\u00a0\u00a0 texture;\/\/ \u7403\u81fa\u7d0b\u7406<\/p>\n<p>VECTOR3D\u00a0 position;\/\/ \u7403\u81fa\u4f4d\u7f6e<\/p>\n<p>VECTOR3D\u00a0 corner[4];\/\/\u7403\u81fa\u89d2\u843d<\/p>\n<p>PLANE3D\u00a0\u00a0\u00a0 wall[4];\/\/ \u7403\u81fa\u570d\u908a\u5e73\u9762<\/p>\n<p>float width;\/\/ \u5bec\u5ea6<\/p>\n<p>float depth;\/\/ \u6df1\u5ea6<\/p>\n<p>float height;\/\/ \u9ad8\u5ea6<\/p>\n<p>}TABLE,*TABLE_PTR;<\/p>\n<p>\u7403\u81fa\u5bec300*\u9577500<a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_texture\/\">\u8f09\u5165\u7d0b\u7406Load_File_Texture()<\/a>\u548c<a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_texture\/\">\u7d81\u5b9a\u7d0b\u7406Bind_Image_Texture()<\/a>.\u570d\u908a\u4f7f\u7528<a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_plane\/\">Init_PLANE3D()<\/a>\u5b9a\u7fa9\u70ba\u5e73\u9762<\/p>\n<p>4.\u5b9a\u7fa9\u300e\u51b0\u7403\u300f\u7d50\u69cb<\/p>\n<p>typedef struct PUCK_TPY {<\/p>\n<p>VECTOR3D\u00a0\u00a0\u00a0\u00a0 position;\/\/ \u4f4d\u7f6e<\/p>\n<p>VECTOR3D\u00a0 acceleration;\/\/ \u52a0\u901f\u5ea6<\/p>\n<p>VECTOR3D\u00a0 velocity;\/\/ \u901f\u5ea6<\/p>\n<p>float\u00a0\u00a0\u00a0\u00a0 radius;\/\/ \u534a\u5f91<\/p>\n<p>}PUCK,*PUCK_PTR;<\/p>\n<p>5.\u5b9a\u7fa9\u300e\u73a9\u5bb6\u89d2\u8272\u300f\u7d50\u69cb<\/p>\n<p>typedef struct PLAYER_TPY {<\/p>\n<p>VECTOR3D\u00a0 position;\/\/ \u4f4d\u7f6e<\/p>\n<p>VECTOR3D\u00a0 velocity;\/\/ \u901f\u5ea6<\/p>\n<p>float\u00a0\u00a0\u00a0\u00a0 radius;\/\/ \u534a\u5f91<\/p>\n<p>float\u00a0\u00a0\u00a0\u00a0 mouseX, mouseY;<\/p>\n<p>}PLAYER,*PLAYER_PTR;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300e\u66f2\u68cd\u7403\u300f\u662f\u78b0\u649e\u7b97\u6cd5\u6700\u597d\u6f14\u793a,\u5728\u904a\u6232\u4e2d\u300e\u7403\u81fa\u300f\u5bec300\u9577500,\u4e26\u4e14\u6709\u56db\u689d\u570d\u908a,\u78ba\u4fdd\u300e\u66f2\u68cd\u7403\u300f\u5728\u300e\u7403\u81fa\u300f\u570d\u908a\u7bc4 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_hockey\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">OpenGL\u4e4b\u66f2\u68cd\u7403<\/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-4188","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\/4188","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=4188"}],"version-history":[{"count":1,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4188\/revisions"}],"predecessor-version":[{"id":4191,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4188\/revisions\/4191"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=4188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=4188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=4188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}