{"id":1841,"date":"2017-09-08T17:57:58","date_gmt":"2017-09-08T09:57:58","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1841"},"modified":"2017-09-09T10:28:26","modified_gmt":"2017-09-09T02:28:26","slug":"%e7%b0%a1%e5%8c%96%e5%9d%90%e6%a8%99","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/public\/1841\/","title":{"rendered":"\u6b63\u898f\u5316\u5ea7\u6a19 Structured Grid"},"content":{"rendered":"<p><del datetime=\"2017-09-09T02:26:13+00:00\">\u5982\u679c\u9700\u8981\u5728\u4e09\u7dad\u7a7a\u9593\u88e1\u4ee5\u4e00\u500b\u7279\u5b9a\u7684\u9577\u5ea6\u4f86\u7c21\u5316\u5750\u6a19, \u6211\u66ab\u4e14\u7a31\u547c\u9019\u500b\u70ba Grid based coordinate. (\u56e0\u70ba\u4e0d\u6e05\u695a\u61c9\u8a72\u600e\u6a23\u7a31\u547c\u6216\u8a31\u662f Grid Position) \u671f\u671b\u6709\u4eba\u7cfe\u6b63\u4e00\u4e0b.<\/del><\/p>\n<p>\u9019\u6771\u897f\u8a72\u7a31\u547c\u70ba \u6b63\u898f\u5316\u5ea7\u6a19,\u00a0Structured Grid<\/p>\n<p>\u9019\u908a\u501f MineCraft \u4f86\u8aaa\u660e\u4e00\u4e0b\u60c5\u6cc1, \u5728\u904a\u6232\u4e16\u754c\u6240\u6709\u6771\u897f\u90fd\u662f\u4e00\u500b\u500b\u65b9\u683c, <strong>\u90a3\u9ebc&#8230;\u6211\u5011\u8a72\u600e\u6a23\u63db\u7b97\u65b9\u683c\u653e\u7f6e\u6642\u5c0d\u61c9\u7684\u683c\u5b50\u5750\u6a19<\/strong>?<\/p>\n<figure style=\"width: 1094px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"irc_mi\" src=\"https:\/\/i.ytimg.com\/vi\/zd6WifCGHs4\/maxresdefault.jpg\" alt=\"minecraft\u7684\u5716\u7247\u641c\u5c0b\u7d50\u679c\" width=\"1094\" height=\"579\" \/><figcaption class=\"wp-caption-text\">Minicraft \u756b\u9762\u793a\u610f\u5716.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">public Bounds GetCell(Vector3 point, float halfExtent)\r\n{\r\n\tfloat size = halfExtent * 2f;\r\n\tVector3 size3D = new Vector3(size, size, size);\r\n\tpoint = new Vector3(\r\n\t\tMathf.Sign(point.x) * (Mathf.Abs(point.x) + halfExtent),\r\n\t\tMathf.Sign(point.y) * (Mathf.Abs(point.y) + halfExtent),\r\n\t\tMathf.Sign(point.z) * (Mathf.Abs(point.z) + halfExtent));\r\n\tVector3 remainder = new Vector3(\r\n\t\tpoint.x % size,\r\n\t\tpoint.y % size,\r\n\t\tpoint.z % size);\r\n\tVector3 center = point - remainder;\r\n\treturn new Bounds(center, size3D);\r\n}<\/pre>\n<p>\u5176\u5be6\u91cd\u9ede\u53ea\u662f\u7c21\u55ae\u7684\u6e1b\u53bb mod \u5f8c\u7684\u9918\u6578. \u50cf\u9019\u6a23.<br \/>\npoint.x &#8211; (point.x % size)<\/p>\n<p>\u5148\u5047\u5b9a size = 1f, point.x = 1.5f<\/p>\n<p>= 1.5f &#8211; (1.5f mod 1f)<br \/>\n= 1.5f &#8211; 0.5f<br \/>\n= 1f<\/p>\n<p>\u4f46\u9019\u908a\u9084\u6709\u4e00\u9ede\u5c0f\u554f\u984c, \u5c31\u662f\u9019\u50cf\u53d6\u5f97\u7d50\u679c, \u9918\u6578 0.5f \u88ab\u62b9\u53bb\u4e86.<br \/>\n\u9020\u6210 \u5750\u6a19\u90fd\u5728 1f \u7684\u6642\u5019, \u9084\u525b\u597d\u53ef\u4ee5\u5728 size \u7684\u7bc4\u570d\u5167, \u8d85\u904e\u5247\u8b8a\u6210\u6709\u9593\u9699\u7684\u72c0\u614b, \u76f4\u5230\u4e0b\u4e00\u500b\u80fd\u5920\u5b8c\u6574 mod \u7684\u5750\u6a19\u4ee5\u524d\u90fd\u662f\u504f\u79fb\u7684.<br \/>\n\u90a3\u5ea6 size \/ 2f \u7684\u9593\u9699\u5c31\u662f\u9700\u8981\u4fee\u6b63\u7684\u6771\u897f.<\/p>\n<figure id=\"attachment_1842\" aria-describedby=\"caption-attachment-1842\" style=\"width: 678px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1842 size-full\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2017\/09\/position_grid.jpg\" alt=\"\" width=\"678\" height=\"413\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2017\/09\/position_grid.jpg 678w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2017\/09\/position_grid-300x183.jpg 300w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><figcaption id=\"caption-attachment-1842\" class=\"wp-caption-text\">\u767d\u8272\u662f\u8f38\u5165\u524d\u7684\u5750\u6a19, \u7d2b\u7d05\u8272\u662f\u7c21\u5316\u5f8c\u7684\u5750\u6a19<\/figcaption><\/figure>\n<p>\u6240\u4ee5\u6211\u5011\u52a0\u4e0a halfExtent (size\/2f) \u4f86\u4fee\u6b63\u9019\u554f\u984c&#8230; \u4f46\u9019\u500b\u53c8\u6703\u4ee4\u5230\u8ca0\u6578\u6642\u7684\u8a08\u7b97\u4e0d\u5c0d&#8230;<br \/>\n\u5176\u7d50\u679c\u5c31\u662f\u5206\u96e2\u6b63\u8ca0\u7684\u6578\u5b57\u518d\u8a08\u7b97.<br \/>\n\u6240\u5f97\u51fa\u7684\u7a0b\u5e8f\u78bc.<\/p>\n<figure id=\"attachment_1843\" aria-describedby=\"caption-attachment-1843\" style=\"width: 709px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1843 size-full\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2017\/09\/position_fix.jpg\" alt=\"\" width=\"709\" height=\"476\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2017\/09\/position_fix.jpg 709w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2017\/09\/position_fix-300x201.jpg 300w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><figcaption id=\"caption-attachment-1843\" class=\"wp-caption-text\">\u4fee\u6b63 halfExtent \u7684\u7d50\u679c<\/figcaption><\/figure>\n<p>\u9019\u662f\u6700\u7d42\u7684\u7d50\u679c.<\/p>\n<figure id=\"attachment_1844\" aria-describedby=\"caption-attachment-1844\" style=\"width: 707px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1844 \" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2017\/09\/grid_base_coordinate.gif\" alt=\"\" width=\"707\" height=\"413\" \/><figcaption id=\"caption-attachment-1844\" class=\"wp-caption-text\">final result.<\/figcaption><\/figure>\n<p>\u4ee5\u4e0a, \u5176\u5be6\u6709\u5f88\u591a\u5b57\u773c\u4e5f\u4e0d\u6e05\u695a, \u671f\u671b\u6709\u9ad8\u4eba\u6307\u5c0e.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u9700\u8981\u5728\u4e09\u7dad\u7a7a\u9593\u88e1\u4ee5\u4e00\u500b\u7279\u5b9a\u7684\u9577\u5ea6\u4f86\u7c21\u5316\u5750\u6a19, \u6211\u66ab\u4e14\u7a31\u547c\u9019\u500b\u70ba Grid based coord &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,78,11,3,4],"tags":[62,102,43],"class_list":["post-1841","post","type-post","status-publish","format-standard","hentry","category-c","category-math","category-unity3d","category-public","category-program","tag-coordinate","tag-grid","tag-unity3d-2"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1841"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1841\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}