{"id":1531,"date":"2009-06-02T17:38:16","date_gmt":"2009-06-02T08:38:16","guid":{"rendered":"http:\/\/r-dimension.xsrv.jp\/classes_j\/?p=1531"},"modified":"2011-05-03T01:26:48","modified_gmt":"2011-05-02T16:26:48","slug":"3_interactive3d","status":"publish","type":"post","link":"https:\/\/r-dimension.xsrv.jp\/classes_j\/3_interactive3d\/","title":{"rendered":"3. \u5ea7\u6a19\u306e\u4fdd\u5b58 \u2013 pushMatrix, popMatrix\uff08processing 3D\u5165\u9580\uff09"},"content":{"rendered":"<h2>\u5ea7\u6a19\u4fdd\u5b58\u306e\u57fa\u790e<\/h2>\n<p>\u3053\u306e\u9805\u3067\u306f\u30013D\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u30b9\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u6982\u5ff5\u3067\u3042\u308b\u3001\u5ea7\u6a19\u306e\u4fdd\u5b58\uff08pushMatrix, popMatrix\uff09\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001\u4ee5\u4e0b\u306e\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u3092\u66f8\u3044\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/r-dimension.xsrv.jp\/classes_j\/wp-content\/uploads\/2009\/06\/sample3_1.jpg\" alt=\"sample3_1\" title=\"sample3_1\" width=\"214\" height=\"223\" class=\"alignnone size-full wp-image-702\" \/><\/p>\n<p><!--more--><\/p>\n<pre lang=\"java\" line=\"1\">\r\nsize(400, 400, P3D);\r\nbackground(0);\r\n\r\n\/\/\u8d64\u3044\u76f4\u65b9\u4f53\r\nfill(255, 0, 0);    \r\ntranslate(100, 100, 0);\r\nbox(50, 50, 1);    \/\/\u76f4\u65b9\u4f53\u3092\u63cf\u304f\r\n\r\n\/\/\u7dd1\u306e\u76f4\u65b9\u4f53\r\nfill(0, 255, 0);    \r\ntranslate(200, 200, 0);\r\nbox(100, 100, 1);    \/\/\u76f4\u65b9\u4f53\u3092\u63cf\u304f<\/pre>\n<p>\u3053\u3053\u3067\u3001translate\u304c2\u56de\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u7d50\u679c\u3092\u898b\u3066\u307f\u308b\u3068\u5206\u304b\u308a\u307e\u3059\u304c\u3001\u5ea7\u6a19\u304c\u8db3\u3055\u308c\u3066\u3044\u3066\u30012\u3064\u76ee\u306ebox\u306e\u4e2d\u5fc3\u70b9\u306f\u3001x = 300, y = 300\u3067\u3059\u3002<br \/>\n\u3053\u308c\u306f\u3001\u3064\u307e\u308a\u76f8\u5bfe\u5ea7\u6a19\u306b\u306a\u308b\u306e\u3067\u3001\u7d76\u5bfe\u5ea7\u6a19\u3067\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408\u3082\u3042\u308b\u3067\u3057\u3087\u3046\u3002\u3068\u3044\u3046\u304b\u3080\u3057\u308d\u305d\u306e\u65b9\u304c\u591a\u3044\u3068\u3044\u3048\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u3001pushMatrix\u3068popMatrix\u3068\u3044\u3046\u6982\u5ff5\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>pushMatrix \u2192 \u73fe\u5728\u306e\u5ea7\u6a19\u3092\u4fdd\u5b58\u3059\u308b\u3002<br \/>\npopMatrix \u2192 \u4fdd\u5b58\u3057\u305f\u5ea7\u6a19\u3092\u518d\u5c55\u958b\u3059\u308b\u3002<\/p>\n<p>\u4f7f\u3044\u65b9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<br \/>\n\u524d\u306e\u30b3\u30fc\u30c9\u306b\u66f8\u304d\u8db3\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/r-dimension.xsrv.jp\/classes_j\/wp-content\/uploads\/2009\/06\/sample3_2.jpg\" alt=\"sample3_2\" title=\"sample3_2\" width=\"214\" height=\"223\" class=\"alignnone size-full wp-image-705\" \/><\/p>\n<pre lang=\"java\" line=\"1\">\r\nsize(400, 400, P3D);\r\nbackground(0);\r\n\r\n\/\/\u8d64\u3044\u76f4\u65b9\u4f53\r\nfill(255, 0, 0);    \r\npushMatrix();    \/\/\u73fe\u5728\u306e\u5ea7\u6a19\u3092\u4fdd\u5b58\r\ntranslate(100, 100, 0);\r\nbox(50, 50, 1);    \/\/\u76f4\u65b9\u4f53\u3092\u63cf\u304f\r\npopMatrix();    \/\/\u5143\u306e\u5ea7\u6a19\u306b\u623b\u3059\r\n\r\n\/\/\u7dd1\u306e\u76f4\u65b9\u4f53\r\nfill(0, 255, 0);    \r\npushMatrix();    \/\/\u73fe\u5728\u306e\u5ea7\u6a19\u3092\u4fdd\u5b58\r\ntranslate(200, 200, 0);\r\nbox(100, 100, 1);    \/\/\u76f4\u65b9\u4f53\u3092\u63cf\u304f\r\npopMatrix();    \/\/\u5143\u306e\u5ea7\u6a19\u306b\u623b\u3059<\/pre>\n<h2>\u5ea7\u6a19\u4fdd\u5b58\u306e\u5fdc\u7528<\/h2>\n<p>\u305d\u308c\u3067\u306f\u3001\u6b21\u306f\u5fdc\u7528\u7de8\u3068\u3057\u3066box\u3092\u305f\u304f\u3055\u3093\u8907\u88fd\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001\u4e0b\u56f3\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002X\u8ef8\u65b9\u5411\u306b6\u500b\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u5148\u307b\u3069\u306e\u9805\u3067\u3084\u3063\u305f\u3082\u306e\u306b\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u30dd\u30a4\u30f3\u30c8\u306f\u3001\u56de\u8ee2\u306e\u4e2d\u5fc3\u8ef8\u3092\u4e2d\u592e\u306b\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/r-dimension.xsrv.jp\/classes_j\/wp-content\/uploads\/2009\/06\/sample3_3_1.jpg\" alt=\"sample3_3_1\" title=\"sample3_3_1\" width=\"214\" height=\"223\" class=\"alignnone size-full wp-image-707\" \/><\/p>\n<pre lang=\"java\" line=\"1\">\r\nfloat boxSize = 20;    \/\/\u7acb\u65b9\u4f53\u306e\u30b5\u30a4\u30ba\r\nfloat distance = 30;    \/\/\u7acb\u65b9\u4f53\u540c\u58eb\u306e\u8ddd\u96e2\r\nfloat halfDis;    \/\/\u7acb\u65b9\u4f53\u540c\u58eb\u306e\u4e00\u8fba\u306e\u5168\u4f53\u306e\u8ddd\u96e2\u306e\u534a\u5206\r\nint boxNum = 6;    \/\/\u7acb\u65b9\u4f53\u306e\u6570\r\n\r\nvoid setup(){\r\n  size(400, 400, P3D);\r\n  halfDis = distance*(boxNum-1)\/2;    \/\/6\u500b\u4e26\u3093\u3060\u969b\u306e\u8ddd\u96e2\u306e\u534a\u5206\r\n}\r\n\r\nvoid draw(){\r\n  background(0);\r\n  stroke(255, 0, 0, 100);\r\n  line(width\/2, 0, width\/2, height);\r\n  line(0, height\/2, width, height\/2);\r\n\r\n  translate(width\/2, height\/2);    \/\/\u7acb\u4f53\u306e\u4e2d\u5fc3\u3092\u753b\u9762\u4e2d\u592e\u306b\u79fb\u52d5   \r\n  rotateY(radians(mouseX));\r\n  rotateX(radians(mouseY));\r\n\r\n  stroke(0);\r\n  fill(255);    \r\n\r\n  for(int x = 0; x < boxNum; x ++){    \/\/\u7acb\u65b9\u4f53\u3092\u3001x\u8ef8\u65b9\u5411\u306b30\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u4e26\u3079\u30666\u500b\u751f\u6210\r\n    pushMatrix();\r\n    translate(x*distance-halfDis, 0, 0);\r\n    box(boxSize, boxSize, boxSize);    \/\/20 x 20 x 20px\u306e\u7acb\u65b9\u4f53\u3092\u63cf\u304f\r\n    popMatrix();\r\n  }\r\n}<\/pre>\n<p>\u305d\u308c\u304c\u3067\u304d\u305f\u3089\u3001Y\u65b9\u5411\u306b\u3082\u5897\u3084\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/r-dimension.xsrv.jp\/classes_j\/wp-content\/uploads\/2009\/06\/sample3_3_2.jpg\" alt=\"sample3_3_2\" title=\"sample3_3_2\" width=\"214\" height=\"223\" class=\"alignnone size-full wp-image-712\" \/><\/p>\n<pre lang=\"java\" line=\"1\">\r\nfloat boxSize = 20;    \/\/\u7acb\u65b9\u4f53\u306e\u30b5\u30a4\u30ba\r\nfloat distance = 30;    \/\/\u7acb\u65b9\u4f53\u540c\u58eb\u306e\u8ddd\u96e2\r\nfloat halfDis;    \/\/\u7acb\u65b9\u4f53\u540c\u58eb\u306e\u4e00\u8fba\u306e\u5168\u4f53\u306e\u8ddd\u96e2\u306e\u534a\u5206\r\nint boxNum = 6;    \/\/\u7acb\u65b9\u4f53\u306e\u6570\r\n\r\nvoid setup(){\r\n  size(400, 400, P3D);\r\n  halfDis = distance*(boxNum-1)\/2;    \/\/6\u500b\u4e26\u3093\u3060\u969b\u306e\u8ddd\u96e2\u306e\u534a\u5206\r\n}\r\n\r\nvoid draw(){\r\n  background(0);\r\n  stroke(255, 0, 0, 100);\r\n  line(width\/2, 0, width\/2, height);\r\n  line(0, height\/2, width, height\/2);\r\n\r\n  translate(width\/2, height\/2);    \/\/\u7acb\u4f53\u306e\u4e2d\u5fc3\u3092\u753b\u9762\u4e2d\u592e\u306b\u79fb\u52d5   \r\n  rotateY(radians(mouseX));\r\n  rotateX(radians(mouseY));\r\n\r\n  stroke(0);\r\n  fill(255);    \r\n\r\n  for(int y = 0; y < boxNum; y ++){    \/\/\u7acb\u65b9\u4f53\u3092\u3001y\u8ef8\u65b9\u5411\u306b30\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u4e26\u3079\u30666\u500b\u751f\u6210  \r\n    for(int x = 0; x < boxNum; x ++){    \/\/\u7acb\u65b9\u4f53\u3092\u3001x\u8ef8\u65b9\u5411\u306b30\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u4e26\u3079\u30666\u500b\u751f\u6210\r\n      pushMatrix();\r\n      translate(x*distance-halfDis, y*distance-halfDis, 0);\r\n      box(boxSize, boxSize, boxSize);    \/\/20 x 20 x 20px\u306e\u7acb\u65b9\u4f53\u3092\u63cf\u304f\r\n      popMatrix();\r\n    }\r\n  }\r\n}<\/pre>\n<p>\u3053\u306e\u8981\u9818\u3067\u3001Z\u65b9\u5411\u306b\u3082\u5897\u3084\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/r-dimension.xsrv.jp\/classes_j\/wp-content\/uploads\/2009\/06\/sample3_3_3.jpg\" alt=\"sample3_3_3\" title=\"sample3_3_3\" width=\"214\" height=\"223\" class=\"alignnone size-full wp-image-714\" \/><\/p>\n<pre lang=\"java\" line=\"1\">\r\nfloat boxSize = 20;    \/\/\u7acb\u65b9\u4f53\u306e\u30b5\u30a4\u30ba\r\nfloat distance = 30;    \/\/\u7acb\u65b9\u4f53\u540c\u58eb\u306e\u8ddd\u96e2\r\nfloat halfDis;    \/\/\u7acb\u65b9\u4f53\u540c\u58eb\u306e\u4e00\u8fba\u306e\u5168\u4f53\u306e\u8ddd\u96e2\u306e\u534a\u5206\r\nint boxNum = 6;    \/\/\u7acb\u65b9\u4f53\u306e\u6570\r\n\r\nvoid setup(){\r\n  size(400, 400, P3D);\r\n  halfDis = distance*(boxNum-1)\/2;    \/\/6\u500b\u4e26\u3093\u3060\u969b\u306e\u8ddd\u96e2\u306e\u534a\u5206\r\n}\r\n\r\nvoid draw(){\r\n  background(0);\r\n  stroke(255, 0, 0, 100);\r\n  line(width\/2, 0, width\/2, height);\r\n  line(0, height\/2, width, height\/2);\r\n\r\n  translate(width\/2, height\/2);    \/\/\u7acb\u4f53\u306e\u4e2d\u5fc3\u3092\u753b\u9762\u4e2d\u592e\u306b\u79fb\u52d5   \r\n  rotateY(radians(mouseX));\r\n  rotateX(radians(mouseY));\r\n\r\n  stroke(0);\r\n  fill(255, 255, 255);    \r\n  \r\n  for(int z = 0; z < boxNum; z ++){    \/\/\u7acb\u65b9\u4f53\u3092\u3001z\u8ef8\u65b9\u5411\u306b30\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u4e26\u3079\u30666\u500b\u751f\u6210  \r\n    for(int y = 0; y < boxNum; y ++){    \/\/\u7acb\u65b9\u4f53\u3092\u3001y\u8ef8\u65b9\u5411\u306b30\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u4e26\u3079\u30666\u500b\u751f\u6210  \r\n      for(int x = 0; x < boxNum; x ++){    \/\/\u7acb\u65b9\u4f53\u3092\u3001x\u8ef8\u65b9\u5411\u306b30\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u4e26\u3079\u30666\u500b\u751f\u6210\r\n        pushMatrix();\r\n        translate(x*distance-halfDis, y*distance-halfDis, z*distance-halfDis);\r\n        box(boxSize, boxSize, boxSize);    \/\/20 x 20 x 20px\u306e\u7acb\u65b9\u4f53\u3092\u63cf\u304f\r\n        popMatrix();\r\n      }\r\n    }\r\n  }\r\n}<\/pre>\n<h2>\u56de\u8ee2\u306e\u4fdd\u5b58<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/r-dimension.xsrv.jp\/classes_j\/wp-content\/uploads\/2009\/06\/sample3_4.jpg\" alt=\"sample3_4\" title=\"sample3_4\" width=\"214\" height=\"223\" class=\"alignnone size-full wp-image-746\" \/><\/p>\n<p>\u56de\u8ee2\u306e\u5834\u5408\u3082\u524d\u8ff0\u306e\u30b5\u30f3\u30d7\u30eb\u3068\u8003\u3048\u65b9\u306f\u4e00\u7dd2\u3067\u3059\u3002\u4e00\u3064\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u56de\u8ee2\u3055\u305b\u308b\u305f\u3073\u306b\u3001pushMatrix\u3068popMatrix\u3092\u4f7f\u3048\u3070\u3001x, y, z\u5ea7\u6a19\u306f\u305d\u306e\u307e\u307e\u3067\u305d\u308c\u305e\u308c\u56de\u8ee2\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<pre lang=\"java\" line=\"1\">\r\n\/\/Y\u8ef8\u3092\u4e2d\u5fc3\u306b\u56de\u8ee2\u3059\u308b\u7acb\u65b9\u4f53\r\n\r\nvoid setup(){\r\n  size(400, 400, P3D);\r\n}\r\n\r\nvoid draw(){\r\n  background(0);\r\n\r\n  for(int i = 0; i < 3; i++){ \r\n    pushMatrix();\r\n    translate((i+1)*100, height\/2);    \/\/\u7acb\u4f53\u306e\u4e2d\u5fc3\u3092\u79fb\u52d5 \r\n    rotateY(radians(mouseX));    \/\/Y\u8ef8\u306b\u5bfe\u3057\u3066angle\u306e\u6570\u5024\u5206\u3060\u3051\u56de\u8ee2\r\n    box(50, 50, 50);    \/\/50 x 50 x 50px\u306e\u7acb\u65b9\u4f53\u3092\u63cf\r\n    popMatrix();\r\n  }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5ea7\u6a19\u4fdd\u5b58\u306e\u57fa\u790e \u3053\u306e\u9805\u3067\u306f\u30013D\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u30b9\u306b\u304a\u3051\u308b\u91cd\u8981\u306a&#8230; <a href=\"https:\/\/r-dimension.xsrv.jp\/classes_j\/3_interactive3d\/\">Read more &raquo;<\/a><\/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],"tags":[],"class_list":["post-1531","post","type-post","status-publish","format-standard","hentry","category-media_third","category-processing"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1531","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=1531"}],"version-history":[{"count":5,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1531\/revisions"}],"predecessor-version":[{"id":2450,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/posts\/1531\/revisions\/2450"}],"wp:attachment":[{"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/media?parent=1531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/categories?post=1531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/r-dimension.xsrv.jp\/classes_j\/wp-json\/wp\/v2\/tags?post=1531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}