Game Development Community

dev|Pro Game Development Curriculum

4/6/8 wheel vehicle creation in Milkshape 3D

by Lloyd [Bleeptech] Godsey · 01/09/2004 (8:24 am) · 3 comments

NOTE: Last updated 01-08-2004 HTML version and example files are on the way.

"Construction of a multi wheel drive vehicle model for the Torque Game Engine in Milkshape"

Or

"How to go nuts trying to insert a wheeled vehicle into Tribes 2 in 4 easy lessons."


What this tutorial will do.
This tutorial is written to allow you to convert any basic 4 to 8
wheeled model to use with the Torque Game Engine.

What this tutorial will NOT do.
Teach you how to put a new wheeled vehicle in Tribes 2.
(I'm Sorry, I know it's a real bummer. But, It's a real pain in the A** with the way Tribes 2 does wheels.)
Teach you how to animate the springs or how to animate anything else.
Mow your lawn, Feed your cat, Bring World Peace..



Before you begin you will need the following software installed...

TorqueDemo 1.2
Milkshape 3D
ms2dtsExporter.dll



LESSON 1. Be Paranoid.

In the TorqueDemo directories find and backup the following files
car.cs
buggy.dts
wheel.dts
Also backup any other game files you modify just in case.


Open the file car.cs go to the bottom and locate

//-----------------------------------------------------------------------------

function WheeledVehicleData::onAdd(%this,%obj)
{
// Setup the car with some defaults tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
%obj.setWheelTire(%i,DefaultCarTire);
%obj.setWheelSpring(%i,DefaultCarSpring);
%obj.setWheelPowered(%i,false);
}

// Steer front tires
%obj.setWheelSteering(0,1);
%obj.setWheelSteering(1,1);

// Only power the two rear wheels...
%obj.setWheelPowered(2,true);
%obj.setWheelPowered(3,true);
}


//-----------------------------------------------------------------------------

and change it to read.

//-----------------------------------------------------------------------------

function WheeledVehicleData::onAdd(%this,%obj)
{
// Setup the car with some defaults tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
%obj.setWheelTire(%i,DefaultCarTire);
%obj.setWheelSpring(%i,DefaultCarSpring);
%obj.setWheelPowered(%i,false);
}

// This works for 4 to 8 wheels, It fails to load with 3 and only shows 8 with 10 installed.
// Steer front and rear tires
// %obj.setWheelSteering(HUB,DIR);
// HUB = hubX, DIR 1=normal 0=none -1=invert

%obj.setWheelSteering(0,1);
%obj.setWheelSteering(1,1);
%obj.setWheelSteering(2,0); // Comment this line out if the left middle wheel acts funny
%obj.setWheelSteering(3,0); // Comment this line out if the right middle wheel acts funny
%obj.setWheelSteering(4,-1);
%obj.setWheelSteering(5,-1);
// %obj.setWheelSteering(6,-1); //Placeholder for wheel 7
// %obj.setWheelSteering(7,-1); //Placeholder for wheel 8

// Power the all the wheels... :)
%obj.setWheelPowered(0,true);
%obj.setWheelPowered(1,true);
%obj.setWheelPowered(2,true);
%obj.setWheelPowered(3,true);
%obj.setWheelPowered(4,true);
%obj.setWheelPowered(5,true);
// %obj.setWheelPowered(6,true); //Placeholder for wheel 7
// %obj.setWheelPowered(7,true); //Placeholder for wheel 8

}



SAVE AND EXIT THE FILE.



LESSON 2. GET YOUR BONES

For a multi wheeled vehicle you want to create several sets of bones and joints.
These will be used as placeholders to replace the DUMMY object from 3DS-MAX.
This allows hub0[..]hub5, mount0[..]mount9, cam, eye and mass to be placed and work properly.


UNCHECK "AUTO TOOL" FOR THE FOLLOWING STEPS, IT DOES NOT WORK WITH JOINT.

