{"id":4064,"date":"2018-05-08T18:51:32","date_gmt":"2018-05-08T10:51:32","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=4064"},"modified":"2018-10-14T21:13:04","modified_gmt":"2018-10-14T13:13:04","slug":"opengl_nurbs","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/opengl_nurbs\/","title":{"rendered":"OpenGL\u4e4bNURBS(\u975e\u5747\u52fb\u6709\u7406B\u6a23\u689d)"},"content":{"rendered":"<figure id=\"attachment_4065\" aria-describedby=\"caption-attachment-4065\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGL_NURBS.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4065\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGL_NURBS.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGL_NURBS.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGL_NURBS-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGL_NURBS-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-4065\" class=\"wp-caption-text\">OpenGL\u4e4bNURBS(\u975e\u5747\u52fb\u6709\u7406B\u6a23\u689d)<\/figcaption><\/figure>\n<p>\u300e<a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_bezier_curve\/\">\u8c9d\u8cfd\u723e(Bezier)\u66f2\u7dda<\/a>\u300f(\u4e0b\u9762\u7c21\u7a31\u70ba\u300e\u66f2\u7dda\u300f)\u8ddf\u64da\u5176\u300e\u63a7\u5236\u9ede\u300f\u6578\u76ee\u5206\u985e.\u64c1\u6709\u4e09\u500b\u63a7\u5236\u9ede\u300e\u66f2\u7dda\u300f\u7a31\u70ba\u300e\u4e8c\u6b21\u66f2\u7dda\u300f. \u64c1\u6709\u56db\u500b\u63a7\u5236\u9ede\u300e\u66f2\u7dda\u300f\u7a31\u70ba\u300e\u4e09\u6b21\u66f2\u7dda\u300f.<\/p>\n<p>\u96a8\u8457\u300e\u66f2\u7dda\u300f\u63a7\u5236\u9ede\u6578\u76ee\u589e\u52a0.\u66f2\u7dda\u7684\u5e73\u6ed1\u5ea6\u53ef\u80fd\u6703\u88ab\u5927\u91cf\u63a7\u5236\u9ede\u62c9\u626f\u800c\u88ab\u7834\u58de.<\/p>\n<p>\u6240\u4ee5\u5f15\u5165NURBS(\u975e\u5747\u52fb\u6709\u7406B\u6a23\u689d).\u300eB\u6a23\u689d\u300f\u5176\u5be6\u5c31\u662f\u300e\u66f2\u7dda\u300f,\u53ea\u4e0d\u904e\u300eB\u6a23\u689d\u300f\u5206\u70ba\u591a\u500b\u300e\u66f2\u7dda\u6bb5\u300f. \u6bcf\u500b\u300e\u66f2\u7dda\u6bb5\u300f\u64c1\u6709\u56db\u500b\u63a7\u5236\u9ede.\u5c07\u6574\u689d\u300e\u66f2\u7dda\u300f\u5206\u70ba\u82e5\u5e72\u300e\u66f2\u7dda\u6bb5\u300f,\u7b49\u65bc\u5c07\u591a\u500b\u300e\u4e09\u6b21\u66f2\u7dda\u300f\u5408\u4f75\u70ba\u300eB\u6a23\u689d\u300f.<\/p>\n<p>\u300eB\u6a23\u689d\u300f\u6709\u56db\u500b\u300e\u63a7\u5236\u9ede\u300f,\u800c\u6bcf\u500b\u300e\u63a7\u5236\u9ede\u300f\u64c1\u6709\u5169\u500b\u300e\u7bc0\u9ede\u300f.\u5176\u503c\u53ef\u4ee5\u53d6u\u548cv\u57df\u7bc4\u570d\u4efb\u610f\u503c.\u300e\u7bc0\u9ede\u300f\u5f71\u97ff\u300e\u63a7\u5236\u9ede\u300f\u5c0d\u300e\u66f2\u7dda\u300f\u5f71\u97ff\u7a0b\u5ea6.\u9019\u4e5f\u662fBezier\u8207NURBS\u5340\u5225\u4e4b\u8655.<a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/05\/OpenGL\u4e4bNURBS.zip\">NURBS\u6f14\u793a\u7a0b\u5f0f\u4e0b\u8f09<\/a>:<\/p>\n<p>1.\u751f\u6210NURBS\u5c0d\u8c61<\/p>\n<p>GLUnurbsObj * object = gluNewNurbsRenderer();<\/p>\n<p>2.\u5b9a\u7fa9\u516b\u500b\u300e\u7bc0\u9ede\u300f<\/p>\n<p>float knots[8] = { 0,0, 0,0, 1,1, 1,1 };<\/p>\n<p>3.\u751f\u6210NURBS\u56db\u500b\u300e\u63a7\u5236\u9ede\u300f<\/p>\n<p>float nurbs[4][4][3] ;<\/p>\n<p>4.\u8a2d\u7f6eNURBS\u66f2\u9762\u63a7\u5236\u9ede,\u5f62\u6210\u5768\u5cf0\u5f62<\/p>\n<p>for (int u = 0; u &lt; 4; ++u){<\/p>\n<p>for (int v = 0; v &lt; 4; ++v){<\/p>\n<p>nurbs[u][v][0] = 3.0f*((float)u &#8211; 1.5f);<\/p>\n<p>nurbs[u][v][1] = 2.0f*((float)v &#8211; 1.5f);<\/p>\n<p>if ((u == 1 || u == 2) &amp;&amp; (v == 1 || v == 2))<\/p>\n<p>nurbs[u][v][2] = 3.0f;<\/p>\n<p>else<\/p>\n<p>nurbs[u][v][2] = -1.0f;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>5.\u8a2d\u7f6e\u591a\u908a\u5f62\u6700\u5927\u9577\u5ea6<\/p>\n<p>gluNurbsProperty(object,GLU_SAMPLING_TOLERANCE,30.0f);<\/p>\n<p>6.\u4ee5\u591a\u908a\u5f62\u7e6a\u88fd\u66f2\u9762<\/p>\n<p>gluNurbsProperty(object,GLU_DISPLAY_MODE,GLU_FILL);<\/p>\n<p>gluNurbsProperty()\u7528\u65bc\u8a2d\u7f6e\u63a1\u6a23\u4ee5\u53ca\u5982\u4f55\u7e6a\u756bNURBS<\/p>\n<p>void gluNurbsProperty(GLUnurbs *nobj,GLenum property,GLfloat value);<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"75\">\u53c3\u6578<\/td>\n<td width=\"198\">\u6578\u503c<\/td>\n<td width=\"279\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"75\"><strong>nobj<\/strong><\/td>\n<td width=\"198\">GLUnurbsObj * object;<\/td>\n<td width=\"279\">NURBS\u5c0d\u8c61<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" width=\"75\"><strong>property<\/strong><\/td>\n<td width=\"198\"><strong>GLU_SAMPLING_TOLERANCE:<\/strong><\/td>\n<td width=\"279\">\u8a2d\u7f6e\u591a\u908a\u5f62\u6700\u5927\u9577\u5ea6<\/td>\n<\/tr>\n<tr>\n<td width=\"198\"><strong>GLU_DISPLAY_MODE: <\/strong><\/td>\n<td width=\"279\"><strong>\u591a\u908a\u5f62\u6e32\u67d3\u6a21\u5f0f<\/strong>GLU_FILL:\u591a\u8b8a\u5f62\u5be6\u9ad4\u586b\u5145<\/td>\n<\/tr>\n<tr>\n<td width=\"75\"><strong>value<\/strong><\/td>\n<td width=\"198\">&nbsp;<\/td>\n<td width=\"279\"><strong>\u4f9dproperty\u800c\u5b9a<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>7.\u8a2d\u7f6eNURBS\u66f2\u9762<\/p>\n<p>gluBeginSurface(object);<\/p>\n<p>8.\u6e96\u5099\u7e6a\u88fdNURBS\u66f2\u9762<\/p>\n<p>gluNurbsSurface(object,8,knots,8, knots,4<em>3,3,(GLfloat<\/em>)&amp;nurbs[0][0][0],4,4, GL_MAP2_VERTEX_3);<\/p>\n<p>\u51fd\u5f0f\u5b9a\u7fa9<\/p>\n<p>void gluNurbsSurface(GLUnurbs<em>nobj,GLint sknot_count,float<\/em>sknot,GLint\u00a0 tknot_count,GLfloat<em>tknot,GLint s_stride,GLint t_stride,GLfloat<\/em>ctlarray,GLint sorder,GLint torder,GLenum type);<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"277\">\u53c3\u6578<\/td>\n<td width=\"277\">\u7c21\u4ecb<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">nobj<\/td>\n<td width=\"277\">NURBS\u5c0d\u8c61<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">sknot_count<\/td>\n<td width=\"277\">u\u7bc0\u9ede\u500b\u6578<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">sknot<\/td>\n<td width=\"277\">u\u7bc0\u9ede<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">tknot_count<\/td>\n<td width=\"277\">v\u7bc0\u9ede\u500b\u6578<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">tknot<\/td>\n<td width=\"277\">v\u7bc0\u9ede<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">s_stride<\/td>\n<td width=\"277\">u\u63a7\u5236\u9ede\u8ddd\u96e2<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">t_stride<\/td>\n<td width=\"277\">v\u63a7\u5236\u9ede\u8ddd\u96e2<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">ctlarray<\/td>\n<td width=\"277\">\u6307\u5411\u63a7\u5236\u9ede<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">sorder<\/td>\n<td width=\"277\">u\u65b9\u5411\u63a7\u5236\u9ede\u500b\u6578<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">torder<\/td>\n<td width=\"277\">v\u65b9\u5411\u63a7\u5236\u9ede\u500b\u6578<\/td>\n<\/tr>\n<tr>\n<td width=\"277\">type<\/td>\n<td width=\"277\">\u66f2\u9762\u985e\u578b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>9.\u5b8c\u6210\u6e32\u67d3<\/p>\n<p>gluEndSurface(object);<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300e\u8c9d\u8cfd\u723e(Bezier)\u66f2\u7dda\u300f(\u4e0b\u9762\u7c21\u7a31\u70ba\u300e\u66f2\u7dda\u300f)\u8ddf\u64da\u5176\u300e\u63a7\u5236\u9ede\u300f\u6578\u76ee\u5206\u985e.\u64c1\u6709\u4e09\u500b\u63a7\u5236\u9ede\u300e\u66f2\u7dda\u300f\u7a31\u70ba\u300e\u4e8c\u6b21 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/opengl_nurbs\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">OpenGL\u4e4bNURBS(\u975e\u5747\u52fb\u6709\u7406B\u6a23\u689d)<\/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-4064","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\/4064","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=4064"}],"version-history":[{"count":1,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4064\/revisions"}],"predecessor-version":[{"id":4067,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4064\/revisions\/4067"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=4064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=4064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=4064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}