{"id":31,"date":"2016-01-22T08:11:37","date_gmt":"2016-01-21T23:11:37","guid":{"rendered":"http:\/\/naonao.info\/blog\/?p=31"},"modified":"2016-01-31T12:42:58","modified_gmt":"2016-01-31T03:42:58","slug":"post-31","status":"publish","type":"post","link":"https:\/\/naonao.info\/?p=31","title":{"rendered":"cocos2d-x\u306eSprite3D\u306e\u30bf\u30c3\u30c1\u3092\u5224\u5b9a\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-37\" src=\"https:\/\/naonao.info\/wp-content\/uploads\/2016\/01\/okame3d.png\" alt=\"\" width=\"280\" height=\"207\" \/><\/p>\n<p>&nbsp;<br \/>\n\u2191\u53ef\u611b\u3044\uff1f\uff08\u7b11\uff09<br \/>\n\u4eca\uff13D\u30b2\u30fc\u30e0\u3092cocos2d-x\u3067\u6311\u6226\u3057\u3066\u308b\u306e\u3067\u3059\u304c\u3001<br \/>\n3\u6b21\u5143\u8868\u793a\u3055\u308c\u305f\u753b\u50cf\u3092\u30bf\u30c3\u30c1\u3055\u308c\u305f\u306e\u3092\u7279\u5b9a\u3059\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u304b\u30fb\u30fb\u30fb<br \/>\n\u305d\u3082\u305d\u30823D\u4f5c\u308b\u306a\u3089Unity\u4f7f\u3048\u3088\u3063\u3066\u8a00\u308f\u308c\u304b\u306d\u306a\u3044\u306e\u3067\u3059\u304c\u3001<br \/>\ncocos2d-x\u3067\u3069\u3053\u307e\u3067\u3067\u304d\u308b\u304b\u3084\u3063\u3066\u307f\u305f\u304b\u3063\u305f\u30fb\u30fb\u30fb<br \/>\n\u3081\u3093\u3069\u304f\u3066\u65e2\u306b\u5f8c\u6094\u4e2d\u3002<\/p>\n<p>\u8a71\u306f\u623b\u3057\u3066\u307e\u305a\u306fSprite3D\u306b\u30bf\u30c3\u30c1\u30a4\u30d9\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u3001\u547c\u3070\u308c\u3066\u304d\u305fSprite3D\u304c<br \/>\n\u81ea\u5206\u304b\u5224\u65ad\u3059\u308b\u624b\u9806\u3067\u3059\u3002<br \/>\n\u4e0b\u306e\u4f8b\u306fSprite3D\u306b\u30bf\u30c3\u30c1\u30a4\u30d9\u30f3\u30c8\u3092\u98db\u3070\u3057\u3066\u307e\u3059\u304c\u3001\u753b\u9762\u306e\u30bf\u30c3\u30c1\u304b\u3089<br \/>\n\u3069\u308c\u304c\u30bf\u30c3\u30c1\u3055\u308c\u305f\u304b\u30eb\u30fc\u30d7\u3067\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3082\u3044\u3044\u3067\u3059\u3088\u3002<br \/>\n\u3046\u30fc\u3093\u30013D\u306e\u5ea7\u6a19\u7ba1\u7406\u3063\u3066\u30e0\u30ba\u30a4\u308f\u3041\u3002<\/p>\n<p>bool GameSceneLayer::onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event)<br \/>\n{<br \/>\nPoint point = touch-&gt;getLocation();<br \/>\nif (_mode != eGSL_GAME_START) return false;<\/p>\n<p>\/\/ \u30bf\u30c3\u30c1\u3055\u308c\u305f\u3082\u306e\u304b\u78ba\u8a8d<br \/>\nSprite3D *sp = (Sprite3D *)event-&gt;getCurrentTarget();<br \/>\nauto size = Director::getInstance()-&gt;getWinSize();<br \/>\nRay ray;<br \/>\nVec3 nears(point.x, point.y, -1.0f);<br \/>\nVec3 fars(point.x, point.y, 1.0f);<\/p>\n<p>\/\/ \u30ab\u30e1\u30e9\u30a2\u30f3\u30b0\u30eb\u304b\u3089\u5b9f\u969b\u3069\u3053\u304c\u30bf\u30c3\u30c1\u3055\u308c\u305f\u306e\u304b\u53d6\u5f97<br \/>\ncam3d-&gt;unprojectGL(size, &amp;nears, &amp;nears);<br \/>\ncam3d-&gt;unprojectGL(size, &amp;fars, &amp;fars);<\/p>\n<p>ray._origin = nears;<br \/>\nray._direction = fars &#8211; nears;<\/p>\n<p>\/\/ \u30bf\u30c3\u30c1\u3055\u308c\u305fbox\u3060\u3063\u305f<br \/>\nif (ray.intersects(sp-&gt;getAABB()) == true)<br \/>\n{<\/p>\n<p>\/\/\u30bf\u30c3\u30c1\u3055\u308c\u305f\u3082\u306e\u304c\u5224\u5b9a\u3067\u304d\u305f\u306e\u3067\u3053\u3053\u304b\u3089\u3084\u308a\u305f\u3044\u51e6\u7406<br \/>\nreturn true;<br \/>\n}<br \/>\nreturn false;<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u2191\u53ef\u611b\u3044\uff1f\uff08\u7b11\uff09 \u4eca\uff13D\u30b2\u30fc\u30e0\u3092cocos2d-x\u3067\u6311\u6226\u3057\u3066\u308b\u306e\u3067\u3059\u304c\u3001 3\u6b21\u5143\u8868\u793a\u3055\u308c\u305f\u753b\u50cf\u3092\u30bf\u30c3\u30c1\u3055\u308c\u305f\u306e\u3092\u7279\u5b9a\u3059\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u304b\u30fb\u30fb\u30fb \u305d\u3082\u305d\u30823D\u4f5c\u308b\u306a\u3089Unity\u4f7f\u3048\u3088\u3063\u3066\u8a00\u308f\u308c\u304b\u306d\u306a\u3044\u306e\u3067 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gamecreate"],"views":5090,"_links":{"self":[{"href":"https:\/\/naonao.info\/index.php?rest_route=\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/naonao.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/naonao.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/naonao.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/naonao.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31"}],"version-history":[{"count":7,"href":"https:\/\/naonao.info\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/naonao.info\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions\/55"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/naonao.info\/index.php?rest_route=\/wp\/v2\/media\/37"}],"wp:attachment":[{"href":"https:\/\/naonao.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/naonao.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/naonao.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}