Silgrad Tower from the Ashes

Full Version: 3ds Max simple animation tutorial
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
[Title]3ds Max Simple Animation Tutorial by nick_op and Razorwing[/Title]

In this tutorial I will demonstrate how to prepare a scene for, create and export a simple animation using 3D Studio Studio Max. This tutorial should work for any version of Max which is supported by the NifTools plugin. The locations of buttons varies slightly from version to version.

This tutorial will not demonstrate how to model, UVW map or create textures, and it assumes you have a basic understanding of 3D Studio Max. There are other tutorials out there that covers the basics of modelling. Collision is mentioned in this tutorial, but only how to set it up for animations.

However, this tutorial also assumes that you have no knowledge of animation within 3ds Max, so beginnners should find it as useful as more experienced animators.

[Title]Things you'll need[/Title]
  • A copy of 3ds Max that is supported by the NifTools plugin
  • The latest version of Nifskope and the 3d Studio Max plugin, found at NifTools.
  • Optional but recommended If you use Max vesion 6, 7 or 8, download the Civ IV exporter found here.
[Title]Preparing the model[/Title]
- Download the tutorial scenes
The preparation for the tutorial model has already been done, and we'll start from Step 01.max.

If you're preparing another model, move it to the correct place and reset it's XForm (Utilities panel > Reset XForm > Reset Selected). If you want the model to rotate you will also need to adjust it's pivot point to the position you want it to rotate around.

[Image: th_screenshot01.jpg]


[Title]Scene Root[/Title]
We're going to start off by creating an object known as a Bone, which is found on the Systems tab of the Create panel.

[Image: th_screenshot02.jpg]

Press the Bones button, and you'll see a bunch of new options appear in the panel. Ignore these, as they don't matter for this kind of animation. Instead, with the Bones button pressed down, left-click anywhere in the viewport. Now you'll see a diamond-shaped object appear in your scene, which rotates as you move your cursor. Left-click again to create the Bone, and then right-click to end the chain. As you can see, a secondary Bone (referred to as a 'nub') has been attached to your first Bone. Press the Delete key to get rid of the nub, as you only want one Bone in the chain.

Move the Bone to origin (X0 Y0 Z0), and set it's rotation to X0 Y0 Z0. This is important in order to avoid export issues later on. Name the Bone Scene Root.

Now we're going to create a hierarchy of objects by linking all the objects in the scene to the Scene Root Bone we just created, thereby making them what's referred to as 'children' of that Bone. Do as follows.

Press the H key to get a list of objects in your scene. Select them in the list, then click the Select button. Now depress the Select and Link button on the main toolbar, shown in the screenshot below. Move your cursor over your selected objects and you'll notice the icon changes to look like two hollow squares with a white square in the middle, indicating that Select and Link is active. Left-click-and-hold, then move your cursor over the Bone object. (Your cursor will then change to look like the bottom left square is filled in with white color.) Release your left mouse button, and the objects are linked.

TIP. Don't forget to unpress the Select and Link button after this, otherwise you won't be able to work like usual. Do so by just activating another selection tool in the main toolbar.

[Image: th_screenshot03a.jpg]

The screenshot shows where the Select and Link button is, and what the heirachy of objects should look like after you have linked them. If you don't see them, make sure display subtree is ticked. If it doesn't look right on your end, select all the objects in your scene and press the Unlink Selection button, located directly to the right of the Select and Link button, and try again. The tutorial scene Step 02a.max has the changes made so far.

[Title]Animation Decisions[/Title]
Now we need to decide how we want the object to be animated.

It's possible to give two parts of your model the exact same animation, by making an additional Bone and then linking the model parts to it just like you linked everything to your Scene Root Bone. Screenshot #3b shows how the hierarchy should look after doing that, and Step 2b.max has a practical example of it.

