{"id":622,"date":"2014-06-09T20:09:24","date_gmt":"2014-06-09T19:09:24","guid":{"rendered":"http:\/\/phoenixgamedevelopment.com\/blog\/?p=622"},"modified":"2014-06-09T20:12:37","modified_gmt":"2014-06-09T19:12:37","slug":"visibility-animation-tutorial-with-3ds-max","status":"publish","type":"post","link":"https:\/\/phoenixgamedevelopment.com\/blog\/visibility-animation-tutorial-with-3ds-max\/","title":{"rendered":"Visibility Animation Tutorial with 3DS Max"},"content":{"rendered":"<p>This is a short tutorial detailing the steps needed to create a visibility animation with 3DS Max, by adding a visibility track. This is the easiest way I have found to do this, and is perfect for animating muzzle flashes in particular, as well as any kind of relatively simple animation where a mesh or meshes needs to have it&#8217;s visibility changed during an animation. I am writing this tutorial with a focus on 3d gaming, but the same techniques could be applied to an 3d scene or animation.<\/p>\n<p>First, the mesh itself. I am animating a laser fence here, and I want the player to be able to turn this on and off. I am going to add two animations, one to make the lasers change from visible to invisible, and one to make them change from invisible to visible.<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_48-Jun.-07-21.00.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_48 Jun. 07 21.00\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_48-Jun.-07-21.00-300x163.jpg\" width=\"300\" height=\"163\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The first thing to do is to hightlight only the mesh whose visibility you wish to animate. In this case, I selected just the laser beams of my mesh, and not the vertical support structures.<br \/>\nThen, click on the &#8220;Track View&#8221; Icon on the command bar, as shown:<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_46-Jun.-07-21.00-copy.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-637\" alt=\"ScreenHunter_46 Jun. 07 21.00 copy\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_46-Jun.-07-21.00-copy-300x163.png\" width=\"300\" height=\"163\" srcset=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_46-Jun.-07-21.00-copy-300x163.png 300w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_46-Jun.-07-21.00-copy-1024x558.png 1024w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_46-Jun.-07-21.00-copy.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Inside the curve editor you will need to make sure that the mesh you wish to animate is selected on the left hand side of the menu.<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_38-Jun.-07-20.51.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_38 Jun. 07 20.51\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_38-Jun.-07-20.51-300x82.jpg\" width=\"300\" height=\"162\" \/><\/a><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_39-Jun.-07-20.51.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_39 Jun. 07 20.51\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_39-Jun.-07-20.51-300x125.jpg\" width=\"300\" height=\"125\" \/><\/a><\/p>\n<p>Then, to add a visibility track, on the command bar, go to Tracks &gt; Visibility Track &gt; Add<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_42-Jun.-07-20.54.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_42 Jun. 07 20.54\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_42-Jun.-07-20.54-300x125.jpg\" width=\"300\" height=\"125\" \/><\/a><\/p>\n<p>You may now animate the visibility of this mesh by using the screen on the right. The numbers a long the bottom are the frames of the animation, and the numbers on the left are the visibility values. By Right clicking on the timeline, and clicking &#8220;add keys&#8221; you create keys. You can then drag these keys and use them to determine the visibility settings at each frame, like I have done here:<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_44-Jun.-07-21.00.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_44 Jun. 07 21.00\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_44-Jun.-07-21.00-300x125.jpg\" width=\"300\" height=\"125\" \/><\/a><\/p>\n<p>This screen shot shows that at frame 0 (The beginning of the ainmation) the visibility is 20. The visibility then fades to -1 at frame 15, before rising again to 20 at frame 30. This means that the mesh will change from visible to invisible and back again over that 30 frame period. I have not been able to make the ainmation fade seamlessly through the frames, it seems to be 100% visible as long as the visiblity value is above 0, and then instantly becomes invisible when it drops below 0.<\/p>\n<p>In T3D, I can split these 30 frames into two separate ainmations, like so:<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>function LaserFenceDAE::onLoad(%this)<br \/>\n{<\/p>\n<p>%this.addSequence(&#8220;ambient&#8221;, &#8220;turnoff&#8221;, &#8220;0&#8221;, &#8220;15&#8221;, &#8220;1&#8221;, &#8220;0&#8221;);<br \/>\n%this.addSequence(&#8220;ambient&#8221;, &#8220;turnon&#8221;, &#8220;15&#8221;, &#8220;30&#8221;, &#8220;1&#8221;, &#8220;0&#8221;);<br \/>\n%this.removesequence(&#8220;ambient&#8221;);<\/p>\n<p>%this.setSequenceCyclic(&#8220;turnoff&#8221;, &#8220;0&#8221;);<br \/>\n%this.setSequenceCyclic(&#8220;turnon&#8221;, &#8220;0&#8221;);<\/p>\n<p>}<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>This splits the default &#8220;ambient&#8221; ainmation into two animations of 15 frames each, a &#8220;turnoff&#8221; ainmation, which stops at frame 15, and a &#8220;turnon&#8221; animation, which starts at frame 15 and continues to frame 30.<\/p>\n<p>This code is placed in the .cs file that is automatically created when a new art asset is added to the level, and the name of the function must match the name of the art asset, like so:<\/p>\n<blockquote><p>\nsingleton TSShapeConstructor(LaserFenceDAE)<br \/>\n{<br \/>\nbaseShape = &#8220;.\/LaserFence.DAE&#8221;;<br \/>\nmatNamePrefix = &#8220;laserfence&#8221;;<br \/>\nloadLights = &#8220;0&#8221;;<br \/>\n};<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>You should now be able to preview this visibility ainmation in 3dsmax. Notice however that insible meshes do not show as completly invisible in max, they just look transparent, like so:<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_47-Jun.-07-21.00.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_47 Jun. 07 21.00\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_47-Jun.-07-21.00-300x163.jpg\" width=\"300\" height=\"163\" \/><\/a><\/p>\n<p>Rendering the scene will show the mesh as completely invisble.<\/p>\n<p>Now all that is left is to export the mesh to T3D.<\/p>\n<p>Select all of the components of the mesh, and go to Export &gt; Export Selected.<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_49-Jun.-07-21.00.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-624\" alt=\"ScreenHunter_49 Jun. 07 21.00\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_49-Jun.-07-21.00-247x300.jpg\" width=\"247\" height=\"300\" srcset=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_49-Jun.-07-21.00-247x300.jpg 247w, https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_49-Jun.-07-21.00.jpg 424w\" sizes=\"(max-width: 247px) 100vw, 247px\" \/><\/a><\/p>\n<p>Choose a filename and location, and you will then be presented with the export dialog:<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_51-Jun.-07-21.01.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_51 Jun. 07 21.01\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_51-Jun.-07-21.01-300x225.jpg\" width=\"300\" height=\"225\" \/><\/a><\/p>\n<p>This is quite simple, and the default values are mostly fine, however, you will need to select the checkbox for &#8220;Animation&#8221;\u00a0 under the &#8220;Ainmation&#8221; heading. You will also need to select &#8220;Bake Ainmation&#8221; under &#8220;Bake Animation&#8221; and make sure tha the Start and End values are set to the actual start and end of your animation (not just the length of the animation bar in max).<\/p>\n<p>This is how the laser fence looks in game:<\/p>\n<p><a href=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_35-Jun.-07-03.40.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"ScreenHunter_35 Jun. 07 03.40\" src=\"https:\/\/phoenixgamedevelopment.com\/blog\/wp-content\/uploads\/2014\/06\/ScreenHunter_35-Jun.-07-03.40-300x232.jpg\" width=\"300\" height=\"232\" \/><\/a><\/p>\n<p>This is a short video showing the animation:<\/p>\n<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/NpI6HLCEsIg\" height=\"315\" width=\"420\" allowfullscreen=\"\" frameborder=\"0\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a short tutorial detailing the steps needed to create a visibility animation with 3DS Max, by adding a visibility track. This is the easiest way I have found to do this, and is perfect for animating muzzle flashes in particular, as well as any kind of relatively simple animation where a mesh or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,12],"tags":[],"class_list":["post-622","post","type-post","status-publish","format-standard","hentry","category-on-game-development","category-tutorials","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"aioseo_notices":[],"builder_content":"","_links":{"self":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/622"}],"collection":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/comments?post=622"}],"version-history":[{"count":3,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":640,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/posts\/622\/revisions\/640"}],"wp:attachment":[{"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phoenixgamedevelopment.com\/blog\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}