Game Development Community

Trouble with wheeled vehicle

by Michael Canty · in Torque Game Engine · 05/31/2007 (7:03 pm) · 8 replies

I am search for a solution to our problem with our vehicle. The wheels for our vehicle do not show up when the object is placed into the game. We have created the vehicle with 10 wheels. After realizing that TGE only supports 8 wheel we removed tow of the wheels. This to no avail did not work either. We folled the vehicle docs in the forum and made sure that our object was like the Starter.Racing example. This still did not work. We took our wheels and replaced the buggy wheels with them and the buggy worked just fine with them. I could use a little help. Oh and we are using lightwave 9 and the DTS exporter utility on TGE 1.5.

#1
05/31/2007 (7:31 pm)
If you have show tool pro, you should try loading up your model and mounting one of your wheels to the vehicle.
#2
05/31/2007 (7:50 pm)
Don't know if this helps, but in the 3ds max exporter sometimes it will export the vehicle with this:

setWheelSteering: wheel index out of bounds, vehicle has 13220583 hubs

However, I don't know if lightwave has the option to turn off "collapse transforms" which fixes the error in 3ds max. Does your console say anything about the wheel in the engine?
#3
05/31/2007 (8:08 pm)
In ShowToolPro the wheels will mount just fine. I found nothing in the console log for wheel out of bounds. Is there a polygon limit on wheel object? My wheels have 147 polys.
#4
05/31/2007 (11:15 pm)
I don't believe there is a poly limit for the wheels. So, your tires worked on the buggy... have you tried mounting the "buggy wheels" to your vehicle? It's hard for me to figure out, without knowledge of lightwave, unless you want to email me the dts's or if you send me .obj files.
#5
05/31/2007 (11:23 pm)
Have you set up a tire datablock? Your wheels won't mount to the vehicle without one.

Example:
datablock WheeledVehicleTire(YourCarTire)
{
   // Tires act as springs and generate lateral and longitudinal
   // forces to move the vehicle. These distortion/spring forces
   // are what convert wheel angular velocity into forces that
   // act on the rigid body.
   shapeFile              = "~/data/shapes/YourCar/YourCar_tire.dts";
   staticFriction         = 4;
   kineticFriction        = 1.25;
   
   // Spring that generates lateral tire forces
   lateralForce           = 6000;
   lateralDamping         = 400;
   lateralRelaxation      = 1;
   
   // Spring that generates longitudinal tire forces
   longitudinalForce      = 6000;
   longitudinalDamping    = 400;
   longitudinalRelaxation = 1;
};
#6
06/01/2007 (6:09 am)
Tim

I have the WheeledVehicleTire datablock in my rover1.cs file. I have however narrowed it to be the object. I placed the object into the start.racing demo and the object loads but without wheels. But if I load it into show tool pro I can click on mount wheels and all 8 wheels mount. I am scratching my head now.

datablock WheeledVehicleTire(RoverTire)
{
   // Tires act as springs and generate lateral and longitudinal
   // forces to move the vehicle. These distortion/spring forces
   // are what convert wheel angular velocity into forces that
   // act on the rigid body.
   shapeFile = "~/data/shapes/vehicles/rover/wheel.dts";
   staticFriction = 4.2;
   kineticFriction = 1.25;

   // Spring that generates lateral tire forces
   lateralForce = 6000;
   lateralDamping = 400;
   lateralRelaxation = 1;

   // Spring that generates longitudinal tire forces
   longitudinalForce = 6000;
   longitudinalDamping = 400;
   longitudinalRelaxation = 1;
};

datablock WheeledVehicleSpring(DefaultCarSpring)
{
   // Wheel suspension properties
   length = 0.85;             // Suspension travel
   force = 2800;              // Spring force
   damping = 3600;             // Spring damping
   antiSwayForce = 3;         // Lateral anti-sway force
};

datablock WheeledVehicleData(rover1)
{
   category = "vehicles";
   shapeFile = "~/data/shapes/vehicles/rover/rover1.dts";
   emap = true;

   maxDamage = 1.0;
   destroyedLevel = 0.5;

   maxSteeringAngle = 0.385;  // Maximum steering angle, should match animation
   //tireEmitter = TireEmitter; // All the tires use the same dust emitter

   // 3rd person camera settings
   cameraRoll = true;         // Roll the camera with the vehicle
   cameraMaxDist = 4.8;         // Far distance from vehicle
   cameraOffset = 1.5;        // Vertical offset from camera mount point
   cameraLag = 0.26;           // Velocity lag of camera
   cameraDecay = 1.25;        // Decay per sec. rate of velocity lag

   // Rigid Body
   mass = 1380;
   massCenter = "0 -0.2 0";    // Center of mass for rigid body
   massBox = "0 0 0";         // Size of box used for moment of inertia,
                              // if zero it defaults to object bounding box
   drag = 0.6;                // Drag coefficient
   bodyFriction = 0.6;
   bodyRestitution = 0.4;
   minImpactSpeed = 5;        // Impacts over this invoke the script callback
   softImpactSpeed = 5;       // Play SoftImpact Sound
   hardImpactSpeed = 15;      // Play HardImpact Sound
   integration = 8;           // Physics integration: TickSec/Rate
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.1;          // Contact velocity tolerance

   // Engine
   engineTorque = 3300;       // Engine power
   engineBrake = 600;         // Braking when throttle is 0
   brakeTorque = 8000;        // When brakes are applied
   maxWheelSpeed = 50;        // Engine scale by current speed / max speed

   // Energy
   maxEnergy = 100;
   jetForce = 3000;
   minJetEnergy = 30;
   jetEnergyDrain = 2;

   // Sounds
//   jetSound = ScoutThrustSound;
//   engineSound = BuggyEngineSound;
//   squealSound = ScoutSquealSound;
//   softImpactSound = SoftImpactSound;
//   hardImpactSound = HardImpactSound;
//   wheelImpactSound = WheelImpactSound;

//   explosion = VehicleExplosion;
};


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