However to keep things simple in the main tutorial we're going to use one animation for one model part. Originally the lever was two model parts, one for the shaft and one for the cap, but they were attached to one another to act as one model part. (In other words, when we export the model later on the lever will be made up of two NiTriStrips.)

[Title]Animating[/Title]
Now on to the fun part - animating the lever!

You always begin work on animation in the Time Configuration menu, which is located at the bottom of the screen and looks like a square with a clock on it. Oblivion animations use a frame rate of 30 FPS (NTSC). For the lever we set the animation length to 180, which equals six seconds.

[Image: th_screenshot04.jpg]

Now you need to set some dummy keys at the beginning and end of the animation. You can change the frame by dragging the slider above the animation track. You only need to set these on the parts of the model that are going to be animated, which in this case is the model part named "Lever". Make sure the frame slider is at frame zero, and press the Set Keys button (the button at the bottom of the screen with a key on it). Then slide it forward to frame 90 and press the button again, and lastly a third time at the end, which is frame 180.

[Image: th_screenshot05.jpg]

When you get more comfortable with animation you can use the Auto Key button, which sets keys automatically to a frame when you make a change to the model part (or bone) that you're animating. For this animation we only need three keys.

With "Lever" still selected, move the frame slider to frame 90. Click on the Motion panel, and make sure the Parameters rollout is active. We want to rotate "Lever", so make sure the Rotation button is depressed. Then press on the X button, as we want "Lever" to rotate on that axis. In the box called Value, enter 90 and hit return.

Now drag the slider back and forth along the track and see what's happening. As you'll notice, the first 90 frames will constitute a Forward animation and the last 90 frames will constitue a Backward animation. The tutorial scene Step 03.max has the changes made so far.

[Image: th_screenshot06.jpg]

[Title]Animation Curve[/Title]

Click on the Play Animation button in the lower right of the screen, and pay attention to how the animation behaves when it is near either side of frame 90. (You may need to adjust the playing speed on the Time Configuration menu to really notice it.) As you can see, "Lever" slows down as it nears frame 90 and is similarly slow to start after frame 90. This is because the tangents are set to smooth. That's a good idea in usual animation, because it makes the movements more fluid, but in this type of animation it just looks weird. So we're going to change the tangents from smooth to linear.

Make sure you still have "Lever" selected in the viewport. Then open the curve editor by choosing "Graph Editors > Track View - Curve Editor..." in the main menu. In the left window you'll see a breakdown of your scene, which looks not unlike windows explorer. It looks complicated when you first view it, but don't let that deter you.
Unroll thusly: Objects > Scene Root > Lever > Transform > Rotation > X Rotation.
Objects contain everything in your scene.
Scene Root is the Bone we created.
Lever is the model part we animated.
Transform is what we're doing to the model.
Rotation is the transform we chose.
X Rotation is the angle we chose.

Now you should see a curve in the right window looking something along the lines of a hill. In the right window, left-click-and-hold and then drag out a selection to cover all three keys. Then click on the Set Tangents to Linear button, and the curve will change to look like an upside-down V. That's all there's to it, the animation will move at a constant speed. Now close the curve editor.

[Image: th_screenshot07.jpg]

[Title]Collision[/Title]
Next we will look at collision. It's a really good idea to use primitives for any type of animated model part, though collision of any static part of a model should be MOPP. Collision is a beast of it's own, but if you're considering animating models then we'll assume you already know how to set that up. There are a few special items of interest worth mentioning though.

You want to use one bhkRigidBody for the static part of the model and one bhkRigidBody for each animated part. In the tutorial example we created a rigid body with Static layer property, which is used by "LeverBox", and another rigid body with AnimStatic layer property which is used by "Lever".

For animated collision there are certain settings in the rigid body that differ from static objects. These are:
  • Layer must be set to AnimStatic
  • Motion System should be set to 6:Keyframed
  • Quality Type should be set to 2:Keyframed
  • Allow Transforms should be ticked

[Image: th_screenshot08.jpg]

