Every Case test In VehicleSample Project of PhysXSDK.
There are several important problems I need to make them clear!!!
I will post a problem each day after I debug in VehicleSample
case 1: I test the suspension spring to see if the chassis is stable without 4 wheels
I just create the chassis shape and suspLimitConstraint ,without 4 wheels shape
I comment some source code in PhysXVehicle and recompile
So the SuspLimitConstraint is not active
I have trace the vehicleSuspLimitConstraintSolverPrep
//Susp limit constraints.
for (PxU32 i = 0;i<4;i++)
Px1DConstraint& p = constraints[numActive];
I think the VehicleConstraints->mData should update when k == numSubsteps - 1 ,
in this way the SuspLimitConstraint will be active and Generate Constraint Force,
Currently ,just the Chassis Shape Collide with the Ground Shape and change the Linear Velocity
It’s hard to know which sub-step to sample. Sometimes the suspension limit will be broken when k==0, sometimes when k==1 etc.
I opted for k==0 becase I reasoned that would be conservative. The sub-steps should give the spring a chance to reduce the difference between the jounce and the suspension limit. I would expect that difference to be greatest at k==0 and to reduce as we progress towards numSubSteps-1. I’m trying to keep the wheels at a legal transform that doesn’t intersect scene geometry and vehicle geometry. There might be cases where the spring can handle the suspension limit without adding the constraint but I’d rather be conservative and make sure that the wheel is always visually in the correct place. That might come at the expense of vehicle handling but that should only happen when the wheel is somewhere near the suspension limit. In those circumstances the player might believe that they have hit the limit anyway.
Yes, you could but it wouldn’t be enough on its own.
PhysX simulates rigid bodies. Car collision requires some means to compute the deformation of the car’s chassis. There are many ways to do this but none of them are available in the sdk itself. If we model the deforming geometry of the car as a triangle mesh then physx can be used to compute contact points between the triangle mesh and external geometry eg a wall. PhysX doesn’t support tri mesh-tri mesh collision but it is possible to decompose scene geometry into convex components. Simple geometry such as a wall is convex anyway so this might not be such a problem.
I can imagine a simulate loop that runs as follows:
a. physx runs 1 simulation step and returns all contact points
b. some other software updates the triangle mesh using the contact points.
I did something like this to model a vehicle driving on a deforming landscape. I updated the heightfield underneath the wheels based on data such as jounce, load etc.
There are many ways to deform the mesh. There is a lot of literature on this topic. Each algorithm has its own pros and cons.
There are a lot of video games that model deforming vehicles using physics engines designed for games. Some of will use physx.
I’m not sure this is the best way to go, though. If accuracy is an issue it sounds more like a job for finite element modelling. It can be computationally expensive and might not be real-time but that might not be a problem. I don’t know the requirements, I’m afraid.