Tutorial 02: Creating main actor

What you learn in this tutorial

  1. How to create simple 3D figure in 3D Studio Max
  2. How to rig and animate basic walk cycle and standing animation
  3. How to create new actor in Dage
  4. How to adjust the settings of actor in Dage

Introduction

This tutorial assumes you have a copy of 3D Studio Max installed in your system, and you have either finished the Tutorial 01: Creating your first room or downloaded Starting Tutorial File and extracted it to folder, which we refer with (Dage)\

Also these tutorials assumes you have basic knowledge how to find things in 3D Studio Max, like property editor, material editor, etc.

In case you are using Blender, you might want to follow this tutorial side by side How to Export SMD from Blender to Dage

Getting SMD exporter

As Dage has only support to SMD (Half Life) actor format, we must first get the SMD Exporter to 3D Studio Max. For Max relases 9, 2008 and 2009 you can find it from here: http://www.wunderboy.org/sourceapps.php#max9_smd See inside the zip file how to install the plugin to your Max system.

Creating the actor model

Reset Max.

I assume you know how to do this, but for this actor I created 6 spheres, one for head, one for body and two for hands and two for feet.

Foot spheres are sliced from -90 to 90 degrees so that they doesn't hit the ground. Let's make a deal that Z=0 axe is our ground here.

Also make sure all spheres have Real-World Map Size unchecked.

Press 'M' to go into material editor.

Create new Standard Material and change the Diffuse color to Bright Green and apply it to all spheres. We must specify a texture for our actor, or else the model will not be exported.

Go to (Dage)\data\ folder and click Create New Folder. Give this name MainActor.

So go to your favourite Image editor and create an image sized 32×32 and fill it bright green color (we will change this later) and save it in (Dage)\data\MainActor\ folder as mainTM.jpg.

Set the Diffuse slot in material editor inside 3dsmax to our newly created image. From this point on, I assume you remember to always check the Use Real-World Scale and tilings appropriate.

Exporting model to Dage

Go to File - Export. Choose (Dage)\data\MainActor folder from Save in.

Make sure Save as type is Source SMD (*.SMD) and set File name to 'Bobby.smd'. Click OK.

Next 3D Studio Max asks if you want to export basemesh or animation mesh. We want to export basemesh, so we choose Export Reference SMD. Make sure nothing is checked and click OK.

If everything went fine, Dialog says Export complete! Click OK.

Now exporting is done, and we are ready to load the model to Dage.

Loading our actor

Open onGameLoad.txt script file.

First we need to tell Dage that we want to create a new actor.

Write inside textfile before line Room01.Load() following lines:

MainActor = TActor.Create();
MainActor.LoadBaseMesh('MainActor/Bobby.smd');

This will tell Dage to create new Actor and load it's base mesh the file we created.

Save the file and go to the (Dage)\ folder and execute dage.exe.

We see something big falling through floor. Not how this is supposed to be!

First we fix the scale issue. We can either do this inside Max and scale the mesh, or do it in Dage. We do now this in Dage.

Add these lines before Room01.Load.

MainActor.SetMeshScale(0.1,0.1,0.1);

Save and execute.

Okay now something smaller went through floor. This happens because Dage doesn't know where our actor is allowed to walk!

Write this line right after Room01.Filename = 'Room01/Room01.3ds';

Room01.Walkarea = 'Room01/Room01.3ds';

Now we made it so that Dage uses same mesh to determine where actor can walk. We tell more about this in future tutorials.

Save and execute.

Okay now we see our little buddy Bobby! Notice: You could change light position if it happened to be inside the actor. I changed the position to SetPosition(0,50,0) and this is how it looked.

Note: If your character stays mid-air and falls through ground after minute or so. Don't panic. We fix this next.

Point&Click Walking

Next we want to control our character with mouse.

Write the following line before loading room.

MainActor.MouseControl = 1;

This tells Dage that we want to control MainActor with mouse. Point&click!

Note: Even though you can define two actors with MouseControl = 1, it causes both actors trying to walk simultaneously to the same target. We recommend if you want to have multiple controllable characters, use the MouseControl with one at a time.

From now on, I assume you remember to save and execute after doing adjustments.

Hmm.. Actor seems to rotate to right direction, but certainly not moving anywhere.

This is because we haven't set up properly the collision sphere for our actor.

Dage uses sphere to detect fast collision with environment (with Walkarea model).

Currently our sphere is very small, and probably inside the mesh. So lets position the actor little higher, so that the collision sphere is certainly not inside our mesh.