Link the Static bhkRigidBody - the one that has the MOPP shape - to the Scene Root bone. Like before, this is done with the Select and Link tool. Then link the capsule primitive's bhkRigidBody to "Lever".

If you move the frame slider back and forth you'll notice that the collision model doesn't move with the animation. This is perfectly fine and won't affect the collision's movement in the finished nif.

The screenshot below shows how the hierarchy should look after you're finished. You might think it looks strange to leave the two collision models outside the hierarchy, but keep in mind that the exporter will sort the hierarchy of those models automatically. The tutorial scene Step 04.max has the changes made so far.

[Image: th_screenshot09.jpg]

[Title]Setting Up for Export - Civ IV[/Title]
There are two methods to set up an animation for export, depending on whether your version of Max supports the Civ IV plugin or not. First we are going to look at the method used with the Civ IV plugin. If you cannot use the Civ IV plugin, skip ahead to the next section.

On the Utilities panel, click the MAXScript button. Select the Civ IV Animation Manager script in the drop-down list. It looks pre-selected, but it isn't; you have to open the list and select it for it to activate. Scroll down until you see a lined box named Actor. Click the Add button just below the drop-down list. After that, press the H key and select the Scene Root Bone in the selection list.

Now scroll down to the lined box named Sequence. In the textbox called 'Active Sequence Name', delete the pre-written name and instead write Forward. Loop Sequence should be left unticked. The number in the Start Frame box should be 0. In the box named End Frame, write 90.

Now click 'Append New Sequence'. In the 'Active Sequence Name' box, delete the pre-written text and instead write Backward. Untick Loop Sequence. Set the start frame to 91 and the end frame to 180. This is all that needs to be done. The tutorial scene Step 05.max has the changes made so far.

[Image: th_screenshot10.jpg]

A list of active sequence names you can use can be found here.

[Title]Setting Up for Export - NifTools[/Title]
If you are able to use the Civ IV exporter, please follow the previous part of the tutorial. This section is for people that cannot use the NifTools exporter.

Since the NifTools exporter does not have an animation manager, we are going to have to use a different methos to enter the necessary data. Open up the Curve Editor and choose modes->Dope Sheet. Expand the Scene Root in the list so that the 'notes' tranck appears.

At frame 0, create a note and right click on it. Type in 'start -name Forward'. At frame 90 create a note and type in 'end'. At frame 91 create a frame and type in 'start -name Backward'. At frame 180 create a note and type in 'end'.

There are other things you can add into the notes. If you want an animation to loop, add '-loop' in with the 'start' note.

Example of the dope sheet:
[Image: th_screenshot11.jpg]

[Title]Exporting the animation[/Title]
Now that we have the animation ready, it's time to export.

Bring up the NifTool export dialogue. There are several important setting that differ from exporting a static model. (See below for an example of export settings.) The most important ones are NIF w/ Manager and Add Accum nodes. The other can vary, but the screenshot shows the settings used for this animation.

[Image: th_screenshot12.jpg]

[Title]NifSkopery[/Title]
There are a few important things that need to be done to the model in order for it to work in-game.

"Lever Nif v1.nif" is the nif freshly exported from 3D Studio Max.

First of all, since you used 3D Studio Max you should run amorilia's nifoptimizer script on your nif to get rid of junk faces. See the PyFFI site for download, and check out Razorwing's Guide for an in-depth explanation of why you should use it. "Lever Nif v2.nif" is after amorilia's script has processed it.

Then open the mesh in NifSkope. The first thing you'll notice is that there are 2 Scene Root nodes. Right-click on the 0 NiNode and chose Block > Remove. Now we're going to make the remaining Scene Root node the root. In the Block Details for it, find the line that reads Num Extra Data List. Change the value from 0 to 1, by doubleclicking the 0 and then replacing the number like usual. See the line Extra Data List just below it? Now right-click it, and chose Array > Update. You'll see a plus sign appear to the left of it. Click the plus sign to open the list, and in the rolled-out entry, replace None with the number assigned to the BSXFlags block.

