Game Development Community

Creating a vehicle

by Jacco Jansen · in Artist Corner · 02/08/2006 (4:14 pm) · 8 replies

Hi there, oh wise people of the forum...

I am trying to get a new vehicle into my game and I am finding it difficult to find info on how to get a vehicle shape to export and work in game. All the info I get is what nodes are needed in the shape and that is it. it doesn't say wether it should be in the start01 node or under the base01 node.

Further more, the nodes I have included in my mesh are:
shape4
detail4
collision1
col1
mount0
cam
eye
mass
ground0
ground1
ground2 and
ground3

According to the info I get on the forums and the torque decumentation This should be all that is needed. I looked at the Maya, Max and Blender tutrials I could find and from the Blender tutorial it seemed that I also needed hub0 to hub3 nodes, so I included them also. For the wheel I simply use the wheel shape from the default buggy that comes with the SDK.

In fact, I use everything from the default racer including the script. The only difference being that I place my shape file in the directory with the buggy and change the script to point to my ferari shape instead of the buggy shape. When I start the game, it gets to the LOADING OBJECTS section and then bombs out.

One last thing that I thought it might be is that it seems my collosion nodes have to be a negative number, or more specifically, negative 1. When I rename my nodes in Maya it automatically becomes col_1 and collision_1 so negative numbers are not an option.

Also, my cam and eye nodes are outside the bounding box. Do you think this could be the problem?

What i would like to ask, is wether I have the correct information or not. Are my nodes all that are needed? What needs to be done before exporting? I am using the Maya2DTS utility on a Mac by the way.

I know the shape works because before I deleted the wheels from the model and added the extra nodes, I was able to import the shape as a static object. Now that I try to use it as an aiWheeledVehicle it crashes my program after I click the Start Mission button. Why is this?

i read somewhere a while ago that I am supposed to setup some kind of a frame to attach the wheels to. Sort of like an axis underneath the vehicle. I am unable to find that post again, so if any of you have any idea about that, a link would be greatly appreciated :D

I have been playing with the demo program for a long while now and only bought the SDK a few weeks ago. It was only then that I first noticed there is an aiWheeledVehicle class. Are there specific recuirements to use this class and that maby I am misusing this class and that is why this is happening?

Basically, my game starts off with the player surviving an attack on a restaurant and then going outside, getting in his car and chasing after the vehicle. The vehicle will follow a set path so I have copied the code in aiPlayer.cs and adapted that to the aiWheeled vehicle class and it works fine (with the buggy) except for the onReachdestination callback...which doesn't get called. Go figure.

Anyway, to close this post off.
1. What do I need to do to my static shape to get it to export as a usable vehicle that can follow a track and also be mounted by the player?
2. Which of the nodes are required and at what level do they need to be in the heirarchy?
3. Why does my shape cause my program to crash at load time?

I thank you for your time in reading this and helping me out. I greatly appreciate any help in this regard and eagerly await your words of wisdom.

#1
02/08/2006 (10:48 pm)
Me again

I tried moving the cam and eye within the bounds. Still no luck.

I have been searching the forums up to now and have found something interresting here.

Am I understanding that I should have hub JOINTS and not hub NODES? I find this interresting!!!! Do I need to create a skeleton for my vehicle and bind mt vehicle mesh to a skeleton? Is this right?
#2
02/09/2006 (1:12 am)
Hey Jacco,
While I'm at a friend's house and unable to answer your post at this time with 100% positive assurance (since I can't test it), I can throw in some things that I hopefully remember correctly, and will double check as soon as I get home. I use Max myself so I cannot understand why Maya would rename things from a negative to an underscore (I'm quite sure it's ok that it's putting an _ there instead, so just let it do its thing!), but the hands down best way to check why your vehicle is crashing TGE is to check your console log in the project directory. I cannot count how many times I've tried to export things in Torque only for it to crash. Everytime it happens I seem to forget about the glory of the console, and most anyone can understand the commands or what is causing it.

With that in mind, you said you tried exporting your mesh before making it vehicle savvy, but did you have the collision mesh when you did this? Akward or complex collision meshes were the cause of many crashes for me, and a console check is a great way to double check this.

I think all of those nodes should keep in as long as they're properly set up in the hierarchy. In this case from what I remember it should be like this:
Bounds Shape (next line all connected to Shape node not eachother)
Start collision-1 detail
(all below connected directly to the start node)
Cam Eye Mount0 Grounds1-4 Col-1