MainActor.Y = 1.5;

You can press F6 to debug our collision sphere.

Now when you click around, actor first turns and then slides to new spot. You can actually make the actor fall off the edge if you want. We will fix this in later tutorials.

We have 5 properties which we can use to control how our actor is walking. I found these values experimentally that determines where we can walk.

MainActor.WalkingSpeed = 75; -- How fast are we walking
MainActor.TargetDistanceStopWalk = 1; -- How close to target we should try to get
MainActor.TurnInsteadWalkDistance = 3; -- If target is closer than this, turn before walking.
MainActor.TurningTargetAngle = 10; -- If angle between walking direction and target is smaller than this, turn before walking
MainActor.maxWalkingTurnAngle = 190; -- How much actor can turn during walking.

Okay once your walking looks good, we should animate the actor to walk instead of sliding.

Rigging our character with Character Studio

Go to Create tab and select Systems. Click Biped and Create it by drag-drop in front viewport. Make it look like I have in picture.

Select some Biped bone and go to Motion Panel in Command Panel.

Click Figure Mode. (The little black guy next to footsteps in Biped rollout)

Select Bip01.

Transfer it so that it is somehow middle of our model and it's feets are touching the ground.

Go to structure rollout and Adjust Spine Links to 1 and fingers to 0, as Bobby doesn't have any Fingers.

Then select arms, legs and head and transform-rotate-scale them so that they look like the following picture.

Click the Figure Mode again to exit from the mode.

Select all the Spheres and from Right click menu, choose Convert to Editable Poly.

From modify panel seek Edit Geometry panel and click Attach button. Select all the spheres. This way we make the model to be unified. Once done, click the attach button again to end Attaching mode.

Select Physique modifier from list and click the little black figure (Attach to node) from Physique rollout.

Select Root Bibed object.

Just click Initialize.

Next we must adjust our envelopes to fit our spheres correctly.

Adjusting Envelopes

With our model selected, change mode to Vertex. Click Select button, then select all vertices in left hand sphere.

Click Assign to Link and choose the nearest bone.

Repeat this to the feet, right hand and head and spine bones.

Once done, exit the Vertex mode and try to rotate bones around. If everything is following the bones correctly you are done.

You can use Remove from link and click all the other links so no other bone is affecting the wrong vertexes.

Save the scene!

From this point on, if you need to adjust the bones or change anything to your actor, you need to redo all animations!

Creating Basic Walking cycle

Select one biped bone and go to Motion panel.

Click the footstep mode. And Create Multiple Footsteps.

From the dialog, adjust Number of Footsteps = 10.

Click OK.

Click Create Keys for Inactive Footsteps from Footstep Operations rollout.

You can play and view the animation.

Click Modes and Display inside Biped rollout and click “In Place Mode” in Modes. This makes the model to walk still, as we do not want translation in Dage.

Exit footstep mode.

If you need to do adjustments to Biped, do it now. For me, the hands are colliding with the body sphere, so I need to adjust them. Is scaled the Clavicles to larger in Figure mode.

Now once we have made adjustments to basemesh (added skeleton) we need to export it again. So export Bobby.smd file as we did last time.

Exporting animation to Dage

Select all.

Look from Trackbar where the feet are about the same phase. For me, it was in frame 54.

Then find the Frame where the feet are in same phase next time. For me, it was in frame 84.

Keep these numbers in mind!

Go to File-Export and this time create new file called walking.smd. This is where Dage automatically finds the walking animation to be.

From Export dialog, this time choose Export Sequence SMD (we want only to export bone animation) and from Export Range set your numbers. Mine was 54 to 84.

Click OK twice.

Now we need to load the animation to Dage Actor. So open onGameLoad.txt.

MainActor.AddAnimation('MainActor/walking.smd');

Now let's test how things look like. Okay when Bobby is walking, it surely look like walking. But it doesn't know what else to do!

We must define standing.smd so Dage know what to do when we are still. Now it thinks we only have to walk around!

Creating standing animation

Save 3ds max scene as Bobby_Walking.max.

Resave as Bobby_Standing.max.

Select All.

Delete all keys expect from frame 0 in Trackbar.

Export this as standing.SMD and choose Export Sequence SMD and Export Range 0 to 1.

Again we need to load the animation to Dage Actor. So open onGameLoad.txt.

MainActor.AddAnimation('MainActor/standing.smd');

Execute Dage and see the result.

Back to top
tutorial02/start.txt · Last modified: 2010/01/05 18:58 by rahakasvi