Game Development Community

Problem whit wheel..Help please...

by CIMO · in Artist Corner · 12/13/2005 (10:52 am) · 5 replies

Hello... i use Milk Shape for create a 3D object for torque.
I try to create a wheel for my truck, but i export in dts and place on torque my wheel don't rotate in circle but rotate on point in circle:
image is an example.
www.game-robot.it/exemple.jpgHow put right pivot?
Help me please .....

#1
12/13/2005 (11:07 am)
Try placing the center of the wheel in the xyz origin in Milkshape.
#2
12/14/2005 (1:30 pm)
Ok thanks =D now function =D
But i have put tire of car only in folder of car and i test my game and tire of car are in all vehicle ????
Why?
How must do to put a different tire of my different vehicle?
Thank =)
#3
12/14/2005 (2:33 pm)
If I'm understanding you correctly, your tire now shows up on any wheeled vehicle?

You need to make sure NOT to overwrite any other files name "tire.dts". Name yours something else... "tire_1.dts" for example.

Then in your vehicles' tire datablock, change the source to "...whateverdirectory/.../tire_1.dts";
#4
12/14/2005 (2:47 pm)
Here is a simple example of one way that you can specify what tires are on each vehicle.

In car.cs there is a datablock for the DefaultCarTire, you will need to make a new datablock for your new tire shape.

Make a copy of this datablock:
datablock WheeledVehicleTire(DefaultCarTire)
{
   // 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/buggy/wheel.dts";
   staticFriction = 4;
   kineticFriction = 1.25;

   // Spring that generates lateral tire forces
   lateralForce = 18000;
   lateralDamping = 4000;
   lateralRelaxation = 1;

   // Spring that generates longitudinal tire forces
   longitudinalForce = 18000;
   longitudinalDamping = 4000;
   longitudinalRelaxation = 1;
};

Then change the name of the new tire so you have another tire to choose from.

And then change the shapefile path to your new dts file.
datablock WheeledVehicleTire([b]MyNewCarTire[/b])
{
   // 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.
   [b]shapeFile = "~/data/shapes/buggy/mynewcartire.dts";[/b]
   staticFriction = 4;
   kineticFriction = 1.25;

   // Spring that generates lateral tire forces
   lateralForce = 18000;
   lateralDamping = 4000;
   lateralRelaxation = 1;

   // Spring that generates longitudinal tire forces
   longitudinalForce = 18000;
   longitudinalDamping = 4000;
   longitudinalRelaxation = 1;
};

Now if this is done correctly you need one more step to choose tires for each vehicle.

This function in car.cs tells torque to put DefaultCarTire on any WheeledVehicleData that is added.
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);
}
You will need to specify what tires you want to use on your vehicle with the setwheeltire function.

The most simple way I can think of to do this is to make a new onAdd function for your other vehicles by copying this function,
and modifying it to put the tires you want on your vehicle.
function [b]MyNewCar[/b]::onAdd(%this,%obj)
{
   // Setup the car with some defaults tires & springs
   for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
     [b] %obj.setWheelTire(%i,MyNewCarTire);[/b]
      %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);
}
#5
12/15/2005 (1:44 am)
Wow Nice ;) it's OK ;) i offer all you a coffee THANKS :D