our physics engine is now capable of simulating full rigid bodies in full 3D.The spring forces and other force generators will work with this approach, but the hard constraintswill not.
A Flight Simulator
As the aricraft's surfaces move at different angles througth the air,the proportion of each kind of force can change dramaticlly.
The Aerodynamic Tensor
To model the aerodynamic forces properly is very complex.To make our life easier I will use a simplification: the“aerodynamic tensor.” The aerodynamic tensor is a way of calculating the total force that a surface of the airplane is generating based only on the speed that the air is moving over it.
The tensor is a matrix: a 3 × 3 matrix, exactly as we used for the inertia tensor. We start with a wind speed vector and transform it using the tensor to give a force vector:
where \(f_{a}\) is the resulting force, A is the aerodynamic tensor, and \(v_{w}\) is the velocity of the air.In practice three tensors are sometimes needed, to represent the two extremes plus the “normal” position of the control surface.
The Aerodynamic Surface
The force generator is created with an aerodynamic tensor, and it is attached to the rigid body at a given point. This is the point at which all its force will be felt.
A Sailing simulator
Originally the force directly acted on the particle. This is fine for representing balls or other regular objects. On a real boat, however, the buoyancy does two jobs: it keeps the boat afloat, and it keeps the boat upright(保持船支的竖直不倾斜). In other words, if the boat begins to lean over (say a gust of wind catches it), the buoyancy will act to right it.
This tendency to stay upright is a result of the torque component of the buoyancy force. Its linear component keeps the boat afloat, and its torque keeps it vertical. It does this because, unlike in our particle force generator, the buoyancy force doesn’t act at the center of gravity.
A submerged part of the boat will have a center of buoyancy, as shown in figure. The center of buoyancy is the point at which the buoyancy force can be thought to be acting. Like the buoyancy force itself, the center of buoyancy is related to the displaced water. The center of mass of the displaced water is the same as the center of buoyancy that it generates. The volume of water displaced depends on the shape of the submerged object, so does the center of buoyancy. The farther the center of buoyancy is from the center of mass, the more torque will be generated and the better the boat will be at righting itself.If the center of mass is above the center of buoyancy, then the torque will apply in the opposite direction and the buoyancy will act to topple the boat. So how do we simulate this in a game? We don’t want to get into the messy details of the shape of the water being displaced and finding its center of mass. Instead we
can simply fix the center of buoyancy to the rigid body. In a real boat the center of buoyancy will move around as the boat pitches and rolls and a different volume of water is displaced. Most boats are designed so that this variation is minimized, however. Fixing the center of buoyancy doesn’t look odd for most games. It shows itself mostly with big waves, but can be easily remedied, as we’ll see later