PGD Home

Visibility Animation Tutorial with 3DS Max

by on Jun.09, 2014, under On Game Development, Tutorials

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’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.

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.

ScreenHunter_48 Jun. 07 21.00

 

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.
Then, click on the “Track View” Icon on the command bar, as shown:

ScreenHunter_46 Jun. 07 21.00 copy

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.

ScreenHunter_38 Jun. 07 20.51ScreenHunter_39 Jun. 07 20.51

Then, to add a visibility track, on the command bar, go to Tracks > Visibility Track > Add

ScreenHunter_42 Jun. 07 20.54

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 “add keys” 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:

ScreenHunter_44 Jun. 07 21.00

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.

In T3D, I can split these 30 frames into two separate ainmations, like so:

 

function LaserFenceDAE::onLoad(%this)
{

%this.addSequence(“ambient”, “turnoff”, “0”, “15”, “1”, “0”);
%this.addSequence(“ambient”, “turnon”, “15”, “30”, “1”, “0”);
%this.removesequence(“ambient”);

%this.setSequenceCyclic(“turnoff”, “0”);
%this.setSequenceCyclic(“turnon”, “0”);

}

 

This splits the default “ambient” ainmation into two animations of 15 frames each, a “turnoff” ainmation, which stops at frame 15, and a “turnon” animation, which starts at frame 15 and continues to frame 30.

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:

singleton TSShapeConstructor(LaserFenceDAE)
{
baseShape = “./LaserFence.DAE”;
matNamePrefix = “laserfence”;
loadLights = “0”;
};

 

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:

ScreenHunter_47 Jun. 07 21.00

Rendering the scene will show the mesh as completely invisble.

Now all that is left is to export the mesh to T3D.

Select all of the components of the mesh, and go to Export > Export Selected.

ScreenHunter_49 Jun. 07 21.00

Choose a filename and location, and you will then be presented with the export dialog:

ScreenHunter_51 Jun. 07 21.01

This is quite simple, and the default values are mostly fine, however, you will need to select the checkbox for “Animation”  under the “Ainmation” heading. You will also need to select “Bake Ainmation” under “Bake Animation” 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).

This is how the laser fence looks in game:

ScreenHunter_35 Jun. 07 03.40

This is a short video showing the animation:

Facebooktwitterredditpinterestlinkedinmail

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!