Step 1: ADDING WHEEL MOUNT POINTS hub0[..]hubX

A. Select: MODEL>JOINT
Place a joint at the front center of the model,
(Place it where you want the center of the front suspension.)

Place another joint at the front left of the model.
(Place it where you want the center of the tire to be at the
top of the suspension travel.)

B. Select: MODEL>SELECT>by Joint
Click on an empty spot in a window to deselect the selected joint.
Click on the center joint to reselect it.

C. Select: MODEL>JOINT
Place another joint at the front right of the model.
(Place it where you want the center of the tire to be at the
top of the suspension travel.)

D. Select: JOINT
Click on joint1.
Enter "front" into the text box and hit Rename.
Click on joint2.
Enter "hub0" into the text box and hit Rename.
Click on joint3.
Enter "hub1" into the text box and hit Rename.


STEP 2: Repeat A,B,C & D for the next axle of the vehicle,
DO NOT CONNECT THESE TO THE FRONT AXLE BONE SET.
Rename "joint4" to "mid1"
Rename "joint5" to "hub2"
Rename "joint6" to "hub3"
If you are making a 4 wheeled vehicle
Rename "joint4" to "rear"
Jump to STEP 5


STEP 3: Repeat A,B,C & D for the next axle of the vehicle,
DO NOT CONNECT THESE TO THE FRONT OR MIDDLE AXLE BONE SETS.
Rename "joint7" to "mid2"
Rename "joint8" to "hub4"
Rename "joint9" to "hub5"
If you are making a 6 wheeled vehicle
Rename "joint7" to "rear"
Jump to STEP 5

STEP 4: Repeat A,B,C & D for the rear of the vehicle,
DO NOT CONNECT THESE TO THE FRONT OR MIDDLE AXLE BONE SETS.
Rename "joint10" to "rear"
Rename "joint11" to "hub4"
Rename "joint12" to "hub5"


STEP 5: Be Paranoid

Reset the 3D view where you can see all the bones and joints and click
on each joint name in the list to make sure that each bone set was created
from the center out (If you look carefully you will notice a taper in the
bone from the center joint to the tips)and that they are properly named thus.

PLACEMENT LEFT CENTER RIGHT

4 wheels
Front Axle "hub0" "front" "hub1"
Rear Axle "hub2" "rear" "hub3"

6 wheels
Front Axle "hub0" "front" "hub1"
Middle Axle "hub2" "mid1" "hub3"
Rear Axle "hub4" "rear" "hub5"

8 wheels
Front Axle "hub0" "front" "hub1"
Middle Axle "hub2" "mid1" "hub3"
Middle Axle2 "hub4" "mid2" "hub5"
Rear Axle "hub6" "rear" "hub7"

REMEMBER! The centers of the hubX joints are the top of the suspension travel.

SAVE THE FILE AS "test.ms3d"

Step 6: ADDING mass, cam, eye, mount0[..]mount9

A. Select: MODEL>JOINT
Place a joint at the mass center of the model. DO NOT CONNECT IT TO ANY OF
THE AXLE BONES
Rename it to "mass".

B. Select the "mass" joint and place another joint where you want the cam view.
Rename it to "cam".
Don't worry if you want it well away from the vehicle, just stretch the bone.

C. Select the "cam" joint and place another joint forward of it for an aiming handle.
Rename it to "cam-dir" so it is easy to find in the joint list.

D. Select the "mass" joint and place another joint where you want the eye view.
Rename it to "eye".

E. Select the "eye" joint and place another joint forward of it for an aiming handle.
Rename it to "eye-dir" so it is easy to find in the joint list.

F. Select the "mass" joint and place another joint where you want mount0.
Rename it to "mount0".

G. Select the "mount0" joint and place another joint forward of it for an aiming handle.
Rename it to "mount0-dir" so it is easy to find in the joint list.

H. Repeat G for each needed mount or other dummy point.


(This should work for Smoke_node and other .dts nodes as well)

SAVE THE FILE AS "test.ms3d"


