{"id":71,"date":"2009-09-19T19:24:18","date_gmt":"2009-09-19T19:24:18","guid":{"rendered":"http:\/\/www.templarcreations.com\/?p=71"},"modified":"2009-09-19T19:24:18","modified_gmt":"2009-09-19T19:24:18","slug":"animated-textures-tutorial-1","status":"publish","type":"post","link":"https:\/\/templarcreations.com\/?p=71","title":{"rendered":"Animated Textures &#8211; Tutorial 1"},"content":{"rendered":"<p><em>With the recent release of the Animated Steampunk Textures pack, this would be a\u00a0good time to do some tutorials on animated textures, so here we go&#8230;<\/em><\/p>\n<p>This is the first of a three-part tutorial about using animated textures in\u00a0Second Life. There three parts, because there are three different ways of\u00a0animating textures, each with their own use. Two of them make use of the LSL\u00a0function, llSetTextureAnim, which is the usual way of animating textures. The\u00a0third way uses a timer and offsets to manually animate the texture &#8212; it is a\u00a0lot less efficient, but can occasionally be useful.<\/p>\n<p>In this first part, however, I&#8217;ll look at the simplest and easiest way of\u00a0animating a texture, using the &#8216;smooth scroll&#8217; option. This simply moves the\u00a0texture across the surface of the prim, and doesn&#8217;t need a specially designed\u00a0texture &#8212; any texture can be scrolled, although some will obviously work better\u00a0than others!<\/p>\n<p>A common use of this is to create a flowing water animation, and that&#8217;s the\u00a0example I&#8217;ll use here, especially as suitable textures are available from the\u00a0built-in Library in every Second Life avatar&#8217;s inventory.<\/p>\n<p>So&#8230;<\/p>\n<p>Rez a simple cube, and apply a water texture to it &#8212; the Water &#8211; ripple layer 1\u00a0texture in the Library\\Textures\\Waterfalls folder should work well. Resize it\u00a0into something fairly long and flat (5 x 2 should be effective).<\/p>\n<p>On the Contents tab of the Build window, click the &#8216;New Script&#8217;, and wait for\u00a0it to appear in the Contents list (if SL is being laggy this might take a few\u00a0seconds). Double-click to open it.<\/p>\n<p>Replace the existing code with the following:<\/p>\n<pre>[sourcecode language=\"cpp\"]\ndefault\n{\n    state_entry()\n    {\n        llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, 0, 1, 1, 1, 1, 0.12);\n    }\n}\n[\/sourcecode]<\/pre>\n<p>Save the script, and the texture will start scrolling. Assuming that you haven&#8217;t\u00a0rotated the prim, this will scroll the top surface.<\/p>\n<p>Ok, now you&#8217;ve seen it in action, let&#8217;s look at the parameters.<\/p>\n<p>The first parameter is a set of flags which specify how the texture should be\u00a0animated. You can string together several flags (as in the above example) by\u00a0using the &#8216;|&#8217; symbol (technically an &#8216;OR&#8217; operator). Note that some combinations\u00a0don&#8217;t make sense.<\/p>\n<p>You can check the <a href=\"http:\/\/www.lslwiki.net\/lslwiki\/wakka.php?wakka=llSetTextureAnim\">LSL Wiki page<\/a> for details of what each flag means, but in\u00a0the example we are switching the animation on (rather important!), and we are\u00a0saying that we want a &#8216;SMOOTH&#8217; animation, which means that the texture will\u00a0simply be scrolled across the surface of the prim (actually, this is not quite\u00a0an accurate description of what SMOOTH does, but I&#8217;ll explain it in more detail\u00a0in the next article).<\/p>\n<p>Finally we are specifying &#8216;LOOP&#8217;, which means that the animation will keep going\u00a0continuously.<\/p>\n<p>Instead of LOOP we could have specified PING-PONG, which reverses the animation\u00a0when it reaches the end. In the case of a smooth animation, it will scroll the\u00a0texture for the entire length, then reverse direction and scroll it back again.<\/p>\n<p>If you want to stop an animation, simply set this parameter to 0. All the other\u00a0parameters are irrelevant in this case.<\/p>\n<p>The next parameter &#8212; 0 in this example &#8212; is the face of the prim that the\u00a0animation should be applied to. All the other faces will be static. However, if\u00a0you use ALL_SIDES for this parameter, all the faces of the prim will animate.<\/p>\n<p>Unfortunately, it isn&#8217;t possible to animate some but not all of the faces &#8212;\u00a0it&#8217;s either 1 face or all faces.<\/p>\n<p>A couple of final notes. You&#8217;ll notice that the Repeat and Flip options for\u00a0textures don&#8217;t have any effect on animated textures. Rotate, however, does.<\/p>\n<p>That will do for now. In the next article, I&#8217;ll take a look at the traditional\u00a0animated texture, which uses a sequence of frames like an animated movie.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the recent release of the Animated Steampunk Textures pack, this would be a\u00a0good time to do some tutorials on animated textures, so here we go&#8230; This is the first of a three-part tutorial about using animated textures in\u00a0Second Life. There three parts, because there are three different ways of\u00a0animating textures, each with their own [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,9],"tags":[14,85,100,103],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-textures","category-tutorials","tag-animated","tag-second-life","tag-textures","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/templarcreations.com\/index.php?rest_route=\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/templarcreations.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/templarcreations.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/templarcreations.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/templarcreations.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":0,"href":"https:\/\/templarcreations.com\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"wp:attachment":[{"href":"https:\/\/templarcreations.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/templarcreations.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/templarcreations.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}