Game Development Community

Wheeled Vehicle Update

by Tim Gift · in Torque Game Engine · 02/15/2002 (9:47 am) · 118 replies

Just moving this thread over from the news items as that was starting to get a little long.

I went ahead and changed the wheeled vehicle to use datablocks for both the tire and spring parameters. The datablocks are set dynamically for each wheel, so you can mix and match suspension and tires...

The tire datablocks also includes the tire shape, so the car body no longer includes the tires. Getting those to render correctly has been a pain in the butt, mainly because MilkShape mangles it's node transforms (and you can't edit them, etc. very annoying). This wasn't so much of a problem when the tires were in the shape, but now that I'm trying to attach them to the hubs, it's lame. Anyway, because I've been having trouble getting the node transforms in MilkShape oriented correctly, I decided to bag it and do all the animations in code. That means the new minimum requirements for a car body is that it contains the root position of the hubs, that's it.

I have it pretty much all working, but rendering the wheels as separate shapes, and the new datablocks has complicated the code a little. I'm going to take some time and do a little more cleanup and re-factoring before I check it all in.

On the animations... the suspension and steering animations are still there, and are still being run, but now have nothing to due with the physics at all, or the placement of the wheels. (You won't even need any animations to import a new car.) You will still be able to do suspension and turning animations though if you want, and the code will try to line them up. I'll put some suspension struts in the test car later and make sure that code is all working correctly :)

I'll post back on this thread when it's checked in... this will, of course, mean re-doing any current test shapes you have, but that's life on the edge :O
#81
03/01/2002 (4:46 am)
Try adding a command to spawn it. Pop into IRC I can walk you thru it if you need help.