Hopefully this makes sense and hopefully my memory serves me correctly (someone please correct me if I'm wrong!)

The cam and eye nodes can definetly be outside the bounds, and the cam node will more than likely need to unless your bounds is huge.

I don't know if there's such an option in Maya, but in max there is a checkbox with the DTS exporter which you can uncheck Collapse Transforms. The Torque Show Tool Pro is a great investment for these kinds of situations, as it shows the nodes once you load them up to show that they're properly exported, and saves a lot of hair pulling from trying to figure out the nodes ingame.

Hopefully this is simply a collision problem and the likely fix would be that the collision mesh is too complex. If that's the case try just using a box for something without a lot of definition like a car. Make sure you have the Col_1 and not just Col1 or that'll almost be a for sure crash on loading.

I hope some of this helped out, just remember to check your console and make sure your hierarchy is set up and you should be good to go. Good luck!
#3
02/09/2006 (2:21 am)
Console log... ahhh, the often forgotten one...
Quote:Error: shape xroads/data/shapes/vehicles/ferari/ferari.dts-collision detail 1 (Collision-1) bounds box invalid!
Mapping string: MissionStartPhase2 to index: 9
*** Phase 2: Download Ghost Objects
Mapping string: MissionStartPhase2Ack to index: 1
xroads/server/scripts/aiGuard.cs (195): Unable to find object: '-1' attempting to call function 'getTransform'
setWheelSteering: wheel index out of bounds, vehicle has 33622743 hubs
setWheelSteering: wheel index out of bounds, vehicle has 33622743 hubs
setWheelPowered: wheel index out of bounds, vehicle has 33622743 hubs

Okay so this is interresting!
My bounds box is invalid? Why? I deleted it and recreated it again and much larger than the vehicle. My bounding box is a simple box that is larger than the car and smaller than the bounds. I tried putting my collision and my shape both insode the hierarchy and outside but still no luck

www.jaccojansen.co.uk/torque/Picture3.jpg
(Just save the above image to your harddrive to see my node structure)
Here you can see my file structure and also see the bounds shape covering the vehicle. What at I doing wrong?

Also, interrestingly enough I have found earlier in the log that my crosbow's collision bounds shape is also invalid. Go figure!!!
#4
02/09/2006 (2:40 am)
Glory be!
It works now! Thanks a lot mate!
The shape file had to be under start as well to make it show up in game and as you will notice from the image, I had collision_1 and col1. As soon as I renamed the col1 to col_1 it worked fine. Funny that beceuae I only changed that last night as a test. Go figure!

Now for two more questions. Why is my crosbow shape's bounds invalid? That is the one I got with the SDK. Hmm...
Also, now that the shape is appearing, it has no wheels, even with the hubs and grounds. Is this also due to incorrect hierarchy structure or is it more seious than that?

Well, I'll be off to try and change the hierarchy. Will let you know what's up if I get it working
#5
02/09/2006 (3:47 am)
Your best option to re-export a vehicle right now is to use the buggy and re-do the mesh, copy over the script, change the shape names, etc.. and voila.

Toby.
#6
02/09/2006 (4:04 am)
Unfortunately I don't have the buggy cause it is in max format.

or do you mean copy the script and replace the shapes mentioned inside it? That is what I have been doing. I now go into the game and type echo($carone.getWheelcount()); and it returns 0.

Using the torque car script and replacing the shapes reveal that when i export my shape, the wheels are not exported.

Do I actually have to import the wheel 4 times into my shape file or do i need to use dummy shapes or are nodes all that is needed? as you can see above, i don't have wheels in my shape because i use the buggy wheels in script. I tried putting my ground nodes under start and under shape and it still reports my wheels as 0 and my hubs as 36000 or something.

somehow i think i am either not naming my hubs correctly or placing them in the wrong place in the hierarchy. any ideas? for interrest sakes, do the wheels mount it's center at the hub nodes or does it mount it's base on the ground nodes? which one of those two actually affect the call to getwheelcount... hold on... i have the sdk... i can go check...
#7
02/09/2006 (5:50 am)
They say the vehicles need tender loving care before they work. Man, how right they are!

So I finally got wheels on my vehicle and I can get it to go from one node to another. All I have to figure out is why the onReachDestination callback doesn't get called. What I found in aiPlayer is that all callbacks are called from the aiPlayer datablock except for the onReachDestination which is called on the derived datablock (for example aiGuardDB) so I assume I need to do this for this vehicle as well. Go figure.

So to help those people out there who are reading this thread, the problem with my shape was this:
I created nodes and positioned them where I wanted them and caled them hub0 to hub3. What I should have done was create a basic poly cube and name that hub0 to hub3. The wheels then actually replace the cubes ingame. Now why didn't anyone tell me that before? Sheesh!

Anyway, now I have yet another problem (when it rains it pours). My hubs were sized and positioned inside the gaps for the wheels but they were placed underneath them so I had to move the hubs up right into the body of the car in order for the car to have wheels instead of riding on top of the wheels. That problem is sorted. Now comes the wierd bit:

The left side of the car is fine, but the wheels on the right side start in the middle of the width of the car. I keep moving the hubs further away and at the moment the hubs are placed a full wheel width away from the car and still after exporting they appear in the middle of the car when the game runs. It seems my real wheel just loooooves the exhast fumes... LOL

At least I made a lot of progress in one day and it all started by one guy saying: make sure you check your spelling :)

Thanks Justin :D
#8
02/09/2006 (12:37 pm)
No problem dude, glad I can help! (as simple of a thing as it was) :)