LESSON 3. GET BONED.

You may be asking yourself why the AXLE BONES are not connected to the mass tree.. This is so that the
joints in the AXLE BONES can be selected/moved without affecting the cam/eye/mount placement.

If you select all the joints in the axles and then move them down it bows the hubs down to change the tire
height. This allows you to change the ride height without having to reset the entire "mass" bone tree.

REMEMBER! The centers of the hubX joints are the top of the suspension travel.

The "cam-dir" & "eye-dir" bones are to allow rotation of the camera as it wants to start inverted.
(You'll just have to play with them till you're happy with the rotation.)

Use the "mountX-dir" bones to adjust player mountings.

At this point you want to add a really narrow flat box for a body. Name it "body" and keep it under the
"eye" and "cam" joints. Now assign it a material.
(Don't worry if it looks like a Clue-By-4 and doesn't reach the edge defined by the hubX joints.)

Make a box that is the same size as the "body" and name it "col1", Leave it as no material.
This is your collision mesh.


SAVE THE FILE AS "test.ms3d"

Under FILE > EXPORT Go all the way to the bottom to "Torque Game Engine DTS"
Under "Collision Mesh" click "use this mesh" and select "col1" in the dropdown box.

Save the exported file over the original buggy.dts

Start up the TorqueDemo and go for a drive in your new multi wheeled wonder.



LESSON 4. I'M BONED.

Well, it really sucked wading through 320 frames of VRML export of the MPB animation
(all 27 megs) fishing for clues to make it work, and I never did get the blasted thing to work in
Tribes 2.. Oh Well, Maybe Tribes 3 will be TGE based. :)



Credits

Community participation made this tutorial possible.
I gratefully acknowledge that writing this article would have been an impossible
task without all the info on the net from all you crazy people out there.
(And several slow computers to weed out the crap.. :)

I would like to thank --

My Wife for being understanding and not looking for a butterfly net when I growl at the computer.

The crew at GarageGames for several "Bitchin!" products and not sueing me yet for doing really rude things to
the TorqueDemo V1.2. (Well, It's like this.. I saw .cs & .dts files and I couldn't resist. Hehehe.. :)

Emo1313 And TerrorX without whom I would have probably given up on Tribes 2 after the Launch/Year 1 fubar.

Loonatik aka Jeremy Whittington for the excellent 3DS tutorial that had some names that matched up with some of
the names in a 320 frame (27 meg) VRML dump of the MPB animation. His tutorial can be found here.
http://tork.zenkel.com/_tutorials/Modelling/vehicles/wheeled.htm

CYGWIN for an X server layer for Win32 and "grep" (without which going through 320 VRML files is
"Death by self induced boredom"). Both are available via free download from
http://www.cygwin.com

http://www.righthemisphere.com/ for 3D Exploration which has a great downloadable mesh converter demo.

A lost post somewhere on the GarageGames Forums that sugggested using bone joints for mount0[..]mount9
in Milkshape.

http://www.shiftermod.com for the .max file of the MPB.

And the guy with 3DS 6 who dumped the .max files to VRML for me
// What? You say your computer is slow running 3DS MAX? Here, Tell it to export this to VRML and let me know how
// long it takes... It took 45 minutes? Better send me the output.. Was there a LOT of drive activity? Yes? It sounds
// like it needs more RAM.. Add another 256 meg to the 64 meg in it.. No, Thank you it was no trouble at all. ROFL! :)

#1
07/14/2004 (5:12 am)
same idea for mutliple propelers right?
#2
12/11/2004 (4:33 am)
Yes that would go the same way
#3
01/01/2005 (2:26 pm)
I am trying to add particle emitter nodes to a dts shape in milkshape...i added the mass joint and then 2 other joints out from mass...i named them JetEmitter and ContrailEmitter (im trying to make jet flyer particles)...for some reason they dont have any particle effects once im flying around in torque. Is there a specific way to add these nodes in milkshape?