`QUICK JUMP:`
## BUILDING RAGDOLLS for the Newton SDK DBPro wrapper by Walaber
## SETTING UP THE MODEL
The setup of the bones in the model is the most important part of making a working ragdoll. As you learned in the previous step, all bones are aligned along their local x-axis. In this part of the tutorial, we'll see how to do this in Character FX, a cheap but powerfull character animation program. However this can probably be done in most other full-featured modelling programs. However, I do not think it's possible in Milkshape alone, because the program does not give you complete control over bone rotation. if someone knows a way to setup bones in Milkshape like mentioned here, please let me know. Okay, open Character FX, and import your model. I model in Milkshape, so I exported my model as a Milkshape ASCII file. Here's how it looks in Character FX (no texture yet): As you can see, we'll be making a ragdoll out of a monkey stuffed-animal. why? Why not? I wanted to do something different than the standard human model, and a monkey's long arms and legs seemed like a prefect fit for a ragdoll demo! The first important step is to make sure Character FX is set up to work in local coordinates. Click the window next to the new/open/save buttons, and select "local":
## ADDING THE ROOT BONE
Okay, now we're ready to add our first bone. Click the Add Bone button: Then click somewhere near the origin to place the bone. It doesn't have to be perfect, we'll fix it in a second. Your screen should now look something like this (front view): As you can see, the origin of our model is somewhere in the Monkey's stomach. This is a problem because the Newton wrapper will use the location and rotation of the root bone to position and rotate the main model. In this case, we want the root bone to be at the bottom of the Monkey's body, which will eventually be made up of 2 bones. So I went back to Milkshape, and re-aligned the monkey. Then I re-imported into Character FX, and added the first bone, near the origin. Now it looks like this (perspective view): Next we need to align the root bone exactly on the origin. To do this we'll manually enter values. select the root bone, and right click on the "tool options" button. A small information window will pop up as shown below: We can see that the root bone is slightly off from the origin. Take a note of these numbers, because we'll need them in a second.
`X` | `-0.13800`
`Y` | `2.34000`
`Z` | `0.00000`
Now right click on the Move button, and select the move tab. then enter the values above, switching the plus/minus sign, to move the bone back to the origin: Select Translate to move the bone. it should now be exactly on the origin. You can check by again right-clicking the options button, and confirming the position of the bone. You may notice that our bone's x-axis is currently facing off to the side of the model. If we were to leave it this way, Newton would build the bone coming from the origin off along this axis. But we want to bone pointing straight up. So right-click the rotate button, and enter a value of -90 into the Z-axis box: Note you could rotate the bone by hand, but for simple rotations I find it easier and more accurate to fill in numbers. Make sure you press Rotate to actually rotate the bone. Your model should now look something like this: It has a single bone, pointing directly up, placed at the origin of the model. This is your root bone.
## ADDING THE OTHER BONES
I've decided to make the main body out of 2 bones, so now let's add another bone mid-way up the body. Directly after you add the bone, it should look something like this: Notice that the bone is not exactly straight Using the same technique as above, find the bone's offset by right-clicking on the tool options button. Notice that now the X value represents the distance UP, Y represents left/right, and Z represents in/out. This is because these numbers are based on the coordinte system of the parent bone. Adjust the bone until only the X value is positive, and the Y and Z values are zero. Now it should look something like this: . This bone needs no rotation because it's going in the same direction as it's parent bone. Now add another bone at the base of the neck. Align it as well, so it has no Y and Z offset. Now your model will look something like this (the middle bone is selected in this screenshot): Okay, that was pretty easy. Now let's ignore the head for a second, and move on to the arms, because they are a little more complicated. First select the middle bone, as this will be the parent for the arm bones. Remember, the pivot for a bone represents one end of the bone. so the middle bone here actually represents the bone that goes from the mid-stomach up to the bottom of the neck. This is basically the monnkey's chest, so it should be the parent for the arms. Add a bone somewhere around the shoulder. After added your monkey should look like this: Notice that the bone maintains the rotation orientation of its parent. If left like this, Newton would define the arm as also pointing straight up! So let's rotate the bone so it's pointing in the right direction. I've made it easy with this monkey model, as the arms point straight out at a 90 degree angle from the body. So again right click on the rotate tool, and add a rotation to the Z-axis of the bone of 90 degrees: Okay! Now we're all set. Normally a human model would only have 2 bones for the arm, but since this is supposed to be a stuffed animal, I'm going to make 3 bones down the length of the arm. Go along adding bones, using the techniques above to make sure that the bones are have no Y or Z offset. Here's the completed arm, including a joint for the hand: Again note that all bones in the arm have their X-axis pointing in the direction of the arm. Now repeat your work to replicate the skeleton on the other arm. You can use the offsets from the first arm to make the 2nd arm exactly the same (in terms of bone size). Now your monkey should look like this: Now we're getting somewhere! Finall take your time and build the rest of the skeleton for the monkey. I have chosen to break the head into 2 pieces to greater reflect the object geometry, and also allow the head to flex a little (like a stuffed animal really would). Also for fun I added bones for each ear as well. The legs are created in a similar manner as the arms, paying careful attention to make sure the X-axis is pointing directly down the leg. You can make use of the prespective view to get this part exactly right. Finally, the model should look like this: Looks pretty good, right? Just for one final check, select all of the bones in our model, and confirm that the X-axis (the red one) is pointing in the direction of each indiviual bone: And there you go! Your model is all set! The last step is to assign the vertices to the appropriate bones. And finally, make sure you build an animation with at least 2 keyframes (they can both be the defaut pose of the model) before exporting. Dark Basic won't let you manually adjust the limbs (which of course the wrapper does when posing the ragdoll) unless the object has an animation. NOTE: CharacterFX seems to be a "right-handed" program, where DBPRO is "left-handed". This means the Z values are reversed when going between programs. This can cause a problem, because if you use the direct rotational values provided by CharacterFX in DBPro, you will end up with a ragdoll skeleton facing the opposite direction of the model! the solution is to export your model "right-handed" with a program like Milkshape.
`QUICK JUMP:`