{"id":10914,"date":"2021-09-16T20:09:40","date_gmt":"2021-09-16T12:09:40","guid":{"rendered":"https:\/\/www.bookcard.net\/wordpress\/?p=10914"},"modified":"2021-10-07T21:59:26","modified_gmt":"2021-10-07T13:59:26","slug":"android_studio_ndk_opengl_es_glulookat","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/android_studio_ndk_opengl_es_glulookat\/","title":{"rendered":"Android Studio NDK-OpenGL ES\u66ff\u63dbgluLookAt()"},"content":{"rendered":"<figure id=\"attachment_10915\" aria-describedby=\"caption-attachment-10915\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/09\/OpenGL_ES_gluLookAt.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10915\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/09\/OpenGL_ES_gluLookAt.jpg\" alt=\"OpenGL ES\u66ff\u63dbgluLookAt()\" width=\"1280\" height=\"800\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/09\/OpenGL_ES_gluLookAt.jpg 1280w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/09\/OpenGL_ES_gluLookAt-300x188.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2021\/09\/OpenGL_ES_gluLookAt-768x480.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><figcaption id=\"caption-attachment-10915\" class=\"wp-caption-text\">OpenGL ES\u66ff\u63dbgluLookAt()<\/figcaption><\/figure>\n<p>gluLookAt() \u00a0UVN\u76f8\u6a5f\u6a21\u578b,\u8a2d\u5b9a\u8996\u9ede(\u76f8\u6a5f)\u4f4d\u7f6e\u548c\u8996\u7dab\u65b9\u5411(\u77e9\u9663\u904b\u7b97).<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">void gluLookAt( GLdouble eyeX,<\/p>\n<p>GLdouble eyeY,<\/p>\n<p>GLdouble eyeZ,<\/p>\n<p>GLdouble centerX,<\/p>\n<p>GLdouble centerY,<\/p>\n<p>GLdouble centerZ,<\/p>\n<p>GLdouble upX,<\/p>\n<p>GLdouble upY,<\/p>\n<p>GLdouble upZ);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>OpenGL ES\u5187gluLookAt() , \u624b\u5de5\u751f\u6210\u300e\u65cb\u8f49\u77e9\u9663\u300f\u300e\u76f8\u6a5f\u4f4d\u7f6e\u300f\u51fd\u5f0f<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,<\/p>\n<p>GLfloat centerx, GLfloat centery, GLfloat centerz,<\/p>\n<p>GLfloat upx, GLfloat upy, GLfloat upz)<\/p>\n<p>{<\/p>\n<p>GLfloat m[16];\/\/ \u65cb\u8f49\u77e9\u9663<\/p>\n<p>GLfloat x[3], y[3], z[3];<\/p>\n<p>GLfloat mag;<\/p>\n<p>\/\/\u751f\u6210\u65cb\u8f49\u77e9\u9663<\/p>\n<p>\/\/ Z\u77e2\u91cf<\/p>\n<p>z[0] = eyex &#8211; centerx;<\/p>\n<p>z[1] = eyey &#8211; centery;<\/p>\n<p>z[2] = eyez &#8211; centerz;<\/p>\n<p>mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);<\/p>\n<p>if (mag) {<\/p>\n<p>z[0]\/= mag;<\/p>\n<p>z[1]\/= mag;<\/p>\n<p>z[2]\/= mag;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ Y\u77e2\u91cf<\/p>\n<p>y[0] = upx;<\/p>\n<p>y[1] = upy;<\/p>\n<p>y[2] = upz;<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ X \u77e2\u91cf = Y \u53c9\u7a4d Z<\/p>\n<p>x[0] = y[1] * z[2] &#8211; y[2] * z[1];<\/p>\n<p>x[1] = -y[0] * z[2] + y[2] * z[0];<\/p>\n<p>x[2] = y[0] * z[1] &#8211; y[1] * z[0];<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ \u91cd\u65b0\u8a08\u7b97 Y = Z \u53c9\u7a4d X<\/p>\n<p>y[0] = z[1] * x[2] &#8211; z[2] * x[1];<\/p>\n<p>y[1] = -z[0] * x[2] + z[2] * x[0];<\/p>\n<p>y[2] = z[0] * x[1] &#8211; z[1] * x[0];<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ \u53c9\u7a4d\u7d66\u51fa\u4e86\u5e73\u884c\u56db\u908a\u5f62\u7684\u9762\u7a4d\uff0c\u5c0d\u4e8e\u975e\u5782\u76f4\u55ae\u4f4d\u9577\u5ea6\u5411\u91cf\uff1b\u6240\u4ee5\u5728\u9019\u88cf\u6a19\u6e96\u5316x\uff0cy<\/p>\n<p>mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);<\/p>\n<p>if (mag) {<\/p>\n<p>x[0]\/= mag;<\/p>\n<p>x[1]\/= mag;<\/p>\n<p>x[2]\/= mag;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);<\/p>\n<p>if (mag) {<\/p>\n<p>y[0]\/= mag;<\/p>\n<p>y[1]\/= mag;<\/p>\n<p>y[2]\/= mag;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>#define M(row,col)\u00a0 m[col*4+row]<\/p>\n<p>M(0, 0) = x[0];<\/p>\n<p>M(0, 1) = x[1];<\/p>\n<p>M(0, 2) = x[2];<\/p>\n<p>M(0, 3) = 0.0;<\/p>\n<p>M(1, 0) = y[0];<\/p>\n<p>M(1, 1) = y[1];<\/p>\n<p>M(1, 2) = y[2];<\/p>\n<p>M(1, 3) = 0.0;<\/p>\n<p>M(2, 0) = z[0];<\/p>\n<p>M(2, 1) = z[1];<\/p>\n<p>M(2, 2) = z[2];<\/p>\n<p>M(2, 3) = 0.0;<\/p>\n<p>M(3, 0) = 0.0;<\/p>\n<p>M(3, 1) = 0.0;<\/p>\n<p>M(3, 2) = 0.0;<\/p>\n<p>M(3, 3) = 1.0;<\/p>\n<p>#undef M<\/p>\n<p>glMultMatrixf(m);<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ \u8996\u9ede(\u76f8\u6a5f)\u4f4d\u7f6e<\/p>\n<p>glTranslatef(-eyex, -eyey, -eyez);<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>gluLookAt() \u00a0UVN\u76f8\u6a5f\u6a21\u578b,\u8a2d\u5b9a\u8996\u9ede(\u76f8\u6a5f)\u4f4d\u7f6e\u548c\u8996\u7dab\u65b9\u5411(\u77e9\u9663\u904b\u7b97). void gluLoo &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/android_studio_ndk_opengl_es_glulookat\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">Android Studio NDK-OpenGL ES\u66ff\u63dbgluLookAt()<\/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":[4,62],"tags":[2,50],"class_list":["post-10914","post","type-post","status-publish","format-standard","hentry","category-android","category-opengl","tag-android","tag-opengl","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/10914","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=10914"}],"version-history":[{"count":2,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/10914\/revisions"}],"predecessor-version":[{"id":10940,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/10914\/revisions\/10940"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=10914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=10914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=10914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}