{"id":4497,"date":"2018-08-31T17:22:09","date_gmt":"2018-08-31T09:22:09","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=4497"},"modified":"2018-10-14T21:27:20","modified_gmt":"2018-10-14T13:27:20","slug":"android_game_material","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/android_game_material\/","title":{"rendered":"Android\u904a\u6232\u4e4b\u6750\u8cea"},"content":{"rendered":"<figure id=\"attachment_4498\" aria-describedby=\"caption-attachment-4498\" style=\"width: 1200px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/08\/Android_Game_Material.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4498\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/08\/Android_Game_Material.jpg\" alt=\"\" width=\"1200\" height=\"800\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/08\/Android_Game_Material.jpg 1200w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/08\/Android_Game_Material-300x200.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/08\/Android_Game_Material-768x512.jpg 768w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/08\/Android_Game_Material-1024x683.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><figcaption id=\"caption-attachment-4498\" class=\"wp-caption-text\">Android\u904a\u6232\u4e4b\u6750\u8cea<\/figcaption><\/figure>\n<p>\u7269\u9ad4\u90fd\u7531\u7279\u5b9a\u6750\u8cea\u69cb\u6210.\u6750\u8cea\u6c7a\u5b9a\u7167\u5c04\u5728\u7269\u9ad4\u4e0a\u5149\u8fd4\u5c04\u65b9\u5f0f\u4e26\u6703\u6539\u8b8a\u53cd\u5c04\u5149\u984f\u8272.\u6750\u8cea\u70ba\u591a\u908a\u5f62\u8a2d\u7f6e\u6750\u8cea\u5c6c\u6027\u7528\u65bc\u5149\u7167\u8a08\u7b97,\u5b83\u662f\u5168\u57df\u6027\u5f71\u97ff\u6240\u6709\u7e6a\u88fd\u591a\u908a\u5f62,\u76f4\u5230\u5b83\u5728\u6b21\u8abf\u7528.OpenGL ES\u4e2d\u9700\u8981\u70ba\u6bcf\u7a2e\u6750\u8cea\u6307\u5b9a\u300e\u74b0\u5883\u8272\u300f\u300e\u6f2b\u53cd\u5c04\u8272\u300f\u300e\u93e1\u9762\u53cd\u5c04\u8272\u300fRGBA\u984f\u8272\u503c.\u6b64\u6750\u8cea\u5438\u6536\u5149.\u53ea\u6709\u300e\u5149\u6e90\u984f\u8272\u300f\u8207\u300e\u6750\u8cea\u984f\u8272\u300f\u6700\u5c0f\u503c\u904b\u7b97(RGB\u503c)\u5f97\u5230\u300e\u53cd\u5c04\u5149\u984f\u8272\u300f<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"184\">\u6750\u8cea\u984f\u8272<\/td>\n<td width=\"184\">\u5149\u6e90\u984f\u8272<\/td>\n<td width=\"184\">\u53cd\u5c04\u5149\u984f\u8272\u300e\u6700\u5c0f\u503c\u904b\u7b97\u300f<\/td>\n<\/tr>\n<tr>\n<td width=\"184\">(0,1,0)<\/td>\n<td width=\"184\">(1,1,1)<\/td>\n<td width=\"184\">(0,1,0)<\/td>\n<\/tr>\n<tr>\n<td width=\"184\">(0,1,0)<\/td>\n<td width=\"184\">(1,0,0)<\/td>\n<td width=\"184\">(0,0,0)<\/td>\n<\/tr>\n<tr>\n<td width=\"184\">(0,0,1)<\/td>\n<td width=\"184\">(1,1,1)<\/td>\n<td width=\"184\">(0,0,1)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6750\u8cea\u985e\u4ee3\u78bc<\/p>\n<p>public class Material {<\/p>\n<p>private float[] ambient\u00a0 = {1.0f, 1.0f, 1.0f, 1.0f};\/\/ \u6750\u8cea-\u74b0\u5883\u8272<\/p>\n<p>private float[] diffuse\u00a0 = {1.0f, 1.0f, 1.0f,\u00a0 1.0f};\/\/ \u6750\u8cea-\u6f2b\u53cd\u5c04\u8272<\/p>\n<p>private float[] specular = {1.0f, 1.0f, 1.0f, 1.0f};\/\/ \u6750\u8cea-\u93e1\u9762\u984f\u8272<\/p>\n<p>\/\/\u8a2d\u7f6e\u6750\u8cea\u74b0\u5883\u8272<\/p>\n<p>public void setAmbient(float r,float g,float b){<\/p>\n<p>ambient[0]=r;<\/p>\n<p>ambient[1]=g;<\/p>\n<p>ambient[2]=b;<\/p>\n<p>ambient[3]=1;<\/p>\n<p>}<\/p>\n<p>\/\/ \u8a2d\u7f6e\u6750\u8cea\u6f2b\u53cd\u5c04\u8272<\/p>\n<p>public void setDiffuse(float r,float g,float b){<\/p>\n<p>diffuse[0]=r;<\/p>\n<p>diffuse[1]=g;<\/p>\n<p>diffuse[2]=b;<\/p>\n<p>diffuse[3]=1;<\/p>\n<p>}<\/p>\n<p>\/\/ \u8a2d\u7f6e\u6750\u8cea\u93e1\u9762\u53cd\u5c04\u8272<\/p>\n<p>public void setSpecular(float r,float g,float b){<\/p>\n<p>specular[0]=r;<\/p>\n<p>specular[1]=g;<\/p>\n<p>specular[2]=b;<\/p>\n<p>specular[3]=1;<\/p>\n<p>}<\/p>\n<p>\/\/\u4f7f\u80fd\u6750\u8cea<\/p>\n<p>public void enable(){<\/p>\n<p>GL10 gl = GRAPHICS.gl;<\/p>\n<p>gl.glMaterialfv(GL10.GL_FRONT_AND_BACK,GL10.GL_AMBIENT,\u00a0 ambient, 0);\/\/ \u74b0\u5883\u8272<\/p>\n<p>gl.glMaterialfv(GL10.GL_FRONT_AND_BACK,GL10.GL_DIFFUSE,\u00a0 diffuse, 0);\/\/\u00a0 \u6f2b\u53cd\u5c04\u8272<\/p>\n<p>gl.glMaterialfv(GL10.GL_FRONT_AND_BACK,GL10.GL_SPECULAR, specular,0);\/\/\u00a0 \u93e1\u9762\u53cd\u5c04\u8272<\/p>\n<p>}<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7269\u9ad4\u90fd\u7531\u7279\u5b9a\u6750\u8cea\u69cb\u6210.\u6750\u8cea\u6c7a\u5b9a\u7167\u5c04\u5728\u7269\u9ad4\u4e0a\u5149\u8fd4\u5c04\u65b9\u5f0f\u4e26\u6703\u6539\u8b8a\u53cd\u5c04\u5149\u984f\u8272.\u6750\u8cea\u70ba\u591a\u908a\u5f62\u8a2d\u7f6e\u6750\u8cea\u5c6c\u6027\u7528\u65bc\u5149\u7167\u8a08\u7b97, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/android_game_material\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">Android\u904a\u6232\u4e4b\u6750\u8cea<\/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-4497","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\/4497","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=4497"}],"version-history":[{"count":1,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4497\/revisions"}],"predecessor-version":[{"id":4499,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4497\/revisions\/4499"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=4497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=4497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=4497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}