{"id":1857,"date":"2008-06-17T19:42:29","date_gmt":"2008-06-17T10:42:29","guid":{"rendered":"http:\/\/r-dimension.xsrv.jp\/classes_j\/?p=1857"},"modified":"2011-05-03T02:10:25","modified_gmt":"2011-05-02T17:10:25","slug":"three_d","status":"publish","type":"post","link":"https:\/\/r-dimension.xsrv.jp\/classes_j\/three_d\/","title":{"rendered":"\u753b\u50cf\u51e6\u7406\u30b5\u30f3\u30d7\u30eb\uff083d\uff09"},"content":{"rendered":"<p>\u30d4\u30af\u30bb\u30eb\u306e\u8272\u306e\u660e\u308b\u3055\u3092\u3001\u5965\u884c\u304d\u306b\u5909\u63db\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<pre lang=\"java\" line=\"1\">\r\nimport processing.opengl.*;    \/\/openGL\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\r\nimport processing.video.*;    \/\/\u30d3\u30c7\u30aa\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\r\n\r\nCapture video;\r\nfloat angleY = 30.0, angleX = -20.0;\r\n\r\nvoid setup() {\r\n  size(640, 480, OPENGL);\r\n  video = new Capture(this, 80, 60, 60);\r\n  noStroke();\r\n}\r\n\r\nvoid draw() {\r\n  lights();\r\n  background(0);\r\n  \/\/\u753b\u9762\u4e2d\u592e\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u304f\u308b\u3088\u3046\u306b\u79fb\u52d5\u3059\u308b\r\n  translate(width\/2, height\/2, -200.0);\r\n  \/\/\u30de\u30a6\u30b9\u306e\u52d5\u304d\u306b\u3088\u3063\u3066\u89d2\u5ea6\u304c\u5909\u308f\u308b\u3002\r\n  angleX = 360.0*((float)mouseY\/(float)height)+180.0;\r\n  angleY = 360.0*((float)mouseX\/(float)width)+180.0;\r\n  rotateX(radians(angleX));\r\n  rotateY(radians(angleY));\r\n\r\n  if (video.available()) {  \/\/\u3082\u3057\u30ad\u30e3\u30d7\u30c1\u30e3\u304c\u3067\u304d\u305f\u3089\u3001\r\n    video.read(); \/\/\u30d3\u30c7\u30aa\u30d5\u30ec\u30fc\u30e0\u306e\u8aad\u307f\u8fbc\u307f\r\n    video.loadPixels(); \/\/\u30d3\u30c7\u30aa\u306e\u30d4\u30af\u30bb\u30eb\u3092\u64cd\u4f5c\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\r\n\r\n    \/\/1\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u8272\u3092\u8abf\u3079\u308b\u3002\r\n    for (int y = 0; y < video.height; y ++) {\r\n      for (int x = 0; x < video.width; x ++) {\r\n        \/\/\u30d3\u30c7\u30aa\u306e\u30d4\u30af\u30bb\u30eb\u3092\u629c\u304d\u51fa\u3059\r\n        int pixelColor = video.pixels[y*video.width + x];\r\n\r\n        \/\/\u8d64\u3001\u7dd1\u3001\u9752\u3092\u305d\u308c\u305e\u308c\u62bd\u51fa\u3059\u308b\u3002\u4ee5\u4e0b\u306e3\u884c\u306f\u30d3\u30c3\u30c8\u30b7\u30d5\u30c8\u3068\u3044\u3063\u3066\u3001\r\n        \/\/\u7406\u89e3\u3059\u308b\u306e\u304c\u7d50\u69cb\u5927\u5909\u306a\u306e\u3067\u3001\u3053\u3053\u3067\u306f\u8a73\u7d30\u306f\u8aac\u660e\u3057\u306a\u3044\u3002\r\n        int r = (pixelColor >> 16) & 0xff;\r\n        int g = (pixelColor >> 8) & 0xff;\r\n        int b = pixelColor & 0xff;\r\n\r\n        pushMatrix();    \/\/\u5ea7\u6a19\u3092\u4fdd\u5b58\r\n        translate(x*8-width\/2, y*8-height\/2, 0.0);        \r\n        fill(r, g, b);    \/\/\u8272\u3092\u9069\u5fdc\u3055\u305b\u308b\r\n        \/\/\u76f4\u65b9\u4f53\u3092\u4f5c\u6210\u3002\u624b\u524d\u304b\u3089\u5965\u306e\u9577\u3055\u306f\u3001\u8272\u306b\u3088\u3063\u3066\u5909\u5316\u3059\u308b\u3002\u6700\u5927\u5024\u306f300\u3002\r\n        \/\/\u9ed2\u306e\u3068\u304d\u306b300\u3001\u767d\u306e\u3068\u304d\u306b0\u306b\u306a\u308b\u3002\r\n        box(7, 7, (float)((255-r)*(255-g)*(255-b))\/pow(255.0, 3)*300.0);\r\n        popMatrix();    \/\/\u5ea7\u6a19\u3092\u5fa9\u5e30\r\n      }\r\n    }\r\n  }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30d4\u30af\u30bb\u30eb\u306e\u8272\u306e\u660e\u308b\u3055\u3092\u3001\u5965\u884c\u304d\u306b\u5909\u63db\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10,11],"tags":[],"class_list":["post-1857","post","type-post","status-publish","format-standard","hentry","category-media_third","category-processing","category-11"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/comments?post=1857"}],"version-history":[{"count":4,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1857\/revisions"}],"predecessor-version":[{"id":2476,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1857\/revisions\/2476"}],"wp:attachment":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/media?parent=1857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/categories?post=1857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/tags?post=1857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}