Here are before- and after screenshots:
[Image: th_screenshot13a.jpg] [Image: th_screenshot13b.jpg]

Use the menu option Spells > Sanitize > Reorder Blocks to sort the blocks.

Notice how there are two junk NiNodes in the block list? They're called bhkRigidBody01 and bhkRigidBody02. As you've probably guessed already, they're there because we used Select and Link to link the helpers to the Scene Root Bone. The exporter seems to interpret these objects twice, both sorting them as real working bhkRigidBody blocks and as empty NiNodes. Delete these empty NiNodes (the ones numbered 44 and 45 in this screenshot). "Lever Nif v3.nif" has the changes so far.

In the main NiNode is a block called NiControllerManager. Unroll it and select the NiMultiTargetTransformController block. In the Block Details you'll see a line that reads "Extra Targets". Unroll the list by clicking the plus sign. You'll see two vacant spots in the list, which used to point to the empty NiNodes we deleted. Enter the numbers of the Scene Root and Scene Root NonAccum NiNodes in the vacant spots. This prevents errors from occuring in the CS.

[Image: th_screenshot14a.jpg] [Image: th_screenshot14b.jpg]

Depending on what model you exported you may need to adjust the number of extra targets; do so by entering the number of extra targets as the value of the "Num Extra Targets" line, then right-clicking on the Extra Targets list and choose Array > Update.

If you have vertex color on your model, don't forget to add NiVertexColorProperties to your NiTriStrips/NiTriShape blocks. It's done by right-clicking the block and choosing Node > Attach Property and then select NiVertexColorProperty in the popup list. Set Flags to 40, Vertex Mode to VERT_MODE_SRC_AMB_DIF and Lighting Mode to LIGHT_MODE_EMI_AMB_DIF. This prevents players with certain video cards from experiencing the black screen bug.

[strike]If you have NiTriStrips/NiTriShape blocks that don't use vertex colors, unroll the blocks and select the NiTriStripsData information. In the block details, ensure that "Has Vertex Colors" is set to No. To change it, just doubleclick on the word Yes/No. This will remove junk vertex color data.[/strike] This bug was fixed in v3.4 of the 3D Studio Max exporter.

You now have a functioning animated .nif, ready to be put in game. Enjoy!

"Lever Nif v4.nif" has the finished model.

[Title]Modding the magic[/Title]

Unless your model is intended to be a door object, it won't work on it's own. You need to set it up in the activator list in the Construction Set and write a script that controls its animations. Below is a base script that starts the forward animation the first time the player clicks it, and then starts the backward animation the second time the player clicks it.

Code:
scn AnimScript01

; Written by sandor from the Silgrad Tower team

short state
short activate

begin OnActivate

    if state == 0 && activate == 0

        playgroup forward 1
        set state to 1
        set activate to 1

    elseif state == 1 && activate == 2

        playgroup backward 1
        set state to 0
        set activate to 0
    endif

    If state == 1 && activate == 1
        set activate to 2
    endif

end

If you only have one animation, use this script instead.

Code:
scn SingleAnimScript

; Written by sandor from the Silgrad Tower team

short state

begin OnActivate

    if state == 0
        playgroup forward 1
        set state to 1
    endif

end


;Optional block if you want to reset the anim on the third day

begin onReset

    reset3DState
    set state to 0

end

[Title]Misc. Notes Regarding Animation[/Title]

A list of Active Sequence Names can be found here. There are certain Active Sequence Names that have special properties:
  • Idle will play the animation automatically, it does not have to be called from script.
  • Unequip will cause the object's havok to kick in. Traps are an example of this.

The NifTools exporter only exports linear keys at the moment. Any quadratic keys will be converted to linear upon export.

When looping an animation, when prepping for export, set the end frame to one less than the last frame of the animation. If you don't do this, you'll get a visible pause when the animation loops.