I have it working just fine, your car and everything :)
#82
03/01/2002 (4:57 am)
All the wheels seem to be there (although you don't have time to mount it to see if it works).

How do you run the game in debug mode? At the moment I use
-game rocketman
in the windows shortcut to run the game. Does the debug mode create a log file or something?

Thanks
#83
03/01/2002 (5:13 am)
@ Edward - Could you try and add a vehicle to your project using the mission editor and see if it crashes at your end? If it doesn't then I know its a specific problem with my app.

Thanks very much.
#84
03/01/2002 (6:25 am)
I can add it just fine, can't mount it that way, but I can add it.

If I spawn it using a server command, I can mount it, so must be something the mission editor does to them.
#85
03/01/2002 (8:10 am)
richard, to use the debug mode you need to compile the Torque Demo using the Debug Release. Using VC++ check out Build->Set Active Configuration.
#86
03/01/2002 (8:41 am)
@ Xavier - Oh, I had been compiling using the Debug mode I just didn't realise it :)
What does the Debug build actually do compared to the Release compile? In a VB engine I have used, the engine would create a debug.txt file so you could examine what was being executed, and where any crashes occured. If this applies to Torque, where can I find the log?

@ Edward - In the racing demo, when the vehicle is spawned it is instead of the player. If you have a spare few minutes could you detail for me how to spawn a vehicle and not replace the player? I'll get onto it now and see if I can figure it out as well.
Also, did you need to add any code to the engine or scripts to make the vehicle mountable?

Thanks very much.
#87
03/01/2002 (9:00 am)
I mean you could run the demo app from within VC6 (if your not already doing this), so that when it crashes, you can see what line it's on in the VC6 debugger. When it's "crashing", does it pop-up an assert message dialog box?

If your having problems with the debugger, you could just zip up and send me your rocketman directory. Shouldn't be hard for me to track it down.
#88
03/01/2002 (9:08 am)
Nothing special at all. I have working mount code, I think the most recent vehicle tut lets you mount properly.

Once you have working mount code, just copy the car.cs into the server/scripts dir, execute it in game.cs and create a server command like the examples in the vehicle tutorial that spans the car.

Car is ready to go, even has damage, if you have damage functions written in vehicle.cs.

Catch me on IRC if you have problems.
#89
03/01/2002 (9:39 am)
@ Tim - I've tried adding cars to the fps demo instead of my project and this works OK. I haven't added mounting code, but the cars appear in the mission and it doesn't crash. I can't work out why it would work for the fps demo and not my Rocketman project, which actually started out as an exact copy of fps.
As I have mentioned previously, I run Rocketman using the -game switch, and because of this I can't see a way of running it in VC++, which executes the fps demo when you click "execute". How would you run another game or mod (ie. a project that uses a switch inside VC to take advantage of the debugging facility)?

@ Edward - Thanks for your feedback. Once I've got the vehicles to appear in my project via the mission editor, I'll have a go at adding the relevant mounting code.
#90
03/01/2002 (10:05 am)
OK, I've figured out what's wrong. In my project I was using a custom made terrain so I edited my mission to load the waterworld terrain instead (minus the water). The result is that my project didn't crash when I added a car via the mission editor. I don't have a clue as to what was wrong with my custom terrain to make it crash when I add a car. The terrain contains no other shapes or anything.
The game seems to crash when the car touches the terrain after being added to the mission (so practically straight away). So I suspect the problem is a conflict with the collision code between the vehicle and my custom terrain.
Any ideas?

Thanks.
#91
03/01/2002 (10:05 am)
You can either change example/main.cs, or add a command line argument to VC6.

In example/main.cs, at the top, there is userMods = "fps"; line, just replace fps with your mod name.

In VC6, right click on the "Torque Demo files" and pop up the settings. On the "Project Settings" dialog, go to the "Debug" tab, and fill in the "Program Arguments" field with "-game yourmodname"
#92
03/01/2002 (10:11 am)
Wow, that's wierd. I can't think of anything off hand that would cause problems with a new terrain. I created a new terrain for the racing mod without problems. Can you get it to run in the debugger? That might give me a clue.
#93
03/01/2002 (10:50 am)
I have custom terrain. No problems here :(
#94
03/01/2002 (11:04 am)
I've solved the crash! I made a copy of my custom terrain directory (located in "example/rocketman/data/terrains") and placed it in the fps directory ("example/fps/data/terrains") and it worked.
This is really wierd though, because the mission file definately loads the terrain data from the rocketman version because if I remove it I get a blank mission (no terrain).
I'll remove the fps version of the terrain and run it in debug mode (to create the crash) so we can get an insight into exactly what's going on.
Maybe somethings hard coded into the vehicle class that causes problems if you are running a project using the -game switch?
#95
03/01/2002 (12:05 pm)
Maybe..

as for the terrain not appearing, open the MIS file in your editor (notepad or whatever) and edit the path to the terrain into it.
#96
03/01/2002 (1:02 pm)
I'm very confused now.
I reverted back to an old backup to try and make sense of this. I copied my terrain directory to the fps directory as described in my last post - and it still crashed. So its not dependant on that at all.
I copied the grassland terrain directory (as supplied with fps) into my project and edited my mission to load that. This worked OK and there was no crash when adding vehicles.
I edited the mission file back so it loaded by custom terrain again - and this time it worked.
So rather strangely, I seem to be at the stage now where if I keep the grassland directory in my project it works (even though the mission loads my custom terrain), and if I remove the grassland terrain directory, I get a crash when adding vehicles onto my custom terrain.
What's that all about!

Anyway I executed my project in a window so when it crashed I could see what happened:

I get a dialog box basically saying "Invalid Page Fault".
The game seems to crash in WheeledVehicle.cc, line 1031, which says:

pEntry->puffColor[x].alpha);

I don't have a clue why it should crash there of all places.
I hope someone does? :)
#97
03/01/2002 (1:11 pm)
Yes, I know what it is. Your new terrain is missing material descriptions. The tire dust color is based on the terrain material, which it apparently can't find. It should not be crashing, but if you add (or copy) the materials from the fps terrain, you should be set.

I'll fix the code so it doesn't crash though.
#98
03/01/2002 (1:35 pm)
I was just about to post a message saying I fixed it, when I noticed your message. I realised that if its working because of the grassland directory being present, my scripts must be referencing it somewhere. I did a search in my scripts for "grassland" and it came up with:

exec("./terrains/grassland/propertyMap.cs");

So I added...

exec("./terrains/mars/propertyMap.cs");

... (where mars is the custom terrain) to my init.cs file, deleted the grassland directory, and it now works without any crashes. :)

Thanks for all your help guys! I've certainly learnt a lot about the engine today.

What do the propertyMap.cs files do exactly (ie. what is addMaterialMapping)? It looks like its used to assign a color and sound file to the terrain textures for movement?

Anyway, next step is to add code so I can mount the vehicle. Did someone say there's a tutorial somewhere, I'll have a look...

Thanks again!
#99
03/01/2002 (1:48 pm)
and post #100 is:

when i mount my vehicle my player wont sit down :\
He likes to ski around with my car
how do u trigger the animation?
#100
03/01/2002 (1:56 pm)
just set: mountPose[0] = sitting; in you car's datablock