{"id":140,"date":"2014-09-12T20:49:15","date_gmt":"2014-09-12T20:49:15","guid":{"rendered":"http:\/\/www.srcxor.org\/blog\/?p=140"},"modified":"2014-10-24T14:26:20","modified_gmt":"2014-10-24T14:26:20","slug":"3d-glitching-part-3","status":"publish","type":"post","link":"http:\/\/www.srcxor.org\/blog\/3d-glitching-part-3\/","title":{"rendered":"3d Glitching &#8211; Part 3"},"content":{"rendered":"<p>Again, this will go better if you&#8217;ve read <a title=\"3d Glitching..\" href=\"http:\/\/www.srcxor.org\/blog\/3d-glitching\/\">part 1<\/a> and <a title=\"3d Glitch Notes.. Part 2\" href=\"http:\/\/www.srcxor.org\/blog\/3d-glitch-notes-part-2\/\">part 2<\/a> of this series!<\/p>\n<p>We&#8217;re going to combine two techniques here. First, we&#8217;ll use the &#8220;Sort by Selection&#8221; method to order the vertices. Second, instead of using a text editor, we&#8217;ll use a spreadsheet to manipulate the data!!<\/p>\n<p>We&#8217;ll use Suzanne, once again, as our model. We&#8217;ll go into &#8220;Edit&#8221; mode and\u00a0 subdivide the mesh a couple times so we have more vertices to work with.<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/1.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-142 size-thumbnail\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/1-200x200.jpg\" alt=\"\" width=\"200\" height=\"200\" \/><\/a><\/p>\n<p>That accomplished, we&#8217;ll select a few of the vertices at the top of Suzanne&#8217;s head, and, after that, we&#8217;ll go to the &#8220;Mesh&#8221; menu, choose &#8220;Sort Elements&#8221;, and then sort by &#8220;Selection&#8221;.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/2.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-143\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/2-200x200.jpg\" alt=\"\" width=\"200\" height=\"200\" \/><\/a><\/p>\n<p>Using the &#8220;visualize vertices&#8221; addon that we introduced in the last set of notes, we can now see that the vertices we selected are in indices 0 through 48 ( a total of 49).<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/4.1jpg.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-145\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/4.1jpg.jpg\" alt=\"4.1jpg\" width=\"496\" height=\"283\" \/><\/a><\/p>\n<p>We then\u00a0 export the mesh in our usual fashion as an .obj file, change the extension to .txt, and open it in a spreadsheet! I&#8217;m using LibreOffice Calc, so I&#8217;m given the option of using spaces to separate the fields, this results in the x,y, and z coordinates being placed correctly in their separate columns.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/5.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-148\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/5.jpg\" alt=\"5\" width=\"317\" height=\"483\" srcset=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/5.jpg 448w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/5-394x600.jpg 394w\" sizes=\"auto, (max-width: 317px) 100vw, 317px\" \/><\/a><\/p>\n<p>We&#8217;re now going to do something that would not have been possible using a text editor.\u00a0 We&#8217;ll select the first 49 coordinates in the &#8220;C&#8221; column.. those represents the &#8220;y&#8221; values for the vertices, which is the &#8220;up&#8221; direction. ( A note here.. most 3d programs treat the &#8220;y&#8221; axis as up, but Blender\u00a0 uses the &#8220;z&#8221; axis for up! When exporting as an .obj file from Blender, in the export options, choose &#8220;Y Up&#8221; and &#8220;Z Forward&#8221;.)<\/p>\n<p>&nbsp;<\/p>\n<p>In this case, sort Column &#8220;C&#8221; by &#8220;Ascending&#8221;.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-150\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6.jpg\" alt=\"6\" width=\"418\" height=\"400\" srcset=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6.jpg 942w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6-600x574.jpg 600w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/a><\/p>\n<p>We&#8217;ve now &#8220;glitched&#8221; our file, but we have to take special care when saving it and changing it back into an .obj file. Choose to save as a text &#8220;.csv&#8221; file. In Calc, you&#8217;ll need to check the &#8220;Edit filter settings&#8221; option. You can also uncheck &#8220;Automatic file name extension&#8221; options, and then change the file extension from &#8220;.csv&#8221; to &#8220;.obj&#8221;.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/71.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-154\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/71.jpg\" alt=\"7\" width=\"463\" height=\"390\" srcset=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/71.jpg 832w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/71-600x504.jpg 600w\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" \/><\/a><\/p>\n<p>Be sure to change the field delimiter to &#8220;space&#8221;:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/8.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-152\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/8.jpg\" alt=\"8\" width=\"458\" height=\"233\" srcset=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/8.jpg 741w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/8-600x305.jpg 600w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>We&#8217;ll now take a look at our glitched file in Meshlab:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/9.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-153\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/9.jpg\" alt=\"9\" width=\"457\" height=\"424\" srcset=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/9.jpg 851w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/9-600x556.jpg 600w\" sizes=\"auto, (max-width: 457px) 100vw, 457px\" \/><\/a><\/p>\n<p>Look at that strange regular pattern of\u00a0 peaks and valleys on top of Suzanne&#8217;s head!\u00a0 What is happening here?<\/p>\n<p>Let&#8217;s look at a comparison of the column containing the values of the &#8220;y&#8221; coordinates before and after we sorted them:<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6.1.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-149\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6.1.jpg\" alt=\"6.1\" width=\"437\" height=\"461\" srcset=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6.1.jpg 722w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/6.1-568x600.jpg 568w\" sizes=\"auto, (max-width: 437px) 100vw, 437px\" \/><\/a><\/p>\n<p>Note that before we did our sort in the spreadsheet, the vertex at index 0\u00a0 (on line 5 of the spreadsheet due to the header info above it) would be at the very top of Suzanne&#8217;s head.. at the highest &#8220;y&#8221; position. After we sorted the &#8220;y&#8221; axis in the spreadsheet in ascending order, that 0 index vertex was now at the <em>lowest<\/em> position on the &#8220;y&#8221; axis relative to the other vertices we selected.\u00a0 Each of the subsequent vertices we selected would be at the next slightly higher position, and the last vertex at index 48 will now be at the highest relative position.<\/p>\n<p>Let&#8217;s look again at the picture of the selected vertices with their index positions displayed.. this time with a visualization of the distribution of those indices:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/4.1withArrows.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-146\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/4.1withArrows.jpg\" alt=\"4.1withArrows\" width=\"533\" height=\"304\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Note how the pattern skips, hopscotch fashion, so the next indexed vertex is never immediately &#8220;spatially&#8221; adjacent in the mesh to the vertices that are just before and after it in the index order.<\/p>\n<p>The &#8220;hopscotch&#8221; arrangement of the vertices results in the regular &#8220;high-low&#8221; alternation along the &#8220;y&#8221; axis that we see saw above. After the sort in the spreadsheet, the vertices reached during the first half of the traverse have all been assigned the lowest &#8220;y&#8221; values, and the vertices spatially in between them on the mesh, being visited last, have been assigned the highest &#8220;y&#8221; values. Of course, the order of the indices would have been different if we&#8217;d chosen a different method of sorting them back when we were in Blender.<\/p>\n<p>This method of selecting chunks of the 3 columns representing the x, y, and z coordinates, and then sorting them various ways &#8211; sometimes ascending, sometimes descending, sometimes sorting one column separately, sometimes sorting more than one column using multiple keys &#8211; can produce some interesting results:<\/p>\n<p><a href=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/aphrodite003resized.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-160\" src=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/aphrodite003resized-819x1024.jpg\" alt=\"aphrodite003resized\" width=\"451\" height=\"564\" srcset=\"http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/aphrodite003resized-819x1024.jpg 819w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/aphrodite003resized-480x600.jpg 480w, http:\/\/www.srcxor.org\/blog\/wp-content\/uploads\/2014\/09\/aphrodite003resized.jpg 1200w\" sizes=\"auto, (max-width: 451px) 100vw, 451px\" \/><\/a><\/p>\n<p>There are many other curious things one can do with spreadsheets.. easily cutting and pasting between the columns, applying formulas.. however, sooner or later the limitations of spreadsheets will get in the way. At that point we&#8217;ll need to use a real scripting language to manipulate the date.. but that will come in a future post.<\/p>\n<p>Before that, though, we&#8217;ll be looking at glitching the texture coordinates of the .obj file.. these control how a 2d image is mapped to the 3d surface of the mesh.. and now you&#8217;re ready to move on to the <a title=\"3d Glitching Notes \u2013 Part 4 \u2013 Texture Map Glitching\u2026\" href=\"http:\/\/www.srcxor.org\/blog\/3d-glitching-notes-part-4-texture-map-glitching\/\">next section<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Again, this will go better if you&#8217;ve read part 1 and part 2 of this series! We&#8217;re going to combine two techniques here. First, we&#8217;ll use the &#8220;Sort by Selection&#8221; method to order the vertices. Second, instead of using a text editor, we&#8217;ll use a spreadsheet to manipulate the data!! We&#8217;ll use Suzanne, once again, &#8230; <a class=\"more-link\" href=\"http:\/\/www.srcxor.org\/blog\/3d-glitching-part-3\/\">[Read more&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9,2,10],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-srcxor","4":"post-140","6":"format-standard","7":"category-3d","8":"category-blender","9":"category-glitch","10":"category-meshlab"},"_links":{"self":[{"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":10,"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":212,"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions\/212"}],"wp:attachment":[{"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.srcxor.org\/blog\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}