[Title]Credits[/Title]

Important: I'd like to apologise to all in this section. Due to a massive oversight I (nick_op) forgot to create the credits section, thus failing to acknowledge those who have helped along the way.

In particular, I'd like to apologize to SaidenStorm, who's techniques formed a huge part of my knowledge of Oblivion related animation. His tutorials can be found at his website (link).

Without further ado:

SaidenStorm for discovering a staggering amount about animation in Oblivion, and then creating some excellent tutorials to share it all. Finally, for answering so many of my questions over the last couple of years.
Razorwing for taking my original draft for the tutorial and turning it into something that's easy to understand.
SACarrow, tazpn, amorilia and the rest of the NifTools team for creating the 3ds Max plugin and NifSkope, both of which are used extensively in this tutorial.
sandor for providing the script used in the tutorial.
Koniption for sharing her knowledge about Oblivion animation with me, in particular the collision stuff that is present in this tutorial.
throttlekitty for sharing his knowledge, providing inspiration and being excellent company at #TESModdersDen and #Fallout3Modding IRC channels.
XMarksTheSpot for sharing his knowledge of animation, several 'outside the box' solutions to animation problems I've had and diagnosing mesh/animation issues for me on the #TESModdersDen IRC channel.

Edit 04/04/2009: Second script updated to be more efficient and stable. Big thanks to sandor.
Edit 26/10/2009: Added credits section.
I figured I should share something I discovered just now. I'm sure all other animators know it already, so it's only meant for beginners like me.

You can't use scale animation, only position and rotation. Tongue

I tried, and spent more time than I care to admit wondering why my nif looked invisible in Nifskope, until I realized scale animation might not be supported. And indeed it isn't. I think Oblivion supports it, because I can swear the roasted rat in the harvest containers mod used a scale animation (which I borrowed for the coinpurse I made awhile back). But I can use the animation types that are supported by the exporter for the model I'm making.
Quote:Originally posted by Razorwing
I figured I should share something I discovered just now. I'm sure all other animators know it already, so it's only meant for beginners like me.

You can't use scale animation, only position and rotation. Tongue
Allow me to clarify. Scale keys in animation are only half supported in Oblivion - there is never a 'base' scale set by the game, so if an animation gets interrupted the object will take it's current scale as it's new 'base' size.

I think with animated statics or activators you'd have to be trying pretty hard to encounter this problem, but with creatures it is unavoidable - just ask Steve about the growing Kwama Forager.

I first discovered this during my second attempt at animating the forager and had SaidenStorm confirm it. So yes, stay away from scaling in animations.

This doesn't mean you can't change the size of a mesh, however - morphs can be used to achieve the same thing, with non of the issues related to scaling.

Thanks for bringing this up Razorwing, the half-support for scaling is a little known fact about animation in Oblivion.
Quote:Originally posted by nick_op
This doesn't mean you can't change the size of a mesh, however - morphs can be used to achieve the same thing, with non of the issues related to scaling.

That sounds interesting. Do you know of a tutorial on the subject of morphs?

I checked out the harvest container but I didn't notice anything weird. Yet the animation clearly moves downward and at the same time scales down into nothingness. I attached a copy of it if you're interested in checking it out. The model is mine but the mechanics of the nif is all from the harvest containers mod, I just piggybacked my model on their nif.
Quote:Originally posted by Razorwing
That sounds interesting. Do you know of a tutorial on the subject of morphs?
There's SaidenStorm's tutorial here.

The gist of morphs is this:

1. Duplicate your mesh. Do not add to or delete any of it - it must have exactly the same amount of vertices plus the vertex index as the 'base' mesh. The base mesh is the mesh that you started with, the duplicate will become the morph target.

2. Set up the new mesh as a morph target. This is done by adding the 'Morpher' modifier to the base mesh.

