|
Latest update: August 24, 2006. Previous update: February 20, 2006. RayCar Executables (Download: Raycar Demo Installer) <-- click to downloadThis is a small demo, showing how to build a race car using the ODE physics library, using a box and four rays for the car physics. It also shows how to build a "player" using a capsule and a raycast to walk through geometry, FPS style. There are some tunables, which you can find in the files media\car.txt, media\player.txt and media\scene-fps.txt. The executable requires DirectX April 2006 to be installed; it is included in the distribution (but it assumes you already have DirectX 9.0c installed). To start the demo, run the program multiplace.exe (which you can find as a shortcut in the application menu). Controls: WASD to drive/move; right the car or jump the player with Space or the A button if you flip it. Also, an Xbox 360 controller will work. Enter, or the B button, to get in or out of the car (when it stands still). Switch between first- and third-person camera using F5 or the Back controller button. The funny-textured lollipop is the player stand-in -- I don't do character animation in this demo. The cylinder is the size of the collision capsule, and the stick at the bottom is about the length of the maximum extension of the leg ray. You can get into the house by pushing through the door -- it is spring loaded, and will close behind you. RayCar Source (Download: raycar-src.zip)Source code made available free of charge, on the condition that the original author is held harmless from all possible use or lack of use thereof, direct and indirect. Modification and redistribution is okay, under the MIT Open Source license. RayCar will build using the included version of the ODE physics library, and the April 2006 Microsoft DirectX SDK, using Visual Studio 2005 C++. It supports XInput controllers and keyboard. You will need the media files found in the raycar.msi executable installer to actually run the built sample. Check out class ObjCar in pcar.cpp for the implementation of the ray-cast car. Especially ObjCar::step() is of interest. Note that the tunables (friction, center-of-gravity sink, max speed, etc) are of very high importance. They are tuned right to the edge of making the car flip. If you sink the car 0.3 instead of 0.35, it'll flip on max turn at max speed. If you inrease the tire mu, it will flip on max turn at max speed. If you increase the max speed, ... you get the picture. Tuning is a black art. The file pplayer.cpp defines the player. Look in ObjPlayer::step() for most of the player logic. In addition, RayCar shows how to structure a simple scene graph based on DirectX, DXUT and the ID3DXEffect framework. It also shows how to use lightmapped .X files exported from the DeleD level editor/modeler program. It plays and mixes ogg and wave files with some amount of interactive control (engine sound, screeching of tires, etc). It's not structured to be an easy-to-read tutorial, but starting in main.cpp, you can hopefully follow the flow. Use 'grep -i' on the source to find points of interest, and set breakpoints to figure out what's going on at what point.
Copyright 2006 Jon Watte (raycar@mindcontrol.org) |
|