{"id":20,"date":"2012-06-17T14:15:01","date_gmt":"2012-06-17T14:15:01","guid":{"rendered":"http:\/\/www.dannywynne.com\/blog\/?p=20"},"modified":"2012-06-17T14:20:50","modified_gmt":"2012-06-17T14:20:50","slug":"maya-minecraft-context","status":"publish","type":"post","link":"http:\/\/www.dannywynne.com\/blog\/?p=20","title":{"rendered":"Maya Minecraft Context"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/dannywynne.com\/images\/minecraft_context.gif\" alt=\"maya minecraft context\" \/><br \/>\n<br \/>\nPlay Minecraft in Maya! Just kidding. I&#8217;ve been playing Minecraft again lately and it inspired me to whip up a Maya script. It is a custom tool context using Maya Python API. With OpenMayaUI I grab the active view port using M3dView.active3dView(). I wrap the pointer to the active view port in a sip instance. With these two objects I can get the mouse pixel position with Qt and event filters, and then cast out a ray from that position into 3d space using M3dView .viewToWorld(). I use that ray in MFnMesh.closestIntersection() to get the point on the mesh and create a cube on the mesh surface. The result is an entirely scripted context that uses shift+click to place cubes on a mesh surface. There&#8217;s lots you can do with this if you edit the &#8220;create_block()&#8221; definition in my script to do whatever you want. <\/p>\n<p>\ndownload the script <a href=\"http:\/\/dannywynne.com\/scripts\/dw_Minecraft_context.zip\" title=\"timeline_markers\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Play Minecraft in Maya! Just kidding. I&#8217;ve been playing Minecraft again lately and it inspired me to whip up a Maya script. It is a custom tool context using Maya Python API. With OpenMayaUI I grab the active view port using M3dView.active3dView(). I wrap the pointer to the active view port in a sip instance. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8],"tags":[3,11,15,5],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-maya-scripting","category-pyqt","tag-maya","tag-maya-python-api","tag-pyqt","tag-python"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20"}],"version-history":[{"count":0,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}