3. Manipulate the vertices of the mesh to be as desired. Note that it must be the vertices that have changed - scaling the mesh while not in sub object mode will have no effect.

4. Turn autokey on and animate the percentage value of the morph target (found in the morpher modifier).

5. Export - Steve did a lot of work getting morph support in the NifTools exporter. It will pick up the morph automatically so no need to change settings. You might have to hide the morph target though.
Quote:I checked out the harvest container but I didn't notice anything weird. Yet the animation clearly moves downward and at the same time scales down into nothingness. I attached a copy of it if you're interested in checking it out. The model is mine but the mechanics of the nif is all from the harvest containers mod, I just piggybacked my model on their nif.
The animation didn't play in NifSkope, but scrubbing the time slider worked. It appears to be a rather odd way of making the mesh disappear, I'd personally have used a VisController to turn that part of the mesh on and off, or an AlphaController if I wanted it to fade.
Thanks for the link, and for the information you provided. I'll have to try that out next time I need to scale a model Smile

I think Harvest Containers use VisControllers for the most part. What attracted me to the roasted rat's way of doing it was that it looked so game-like, though as I discovered when I playtested the animation plays so fast that the effect goes to waste. Which was probably the idea, and it was probably like you said intended as a way to disappear the mesh rather than to add an effect.

The AlphaController sounds interesting. I'll investigate it later on and see if I can update my coinpurse model to use it. Smile
Ok this may be a silly question.
I'm working thru this tutorial and i'm starting the "collision" part.
The tutorial says
Quote:" It's a really good idea to use primitives for any type of animated model part, though collision of any static part of a model should be MOPP. Collision is a beast of it's own, but if you're considering animating models then we'll assume you already know how to set that up. There are a few special items of interest worth mentioning though."
What's MOPP?
Also, for my own meshes (statics), i've just been creating a simple mesh, naming it "collision", then using NifProps and ticking the box for "Is Collison Mesh".
Which is obviously very simple.
What am i missing regarding Collision being a beast of it's own?

Quote:"You want to use one bhkRigidBody for the static part of the model and one bhkRigidBody for each animated part."

Are these just meshes named like that?

Also, when i open the tutorial file: "Step 04.max", it seems i'm missing some plugins. FileName: NifPlugins.dlu Class: bhkRigidBody and bhkCapsule
Wonder am i using the correct version of Nif Plugins...
Quote:Originally posted by jman0war
What's MOPP?
It stands for Memory Optimised Partial Polytope. Basically, it's the most efficient type of collision that can be used, and should be used for most things (animated parts of a model are an exception, though).
Quote:Also, for my own meshes (statics), i've just been creating a simple mesh, naming it "collision", then using NifProps and ticking the box for "Is Collison Mesh".
Which is obviously very simple.
What am I missing regarding Collision being a beast of it's own?
NifProps is very outdated, as far as I know, so you should either used the bhkRigidBody modifier (for non primitives), or use the bhkRigidBody helper in combination with one of the NifTools collision shape helpers (for animted collision). You'll find the helpers in the create panel, under Helpers->NifTools.
Quote:Also, when I open the tutorial file: "Step 04.max", it seems i'm missing some plugins. FileName: NifPlugins.dlu Class: bhkRigidBody and bhkCapsule
Wonder am I using the correct version of Nif Plugins...
The latest version can be found here, on the NifTools forums.
Thanks for pointing that out.
Though i've still got questions.

My questions will have to wait however as niftools-max-plugins-3.5.5.4728 causes my 3d studio max to crash upon export as NIF.
I'm using Max v8 SP3.
I found niftools 3.1.2 crashes on export as well.
This is why i reverted to NifProps.
Quote:Originally posted by jman0war
My questions will have to wait however as niftools-max-plugins-3.5.5.4728 causes my 3d studio max to crash upon export as NIF.
You're probably best off posting over at the NifTools forums with your issue as they are more likely to be able to help.
Pages: 1 2 3 4