{"id":299,"date":"2018-10-26T11:51:39","date_gmt":"2018-10-26T11:51:39","guid":{"rendered":"http:\/\/cliffnordman.com\/blog\/?p=299"},"modified":"2019-04-02T11:17:33","modified_gmt":"2019-04-02T11:17:33","slug":"procjam-7dfps-2018-day-5","status":"publish","type":"post","link":"https:\/\/cliffnordman.com\/blog\/2018\/10\/26\/procjam-7dfps-2018-day-5\/","title":{"rendered":"PROCJAM \/ 7DFPS 2018, Day 5"},"content":{"rendered":"<p><a href=\"http:\/\/www.procjam.com\/\">PROCJAM<\/a>, <a href=\"http:\/\/7dfps.com\/\">7DFPS<\/a><\/p>\n<p><a href=\"https:\/\/cliffnordman.com\/blog\/2018\/10\/23\/procjam-2018-photo-copy-day-1\/\">Day 1<\/a>, <a href=\"http:\/\/cliffnordman.com\/blog\/2018\/10\/25\/procjam-2018-photo-copy-day-2\/\">Day 2<\/a>, <a href=\"http:\/\/cliffnordman.com\/blog\/2018\/10\/25\/procjam-2018-photo-copy-day-3\/\">Day 3<\/a>, <a href=\"http:\/\/cliffnordman.com\/blog\/2018\/10\/25\/procjam-7dfps-2018-day-4\/\">Day 4<\/a><\/p>\n<p>Unity uses two programming languages:\u00a0 C# and JavaScript.\u00a0 I use C# because I like strongly-typed languages.\u00a0 I want to see as many mistakes at compile-time as possible. But Tracery (which I used to generate Burning Man Camp names) is written in JavaScript. Can I just copy the files in to my project&#8217;s directory structure? No! Unity finds several errors in files that work just fine in a web browser.\u00a0 Searching online reveals two people that ported Tracery to C# specifically for use in Unity.\u00a0 Both authors caution that these ports are completely unsupported, but that&#8217;s good enough for me.\u00a0 I assign a name to each city block, but displaying that name to the user requires learning how to use Unity&#8217;s UI features.\u00a0 I don&#8217;t want to deal with that hassle, so I switch tasks!<\/p>\n<p>The Temple was a giant blank cylinder, and the Man was standing on a similarly boring box. I create a Lathe algorithm to replace both.\u00a0 The Lathe draws some line segments from bottom to top, then rotates that outline around the Y-axis, kinda like a vase.\u00a0 This is quite-low-level compared to most of what I&#8217;ve built.\u00a0 I&#8217;m not using built-in primitives or importing meshes I built in a 3D editor.\u00a0 I&#8217;m creating the object one piece at a time while the game is running. Not only do I have to write nested loops to place each vertex, I have to remember what order I created them, because the triangles are one giant list of references to the one giant list of vertices.\u00a0 Speed is important at this level, so I don&#8217;t get the luxury of a big tree structure of objects. After writing some triangles backwards, and forgetting a few numbers, I get a shape!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-301\" src=\"http:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/lathebug.png\" alt=\"\" width=\"739\" height=\"537\" srcset=\"https:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/lathebug.png 739w, https:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/lathebug-300x218.png 300w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><\/p>\n<p>What is this? The light acts like it&#8217;s completely flat!\u00a0 I had missed two things.<\/p>\n<ol>\n<li>Unity stores only one normal per vertex, so if two triangles share a vertex, Unity will smooth the join between those triangles.\u00a0 I want the angular, low-poly look, so I don&#8217;t want any triangles to share vertexes.\u00a0 A quick sketch shows that each vertex borders six triangles, so I have to edit my vertex generation loop so it creates six times as many verticex!\u00a0 Now the triangle creation loop needs to use each of those vertices exactly once.\u00a0 Yikes!<\/li>\n<li>The second step is to call the RecalculateNormals() function.\u00a0 Much easier!<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-300\" src=\"http:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/latheOK.png\" alt=\"\" width=\"597\" height=\"536\" srcset=\"https:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/latheOK.png 597w, https:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/latheOK-300x269.png 300w\" sizes=\"(max-width: 597px) 100vw, 597px\" \/><\/p>\n<p>So much better!\u00a0 You&#8217;ll notice that this temple is spikier than a vase.\u00a0 That&#8217;s &#8220;star mode.&#8221;\u00a0 I bring a piece of code over from my <a href=\"http:\/\/cliffnordman.com\/blog\/2018\/05\/04\/bodypaint-generator-code-clean-up\/\">bodypaint generator<\/a> that reduces\u00a0 the radius of every other vertical row of vertices.<\/p>\n<p>After finishing this project, I am ready to tackle some UI work. People won&#8217;t enjoy even the coolest game if they don&#8217;t know how to play, so I need to explain myself.\u00a0 I add a title screen with a list of controls and a bit of story.\u00a0 This is a game about copying photo.s. The original code name was &#8220;Art Fraud&#8221; But now i&#8217;m having second thoughts.\u00a0 Taking photos in a magical, beautiful place seems so joyful and positive. Do I really want to flavor it as theft and subterfuge? As a compromise, I let the user select Light or Dark stories. There&#8217;s no mechanical difference, but the little paragraph re-contextualizes why one has these photos, and why one wants to re-create them.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-302\" src=\"http:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/menu.png\" alt=\"\" width=\"677\" height=\"429\" srcset=\"https:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/menu.png 677w, https:\/\/cliffnordman.com\/blog\/wp-content\/uploads\/2018\/10\/menu-300x190.png 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PROCJAM, 7DFPS Day 1, Day 2, Day 3, Day 4 Unity uses two programming languages:\u00a0 C# and JavaScript.\u00a0 I use C# because I like strongly-typed languages.\u00a0 I want to see as many mistakes at compile-time as possible. But Tracery (which I used to generate Burning Man Camp names) is written in JavaScript. Can I just &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/cliffnordman.com\/blog\/2018\/10\/26\/procjam-7dfps-2018-day-5\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PROCJAM \/ 7DFPS 2018, Day 5&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,8,1],"tags":[],"class_list":["post-299","post","type-post","status-publish","format-standard","hentry","category-photography","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/posts\/299"}],"collection":[{"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/comments?post=299"}],"version-history":[{"count":2,"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/posts\/299\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/posts\/299\/revisions\/304"}],"wp:attachment":[{"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/media?parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/categories?post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cliffnordman.com\/blog\/wp-json\/wp\/v2\/tags?post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}