Wheel Contacts

frier

18-09-2007 11:04:30

I just want to know how to create wheelcontacts so i know if the wheels are colliding with the floor like ive done for the cars body..

is it the same sort of thing?

wheels = mScene->createActorGroup("wheel");
...
sp.mOffset = toNxVec3(frontLeft);
sp.mGroup = "wheel";
w.frontLeft = static_cast<Wheel*>(actor->addShape(new WheelShape(radius, sp, wp)));


I want to do this so i know if the cars in midair so i can change some dampening values. So i have contacts for both the cars Actor and all its wheels? it sounds fairly expensive, is there a more efficient way of doing this?

Thanks

luis

19-09-2007 08:51:42

I want to do this so i know if the cars in midair so i can change some dampening values. So i have contacts for both the cars Actor and all its wheels? it sounds fairly expensive, is there a more efficient way of doing this?

if you want to know if a wheel is in contact with another shape this is the way:


NxWheelContactData wcd;
NxShape* s = NxOgre::wheel->getNxWheelShape()->getContact(wcd);
if(s)
{
// this wheel is in contact with another shape.
// if you want more information about the contact just inspect the
// returned NxWheelContactData here
}


i'm using this code for each wheel and for 8 cars at the same time with no performace hit, any way i dont think you need to do it for each frame, so you could limit the number of times you do it to something like 10Hz or similar ;)

frier

19-09-2007 11:36:39

ohh thats how you do it.. cool...

So if i may ask, what kind of stuff do you use wheel collision for in your game luis? unless its secret of course.

I'm thinking of changing the cars dampening(angular linear), also incorporating sounds and emitters hopefully.

*edit* does your intellisense work on the returned NxWheelContactData?

luis

19-09-2007 13:45:32


So if i may ask, what kind of stuff do you use wheel collision for in your game luis? unless its secret of course.
I'm thinking of changing the cars dampening(angular linear), also incorporating sounds and emitters hopefully.


no, it isn't a secret ! feel free to ask...

a- i'm using the collisions mostly for the particle effect (dust trail) and sounds..
Sounds:
Engine pitch: calculate the average RPM (axle speed) for each wheel with contact and the relation with the max RPM for the car.
Skid gain: sum of the lateral/long impulse.
Particles:
Dust trail: calculate the tangential speed and turn on/off the particle emitter for each wheel. If ON, make the emision rate relative to the tangential speed. If the wheel has no contact, the emitter is off.

b- i'm not changing the cars dampening(angular linear) at all.

hope this helps you ;)

Edit: yes, my intellisense works with the NxWheelContactData... delete the .ncb file in your solution's folder and re-open the solution.

frier

19-09-2007 13:50:28

Ok nice to know! i saw your car demo and i want my cars to move verrry similar to yours. But when i go off ramps the car doesn't tilt on the X axis i think it is as nicely as your one.. but im pretty sure its my dampening doing it. Ill have to sort out something to suit my problems!

but thanks for info. seems like im mostly on track.

Oh yeah and one last question i forgot to ask and while your here.. i want to make my car(in my case its a racing bug).. so my Bug to jump just like a character would in a FPS game. How would i achieve this with a physX car with wheels.. Would i have to apply some force to the object from underneath?

Thanks!

luis

19-09-2007 14:03:14


as your one.. but im pretty sure its my dampening doing it. Ill have to sort out something to suit my problems!


I'm using *real* parameters for almost everything... weight, dimentions etc.. and the default dampening, but to make my vehicles behave like that i had to tunne up mass center, engine torque, suspension travel, wheel's grip... etc.
Keep tunning your *bug* and you'll reach the point to be happy with it :)

Would i have to apply some force to the object from underneath?


you could apply a strong force from the mass center to +Y, but take in count that applying forces is FPS dependent so do it in a fixed amount of time.

BloodyFanatic

13-10-2007 16:13:14

hey luis, i also use most "real" values for everything, but currently i've lost my patience with something really bad: the wheel grip is fps dependend...
i get completely different results when i run my game at 30 fps instead of 60 or more. maybe you or someone else can help me with this... :roll:

some more information:

NxOgre::WheelParams wp;

wp.clamped_friction = false;
wp.emulate_legacy_wheel = false;
wp.unscaled_spring_behavior = false;
wp.axle_speed_override = false;
wp.input_lat_slipvelocity = true;
wp.input_long_slipvelocity = true;


and these parameters are read from a xml file:
<parameter name="fLateralTireAsymptoteSlip" value="2.0" />
<parameter name="fLateralTireAsymptoteValue" value="0.7" />
<parameter name="fLateralTireExtremumSlip" value="0.15" />
<parameter name="fLateralTireExtremumValue" value="1.0" />
<parameter name="fLateralTireStiffnessFactor" value="1500.0" />

<parameter name="fLongitudalTireAsymptoteSlip" value="2.0" />
<parameter name="fLongitudalTireAsymptoteValue" value="0.7" />
<parameter name="fLongitudalTireExtremumSlip" value="0.15" />
<parameter name="fLongitudalTireExtremumValue" value="1.0" />
<parameter name="fLongitudalTireStiffnessFactor" value="7500.0" />

<parameter name="fInvertedWheelMass" value="0.2" />


With these settings ( Note: somehow exaggerated for testing purposes ) at 30 fps I can slide perfectly, but at 60 fps my car turns over when trying to drift. I noticed that with 60 fps the wheels have more than twice as much grip as with 30 fps.

luis

13-10-2007 20:14:04

hello ! I'm having exactly the same problem, but i think the relation between grip and the FPS is linear.....

I have the grip working ok at 60hz so I'm going use a linear interpolation but just in lateral/long stiffness factor, i think it should be enough for a range 60-75hz (the most common in TFT monitors).

it is a bug in Physx, since i use variable time step and everything behavies ok except for the grip.... :( and the grip is just another force after all, so it shouldnt be FPS dependent.

BloodyFanatic

13-10-2007 20:53:02

maybe we've to modify the function that provides the grip / force values to be fps independent.
or your method in changing the stiffness factor every frame based on delta time...

i hope that there is a real linear relation between grip and fps since i've to cover a wide range ( 30 to 100+ ) of fps :roll:

if you get it to work properly, can you post it here? that would be great :)

luis

13-10-2007 23:44:27


or your method in changing the stiffness factor every frame based on delta time...


you dont have to do it for each frame, you could ask ogre the average FPS and adjust the stiffness in a very low frec. for example 1-2 Hz.

if you get it to work properly, can you post it here?
no problem, but if you're hurried it is better if you try it by your self first because it is not a priority to me since i'm forcing the game to have VSync on ;)

BloodyFanatic

20-10-2007 14:45:29

no problem, but if you're hurried it is better if you try it by your self first because it is not a priority to me since i'm forcing the game to have VSync on ;)

no no, i've as much time as i need ^^ but i need it also for 100 Hz since my monitor runs at 1600x1200 with 100 Hz ^^