function WheeledVehicleData::create(%block)
{
   %obj = new WheeledVehicle() {
      dataBlock = %block;
   };
   return(%obj);
}

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

datablock StaticShapeData(headlight1)
{
category = "vehicles";

shapeFile = "~/data/shapes/vehicles/rover/headlight.dts";
};

datablock StaticShapeData(headlight2)
{
category = "vehicles";

shapeFile = "~/data/shapes/vehicles/rover/headlight.dts";
};

datablock StaticShapeData(spotlight1)
{
category = "vehicles";

shapeFile = "~/data/shapes/vehicles/rover/spotlight.dts";
};

datablock StaticShapeData(spotlight2)
{
category = "vehicles";

shapeFile = "~/data/shapes/vehicles/rover/spotlight.dts";
};

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

   // Only power eight of the wheels...
   %obj.setWheelPowered(2,true);
   %obj.setWheelPowered(3,true);
   %obj.setWheelPowered(4,true);
   %obj.setWheelPowered(5,true);
   %obj.setWheelPowered(6,true);
   %obj.setWheelPowered(7,true);


	%mountObj =    new StaticShape(headlight1) 
	{
		canSaveDynamicFields = "1";
		internalName = "headlight1";
		position = "-444.662 376.363 29.8628";
		rotation = "1 0 0 0";
		scale = "1.4 1.4 1.4";
		nameTag = "headlight1";
		dataBlock = "headlight1";
		receiveSunLight = "1";
		receiveLMLighting = "1";
		useAdaptiveSelfIllumination = "0";
		useCustomAmbientLighting = "0";
		customAmbientSelfIllumination = "0";
		customAmbientLighting = "0 0 0 1";
	};

	%Obj.mountObject(%mountObj, 4); 

	%mountObj =    new StaticShape(headlight2) 
	{
		canSaveDynamicFields = "1";
		internalName = "headlight2";
		position = "-444.662 376.363 29.8628";
		rotation = "1 0 0 0";
		scale = "1.4 1.4 1.4";
		nameTag = "headlight2";
		dataBlock = "headlight2";
		receiveSunLight = "1";
		receiveLMLighting = "1";
		useAdaptiveSelfIllumination = "0";
		useCustomAmbientLighting = "0";
		customAmbientSelfIllumination = "0";
		customAmbientLighting = "0 0 0 1";
	};

	%Obj.mountObject(%mountObj, 5); 

	%mountObj =    new StaticShape(spotlight1) 
	{
		canSaveDynamicFields = "1";
		internalName = "spotlight1";
		position = "-444.662 376.363 29.8628";
		rotation = "1 0 0 0";
		scale = "1.4 1.4 1.4";
		nameTag = "spotlight1";
		dataBlock = "spotlight1";
		receiveSunLight = "1";
		receiveLMLighting = "1";
		useAdaptiveSelfIllumination = "0";
		useCustomAmbientLighting = "0";
		customAmbientSelfIllumination = "0";
		customAmbientLighting = "0 0 0 1";
	};

	%Obj.mountObject(%mountObj, 6); 

	%mountObj =    new StaticShape(spotlight2) 
	{
		canSaveDynamicFields = "1";
		internalName = "spotlight2";
		position = "-444.662 376.363 29.8628";
		rotation = "1 0 0 0";
		scale = "1.4 1.4 1.4";
		nameTag = "spotlight2";
		dataBlock = "spotlight2";
		receiveSunLight = "1";
		receiveLMLighting = "1";
		useAdaptiveSelfIllumination = "0";
		useCustomAmbientLighting = "0";
		customAmbientSelfIllumination = "0";
		customAmbientLighting = "0 0 0 1";
	};

	%Obj.mountObject(%mountObj, 7); 

}

The code that I am using is nothing special. I am using TGE 1.5 . I have the update to 1.5.2 but have not updated yet. Could this be the problem? Although I do not think so since I saw nothing in the update bug fixes that indicate that there was a problem with vehicles in 1.5.
#7
06/01/2007 (7:16 am)
Your for loop looks a little weird to me.

for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {


couldnt you just do (just seems easier to read):

for (%i=0; %i<=7; %i++)
{
...
}
#8
06/01/2007 (10:06 pm)
If Lightwave has the same hierarchy setup as 3ds max does then it should like this:

//myVehicle

base01 //node for export
start01 //node for export
light0 //node for export
light1 //node for export
mount0 //node for export
eye //node for export
cam //node for export
hub0 //node for export
hub1 //node for export
hub2 //node for export
hub3 //node for export add more hubs as needed
Car2 //car mesh
col-1 //my one collision mesh
Collision-1 //node for export
detail2 //node for export

bounds //node for export and is all by itself
////////////////////////////////////////////////////////////////////
//myWheel

base01 //node for export
start01 //node for export
Cylinder2 //wheel mesh
col-1 //my one collision mesh
Collision-1 //node for export
detail2 //node for export

bounds //node for export and is all by itself

I tried digging around for a lightwave dts setup, but it all seems old.