{"id":1614,"date":"2022-08-03T00:27:02","date_gmt":"2022-08-03T00:27:02","guid":{"rendered":"https:\/\/writingagame.com\/?p=1614"},"modified":"2022-08-06T20:47:29","modified_gmt":"2022-08-06T20:47:29","slug":"chapter-42-models-variability","status":"publish","type":"post","link":"https:\/\/writingagame.com\/index.php\/2022\/08\/03\/chapter-42-models-variability\/","title":{"rendered":"Chapter 42. Models variability (with GitHub)"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>Ok, time for a new GitHub repo.<\/p>\n\n\n\n<p>The topic of this chapter is Models variability.<\/p>\n\n\n\n<p>Of course, 1 single car model isn&#8217;t enough for the Project. We&#8217;ll need more. At least &#8211; in different colors. Creating a set of practically identical models with just different colors looks kind of wasteful. Instead, we can randomly customize models &#8220;on the fly&#8221;, when loading.<\/p>\n\n\n\n<p>So I added a new function in <em>GameSubj<\/em> class &#8211; <em>onDeploy()<\/em>, which will define for each deployed model it&#8217;s own settings, such as colors, color schemas, options, such as open or closed roof, spare wheel placement (on the back or on sides), and so on, including optional fog lights, mirrors, signal lights. Like this:<\/p>\n\n\n\n<p><img decoding=\"async\" src=\"https:\/\/writingagame.com\/img\/b01\/c42\/01.jpg\"><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Instructions on <strong>how<\/strong> to customize &#8211; in a separate file &#8211; <em>ondeploy.txt<\/em>.<br>Same XML format as in <em>ModelLoader<\/em>. Since it&#8217;s a different set of tags for different purpose, I wrapped it in a separate class &#8211; <em>ModelLoaderCmd.cpp\/h<\/em>. Works the same as <em>ModelLoader<\/em>.<\/p>\n\n\n\n<p>2. Original model is 1:64 scale, but in this sample I rescaled it to 1:150 (&#8220;N scale&#8221;), which involved another new function in <em>GameSubj &#8211; scaleMe()<\/em>, which scales the subj itself, plus all it&#8217;s &#8220;childs&#8221; and their attachment coordinates.<\/p>\n\n\n\n<p>3. Also we have a bunch of changes from previous chapter.<\/p>\n\n\n\n<p>So, here is a new repository (as promised earlier, now &#8211; <strong>leak-free<\/strong>):<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/bkantemir\/_wg42\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/bkantemir\/_wg42<\/a><\/p>\n\n\n\n<p>Again, instruction how to use it &#8211; in chapter 37.2.<\/p>\n\n\n\n<p>Result:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<iframe loading=\"lazy\" width=\"100%\" height=\"400\" src=\"https:\/\/www.youtube.com\/embed\/qEPrUWaco7o?controls=0&amp;autoplay=1&amp;loop=1&amp;playlist=qEPrUWaco7o\" title=\"Models variability\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe>\n\n\n\n<p><\/p>\n\n\n\n<p>Also, on each start it will be a different set.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"mb-2\">Ok, time for a new GitHub repo. The topic of this chapter is Models variability. Of course, 1 single car model isn&#8217;t enough for the Project. We&#8217;ll need more. At least &#8211; in different colors. Creating a set of practically identical models with just different colors looks kind of wasteful. Instead, we can randomly customize [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1644,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1614","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cross-platform-3d"],"_links":{"self":[{"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/posts\/1614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/comments?post=1614"}],"version-history":[{"count":15,"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/posts\/1614\/revisions"}],"predecessor-version":[{"id":1670,"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/posts\/1614\/revisions\/1670"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/media\/1644"}],"wp:attachment":[{"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/media?parent=1614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/categories?post=1614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/writingagame.com\/index.php\/wp-json\/wp\/v2\/tags?post=1614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}